nRF5340 - Transferring a project between cpuapp and cpunet

Hello,

I am using Nordic nRF Connect SDK v3.1.1 and nRF5340DK board.
My project is based on the project: GitHub - nordic-auko/nRF5-ble-timesync-demo: nRF52 clock synchronization demo code.
Timesync project is intended to be built on cpunet, so also my project.

I want to collect data from ADC, send it via BLE and synchronizing (like in ble-timesync-demo), so I want to build this project on cpuapp or make multi core app where cpuapp will collect data from ADC and cpunet will sending/receiving data via BLE and synchronizing. 

Is it possible and if so, how to do it?

When I tried to build this project on cpuapp i get many errors. Below are some of them:
C:/ncs/v3.1.1/modules/hal/nordic/nrfx/hal/nrf_radio.h:65:41: error: unknown type name 'NRF_RADIO_Type'
65 | NRF_RADIO_TASK_TXEN = offsetof(NRF_RADIO_Type, TASKS_TXEN), /**< Enable RADIO in TX mode. */
| ^~~~~~~~~~~~~~
C:/ncs/v3.1.1/modules/hal/nordic/nrfx/hal/nrf_radio.h:66:41: error: unknown type name 'NRF_RADIO_Type'
66 | NRF_RADIO_TASK_RXEN = offsetof(NRF_RADIO_Type, TASKS_RXEN), /**< Enable RADIO in RX mode. */
| ^~~~~~~~~~~~~~
C:/ncs/v3.1.1/modules/hal/nordic/nrfx/hal/nrf_radio.h:67:41: error: unknown type name 'NRF_RADIO_Type'
67 | NRF_RADIO_TASK_START = offsetof(NRF_RADIO_Type, TASKS_START), /**< Start RADIO. */


C:/ncs/v3.1.1/modules/hal/nordic/nrfx/hal/nrf_radio.h:328:47: error: 'RADIO_SHORTS_ADDRESS_RSSISTART_Msk' undeclared here (not in a function)
328 | NRF_RADIO_SHORT_ADDRESS_RSSISTART_MASK = RADIO_SHORTS_ADDRESS_RSSISTART_Msk, /**< Shortcut between ADDRESS event and RSSISTART task. */
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/ncs/v3.1.1/modules/hal/nordic/nrfx/hal/nrf_radio.h:329:47: error: 'RADIO_SHORTS_END_START_Msk' undeclared here (not in a function); did you mean 'SPIM_SHORTS_END_START_Msk'?
329 | NRF_RADIO_SHORT_END_START_MASK = RADIO_SHORTS_END_START_Msk, /**< Shortcut between END event and START task. */
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
| SPIM_SHORTS_END_START_Msk
C:/ncs/v3.1.1/modules/hal/nordic/nrfx/hal/nrf_radio.h:330:47: error: 'RADIO_SHORTS_ADDRESS_BCSTART_Msk' undeclared here (not in a function); did you mean 'NRF_RADIO_SHORT_ADDRESS_RSSISTART_MASK'?
330 | NRF_RADIO_SHORT_ADDRESS_BCSTART_MASK = RADIO_SHORTS_ADDRESS_BCSTART_Msk, /**< Shortcut between ADDRESS event and BCSTART task. */
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| NRF_RADIO_SHORT_ADDRESS_RSSISTART_MASK


