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

nrf9160 cannot enable uarte2

Hi

I am using the mqtt_simple project and want to use the second UART (UARTE2) for other serial communication. 

For quick test I have add the folloing in the main function:

struct device *uart1 = device_get_binding("UART_1");
uart_irq_callback_set(uart1, uart_cb);

This cause errors:

Exception occurred in Secure State
***** HARD FAULT *****
Fault escalation (see below)
***** BUS FAULT *****
Precise data bus error
BFAR Address: 0x50008120
***** Hardware exception *****
Current thread ID = 0x20020284
Faulting instruction address = 0x959a
Fatal fault in ISR! Spinning...

I am using command line build with west and non-secure

When I look at the debug output I see that UARTE2 is in the secure domain:

Peripheral Domain Status
04 NRF_UARTE1 Non-Secure OK
05 NRF_UARTE2 Secure SKIP

Anyone know how to proceed with UARTE2?

Do I have to make modifications to SPM (secure_partition_manager) or is it a project setting I have missed?

 

  • Hello, 

    You need to add UART settings in an overlay fileHow it's done is that you create a "$BOARD.overlay" file, in this case named "nrf9160_pca10090ns.overlay" in the project you want to evaluate, for instance $ncs/samples/nrf9160/mqtt_simple/nrf9160_pca10090ns.overlay, which "describes" the peripherals used. Below is an example of this type of file:

    /* needed to get the NRF_UARTE2 defined */
    &uart2 {
    	current-speed = <1000000>;
    	status = "ok";
    	tx-pin = <18>;
    	rx-pin = <17>;
    	rts-pin = <19>;
    	cts-pin = <21>;
    };
    
    &uart1 {
    	current-speed = <115200>;
    	status = "ok";
    	tx-pin = <MY_TXD>;
    	rx-pin = <MY_RXD>;
    	rts-pin = <MY_RTS>;
    	cts-pin = <MY_CTS>;
    };

    You may have to add the same overlay, with UART2 only, to the SPM folder as well. But please try in MQTT_SIMPLE first.

     

    This cause errors:

    Exception occurred in Secure State
    ***** HARD FAULT *****
    Fault escalation (see below)
    ***** BUS FAULT *****
    Precise data bus error
    BFAR Address: 0x50008120
    ***** Hardware exception *****
    Current thread ID = 0x20020284
    Faulting instruction address = 0x959a
    Fatal fault in ISR! Spinning...

     Thiis error is due to the missing overlay file.

    Let me know how this works for you!

    Kind regards,
    Øyvind

  • Hi.

    Last night I modified Kconfig file for SPM:

    config SPM_NRF_UARTE2_NS
    bool "UARTE2 is Non-Secure"
    # default n
    default y

    Default was n, and and then I build SPM again.

    After I added to the mqtt_simple's prj.conf file:

    # UART 1
    CONFIG_UART_1_NRF_UARTE=y

    So now I have serial communication through the VCOM2 :-)

    So I did not use any overlay file to get this running.

    But today I have wanted to use some IO pins for serial communication, not VCOM2.

    Then I read that I have to program the nrf52840 to achieve this (personally I would have prefer a more hardware related solution with open/close the signal paths on a development kit). So I changed the Kconfig file for the nrf52840_pca10090:

    prompt "nRF9160 UART1 routing"
    #default BOARD_PCA10090_UART1_VCOM
    default BOARD_PCA10090_UART1_ARDUINO

    Set to default BOARD_PCA10090_UART1_ARDUINO

    Since I used the hello_world sample, I added to the prj.conf file:

    CONFIG_BOARD_PCA10090_UART1_ARDUINO=y

    Then I built and program zephyr\samples\hello_world to the nrf52840

    I lost my serial communication with VCOM2 which was expected, but I did not get the serial communication at the expected pins  (P0.00 - TXD, P0.01 - RXD, P0.14 - CTS and P0.15 RTS). I checked and found out that the voltage level was not 3.3V, but 1.8V and I am pretty sure I have TXD from nrf9160 on pin P0.01 and not RXD which is documented in nRF91_DK_User_Guide, Table 4: Board control routing

    Now I have serial communication through the IO pins also :-)

    I do not know if it was an overlay file before I started or I made/copy it myself to be honest, but in the spm project I have an overlay file (which I need to have if not build error). The content of this overlay file is:

    /* needed to get the NRF_UARTE2 defined */
    &uart2 {
    status = "ok";
    };

    To summarize, I have UARTE2 communication through the IO pins, or should I refer to the uart as UART_1. I am confused about the naming here.

  • I am glad you were able to get this working! In regards to the pin mapping, please see this thread.

    Kind regards,
    Øyvind

Related