nrf_modem_lib_init wont return / gets stuck on ncs 3.4.0 nrf9160

Hello,

when migrating to ncs 3.4.1 I discovered that calling nrf_modem_lib_init makes the firmware get stuck and never comes back from that call.

It is the same behaviour with ncs 3.4.0. When building and running it with ncs 2.8.0 the problem does not occur.

I am running it on an Actinius Icarus V2 with a nrf9160 chip on (build target: [email protected]/nrf9160/ns). I have read that some people have problems with connected reserved pins in their custom boards which causes similar issues, but with the Actinius boards we never had that problem. The behaviour is the same on multiple boards.

I took the hello world example added the following things:

sysbuild.conf:

SB_CONFIG_BOOTLOADER_MCUBOOT=y

proj.conf:

CONFIG_LOG=y
CONFIG_NRF_MODEM_LIB=y

CONFIG_NETWORKING=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_OFFLOAD=y
CONFIG_NET_NATIVE=n

CONFIG_HEAP_MEM_POOL_SIZE=4096
CONFIG_MAIN_STACK_SIZE=4096

main.c:

#include <stdio.h>
#include <zephyr/kernel.h>
#include <modem/nrf_modem_lib.h>

int main(void)
{
	printf("Hello World! %s\n", CONFIG_BOARD_TARGET);

	k_sleep(K_SECONDS(1));
	printf("Ready\n");

	nrf_modem_lib_init();

	printf("Finished\n");

	return 0;
}

I attached the project.

Thank you for your support!

Best regards

Moritz

