Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NRF52840_DK UART driver and adapt FPGA test #12368

Merged
merged 4 commits into from
Feb 10, 2020

Conversation

mprse
Copy link
Contributor

@mprse mprse commented Feb 5, 2020

Summary of changes

The goal of this PR is to make tests-mbed_hal_fpga_ci_test_shield-uart passing on NRF52840_DK.

The test is failing because of the following reasons:

  • NRF52840_DK uart driver does not use pooling mode instead for all transfers DMA/Interrupt mode is used. According to the requirements, we assume that TxIrq interrupt is triggered when TXD register is empty (also after enabling TxIrq interrupt):

mbed-os/hal/serial_api.h

Lines 144 to 147 in f73a62a

* * If `TxIrq` is enabled by ::serial_irq_set, ::serial_irq_handler will be invoked whenever
* Transmit Data Register Empty IRQ is generated.
* * If the interrupt condition holds true, when the interrupt is enabled with ::serial_irq_set,
* the ::serial_irq_handler is called instantly.

The driver fires interrupt when the whole DMA buffer is transmitted, but the interrupt is not fired after enabling the TxIrq interrupt when the TXD register is empty. To fix that we will trigger the interrupt manually.

  • Due to hardware limitations NRF52840_DK does not support odd parity bit and 2 stop bits. This PR will skip these test cases using !defined(TARGET_NRF52840) directive.
    This should be temporary solutions since we need a fast fix. But in my opinion, we should consider adding something like uart_get_capabilities() function and use it to skip the unsupported test case instead of !defined(TARGET_NRF52840) directive. This requires discussion with @fkjagodzinski who is an author of the UART FPGA test and has wide knowledge about UART drivers and hardware limitations across different platforms.

Test results:

| target              | platform_name | test suite                              | result | elapsed_time (sec) | copy_method |
|---------------------|---------------|-----------------------------------------|--------|--------------------|-------------|
| NRF52840_DK-GCC_ARM | NRF52840_DK   | tests-mbed_hal_fpga_ci_test_shield-uart | OK     | 32.06              | default     |
mbedgt: test suite results: 1 OK
mbedgt: test case report:
| target              | platform_name | test suite                              | test case                              | passed | failed | result | elapsed_time (sec) |
|---------------------|---------------|-----------------------------------------|----------------------------------------|--------|--------|--------|--------------------|
| NRF52840_DK-GCC_ARM | NRF52840_DK   | tests-mbed_hal_fpga_ci_test_shield-uart | 115200, 8N1, FC off                    | 1      | 0      | OK     | 0.3                |
| NRF52840_DK-GCC_ARM | NRF52840_DK   | tests-mbed_hal_fpga_ci_test_shield-uart | 115200, 8N1, FC on                     | 1      | 0      | OK     | 0.35               |
| NRF52840_DK-GCC_ARM | NRF52840_DK   | tests-mbed_hal_fpga_ci_test_shield-uart | 19200, 8N1, FC off                     | 1      | 0      | OK     | 0.33               |
| NRF52840_DK-GCC_ARM | NRF52840_DK   | tests-mbed_hal_fpga_ci_test_shield-uart | 19200, 8N1, FC on                      | 1      | 0      | OK     | 0.37               |
| NRF52840_DK-GCC_ARM | NRF52840_DK   | tests-mbed_hal_fpga_ci_test_shield-uart | 38400, 8N1, FC off                     | 1      | 0      | OK     | 0.32               |
| NRF52840_DK-GCC_ARM | NRF52840_DK   | tests-mbed_hal_fpga_ci_test_shield-uart | 38400, 8N1, FC on                      | 1      | 0      | OK     | 0.35               |
| NRF52840_DK-GCC_ARM | NRF52840_DK   | tests-mbed_hal_fpga_ci_test_shield-uart | 9600, 8E1, FC on                       | 1      | 0      | OK     | 0.4                |
| NRF52840_DK-GCC_ARM | NRF52840_DK   | tests-mbed_hal_fpga_ci_test_shield-uart | basic (direct init), 9600, 8N1, FC off | 1      | 0      | OK     | 0.38               |
| NRF52840_DK-GCC_ARM | NRF52840_DK   | tests-mbed_hal_fpga_ci_test_shield-uart | basic (direct init), 9600, 8N1, FC on  | 1      | 0      | OK     | 0.42               |
| NRF52840_DK-GCC_ARM | NRF52840_DK   | tests-mbed_hal_fpga_ci_test_shield-uart | basic, 9600, 8N1, FC off               | 1      | 0      | OK     | 0.36               |
| NRF52840_DK-GCC_ARM | NRF52840_DK   | tests-mbed_hal_fpga_ci_test_shield-uart | basic, 9600, 8N1, FC on                | 1      | 0      | OK     | 0.39               |
| NRF52840_DK-GCC_ARM | NRF52840_DK   | tests-mbed_hal_fpga_ci_test_shield-uart | init/free, FC off                      | 1      | 0      | OK     | 1.61               |
| NRF52840_DK-GCC_ARM | NRF52840_DK   | tests-mbed_hal_fpga_ci_test_shield-uart | init/free, FC on                       | 1      | 0      | OK     | 2.02               |

