Add DFU support to custom HCI_RPMSG netcore image

I have separate app core enabled with DFU and secure boot. I added all that support with help from this ticket  nRF5340 Firmware Update from external NOR QSPI flash 

DFU for net core works fine.But it only works with an hci_rpmsg included automatically. How can I include the netcore DFU support in modified hci_rpmsg project. We compile this project but no "net_core_app_update.bin" is generated. How can I generate this DFU binary?

On app core image I have following configs enabled?

prj.conf

CONFIG_NRF53_UPGRADE_NETWORK_CORE=y
CONFIG_BOOT_IMAGE_ACCESS_HOOKS=y
CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y
CONFIG_ADD_MCUBOOT_MEDIATE_SIM_FLASH_DTS=y

/child_image/mcuboot/prj.conf

CONFIG_PM_PARTITION_SIZE_MCUBOOT=0x10000
CONFIG_NORDIC_QSPI_NOR=y
CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=16

CONFIG_PCD_APP=y
CONFIG_UPDATEABLE_IMAGE_NUMBER=2
CONFIG_FLASH_SIMULATOR=y
CONFIG_FLASH_SIMULATOR_DOUBLE_WRITES=y
CONFIG_FLASH_SIMULATOR_STATS=n
CONFIG_BOOT_UPGRADE_ONLY=y


# Enable flash operations.
# CONFIG_SPI=y
CONFIG_FLASH=y
# This must be increased to accommodate the bigger images.
CONFIG_BOOT_MAX_IMG_SECTORS=256

# Disable netcore image OTA udpate
CONFIG_BOOT_IMAGE_ACCESS_HOOKS=n

