The library implements a communication interface between the Application and Modem cores on the nRF9160 through the RPC protocol, using the Inter Processor Communication (IPC) peripheral and a shared region of RAM.
The shared memory between the application and modem cores must reside within the lowest 128 kilobytes of RAM.
The application is responsible for reserving the memory area before passing it onto the library.
In bootloader mode, the shared memory area must be as large as the value of
NRF_MODEM_SHMEM_BOOTLOADER_SIZE and its base address must be 4-bytes aligned.
The library accepts the shared memory base address and size as parameters to the
nrf_modem_bootloader_init() function through the
In normal operating mode, the shared memory is divided into the following four regions:
The application can adjust the size of these regions based on its requirements, with the exception of the control region, which has a fixed size that must be equal to the value of
The base address of all regions must be 4-bytes aligned.
The library accepts the layout of these regions as parameters to the
nrf_modem_init() function through the
For nRF Connect SDK users, the Partition Manager will automatically reserve some RAM for each region during linking, according to the size of each region as specified in the glue.
The control area contains the data structures that are used to setup the communication between the modem core and the application core.
Among the sizes of the memory regions, only the size of the control area is fixed, and it is exported in the
For nRF Connect SDK users, the build system and the glue implementation will automatically take care of passing the correct size to the
The TX area contains the data payload of messages that are sent to the modem.
The size of this area affects the largest buffer that
nrf_send() can send in a single call, and the size of the longest AT command that can be sent to the modem.
When provisioning the TLS certificates, the size of the TX area must be large enough to accommodate the TLS certificate and the AT command that is used for provisioning.
The library OS abstraction layer defines the following functions to allocate and free data in this memory region:
It must be possible for the Modem library to allocate up to the number of bytes passed by the TX region size in the
If the OS implementation of
nrf_modem_os_shm_tx_alloc() requires any overhead, additional memory must be set aside by the application.
The RX area is entirely managed by the modem and this area contains all the incoming data from the modem.
The incoming data includes GNSS data, AT command responses, and IP traffic.
The size of this area determines the maximum amount of incoming data from the modem that the application core can buffer.
If the area is full and the application has not read the data yet, new data cannot be buffered in this area.
An example of an operation that requires a large RX area is the reading of a TLS certificate associated with a security tag.
The size of the RX area must be as large as the size of the TLS certificate that is being read, and the AT command that is used to read the certificate.
The trace area contains the trace output from the modem core.
This area of memory is optional, and the area size can be configured to be zero, to disable the trace output.