Impact of changes

Migration actions required

Documentation


Pull request type

[X] Patch update (Bug fix / Target update / Docs update / Test update / Refactor)
[] Feature update (New feature / Functionality change / New API)
[] Major update (Breaking change E.g. Return code change / API behaviour change)

Test results

[] No Tests required for this change (E.g docs only update)
[X] Covered by existing mbed-os tests (Greentea or Unittest)
[] Tests / results supplied as part of this PR

Reviewers

@jamesbeyond @maciejbocianski @0xc0170 @fkjagodzinski


mprse added 3 commits February 5, 2020 08:47
It is required by Mbed HAL API to generate TxIrq interrupt when TXD register is empty (also after enabling TxIrq interrupt):
https://github.com/ARMmbed/mbed-os/blob/f73a62afbf4052b4da8c5b862ffb4708a80c1b6e/hal/serial_api.h#L144-L147

The driver uses DMA to perform uart transfer and TxIrq is generated after the transfer is finished.
While enabling TxIrq we will check if TXD reg is empty and manually trigger the interrupt.
…0_DK target

According to the documentation, `NRF52840_DK` does not support odd parity and 2 stop bits. Skip these test case using #if !defined(TARGET_NRF52840) directive.
This is temporary solution. In the future we shell consider adding `uart_get_capabilities()` function.
-
@ciarmcom
Copy link
Member

ciarmcom commented Feb 5, 2020

@mprse, thank you for your changes.
@fkjagodzinski @maciejbocianski @jamesbeyond @0xc0170 @ARMmbed/mbed-os-hal @ARMmbed/mbed-os-test @ARMmbed/mbed-os-maintainers please review.

@mprse
Copy link
Contributor Author

mprse commented Feb 5, 2020

@0xc0170 Looks like something went wrong:

0.07s$ arm-none-eabi-gcc --version
The program 'arm-none-eabi-gcc' is currently not installed. To run 'arm-none-eabi-gcc' please ask your administrator to install the package 'gcc-arm-none-eabi'
The command "arm-none-eabi-gcc --version" failed and exited with 127 during .

@0xc0170
Copy link
Contributor

0xc0170 commented Feb 5, 2020

@mprse It is. I checked other tools jobs in Travis, they passed the same command. I restarted the subjob (if it does not help, will restart entire pipeline).

One PR after this one passed Travis, so this was a hiccup somewhere in the CI.

@@ -338,7 +338,9 @@ Case cases[] = {
Case("38400, 8N1, FC off", one_peripheral<UARTNoFCPort, DefaultFormFactor, fpga_uart_test_common_no_fc<38400, 8, ParityNone, 1, false> >),
Case("115200, 8N1, FC off", one_peripheral<UARTNoFCPort, DefaultFormFactor, fpga_uart_test_common_no_fc<115200, 8, ParityNone, 1, false> >),
// stop bits
#if !defined(TARGET_NRF52840)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i really don't like this per board exceptions. I'd rather have a macro defined in the target definition, something like UART_WHATEVER_NOT_SUPPORTED. It's way clearer and also gives you a clear answer to "why".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like I mentioned in the description I consider this as a temporary solution that should be replaced by get_capabilities() function when @fkjagodzinski is back.
But using UART_WHATEVER_NOT_SUPPORTED should be easy to change. I will do it later today.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

jamesbeyond
jamesbeyond previously approved these changes Feb 5, 2020
@mergify mergify bot added needs: CI and removed needs: review labels Feb 5, 2020
@@ -8,7 +8,8 @@
"components": [
"PSA_SRV_IMPL",
"PSA_SRV_EMUL",
"NSPE"
"NSPE",
"FPGA_CI_TEST_SHIELD"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mprse adding this is intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch. 👍

I will remove this. I added this to be able to run FPGA tests and also added this to commit by mistake.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@mprse mprse force-pushed the NRF_Serial_Fpga_fix branch from ecf9ce1 to 8fda5a4 Compare February 6, 2020 11:54
@mergify mergify bot dismissed jamesbeyond’s stale review February 6, 2020 11:54

Pull request has been modified.

@0xc0170
Copy link
Contributor

0xc0170 commented Feb 7, 2020

CI started

@jamesbeyond jamesbeyond self-requested a review February 7, 2020 16:30
@mbed-ci
Copy link

mbed-ci commented Feb 7, 2020

Test run: SUCCESS

Summary: 11 of 11 test jobs passed
Build number : 1
Build artifacts

Copy link
Member

@fkjagodzinski fkjagodzinski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this fix 👍

@0xc0170 0xc0170 merged commit a8e8723 into ARMmbed:master Feb 10, 2020
@mergify mergify bot added release version missing When PR does not contain release version, bot should label it and we fix it afterwards and removed ready for merge labels Feb 10, 2020
@mergify
Copy link

mergify bot commented Feb 10, 2020

This PR does not contain release version label after merging.

@0xc0170 0xc0170 added release-version: 6.0.0-alpha-2 Second pre-release version of 6.0.0 and removed release version missing When PR does not contain release version, bot should label it and we fix it afterwards labels Feb 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-version: 6.0.0-alpha-2 Second pre-release version of 6.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants