how to customize blinky sample build so that it can run from b0n on netcore

Hello,

We are using NCS SDK 2.4.2. We use MCUBoot for appcore and b0n for netcore. We use https://github.com/zephyrproject-rtos/zephyr/tree/main/samples/bluetooth/hci_ipc  sample for our netcore. Since MCUBoot and Secure Boot is enabled for app core, It includes b0n ( netboot sample ) for netcore. 

Our manufacturing partner doesn't use MCUBoot or b0n. We want to run their image in our net core for some testing.

Flash layout of netcore.

0x1000000 - b0n / netboot - generated by us

0x1008580 - provision.hex - generated by us

0x1008800 - blinky sample - generated by manufacturing partner

1. Is it possible to modify blinky sample so that it can be loaded by b0n, even though it's not build with it ?

2. I changed few project config to so that linker.cmd is generated in a way that blinky zephyr.hex is at 0x1008800. But net core is continuously rebooting, I get b0n logs, but no logs from blinky sample.

CONFIG_FLASH_BASE_ADDRESS=0x1008800

first few lines of generated linker.cmd

MEMORY
    {
    FLASH (rx) : ORIGIN = (0x1000000 + 0x8800), LENGTH = (256*1K - 0x8800)
    RAM (wx) : ORIGIN = 0x21000000, LENGTH = (64 * 1K)
    SRAM1 : ORIGIN = 553648128, LENGTH = 65536
    IDT_LIST (wx) : ORIGIN = 0xFFFFF7FF, LENGTH = 2K
    }

3. Is there any other way to address this situation ?

For now, ignoring complexity of image signature and keys sharing. It look like b0n isn't verifying any signature in this version.

Thanks,

