This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

LP-UART sample crashes continuously

Setup -

  1. nRF52840-DK
  2. Nordic Connect SDK version 1.5.0
  3. Sample - nrf/samples/peripheral/lpuart
  4. Commented out "uart0" in the board specific overlay
  5. Uncommented console logging from "prj.conf"
  6. Commented "CONFIG_CONSOLE=n" and "CONFIG_UART_CONSOLE=n"
  7. As mentioned in the sample, shorted TX with RX and Request Pin with Response Pin.
  8. Built and flashed the firmware

"MPU FAULT" error is observed, with continuous crashes (console logs are attached).

On "nRF9160 DK" when LP-UART is used instead of UART, there is no communication between nRF9160 and nRF52840 on the DK.

[:00�:01.259,033] <inf> app: Received data 5 bytes
[00:00:01.758,911] <inf> app: Received data 1 bytes
[00:00:01.858,947] <inf> app: Tx sent 5 bytes
[00:00:01.859,619] <inf> app: Received data 5 bytes
[2021-03-04 23:19:28] [00:00:02.258,575] <err> os: ***** MPU FAULT *****
[2021-03-04 23:19:28] [00:00:02.258,605] <err> os:   Stacking error (context area might be not valid)
[2021-03-04 23:19:28] [00:00:02.258,605] <err> os:   Data Access Violation
[2021-03-04 23:19:28] [00:00:02.258,636] <err> os:   MMFAR Address: 0x20000d9c
[2021-03-04 23:19:28] [00:00:02.258,666] <err> os: r0/a1:  0x0000072c  r1/a2:  0x00000730  r2/a3:  0x00000734
[2021-03-04 23:19:28] [00:00:02.258,666] <err> os: r3/a4:  0x00000738 r12/ip:  0x0000073c r14/lr:  0x00000740
[2021-03-04 23:19:28] [00:00:02.258,697] <err> os:  xpsr:  0x00000600
[2021-03-04 23:19:28] [00:00:02.258,728] <err> os: Faulting instruction address (r15/pc): 0x00000744
[2021-03-04 23:19:28] [00:00:02.258,758] <err> os: >>> ZEPHYR FATAL ERROR 2: Stack overflow on CPU 0
[2021-03-04 23:19:28] [00:00:02.258,758] <err> os: Current thread: 0x20000318 (unknown)
[2021-03-04 23:19:28] [00:00:02.353,057] <err> fatal_error: Resetting system�*** Booting Zephyr OS build v2.4.99-ncs1  ***
[2021-03-04 23:19:30.758] [0[00:00:01.259,063] <inf> app: Received data 5 bytes
[2021-03-04 23:19:30.762] [00:00:01.758,941] <inf> app: Received data 1 bytes
[2021-03-04 23:19:30.769] [00:00:01.858,978] <inf> app: Tx sent 5 bytes
[2021-03-04 23:19:30.773] [00:00:01.859,649] <inf> app: Received data 5 bytes
[2021-03-04 23:19:30.778] [00:00:02.258,605] <err> os: ***** MPU FAULT *****
[2021-03-04 23:19:30.784] [00:00:02.258,636] <err> os:   Stacking error (context area might be not valid)
[2021-03-04 23:19:30.792] [00:00:02.258,636] <err> os:   Data Access Violation
[2021-03-04 23:19:30.798] [00:00:02.258,666] <err> os:   MMFAR Address: 0x20000d9c
[2021-03-04 23:19:30.804] [00:00:02.258,697] <err> os: r0/a1:  0x0000072c  r1/a2:  0x00000730  r2/a3:  0x00000734
[2021-03-04 23:19:30.814] [00:00:02.258,697] <err> os: r3/a4:  0x00000738 r12/ip:  0x0000073c r14/lr:  0x00000740
[2021-03-04 23:19:30.822] [00:00:02.258,728] <err> os:  xpsr:  0x00000600
[2021-03-04 23:19:30.828] [00:00:02.258,758] <err> os: Faulting instruction address (r15/pc): 0x00000744
[2021-03-04 23:19:30.836] [00:00:02.258,789] <err> os: >>> ZEPHYR FATAL ERROR 2: Stack overflow on CPU 0
[2021-03-04 23:19:30.844] [00:00:02.258,789] <err> os: Current thread: 0x20000318 (unknown)
[2021-03-04 23:19:30.852] [00:00:02.352,996] <err> fatal_error: Resetting system�*** Booting Zephyr OS build v2.4.99-ncs1  ***
[2021-03-04 23:19:33.117] [0[00:00:01.259,094] <inf> app: Received data 5 bytes
[2021-03-04 23:19:33.122] [00:00:01.758,972] <inf> app: Received data 1 bytes
[2021-03-04 23:19:33.128] [00:00:01.859,008] <inf> app: Tx sent 5 bytes
[2021-03-04 23:19:33.133] [00:00:01.859,680] <inf> app: Received data 5 bytes
[2021-03-04 23:19:33.138] [00:00:02.258,636] <err> os: ***** MPU FAULT *****
[2021-03-04 23:19:33.144] [00:00:02.258,666] <err> os:   Stacking error (context area might be not valid)
[2021-03-04 23:19:33.152] [00:00:02.258,666] <err> os:   Data Access Violation
[2021-03-04 23:19:33.158] [00:00:02.258,697] <err> os:   MMFAR Address: 0x20000d9c
[2021-03-04 23:19:33.164] [00:00:02.258,728] <err> os: r0/a1:  0x0000072c  r1/a2:  0x00000730  r2/a3:  0x00000734
[2021-03-04 23:19:33.173] [00:00:02.258,728] <err> os: r3/a4:  0x00000738 r12/ip:  0x0000073c r14/lr:  0x00000740
[2021-03-04 23:19:33.182] [00:00:02.258,758] <err> os:  xpsr:  0x00000600
[2021-03-04 23:19:33.188] [00:00:02.258,789] <err> os: Faulting instruction address (r15/pc): 0x00000744
[2021-03-04 23:19:33.196] [00:00:02.258,819] <err> os: >>> ZEPHYR FATAL ERROR 2: Stack overflow on CPU 0
[2021-03-04 23:19:33.204] [00:00:02.258,819] <err> os: Current thread: 0x20000318 (unknown)
[2021-03-04 23:19:33.211] [00:00:02.353,088] <err> fatal_error: Resetting system�*** Booting Zephyr OS build v2.4.99-ncs1  ***
[2021-03-04 23:19:35.476] [0[00:00:01.259,094] <inf> app: Received data 5 bytes
[2021-03-04 23:19:35.481] [00:00:01.758,972] <inf> app: Received data 1 bytes
[2021-03-04 23:19:35.487] [00:00:01.859,008] <inf> app: Tx sent 5 bytes
[2021-03-04 23:19:35.492] [00:00:01.859,680] <inf> app: Received data 5 bytes
[2021-03-04 23:19:35.497] [00:00:02.258,636] <err> os: ***** MPU FAULT *****
[2021-03-04 23:19:35.503] [00:00:02.258,666] <err> os:   Stacking error (context area might be not valid)
[2021-03-04 23:19:35.511] [00:00:02.258,666] <err> os:   Data Access Violation
[2021-03-04 23:19:35.517] [00:00:02.258,697] <err> os:   MMFAR Address: 0x20000d9c
[2021-03-04 23:19:35.523] [00:00:02.258,728] <err> os: r0/a1:  0x0000072c  r1/a2:  0x00000730  r2/a3:  0x00000734
[2021-03-04 23:19:35.532] [00:00:02.258,728] <err> os: r3/a4:  0x00000738 r12/ip:  0x0000073c r14/lr:  0x00000740
[2021-03-04 23:19:35.541] [00:00:02.258,758] <err> os:  xpsr:  0x00000600
[2021-03-04 23:19:35.547] [00:00:02.258,789] <err> os: Faulting instruction address (r15/pc): 0x00000744
[2021-03-04 23:19:35.555] [00:00:02.258,819] <err> os: >>> ZEPHYR FATAL ERROR 2: Stack overflow on CPU 0
[2021-03-04 23:19:35.563] [00:00:02.258,819] <err> os: Current thread: 0x20000318 (unknown)
[2021-03-04 23:19:35.570] [00:00:02.353,088] <err> fatal_error: Resetting system�*** Booting Zephyr OS build v2.4.99-ncs1  ***
[2021-03-04 23:19:37.834] [0[00:00:01.259,063] <inf> app: Received data 5 bytes
[2021-03-04 23:19:37.840] [00:00:01.758,941] <inf> app: Received data 1 bytes
[2021-03-04 23:19:37.846] [00:00:01.858,978] <inf> app: Tx sent 5 bytes
[2021-03-04 23:19:37.851] [00:00:01.859,649] <inf> app: Received data 5 bytes
[2021-03-04 23:19:37.856] [00:00:02.258,605] <err> os: ***** MPU FAULT *****
[2021-03-04 23:19:37.862] [00:00:02.258,636] <err> os:   Stacking error (context area might be not valid)
[2021-03-04 23:19:37.870] [00:00:02.258,636] <err> os:   Data Access Violation
[2021-03-04 23:19:37.876] [00:00:02.258,666] <err> os:   MMFAR Address: 0x20000d9c
[2021-03-04 23:19:37.882] [00:00:02.258,697] <err> os: r0/a1:  0x0000072c  r1/a2:  0x00000730  r2/a3:  0x00000734
[2021-03-04 23:19:37.891] [00:00:02.258,697] <err> os: r3/a4:  0x00000738 r12/ip:  0x0000073c r14/lr:  0x00000740
[2021-03-04 23:19:37.900] [00:00:02.258,728] <err> os:  xpsr:  0x00000600
[2021-03-04 23:19:37.905] [00:00:02.258,758] <err> os: Faulting instruction address (r15/pc): 0x00000744
[2021-03-04 23:19:37.914] [00:00:02.258,789] <err> os: >>> ZEPHYR FATAL ERROR 2: Stack overflow on CPU 0
[2021-03-04 23:19:37.922] [00:00:02.258,789] <err> os: Current thread: 0x20000318 (unknown)
[2021-03-04 23:19:37.929] [00:00:02.353,057] <err> fatal_error: Resetting system�*** Booting Zephyr OS build v2.4.99-ncs1  ***

  • I was not able to reproduce the MPU fault. Can you test with the same changes I did:

    diff --git a/samples/peripheral/lpuart/boards/nrf52840dk_nrf52840.overlay b/samples/peripheral/lpuart/boards/nrf52840dk_nrf52840.overlay
    index 54d3d0bc1..d3ad94ce1 100644
    --- a/samples/peripheral/lpuart/boards/nrf52840dk_nrf52840.overlay
    +++ b/samples/peripheral/lpuart/boards/nrf52840dk_nrf52840.overlay
    @@ -1,8 +1,8 @@
     /* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */
    
     &uart1 {
    -       rx-pin = <44>;
    -       tx-pin = <45>;
    +       rx-pin = <44>; // 12
    +       tx-pin = <45>; // 13
            /delete-property/ rts-pin;
            /delete-property/ cts-pin;
    
    @@ -10,11 +10,11 @@
                    compatible = "nordic,nrf-sw-lpuart";
                    status = "okay";
                    label = "LPUART";
    -               req-pin = <46>;
    -               rdy-pin = <47>;
    +               req-pin = <46>; // 14
    +               rdy-pin = <47>; // 15
            };
     };
    
    -&uart0 {
    +/*&uart0 {
            status = "disabled";
    -};
    +};*/
    diff --git a/samples/peripheral/lpuart/prj.conf b/samples/peripheral/lpuart/prj.conf
    index ba5f898e0..6c0eaf00c 100644
    --- a/samples/peripheral/lpuart/prj.conf
    +++ b/samples/peripheral/lpuart/prj.conf
    @@ -11,13 +11,13 @@ CONFIG_NRF_SW_LPUART=y
     # in overlay.
    
     # CONFIG_USE_SEGGER_RTT=n
    -# CONFIG_LOG=y
    +CONFIG_LOG=y
     # CONFIG_NO_OPTIMIZATIONS=y
     # CONFIG_ASSERT=y
    
     # Comment this section for debugging
    -CONFIG_CONSOLE=n
    -CONFIG_UART_CONSOLE=n
    +#CONFIG_CONSOLE=n
    +#CONFIG_UART_CONSOLE=n
    
     # Uncomment to use lpuart using interrupt driven API
     # CONFIG_NRF_SW_LPUART_INT_DRIVEN=y

    Best regards,

    Simon

  • That config seems to work fine, when I apply the patches - Patch 1 and Patch 2. Changing the prj.conf by itself does not make this work.

    With the patch applied, LP-UART works when "async" mode is used.

    When configuration is changed to "Interrupt Driven" mode, MPU fault is observed. Following configuration changes were made -

    In prj.conf enabled - CONFIG_NRF_SW_LPUART_INT_DRIVEN=y

    In board specific config -

    CONFIG_UART_1_ASYNC=n
    CONFIG_UART_1_INTERRUPT_DRIVEN=y

    Changing these configurations results in continuous crash due to "MPU Fault - Data Access Violation"

    Which configurations are to be modified to change to "interrupt driven" mode?

  • I was able to make "interrupt driven" mode work using NCS v1.5.0 and nrf52840dk_nrf52840 and the following changes:

    diff --git a/samples/peripheral/lpuart/boards/nrf52840dk_nrf52840.overlay b/samples/peripheral/lpuart/boards/nrf52840dk_nrf52840.overlay
    index 54d3d0bc1..266936e12 100644
    --- a/samples/peripheral/lpuart/boards/nrf52840dk_nrf52840.overlay
    +++ b/samples/peripheral/lpuart/boards/nrf52840dk_nrf52840.overlay
    @@ -15,6 +15,6 @@
            };
     };
    
    -&uart0 {
    +/*&uart0 {
            status = "disabled";
    -};
    +};*/
    diff --git a/samples/peripheral/lpuart/diffs.patch b/samples/peripheral/lpuart/diffs.patch
    new file mode 100644
    index 000000000..e69de29bb
    diff --git a/samples/peripheral/lpuart/prj.conf b/samples/peripheral/lpuart/prj.conf
    index ba5f898e0..4f1e856dd 100644
    --- a/samples/peripheral/lpuart/prj.conf
    +++ b/samples/peripheral/lpuart/prj.conf
    @@ -11,13 +11,13 @@ CONFIG_NRF_SW_LPUART=y
     # in overlay.
    
     # CONFIG_USE_SEGGER_RTT=n
    -# CONFIG_LOG=y
    +CONFIG_LOG=y
     # CONFIG_NO_OPTIMIZATIONS=y
     # CONFIG_ASSERT=y
    
     # Comment this section for debugging
    -CONFIG_CONSOLE=n
    -CONFIG_UART_CONSOLE=n
    +#CONFIG_CONSOLE=n
    +#CONFIG_UART_CONSOLE=n
    
     # Uncomment to use lpuart using interrupt driven API
    -# CONFIG_NRF_SW_LPUART_INT_DRIVEN=y
    +CONFIG_NRF_SW_LPUART_INT_DRIVEN=y

    I then got the following output in Termite:

    *** Booting Zephyr OS build v2.4.99-ncs1  ***
    read 5 bytes
    read 1 bytes
    read 5 bytes
    read 1 bytes
    read 5 bytes
    read 1 bytes
    read 5 bytes
    read 1 bytes
    read 5 bytes
    read 1 bytes
    read 5 bytes
    read 1 bytes
    read 5 bytes
    read 1 bytes
    read 5 bytes
    read 1 bytes
    read 5 bytes

    Could you test this on your end and see if you're able to make it work?

  • hei
    Can you help me to make the UART transmitioin goes only once?

Related