hello_world_modem_init_fail.zip

  • Hi,

    Thanks for reaching out. Can you share the picture of Sip marking of your board and the modem firmware version. Moreover you confirm that nrf_modem_lib_init works on ncs 2.8.0 but not on ncs 3.4.1/ncs 3.4.0?

    Best Regards,
    Syed Maysum

  • Hi Syed Maysum,

    Modem Firmware Version is 1.3.7.

    I can confirm that it works on 2.8.0 but not on 3.4.0/3.4.1. 

    Best regards

    Moritz

  • Hi,

    Thanks for the detailed report.

    I checked this works on the nRF9160 DK with NCS 3.4.1, so the issue looks to be specific to the Actinius Icarus V2 board. Actually in NCS 3.4.x, the Partition Manager is disabled by default. Previously it auto generated the correct memory layout for any nRF9160 based board. Now, each board must explicitly define its flash and SRAM partitions using devicetree overlays, including the shared memory region used for modem communication. So can you try adding the following includes to your board's .overlay file:

    Since you're using MCUboot:

    #include <samples/cellular/nrf91_bootloader_partitions.dtsi>
    #include <samples/cellular/nrf91_sram_partitions.dtsi>

    Or without MCUboot: 
    #include <samples/cellular/nrf91_no_bootloader_partitions.dtsi>
    #include <samples/cellular/nrf91_sram_partitions.dtsi>
    These are provided by NCS under nrf/dts/samples/cellular/ and define the correct partition layout for any nRF91 Series device.

    See: Configuring partitions on an nRF91 Series device

    Best Regards,
    Syed Maysum

  • And what's the output your app writes? Is the "Hello World! ???" there, but the "Finished" missing?

    Though the "actinius_icarus_common.dtsi" includes the "nordic/nrf91xx_partition.dtsi", so if this is related to the partitions, I would just disable the "SB_CONFIG_BOOTLOADER_MCUBOOT=n" to see, if that helps.

  • yes, it prints the "Hello World" and "Ready" line, but never the "Finished".

    Hello World! [email protected]/nrf9160/ns
    [00:00:00.251,464] <inf> actinius_board_control: eSIM is selected
    [00:00:00.251,495] <inf> actinius_board_control: Charger is set to auto
    *** Booting nRF Connect SDK v3.4.1-b20f8619ba9a ***
    *** Using Zephyr OS v4.4.2-33fa6a7aac6a ***
    Ready

    I tried the suggested include from Syed Maysum, but I get compiler errors:

    With MCUBoot enabled:

    /home/xxx/ncs/v3.4.1/modules/tee/tf-m/trusted-firmware-m/platform/ext/common/tfm_hal_ps.c:16:2: error: #error "TFM_HAL_PS_FLASH_AREA_ADDR must be defined by the target inflash_layout.h"
       16 | #error "TFM_HAL_PS_FLASH_AREA_ADDR must be defined by the target in flash_layout.h"
          |  ^~~~~
    /home/xxx/ncs/v3.4.1/modules/tee/tf-m/trusted-firmware-m/platform/ext/common/tfm_hal_ps.c:21:2: error: #error "TFM_HAL_PS_FLASH_AREA_SIZE must be defined by the target inflash_layout.h"
       21 | #error "TFM_HAL_PS_FLASH_AREA_SIZE must be defined by the target in flash_layout.h"
          |  ^~~~~
    /home/xxx/ncs/v3.4.1/modules/tee/tf-m/trusted-firmware-m/platform/ext/common/tfm_hal_ps.c: In function 'tfm_hal_ps_fs_info':
    /home/xxx/ncs/v3.4.1/modules/tee/tf-m/trusted-firmware-m/platform/ext/common/tfm_hal_ps.c:39:32: error: 'TFM_HAL_PS_FLASH_AREA_ADDR' undeclared (first use in this function); did you mean 'TFM_HAL_ITS_FLASH_AREA_ADDR'?
       39 |     fs_info->flash_area_addr = TFM_HAL_PS_FLASH_AREA_ADDR;
          |                                ^~~~~~~~~~~~~~~~~~~~~~~~~~
          |                                TFM_HAL_ITS_FLASH_AREA_ADDR
    /home/xxx/ncs/v3.4.1/modules/tee/tf-m/trusted-firmware-m/platform/ext/common/tfm_hal_ps.c:39:32: note: each undeclared identifier is reported only once for each function it appears in
    /home/xxx/ncs/v3.4.1/modules/tee/tf-m/trusted-firmware-m/platform/ext/common/tfm_hal_ps.c:40:32: error: 'TFM_HAL_PS_FLASH_AREA_SIZE' undeclared (first use in this function); did you mean 'TFM_HAL_ITS_FLASH_AREA_SIZE'?
       40 |     fs_info->flash_area_size = TFM_HAL_PS_FLASH_AREA_SIZE;
          |                                ^~~~~~~~~~~~~~~~~~~~~~~~~~

    With MCUBoot disabled:

    /home/xxx/ncs/v3.4.1/modules/tee/tf-m/trusted-firmware-m/platform/ext/common/tfm_hal_ps.c:16:2: error: #error "TFM_HAL_PS_FLASH_AREA_ADDR must be defined by the target inflash_layout.h"
       16 | #error "TFM_HAL_PS_FLASH_AREA_ADDR must be defined by the target in flash_layout.h"
          |  ^~~~~
    /home/xxx/ncs/v3.4.1/modules/tee/tf-m/trusted-firmware-m/platform/ext/common/tfm_hal_ps.c:21:2: error: #error "TFM_HAL_PS_FLASH_AREA_SIZE must be defined by the target inflash_layout.h"
       21 | #error "TFM_HAL_PS_FLASH_AREA_SIZE must be defined by the target in flash_layout.h"
          |  ^~~~~
    /home/xxx/ncs/v3.4.1/modules/tee/tf-m/trusted-firmware-m/platform/ext/common/tfm_hal_ps.c: In function 'tfm_hal_ps_fs_info':
    /home/xxx/ncs/v3.4.1/modules/tee/tf-m/trusted-firmware-m/platform/ext/common/tfm_hal_ps.c:39:32: error: 'TFM_HAL_PS_FLASH_AREA_ADDR' undeclared (first use in this function); did you mean 'TFM_HAL_ITS_FLASH_AREA_ADDR'?
       39 |     fs_info->flash_area_addr = TFM_HAL_PS_FLASH_AREA_ADDR;
          |                                ^~~~~~~~~~~~~~~~~~~~~~~~~~
          |                                TFM_HAL_ITS_FLASH_AREA_ADDR
    /home/xxx/ncs/v3.4.1/modules/tee/tf-m/trusted-firmware-m/platform/ext/common/tfm_hal_ps.c:39:32: note: each undeclared identifier is reported only once for each function it appears in
    /home/xxx/ncs/v3.4.1/modules/tee/tf-m/trusted-firmware-m/platform/ext/common/tfm_hal_ps.c:40:32: error: 'TFM_HAL_PS_FLASH_AREA_SIZE' undeclared (first use in this function); did you mean 'TFM_HAL_ITS_FLASH_AREA_SIZE'?
       40 |     fs_info->flash_area_size = TFM_HAL_PS_FLASH_AREA_SIZE;
          |                                ^~~~~~~~~~~~~~~~~~~~~~~~~~
          |                                TFM_HAL_ITS_FLASH_AREA_SIZE
    ....
    
    In file included from /home/xxx/ncs/v3.4.1/modules/tee/tf-m/trusted-firmware-m/platform/include/tfm_hal_its.h:16,
                     from /home/xxx/ncs/v3.4.1/modules/tee/tf-m/trusted-firmware-m/platform/ext/common/tfm_hal_its.c:9:
    /home/xxx/ncs/v3.4.1/modules/tee/tf-m/trusted-firmware-m/platform/ext/common/tfm_hal_its.c: In function 'tfm_hal_its_fs_info':
    /home/xxx/ncs/v3.4.1/nrf/modules/trusted-firmware-m/tfm_boards/partition/flash_layout.h:210:39: error: 'FLASH_ITS_AREA_OFFSET' undeclared (first use in this function)
      210 | #define TFM_HAL_ITS_FLASH_AREA_ADDR   FLASH_ITS_AREA_OFFSET
          |                                       ^~~~~~~~~~~~~~~~~~~~~
    /home/xxx/ncs/v3.4.1/modules/tee/tf-m/trusted-firmware-m/platform/ext/common/tfm_hal_its.c:39:32: note: in expansion of macro 'TFM_HAL_ITS_FLASH_AREA_ADDR'
       39 |     fs_info->flash_area_addr = TFM_HAL_ITS_FLASH_AREA_ADDR;
          |                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/xxx/ncs/v3.4.1/nrf/modules/trusted-firmware-m/tfm_boards/partition/flash_layout.h:210:39: note: each undeclared identifier is reported only once for each function it appears in
      210 | #define TFM_HAL_ITS_FLASH_AREA_ADDR   FLASH_ITS_AREA_OFFSET
          |                                       ^~~~~~~~~~~~~~~~~~~~~
    /home/xxx/ncs/v3.4.1/modules/tee/tf-m/trusted-firmware-m/platform/ext/common/tfm_hal_its.c:39:32: note: in expansion of macro 'TFM_HAL_ITS_FLASH_AREA_ADDR'
       39 |     fs_info->flash_area_addr = TFM_HAL_ITS_FLASH_AREA_ADDR;
          |                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/xxx/ncs/v3.4.1/nrf/modules/trusted-firmware-m/tfm_boards/partition/flash_layout.h:212:39: error: 'FLASH_ITS_AREA_SIZE' undeclared (first use in this function); did you mean 'FLASH_TOTAL_SIZE'?
      212 | #define TFM_HAL_ITS_FLASH_AREA_SIZE   FLASH_ITS_AREA_SIZE
          |                                       ^~~~~~~~~~~~~~~~~~~
    /home/xxx/ncs/v3.4.1/modules/tee/tf-m/trusted-firmware-m/platform/ext/common/tfm_hal_its.c:40:32: note: in expansion of macro 'TFM_HAL_ITS_FLASH_AREA_SIZE'
       40 |     fs_info->flash_area_size = TFM_HAL_ITS_FLASH_AREA_SIZE;
          |                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~

    If I set SB_CONFIG_BOOTLOADER_MCUBOOT=n without any extra includes in the overlay file it wont boot (erased and flashed using JLink)

    I also tried building for nrf9160dk/nrf9160/ns, but that results in the same compiler errors.

    Best regards

    Moritz

Related