MCUBoot without Partition Manager

Hi, I want to implement DFU on an nRF52832 with a mx25r1635f external flash, originally I implement the partitions and everything using the devicetree since I find it a lot more comfortable to use. I followed this proccess: https://devzone.nordicsemi.com/guides/nrf-connect-sdk-guides/b/software/posts/ncs-dfu , but the CONFIG_BOOTLOADER_MCUBOOT option enables the partition manager by default, is there a way to use it with the devicetree method for partitions? I saw that most applications on Zephyr do actually use the devicetree instead of the partition manager, so I expect it to be possible, but couldn't find a way to do it.

Parents
  • Hi, 

    Which NCS are you using? Is it v2.2.0? If so, You can have .conf and .overly for mcuboot as this example

    Regards,
    Amanda H.

  • Hi, I tried to build the code, but I'm getting a lot of error messages, I tried taking out a couple of config parameters, even after trying many combinations, I still can't make it build. Do you know what config parameters I need to use for the nRF52832 with SPI-NOR flash, not QSPI? 

  • Hi, 

    Your board config should be similar to this (ie. boards/$board.conf):

    # SPI Flash
    CONFIG_SPI=y
    CONFIG_SPI_NOR=y
    
    
    # Enable flash operations.
    CONFIG_FLASH=y
    CONFIG_FLASH_MAP=y
    CONFIG_FLASH_PAGE_LAYOUT=y

    And the overlay is similar to this example (boards/$board.overlay). Instance number and pin definitions can vary, of course.

    In your child_image/mcuboot.conf, you will need to add this symbol when using SPI and flash:

    CONFIG_PM_OVERRIDE_EXTERNAL_DRIVER_CHECK=y

    -Amanda H.

  • Now I'm getting these error messages:

    C:\ncs\v2.2.0\bootloader\mcuboot\boot\zephyr\include\sysflash\sysflash.h:45:12: error: 'PM_MCUBOOT_PRIMARY_1_ID' undeclared (first use in this function); did you mean 'PM_MCUBOOT_PRIMARY_ID'?
       45 |            PM_MCUBOOT_PRIMARY_1_ID :         \
          |            ^~~~~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.2.0\bootloader\mcuboot\boot\zephyr\flash_map_extended.c:54:20: note: in expansion of macro 'FLASH_AREA_IMAGE_PRIMARY'
       54 |     case 0: return FLASH_AREA_IMAGE_PRIMARY(image_index);
          |                    ^~~~~~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.2.0\bootloader\mcuboot\boot\zephyr\include\sysflash\sysflash.h:45:12: note: each undeclared identifier is reported only once for each function it appears in
       45 |            PM_MCUBOOT_PRIMARY_1_ID :         \
          |            ^~~~~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.2.0\bootloader\mcuboot\boot\zephyr\flash_map_extended.c:54:20: note: in expansion of macro 'FLASH_AREA_IMAGE_PRIMARY'
       54 |     case 0: return FLASH_AREA_IMAGE_PRIMARY(image_index);
          |                    ^~~~~~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.2.0\bootloader\mcuboot\boot\zephyr\include\sysflash\sysflash.h:52:12: error: 'PM_MCUBOOT_SECONDARY_1_ID' undeclared (first use in this function); did you mean 'PM_MCUBOOT_SECONDARY_ID'?
       52 |            PM_MCUBOOT_SECONDARY_1_ID: \
          |            ^~~~~~~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.2.0\bootloader\mcuboot\boot\zephyr\flash_map_extended.c:56:20: note: in expansion of macro 'FLASH_AREA_IMAGE_SECONDARY'
       56 |     case 1: return FLASH_AREA_IMAGE_SECONDARY(image_index);
          |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~
    C:/ncs/v2.2.0/bootloader/mcuboot/boot/zephyr/flash_map_extended.c: In function 'flash_area_id_to_multi_image_slot':
    C:\ncs\v2.2.0\bootloader\mcuboot\boot\zephyr\include\sysflash\sysflash.h:45:12: error: 'PM_MCUBOOT_PRIMARY_1_ID' undeclared (first use in this function); did you mean 'PM_MCUBOOT_PRIMARY_ID'?
       45 |            PM_MCUBOOT_PRIMARY_1_ID :         \
          |            ^~~~~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.2.0\bootloader\mcuboot\boot\zephyr\flash_map_extended.c:73:20: note: in expansion of macro 'FLASH_AREA_IMAGE_PRIMARY'
       73 |     if (area_id == FLASH_AREA_IMAGE_PRIMARY(image_index)) {
          |                    ^~~~~~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.2.0\bootloader\mcuboot\boot\zephyr\include\sysflash\sysflash.h:52:12: error: 'PM_MCUBOOT_SECONDARY_1_ID' undeclared (first use in this function); did you mean 'PM_MCUBOOT_SECONDARY_ID'?
       52 |            PM_MCUBOOT_SECONDARY_1_ID: \
          |            ^~~~~~~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.2.0\bootloader\mcuboot\boot\zephyr\flash_map_extended.c:77:20: note: in expansion of macro 'FLASH_AREA_IMAGE_SECONDARY'
       77 |     if (area_id == FLASH_AREA_IMAGE_SECONDARY(image_index)) {
          |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~
    Do you know what could be causing it?
    I couldn't find anything about it that didn't involve using the Partition Manager.

Reply
  • Now I'm getting these error messages:

    C:\ncs\v2.2.0\bootloader\mcuboot\boot\zephyr\include\sysflash\sysflash.h:45:12: error: 'PM_MCUBOOT_PRIMARY_1_ID' undeclared (first use in this function); did you mean 'PM_MCUBOOT_PRIMARY_ID'?
       45 |            PM_MCUBOOT_PRIMARY_1_ID :         \
          |            ^~~~~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.2.0\bootloader\mcuboot\boot\zephyr\flash_map_extended.c:54:20: note: in expansion of macro 'FLASH_AREA_IMAGE_PRIMARY'
       54 |     case 0: return FLASH_AREA_IMAGE_PRIMARY(image_index);
          |                    ^~~~~~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.2.0\bootloader\mcuboot\boot\zephyr\include\sysflash\sysflash.h:45:12: note: each undeclared identifier is reported only once for each function it appears in
       45 |            PM_MCUBOOT_PRIMARY_1_ID :         \
          |            ^~~~~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.2.0\bootloader\mcuboot\boot\zephyr\flash_map_extended.c:54:20: note: in expansion of macro 'FLASH_AREA_IMAGE_PRIMARY'
       54 |     case 0: return FLASH_AREA_IMAGE_PRIMARY(image_index);
          |                    ^~~~~~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.2.0\bootloader\mcuboot\boot\zephyr\include\sysflash\sysflash.h:52:12: error: 'PM_MCUBOOT_SECONDARY_1_ID' undeclared (first use in this function); did you mean 'PM_MCUBOOT_SECONDARY_ID'?
       52 |            PM_MCUBOOT_SECONDARY_1_ID: \
          |            ^~~~~~~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.2.0\bootloader\mcuboot\boot\zephyr\flash_map_extended.c:56:20: note: in expansion of macro 'FLASH_AREA_IMAGE_SECONDARY'
       56 |     case 1: return FLASH_AREA_IMAGE_SECONDARY(image_index);
          |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~
    C:/ncs/v2.2.0/bootloader/mcuboot/boot/zephyr/flash_map_extended.c: In function 'flash_area_id_to_multi_image_slot':
    C:\ncs\v2.2.0\bootloader\mcuboot\boot\zephyr\include\sysflash\sysflash.h:45:12: error: 'PM_MCUBOOT_PRIMARY_1_ID' undeclared (first use in this function); did you mean 'PM_MCUBOOT_PRIMARY_ID'?
       45 |            PM_MCUBOOT_PRIMARY_1_ID :         \
          |            ^~~~~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.2.0\bootloader\mcuboot\boot\zephyr\flash_map_extended.c:73:20: note: in expansion of macro 'FLASH_AREA_IMAGE_PRIMARY'
       73 |     if (area_id == FLASH_AREA_IMAGE_PRIMARY(image_index)) {
          |                    ^~~~~~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.2.0\bootloader\mcuboot\boot\zephyr\include\sysflash\sysflash.h:52:12: error: 'PM_MCUBOOT_SECONDARY_1_ID' undeclared (first use in this function); did you mean 'PM_MCUBOOT_SECONDARY_ID'?
       52 |            PM_MCUBOOT_SECONDARY_1_ID: \
          |            ^~~~~~~~~~~~~~~~~~~~~~~~~
    C:\ncs\v2.2.0\bootloader\mcuboot\boot\zephyr\flash_map_extended.c:77:20: note: in expansion of macro 'FLASH_AREA_IMAGE_SECONDARY'
       77 |     if (area_id == FLASH_AREA_IMAGE_SECONDARY(image_index)) {
          |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~
    Do you know what could be causing it?
    I couldn't find anything about it that didn't involve using the Partition Manager.

Children
  • I have a DFU with the external SPI-NOR flash sample for nRF52840DK: 7851.peripheral_lbs_DFU_ext_flash_spi_nor_NCSv2.2.0.7z   which I follow that adding DFU guide and it can work for me as:

    *** Booting Zephyr OS build v3.2.99-ncs1 ***
    I: Starting bootloader
    I: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    I: Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    I: Boot source: none
    I: Swap type: none
    I: Bootloader chainload address offset: 0xc000
    *** Booting Zephyr OS build v3.2.99-ncs1 ***
    Starting Bluetooth Peripheral LBS example
    build time: Mar  6 2023 17:41:19
    I: 2 Sectors of 4096 bytes
    I: alloc wra: 0, fe8
    I: data wra: 0, 0
    I: SoftDevice Controller build revision:
    I: 6d 90 41 2a 38 e8 ad 17 |m.A*8...
    I: 29 a5 03 38 39 27 d7 85 |)..89'..
    I: 1f 85 d8 e1             |....
    I: No ID address. App must call settings_load()
    Bluetooth initialized
    Advertising successfully started
    Connected
    I: Swap type: none
    I: Swap type: none
    I: Swap type: none
    I: Swap type: none
    I: Erased 0x31000 bytes of image slot
    I: Erased 0x1000 bytes of image slot trailer
    I: Swap type: none
    I: Swap type: test
    I: Swap type: test
    *** Booting Zephyr OS build v3.2.99-ncs1 ***
    I: Starting bootloader
    I: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    I: Secondary image: magic=good, swap_type=0x2, copy_done=0x3, image_ok=0x3
    I: Boot source: none
    I: Swap type: test
    I: Starting swap using move algorithm.
    I: Bootloader chainload address offset: 0xc000
    *** Booting Zephyr OS build v2.6.99-ncs1-1  ***
    Starting Bluetooth Peripheral LBS example
    CONFIG_BT_L2CAP_TX_MTU 512
    build time: Jan 10 2023 11:16:09
    I: 2 Sectors of 4096 bytes
    I: alloc wra: 0, fd0
    I: data wra: 0, 1c
    I: SoftDevice Controller build revision:
    I: 3f 47 70 8e 81 95 4e 86 |?Gp...N.
    I: 9d d3 a2 95 88 f6 30 0a |......0.
    I: 7f 53 49 fd             |.SI.
    I: No ID address. App must call settings_load()
    Bluetooth initialized
    Advertising successfully started
    Connected
    I: Swap type: test
    I: Swap type: test
    I: Swap type: test
    

    You can take a look at the board's conf and overlay files under boards and child_image\mcuboot\boards. 

    “Beware that this code/configuration is not fully tested or qualified and should be considered provided “as-is”. Please test it with your application and let me know if you find any issues.”

    -Amanda H.

  • Hi, I tried to compile the code following this process, however it uses the Partition Manager(in the build folder you can see there is a pm.config) and I don't want to use it, that was my original question, is there a way to use the DFU Update without using the partition manager?

  • Unfortunately, the Partition Manager cannot be disabled, but you can use static partitions to modify the memory layout as you desire. See Configuring static partitions and this example

    -Amanda H.

  • Ok, that's very unfortunate, but if there's no alternative I'll have to use it. So I added the pm.yml file and now I'm having trouble with defining my own partition, it gives this error:

    C:\ncs\v2.2.0\nrf\include\flash_map_pm.h:41:22: error: 'PM_lfs1_part_ID' undeclared here (not in a function)
       41 | #define PM_ID(label) PM_##label##_ID
          |                      ^~~
    C:\ncs\v2.2.0\nrf\include\flash_map_pm.h:46:35: note: in expansion of macro 'PM_ID'
       46 | #define FIXED_PARTITION_ID(label) PM_ID(label)
          |                                   ^~~~~
    c:\Projetos\Smartpet\sirros_smartpet\firmware\Smartpet_NRF52_SDK\src\Sirros_NRF52_configHandler.c:25:32: note: in expansion of macro 'FIXED_PARTITION_ID'
       25 |         .storage_dev = (void *)FIXED_PARTITION_ID(lfs1_part),

    The pm.yml file is this:

    app:
      address: 0x20200
      region: flash_primary
      size: 0xdfe00
    mcuboot:
      address: 0x0
      region: flash_primary
      size: 0x20000
    mcuboot_pad:
      address: 0x20000
      region: flash_primary
      size: 0x200
    mcuboot_primary:
      address: 0x20000
      orig_span: &id001
      - mcuboot_pad
      - app
      region: flash_primary
      size: 0xe0000
      span: *id001
    mcuboot_primary_app:
      address: 0x20200
      orig_span: &id002
      - app
      region: flash_primary
      size: 0xdfe00
      span: *id002
    mcuboot_primary_1:
      address: 0x0
      size: 0x40000
      device: flash_ctrl
      region: ram_flash
    mcuboot_secondary:
      address: 0x00000
      size: 0xe0000
      device: MX25R16
      region: external_flash
    mcuboot_secondary_1:
      address: 0xe0000
      size: 0x40000
      device: MX25R16
      region: external_flash
    lfs1_part:
      address: 0x120000
      size: 0x6e0000
      device: MX25R16
      region: external_flash

    Do you know what I'm doing wrong?

  • Hi, 

    Are you trying to allocate a separate partition for littleFS? If so, you can take a look at this post

    The pm_static.yml example is for nRF5340 which has two cores and that might mislead you, so I have updated it for nRF52. I also update my example in the previous reply with the pm_static.yml as 

    mcuboot_primary:
        orig_span: &id001
            - mcuboot_pad
            - app
        span: *id001
        address: 0xc000
        size: 0xf2000
        region: flash_primary
    mcuboot_primary_app:
        orig_span: &id002
            - app
        span: *id002
        address: 0xc200
        size: 0xf1e00
    
    settings_storage:
        address: 0xfe000
        size: 0x2000
        region: flash_primary
    
    mcuboot_secondary:
        address: 0x0
        size: 0xf2000
        device: MX25R64
        region: external_flash
        
    
    littlefs_storage:
        address: 0xf2000
        size: 0x7000
        device: MX25R64
        region: external_flash
     
    external_flash:
       address: 0xf9000
       size: 0x707000
       device: MX25R64
       region: external_flash 

    It would look like this

    -Amanda H.

Related