C:/ncs/v3.1.1/modules/hal/nordic/nrfx/hal/nrf_radio.h:507:41: error: 'RADIO_MODE_MODE_Ble_1Mbit' undeclared here (not in a function)
507 | NRF_RADIO_MODE_BLE_1MBIT = RADIO_MODE_MODE_Ble_1Mbit, /**< 1 Mbit/s Bluetooth Low Energy. */
| ^~~~~~~~~~~~~~~~~~~~~~~~~
C:/ncs/v3.1.1/modules/hal/nordic/nrfx/hal/nrf_radio.h:543:37: error: 'RADIO_CRCCNF_OFFSET_Include' undeclared here (not in a function)
543 | NRF_RADIO_CRC_ADDR_INCLUDE = RADIO_CRCCNF_OFFSET_Include, /**< CRC calculation includes address field. */
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/ncs/v3.1.1/modules/hal/nordic/nrfx/hal/nrf_radio.h:548:37: error: 'RADIO_CRCCNF_OFFSET_Skip' undeclared here (not in a function)
548 | NRF_RADIO_CRC_ADDR_SKIP = RADIO_CRCCNF_OFFSET_Skip, /**< CRC calculation does not include address field. */
| ^~~~~~~~~~~~~~~~~~~~~~~~
C:/ncs/v3.1.1/modules/hal/nordic/nrfx/hal/nrf_radio.h:713:47: error: unknown type name 'NRF_RADIO_Type'; did you mean 'NRF_GPIO_Type'?
713 | NRF_STATIC_INLINE void nrf_radio_task_trigger(NRF_RADIO_Type * p_reg, nrf_radio_task_t task);
| ^~~~~~~~~~~~~~
| NRF_GPIO_Type
C:/ncs/v3.1.1/modules/hal/nordic/nrfx/hal/nrf_radio.h:725:55: error: unknown type name 'NRF_RADIO_Type'; did you mean 'NRF_GPIO_Type'?
725 | NRF_STATIC_INLINE uint32_t nrf_radio_task_address_get(NRF_RADIO_Type const * p_reg,
| ^~~~~~~~~~~~~~
| NRF_GPIO_Type
C:/ncs/v3.1.1/modules/hal/nordic/nrfx/hal/nrf_radio.h:734:46: error: unknown type name 'NRF_RADIO_Type'; did you mean 'NRF_GPIO_Type'?
734 | NRF_STATIC_INLINE void nrf_radio_event_clear(NRF_RADIO_Type * p_reg, nrf_radio_event_t event);
| ^~~~~~~~~~~~~~
| NRF_GPIO_Type



Best Regards

Parents
  • Hi,

    This sample needs direct access to the radio for th etime syncronization code and so can only run on the network core. In principle you could expand it to handle inter process communication, and communciate with your app core application (the same as is use an empty app core image that just forwards a few GPIO ports and starts the network core, before the application core enters sleep.

    May I ask about the sue case? Note that the time syncrhonisation is done with propritary radio and not BLE, so it can only work between two nRF devices that you controll.

Reply
  • Hi,

    This sample needs direct access to the radio for th etime syncronization code and so can only run on the network core. In principle you could expand it to handle inter process communication, and communciate with your app core application (the same as is use an empty app core image that just forwards a few GPIO ports and starts the network core, before the application core enters sleep.

    May I ask about the sue case? Note that the time syncrhonisation is done with propritary radio and not BLE, so it can only work between two nRF devices that you controll.

Children
  • I want to know how to use peripherals from cpuapp in appliction, that is built on cpunet.

    I want to use ADC and send data from one device to another one (with time synchronization).

    But I don't knot how to do it. I know, that there is forward mechanizm, but I want to know how to use it, and share peripherals between cpuapp and cpunet.


  • Hi,

    This is not trivial. Do you have a specific need for the nRF5340? If not, I would consider the nRF54L15 (or even the nRF52840) to avoid the complexities of multi core.

    Also, can you elaborate on the over all goal here? As mentionned, the time syncrhonization does not use Bluetooht so you will only be able to use this between nRF devices that you controll in both ends.

    Th network core has limited memory, and accessing application core resources is not straight-forward. So you will have to implement an network core application that handles the radio (Bluetooth and ESB),  and application core application that handles the peripherals and communicate between the cores.

  • I know, that time syncrhonization does not use BLE. I added communication via BLE to timesync app and I built two separate applications based on timesync-demo sample. 

    I have 2 applications:
    - First is receiving BLE data and sending synchronization data - which I will have on one device
    - Second is sending BLE data and receiving synchronization - which I will have on two or three devices

    Now I am synchronizing all devices and sending dummy data via BLE, but I want to read data from ADC and send it via BLE.
    But app is build for cpunet.

    Can you describe what I should do to implement this ?

    Are only changes in the board files or .overlay files are enough or do I also need to make changes to the application code?

  • I see. You will need to do more than just .overlay files, implementation work is needed. But there are samples for all the building blocks, which you need to combine and adapt to your needs yourself.

    You can use the unofficial time sync demo you have found as a basis for the network core application. But you also need to implement the app core application performing ADC sampling (you can refer to the ADC samples). Lastly, you need to somehow communicate between the app core ant the net core so that the net core can obtain the ADC samples. I recommend you look at the IPC service sample for that.

Related