Parents
  • Hi,

    modified hci_rpmsg project.

    The answer here depends on how you include the modified hci_rpmsg project into your application.

    What is your method for having a custom image on the network core?

    Regards,
    Sigurd Hellesvik

  • We treat it as separate project. we compile it separate and flash the netcore bin file via Jflash.
    Can we include the modified hci_rpmsg as a child image? It will be best case scenario.

  • Dilawar Ali said:
    Can we include the modified hci_rpmsg as a child image?

    You can do so, in which case you have some options:

    The easiest solution, although not pretty, is to make changes directly to the nRF Connect SDK, for example by forking the SDK. See Adding your own code for some tips on this.

    If you want to add it on a project level, then the solution will depend on which multi-image build tool is used: Multi-Image Builds or Sysbuild. Sysbuild will soon replace the multi-image build system we currently use by default, ref.

    For multi-image builds, I know it has previously been a bit buggy to add a child image to a child image (which is what adding a netcore bootloader would be. In fact, when I search for the previous example we used to showcase this, I can not find it in v2.5.0. Instead, I find the Multicore sample, which uses sysbuild.

    So, I would suggest using sysbuild if you want to include the hci_rpmsg with a bootloader automatically. See the Multicore

    The last option is to do as you have done so far, and build the netboot sample standalone for your project. Then you can build the hci_rpmsg project with CONFIG_FLASH_LOAD_OFFSET to offset the start address with the bootloader size.
    In this case, you also need to take care of signing of the network core image for DFU yourself I think.

    Did this help?

  • Best approach for us is to use the multicore with sysbuild. I have added the configurations as per the sample. But I am facing compilation issues because we have static partitions defined where the mcuboot_primary and mcuboot_secondary both are placed in  the external flash.

    here is the pm_static_<board name>.yml

    external_flash:
      address: 0x0
      end_address: 0x200000
      region: external_flash
      size: 0x200000
    
    mcuboot_secondary:
      address: 0x0
      device: mx25r16
      region: external_flash
      size: 0x100000
    
    mcuboot_secondary_1:
      address: 0x100000
      device: mx25r16
      end_address: 0x13FFFF
      region: external_flash
      size: 0x40000
    
    littlefs_storage:
      address: 0x140000
      device: mx25r16
      region: external_flash
      size: 0xC0000
    
    mcuboot_primary_1:
      address: 0x0
      device: flash_ctrl
      end_address: 0x40000
      region: ram_flash
      size: 0x40000
    
    ram_flash:
      address: 0x40000
      end_address: 0x40000
      region: ram_flash
      size: 0x0

    Compile output is:\

    In file included from C:/ncs/v2.5.0/zephyr/include/zephyr/storage/flash_map.h:275,
                     from C:/ncs/v2.5.0/zephyr/subsys/mgmt/mcumgr/grp/img_mgmt/src/zephyr_img_mgmt.c:10:
    C:/ncs/v2.5.0/zephyr/subsys/mgmt/mcumgr/grp/img_mgmt/src/zephyr_img_mgmt.c: In function 'img_mgmt_flash_area_id':
    C:/ncs/v2.5.0/nrf/include/flash_map_pm.h:43:22: error: 'PM_mcuboot_primary_ID' undeclared (first use in this function); did you mean 'PM_mcuboot_secondary_ID'?
       43 | #define PM_ID(label) PM_##label##_ID
          |                      ^~~
    C:/ncs/v2.5.0/nrf/include/flash_map_pm.h:48:35: note: in expansion of macro 'PM_ID'
       48 | #define FIXED_PARTITION_ID(label) PM_ID(label)
          |                                   ^~~~~
    C:/ncs/v2.5.0/zephyr/subsys/mgmt/mcumgr/grp/img_mgmt/src/zephyr_img_mgmt.c:135:25: note: in expansion of macro 'FIXED_PARTITION_ID'
      135 |                 fa_id = FIXED_PARTITION_ID(SLOT0_PARTITION);
          |                         ^~~~~~~~~~~~~~~~~~
    C:/ncs/v2.5.0/nrf/include/flash_map_pm.h:43:22: note: each undeclared identifier is reported only once for each function it appears in
       43 | #define PM_ID(label) PM_##label##_ID
          |                      ^~~
    C:/ncs/v2.5.0/nrf/include/flash_map_pm.h:48:35: note: in expansion of macro 'PM_ID'
       48 | #define FIXED_PARTITION_ID(label) PM_ID(label)
          |                                   ^~~~~
    C:/ncs/v2.5.0/zephyr/subsys/mgmt/mcumgr/grp/img_mgmt/src/zephyr_img_mgmt.c:135:25: note: in expansion of macro 'FIXED_PARTITION_ID'
      135 |                 fa_id = FIXED_PARTITION_ID(SLOT0_PARTITION);

  • Please use "Insert-> Code" to paste long logs. It makes the case a lot easier to read. You can also edit previous comments.

    Did you say that you put mcuboot_primary into external flash? This is where the app lives, and can not be moved entirely to external flash.

  • I was not able to add the complete logs in code section. I have updated the above comment with error logs.

    Sorry my mistake,  mcuboot_primary is not in external flash. mcuboot_secondary and mcuboot_secondary_1 is in external flash.

    Complete build logs are available here: https://drive.google.com/file/d/1c9x6k_6xRPY5mrgrVODx276-YZKQ8OIk/view?usp=sharing

    I was not able to attach log file here.

    mcuboot_secondary:
    address: 0x0
    device: mx25r16
    region: external_flash
    size: 0x100000

    mcuboot_secondary_1:
    address: 0x100000
    device: mx25r16
    end_address: 0x13FFFF
    region: external_flash
    size: 0x40000

  • Do you get the same error if you do not use static partitioning? (aka not have pm_static.yml)

Reply Children
  • I compiled the multicore sample, and that was without the static partitioning. That worked fine.
    However I can not remove the static partitioning as there are multiple things dependent on it.

  • As show below in static file. We have an external flash. We want to place both app core and net core DFU images in external flash instead of the internal. We do not have enough space in internal. Also a region in external flash is dedicated for the file system to store the configuration and other data.

    That is why we require to define pm_static.yml file.

    external_flash:
      address: 0x0
      end_address: 0x200000
      region: external_flash
      size: 0x200000
    
    mcuboot_secondary:
      address: 0x0
      device: mx25r16
      region: external_flash
      size: 0x100000
    
    mcuboot_secondary_1:
      address: 0x100000
      device: mx25r16
      end_address: 0x13FFFF
      region: external_flash
      size: 0x40000
    
    littlefs_storage:
      address: 0x140000
      device: mx25r16
      region: external_flash
      size: 0xC0000
    
    mcuboot_primary_1:
      address: 0x0
      device: flash_ctrl
      end_address: 0x40000
      region: ram_flash
      size: 0x40000
    
    ram_flash:
      address: 0x40000
      end_address: 0x40000
      region: ram_flash
      size: 0x0

  • Dilawar Ali said:
    That is why we require to define pm_static.yml file.

    It is not required for this.

    The Partition Manager will automatically partition secondary mcuboot images to external flash if you have enabled external flash for the partition manager.

    The same is true for file systems.

    You can check this from the partiton report either from VS Code -> Memory Report or "west build -t partition_manager_report"

  • Apologies for late reply. Got busy with other urgent tasks.

    I created a sample project added the multicore compilation part as per defined in sample hellow world. Used the dynamic partition management.

    I see there is a line in sysbuild.cmake "set(CPUNET_PM_DOMAIN_DYNAMIC_PARTITION hci_rpmsg CACHE INTERNAL "")"
    So using this line we should use dynamic partition management.

    Afterall the project compiles with no error but only netcore image is generated. No app core image is found.

    Here is the partitions.yml content generated after build. I do not see any mcuboot_primary, mcuboot_primary_1, mcuboot_secondary, or mcuboot_primary_1.

    app:
      address: 0x0
      end_address: 0x100000
      region: flash_primary
      size: 0x100000
    external_flash:
      address: 0x0
      end_address: 0x800000
      region: external_flash
      size: 0x800000
    otp:
      address: 0xff8100
      end_address: 0xff83fc
      region: otp
      size: 0x2fc
    rpmsg_nrf53_sram:
      address: 0x20070100
      end_address: 0x20080000
      placement:
        before:
        - end
      region: sram_primary
      size: 0xff00
    sram_primary:
      address: 0x20000000
      end_address: 0x20070100
      region: sram_primary
      size: 0x70100
    

    Why the main appcore project fails to compile? I have attached the project files for details as well. Using hci_rpmsg sample this project works fine for app core and net core DFU.

    hrdfu.zip

Related