Darshan

  • Tried another approach, enabling  CONFIG_SECURE_BOOT=y in blinky prjoject with net core target, getting build error.

    Is it possible to standalone enable `b0n` on netcore at the build time  ( without building / adding app core child image with MCUBoot enabled ) ?

    ➜  blinky git:(v3.3.99-ncs1-2) ✗ west build -b nrf5340dk_nrf5340_cpunet   --pristine -- -DCMAKE_VERBOSE_MAKEFILE=1 
    -- west build: making build dir ws/zephyr/samples/basic/blinky/build pristine
    -- west build: generating a build system
    Loading Zephyr default modules (Zephyr base).
    -- Application: ws/zephyr/samples/basic/blinky
    -- CMake version: 3.20.0
    -- Found Python3: /usr/bin/python3.8 (found suitable exact version "3.8.10") found components: Interpreter 
    -- Cache files will be written to: /home/.cache/zephyr
    -- Zephyr version: 3.3.99 (ws/zephyr)
    -- Found west (found suitable version "1.2.0", minimum required is "0.7.1")
    -- Board: nrf5340dk_nrf5340_cpunet
    -- ZEPHYR_TOOLCHAIN_VARIANT not set, trying to locate Zephyr SDK
    -- Found host-tools: zephyr 0.16.5 (/home/zephyr-sdk-0.16.5-1)
    -- Found toolchain: zephyr 0.16.5 (/home/zephyr-sdk-0.16.5-1)
    -- Found Dtc: /home/zephyr-sdk-0.16.5-1/sysroots/x86_64-pokysdk-linux/usr/bin/dtc (found suitable version "1.6.0", minimum required is "1.4.6") 
    -- Found BOARD.dts: ws/zephyr/boards/arm/nrf5340dk_nrf5340/nrf5340dk_nrf5340_cpunet.dts
    -- Generated zephyr.dts: ws/zephyr/samples/basic/blinky/build/zephyr/zephyr.dts
    -- Generated devicetree_generated.h: ws/zephyr/samples/basic/blinky/build/zephyr/include/generated/devicetree_generated.h
    -- Including generated dts.cmake file: ws/zephyr/samples/basic/blinky/build/zephyr/dts.cmake
    Parsing ws/zephyr/Kconfig
    Loaded configuration 'ws/zephyr/boards/arm/nrf5340dk_nrf5340/nrf5340dk_nrf5340_cpunet_defconfig'
    Merged configuration 'ws/zephyr/samples/basic/blinky/prj.conf'
    Configuration saved to 'ws/zephyr/samples/basic/blinky/build/zephyr/.config'
    Kconfig header saved to 'ws/zephyr/samples/basic/blinky/build/zephyr/include/generated/autoconf.h'
    -- Found GnuLd: /home/zephyr-sdk-0.16.5-1/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd (found version "2.38") 
    -- The C compiler identification is GNU 12.2.0
    -- The CXX compiler identification is GNU 12.2.0
    -- The ASM compiler identification is GNU
    -- Found assembler: /home/zephyr-sdk-0.16.5-1/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
    
    === child image b0n -  begin ===
    loading initial cache file ws/zephyr/samples/basic/blinky/build/b0n/child_image_preload.cmake
    Loading Zephyr default modules (Zephyr base).
    -- Application: ws/nrf/samples/nrf5340/netboot
    -- CMake version: 3.20.0
    -- Found Python3: /usr/bin/python3.8 (found suitable exact version "3.8.10") found components: Interpreter 
    -- Cache files will be written to: /home/.cache/zephyr
    -- Zephyr version: 3.3.99 (ws/zephyr)
    -- Found west (found suitable version "1.2.0", minimum required is "0.7.1")
    -- Board: nrf5340dk_nrf5340_cpunet
    -- Found host-tools: zephyr 0.16.5 (/home/zephyr-sdk-0.16.5-1)
    -- Found toolchain: zephyr 0.16.5 (/home/zephyr-sdk-0.16.5-1)
    -- Found Dtc: /home/zephyr-sdk-0.16.5-1/sysroots/x86_64-pokysdk-linux/usr/bin/dtc (found suitable version "1.6.0", minimum required is "1.4.6") 
    -- Found BOARD.dts: ws/zephyr/boards/arm/nrf5340dk_nrf5340/nrf5340dk_nrf5340_cpunet.dts
    -- Generated zephyr.dts: ws/zephyr/samples/basic/blinky/build/b0n/zephyr/zephyr.dts
    -- Generated devicetree_generated.h: ws/zephyr/samples/basic/blinky/build/b0n/zephyr/include/generated/devicetree_generated.h
    -- Including generated dts.cmake file: ws/zephyr/samples/basic/blinky/build/b0n/zephyr/dts.cmake
    Parsing ws/nrf/samples/nrf5340/netboot/Kconfig
    Loaded configuration 'ws/zephyr/boards/arm/nrf5340dk_nrf5340/nrf5340dk_nrf5340_cpunet_defconfig'
    Merged configuration 'ws/nrf/samples/nrf5340/netboot/prj.conf'
    Merged configuration 'ws/nrf/subsys/partition_manager/partition_manager_enabled.conf'
    Configuration saved to 'ws/zephyr/samples/basic/blinky/build/b0n/zephyr/.config'
    Kconfig header saved to 'ws/zephyr/samples/basic/blinky/build/b0n/zephyr/include/generated/autoconf.h'
    -- Found GnuLd: /home/zephyr-sdk-0.16.5-1/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd (found version "2.38") 
    -- The C compiler identification is GNU 12.2.0
    -- The CXX compiler identification is GNU 12.2.0
    -- The ASM compiler identification is GNU
    -- Found assembler: /home/zephyr-sdk-0.16.5-1/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
    CMake Warning at ws/zephyr/CMakeLists.txt:839 (message):
      No SOURCES given to Zephyr library: lib__libc__common
    
      Excluding target from build.
    
    
    CMake Warning at ws/zephyr/CMakeLists.txt:1865 (message):
      __ASSERT() statements are globally ENABLED
    
    
    -- Configuring done
    -- Generating done
    -- Build files have been written to: ws/zephyr/samples/basic/blinky/build/b0n
    === child image b0n -  end ===
    
    CMake Warning at ws/nrf/subsys/bootloader/cmake/debug_keys.cmake:36 (message):
      
    
          --------------------------------------------------------------
          --- WARNING: Using generated NSIB public/private key-pair. ---
          --- It should not be used for production.                  ---
          --- See CONFIG_SB_SIGNING_KEY_FILE                         ---
          --------------------------------------------------------------
          
    
    Call Stack (most recent call first):
      ws/nrf/subsys/bootloader/cmake/provision_hex.cmake:37 (include)
      ws/nrf/subsys/CMakeLists.txt:17 (include)
    
    
    CMake Warning at ../../../CMakeLists.txt:839 (message):
      No SOURCES given to Zephyr library: lib__libc__common
    
      Excluding target from build.
    
    
    -- Configuring done
    -- Generating done
    -- Build files have been written to: ws/zephyr/samples/basic/blinky/build
    -- west build: building application
    ninja: error: 'modules/nrf/subsys/app_hex', needed by 'zephyr/nrf/subsys/bootloader/generated/app_firmware.signature', missing and no known rule to make it
    FATAL ERROR: command exited with status 1: /usr/local/bin/cmake --build ws/zephyr/samples/basic/blinky/build

  • Hi,

    I think what you describe should be possible, but to see that I understand correctly:

    You have custom everything in place, but want to swap out only the network core application?

    Here is how:

    1. Build new netcore app with CONFIG_FLASH_LOAD_OFFSET to the start addr of netcore app.
    2. Build old project with "west -vvv build". Find comand used to generate .hex files for network core
    3. Run command and use your file instead.

    Does  that work for you?

    Regards,
    Sigurd Hellesvik

  • Hi Sigurd,

    This isn't working. network core is continuously rebooting. I added logs in samples/nrf5340/netboot. I am getting logs up to this point https://github.com/nrfconnect/sdk-nrf/blob/main/subsys/bootloader/bl_boot/bl_boot.c#L93. Added logs in blinky sample first line in main function, but that doesn't print. so unclear whether it's  able to pass control to blinky.

    Beyond this point it's all instructions, logs can't help. Any suggestion how to debug and fix this ?

    Thanks,

    Darshan 

  • Ok, It seems like b0n is looking for FW metadata at inside FW file before booting.

    https://github.com/nrfconnect/sdk-nrf/blob/main/include/fw_info_bare.h#L205

    I added CONFIG_FW_INFO=y and it includes that metadata, able to boot blinky sample now.

    So two flags,
    CONFIG_FLASH_LOAD_OFFSET=0x8800
    CONFIG_FW_INFO=y 

    with that I should be safe to boot blinky ( or bluetooh/direct_test_mode or any other example on network core ) without enabling b0n / MCUBoot in project right ?

    Any risk / downside in this approach ?

    Thanks,

    Darshan

  • darshan.patel said:
    Ok, It seems like b0n is looking for FW metadata at inside FW file before booting.

    Good find! You are correct, NSIB uses FW_INFO to boot the next application.
    This is the correct approach.

Related