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

How to use UARTE1 for mesh serial DFU instead of UARTE0?

Current situation:

    I am using uarte to communicate over UART, at Individual level this works.
    I have serial mesh DFU implemented in my application and at individual level this works. (I see the serial_uart_init uses NRF_UART0 directly)

Now I have to integrate both in same application. I tried it and I'm getting following error

1> build/aio_Debug/obj/nrfx_uarte.o: In function `UARTE0_UART0_IRQHandler':
1> /home/shubham/aio/nRF_SDKs/nRF5_SDK_15.2.0_9412b96/modules/nrfx/drivers/src/nrfx_uarte.c:575: multiple definition of `UARTE0_UART0_IRQHandler'
1> build/aio_Debug/obj/serial_uart.o:/home/shubham/aio/nRF_SDKs/nrf5SDKforMeshv310src/mesh/serial/src/serial_uart.c:60: first defined here
Build failed


Rather I would like to know how to use both UARTs is there any simpler way to integrate both usages?

Parents
  • Hi Shubham, 

    Could you tell what you use UART for? If you use UART for purely logging and debugging, I would suggest to use RTT.

    If you user UART for communication, you would need to chose to use either nrfx_uarte.c or serial_uart.c 

    I would suggest to use serial_uart.c (serial.c)  to not to break the DFU features that included inside the serial library of Mesh. 

    In that case you would need to adapt your protocol to into the m_cmd_handlers[] list as defined in serial.c 

    x Is it possible to use different UART ? You may think of using UART instead of UARTE ? 

    If you want to use the same UART/UARTE, one option is to use a flag, so you will have single UARTE0_UART0_IRQHandler() but depend on the flag, you can call either the handler inside the nrfx_uarte.c or the handler inside serial_uart.c 

    What is your exact use case ? 

  • you will have single UARTE0_UART0_IRQHandler() but depend on the flag, you can call either the handler inside the nrfx_uarte.c or the handler inside serial_uart.c 

    How to decide which handler to call?

Reply Children
  • This only applied if you don't plan to have both UART operating simultaneously. If you know exactly when you want to do DFU then you can switch the flag to forward the interrupt to serial_uart.c

    For your application, I would suggest to follow the first suggestion to use only serial_uart.c and then add your own opcode into the list. 

  • Hey Hung,

    It is working.

    In sdk_config.h, enabled UART0_ENABLED, UART1_ENABLED and UART_EASY_DMA_SUPPORT.
    Above setting enables NRFX_UARTE0_ENABLED and NRFX_UARTE1_ENABLED.

    I used UARTE1 in nrf sdk and commented the IRQ handler for UARTE0.

    This way I can use UARTE1 from nrf sdk and nrf mesh sdk uses UART0.

    So I am not getting any build conflicts as well as both serials are working fine just that I changed the pin numbers in serial_uart.c


    Do you see any downside here? FYI, for serial DFU, I will be getting firmware on UARTE1 and then I may have to direct it to mesh sdk's UART.

  • Also I found following scenario strange:

    In sdk_config.h
        UART0_ENABLED is disabled,
        UART1_ENABLED and UART_EASY_DMA_SUPPORT is enabled.
    Above setting enables NRFX_UARTE1_ENABLED and disables NRFX_UARTE0_ENABLED.

    I have not commented the IRQ handler for UARTE0 in nrfx_uarte.c and even this is working fine.

    UART0 is disabled in this case so why is it working? Does it has something to do about direct use of Register NRF_UART0?

  • Hi Shubham, 

    I'm sorry for my mistake. I was thinking that you were using nRF52832 where there is only one UARTE. 

    On the nRF52840 you have 2 UARTEs. 

    Regarding your question, please be aware that sdk_config.h is mainly made for nRF52 SDK not for nRFMesh SDK. So the libary in serial_uart.c doesn't use the defines in sdk_config.h. 

    Actually it doesn't use UARTE at all. It use UART (which share the same register address as UARTE0). You can find that by looking at the enable call inside serial_uart_init: 

    NRF_UART0->ENABLE = UART_ENABLE_ENABLE_Enabled << UART_ENABLE_ENABLE_Pos;

    So it's totally fine to have UARTE1 and UART at the same time. 

  • Thats good then

    I'll use UARTE1 from nrf sdk and UART0 from nrf mesh sdk.


    Thanks

Related