nRF5340 - Accessing Shared Memory

Hello. I am just getting started with nRF5340 development using the u-Blox NORA-B106 dev kit. I am trying to use the peripheral_uart code example to understand how the two processors use the shared memory space to communicate. I am able to send data over Bluetooth and have it appear in a terminal connected to the J-link UART, so the app is working. But tracing through the code, I'm unable to find where the received data is being put in shared memory so the UART function call can see it.

1) Can someone point me to the specific code within this example where this happens?

2) In general, how do you assign a variable to reside in this space so that both processors can access it? I'm assuming this is done through linker files for both net and app builds so that the same variable is mapped to the same memory location, but I can't find those files either.

Coming from STM32 and FreeRTOS, so the Zephyr learning curve is feeling steep so far. Any help is appreciated.

Thanks,

Jamie

  • Hello and sorry about the delay. I must've overlooked this case for a while.

    jmilliken said:
    So now we have established a shared memory region, okay, so far so good.

    Yes, this is where it is defined.

    The documentation on what is mentioned in the snippets you have from device tree there could arguably be improved, but there is a lot available. Here is a bit on the "ipc-openamp-static-vrings" devicetree binding, and there is apparently also a sample on it. And here is a bit on the mboxes.

    jmilliken said:
    also, where are the linker files?

    Build/zephyr/

    jmilliken said:
    How do each of the programs use this memory region?

    Well that depends. IPC might be the most common, though here is also an example of something a bit more basic: this module is used to write a single struct to a RAM area which is known by both cores. The appcore writes here, and the netcore reads here.

    In the case of IPC, the PS probably describes this best (Section 7.16). 

    The IPC indicates to the other core that there is new data available to pick up. The actual data exchange is handled by Open Asymmetric Multi-Processing (OpenAMP). Zephyr includes the OpenAMP library, which provides a complete solution for exchanging messages between the cores. The IPC peripheral is presented to Zephyr as an Interprocessor Mailbox (IPM) device. The OpenAMP library uses the IPM SHIM layer, which in turn uses the IPC driver in nrfx.

    jmilliken said:
    const struct device *hci_ipc_instance = DEVICE_DT_GET(DT_NODELABEL(ipc0));

    That creates a pointer to the device driver. There is more on that here.

    jmilliken said:
    How is peripheral_uart using the ipc system and the shared memory?

    I believe this happens in the dts file nrf5340_cpuapp_common.dts:

    REgards,

    Elfving

Related