NRF5340 MCUboot is incompatible with PacketCraft and Large Application

We finished our application on the NRF5340 and need to do firmware updates and are unable due to the current criteria: 

  1. NRF53 firmware update over USB CDC ACM (which needs at least 0x10000 rather than 0xC000)
  2. Our application is large and is over 920KB (which needs large primary slot)
  3. Packet craft network core

We found many unopen tickets about MCUboot forcing having a secondary partition and crashing on the slot size despite using the config CONFIG_SINGLE_APPLICATION_SLOT. This would be perfect for our application, because we are okay with setting it into recovery mode. 

We also tried to look into editing the pm_static.yml file but found on editing that the device crashes on boot even giving proper space. 

Please advise on how we can use packet craft on the network core, doing firmware updates on USBCDC, and having a large application. 

Thank you for your time!

  • Hi! 

    We figured it out!! For anyone who needs an answer for this, there are two main options for the NRF5340 with MCUboot and your application is large (larger then the allowed 400k for both slot0 and slot1) and we needed USB as well:

    1. need to be able to update just the application core (CONFIG_SINGLE_APPLICATION_SLOT)

    2. need to update the the application and network core (CONFIG_SINGLE_APPLICATION_SLOT and CONFIG_NRF53_RECOVERY_NETWORK_CORE)

    For, the first option you should be able to use this example USB_CDC or the serial example. (There are a number of options, waiting for boot, button, USB in these examples.)

    For the second option, there are a few things you will have to do. For most of this we are mainly combining the files for mcuboot_serial_recovery_cdc_acm and  mcuboot_netcore_serial_recovery examples:

    1. For your prj.conf include 
      1. CONFIG_BT=y
        CONFIG_MCUBOOT_IMAGE_VERSION="0.0.0+0"
        CONFIG_BOOTLOADER_MCUBOOT=y
        CONFIG_NRF53_UPGRADE_NETWORK_CORE=y
        CONFIG_ADD_MCUBOOT_MEDIATE_SIM_FLASH_DTS=y
        CONFIG_USB_CDC_ACM=y
        CONFIG_LOG=n
        CONFIG_LOG_MODE_MINIMAL=y
    2. For your child_image/mcu_boot.conf
      1. #
        # Copyright (c) 2022 Nordic Semiconductor
        #
        # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
        #
        
        CONFIG_MAIN_STACK_SIZE=10240
        # Flash
        CONFIG_FLASH=y
        
        # Enable MCUboot Serial Recovery
        CONFIG_MCUBOOT_SERIAL=y
        CONFIG_UART_CONSOLE=n
        CONFIG_SIZE_OPTIMIZATIONS=y
        CONFIG_SINGLE_APPLICATION_SLOT=y
        
        # MCUBoot serial
        CONFIG_MCUBOOT_SERIAL=y
        CONFIG_MCUBOOT_SERIAL_DIRECT_IMAGE_UPLOAD=y
        
        # Point Serial Recovery to CDC_ACM
        CONFIG_BOOT_SERIAL_CDC_ACM=y
        CONFIG_PM_PARTITION_SIZE_MCUBOOT=0x10000
        
        # Decrease memory footprint
        CONFIG_CBPRINTF_NANO=y
        CONFIG_TIMESLICING=n
        CONFIG_BOOT_BANNER=n
        CONFIG_CONSOLE=n
        CONFIG_CONSOLE_HANDLER=n
        CONFIG_UART_CONSOLE=n
        CONFIG_RTT_CONSOLE=n
        CONFIG_USE_SEGGER_RTT=n
        CONFIG_LOG=n
        CONFIG_RESET_ON_FATAL_ERROR=n
        
        # The following configurations are required to support serial recovery of the
        # network image
        CONFIG_PCD_APP=y
        
        CONFIG_FLASH_SIMULATOR=y
        CONFIG_FLASH_SIMULATOR_DOUBLE_WRITES=y
        CONFIG_FLASH_SIMULATOR_STATS=n
        
        CONFIG_BOOT_IMAGE_ACCESS_HOOKS=y
        CONFIG_NRF53_RECOVERY_NETWORK_CORE=y
        CONFIG_MCUBOOT_INDICATION_LED=y
    3. We needed USB so we included pm_static.yml for increasing the size for the USB_CDC
      1. mcuboot:
          address: 0x0
          end_address: 0x10000
          placement:
            before:
            - mcuboot_primary
          region: flash_primary
          size: 0x10000
    4. Edit the CMAKE for C:\ncs\v2.4.0\nrf\modules\mcuboot\CMakeLists.txt and put (this is where we messed up before because we needed to put network core starting address which we found was 0x1008800. We used a slot size of 0x40000 of the primary_bootloader1). This should get you passed the img_tool.py error. 
    5. If you are using packet craft (NRF5340 audio binary), you have two more steps:
      1. Edit the \tools\buildprog\ble5-ctr-rpmsg_sign.py (the size of our slot, because its hardcoded to look for the secondary slot, which we don't want or need).
      2. When building your audio application, we found creating and building the audio example with CONFIG_BOOTLOADER_MCU enabled was easiest to getting the MCUBOOT firmware update file. 
        1. NOTE: You may have to edit the nrf5340_audio\dfu\conf\Kconfig.dfu to 
          AUDIO_DFU to 1 and 
          B0N_MINIMAL to y. 
        2. Once you build you will have a file build\ble5-ctr_net_core_update.bin
          1. This is the way to update the network core. 
    6. Finally, we can update our device over the mcumgr. Reset your device and hold down your button or your preferred way to get it into boot loader mode then: 
      1. for updating your application 
        1. mcumgr --conntype serial --connstring COM49 image upload -e build\zephyr\app_update.bin -n 1
      2. for updating your network core
        1. mcumgr --conntype serial --connstring COM49 image upload -e build\zephyr\net_core_app_update.bin -n 3

    We are now done!! Hope this helps anyone in the same predicament. 

Related