Logging app core and net core on same UART peripheral.

Hi, 

Is it possible to use the same UART instance for app core and net core to put the log messages? I am using an nRF5340DK board, which uses a separate COM port for each core logging function.

  • The main problem of sharing a resource is who gets to use it when two people want to write to it. You would need to include something in the output driver that throws away messages from the net core when the app core uses it (or the other way around). If you want messages from both then it gets more difficult, with the need for some kind of queue and some task that processes that queue. Then the log messages need to write to queue in an efficient and safe way. 

    It's doable but you may need to create something to handle it. 

    Now that I typed this, I wouldn't be surprised if this is handled some way in zephyr. Maybe search the documentation and see if there is resource sharing on multiple core support.

  • Hello,

    The way that the peripherals work in the nRF5340 is that they need to belong to either the network core or the application core. So actually, it is not possible for both of them to access the same UART instance. Technically, you could use two UART instances, and short their TX pins together with some resistors, but that would turn into jibberish if (when) they try to write at the same time. 

    If you really want this, I think the way to go is to send a message from one core to the other, and then have that core push it out through the log. For this, you can look into the ipc service sample (ncs\nrf\samples\ipc\ipc_service). 

    But I imagine it is more work than just opening two UART terminals. 

    Best regards,

    Edvin

Related