Partitions for custom boards with SDK 2.8.0 and sysbuild

Hi everyone!

I have a custom board with the Adarfuit UF2 Bootloader (https://github.com/adafruit/Adafruit_nRF52_Bootloader) and a SoftDevice. With the old SDK v2.5.1 I created my own boards and defined fixed partition in the dts of my board files to account for the bootloader and SoftDevice, so that they are not overwritten. I found this approach nice and clean because I didn't have to specify static partitions in my applications, they were just working out of the box. I configured my board-defconfig file to output uf2 files and I simply could pre-flash the bootloader and afterwards use the uf2 images to load my applications. As simple as that.

Now I wanted to migrate to the SDK v2.8.0 and sysbuild. However, I'm a bit lost now, because my initial approach does not seem to work anymore. Specifically, the fixed partition in my dts files are ignored. Which seems to be intended according to this post (Defining static partitions in NC2.7 (sysbuild vs partition manger)).

What I tried so far and what was working is the following:

  1. I can use a pm_static.yml in my applications to tell the Partition Manager to put my application after the SoftDevice and MBR. BUT: I don't like to add it to all my applications.
  2. I disabled the Partition Manager in sysbuild.conf using 
    SB_CONFIG_PARTITION_MANAGER=n
    . But somehow I don't think it is a nice solution to simply disable the partition manager.

I also tried it similar to the nrf52840dongle board files. Which simply define a flash load offset if CONFIG_BOARD_HAS_NRF5_BOOTLOADER=y.

File Kconfig

if BOARD_NRF52840DONGLE

config BOARD_HAS_NRF5_BOOTLOADER
	bool "Board has nRF5 bootloader"
	default y
	help
	  If selected, applications are linked so that they can be loaded by Nordic
	  nRF5 bootloader.

endif # BOARD_NRF52840DONGLE

File Kconfig.defconfig
 

if BOARD_NRF52840DONGLE

# To let the nRF5 bootloader load an application, the application
# must be linked after Nordic MBR, that is factory-programmed on the board.

# Nordic nRF5 bootloader exists outside of the partitions specified in the
# DTS file, so we manually override FLASH_LOAD_OFFSET to link the application
# correctly, after Nordic MBR.

# When building MCUBoot, MCUBoot itself will select USE_DT_CODE_PARTITION
# which will make it link into the correct partition specified in DTS file,
# the offset is applied here so that the full partition size can be used when
# the bootloader Kconfig option has been disabled.

config FLASH_LOAD_OFFSET
	default 0x1000
	depends on BOARD_HAS_NRF5_BOOTLOADER && (MCUBOOT || !USE_DT_CODE_PARTITION)
	
# ... other config not shown

endif #BOARD_NRF52840DONGLE

I also tried this with my custom board, but for any reason it does not work.

So what I initially wanted to ask is, if there is any approach how to properly account for an exsisting bootloader, SoftDevice, etc. in the board configuration files?

Thank you in advance, 
Mathias

Parents
  • Hi,

    Specifically, the fixed partition in my dts files are ignored.

    Yes, that is correct. With the nRF Connect SDK, the partition manager is used for partitioning the memory, and not the device tree. What you have in the device tree is ignored. This is regardless if you are using sysbuild or not (or hardware model v2 or not for that matter).

    The approach used for the nRF52840 dongle with BOARD_HAS_NRF5_BOOTLOADER and FLASH_LOAD_OFFSET works in SDK 2.8.0 as well, so you can do the same for your custom board. I suspect that if you check the generated .config you are missing some of these configs:

    • CONFIG_FLASH_LOAD_OFFSET=0x1000
    • CONFIG_HAS_FLASH_LOAD_OFFSET=y
    • CONFIG_BOARD_HAS_NRF5_BOOTLOADER=y

    Can you check if that is the case? If so, the next step is to look at your board fiels to understand why.

  • Hi!

    I tried it with the blinky sample and I can find all three configs in the build/blinky/zephyr/.config file. But still the image starts at offset 0x0. The weird thing is though, I get the following output in the terminal:

    Converted to uf2, output size: 75776, start address: 0x27000

    But if I have a look at the image in the nRF Connect Programmer it starts at 0x0. And when I flash the UF2 image, my bootloader and softdevice are overwritten.

    This is what I specified in my board files:

    Kconfig:

    config BOARD_HAS_UF2_BOOTLOADER
    	bool "Board has Adafruit UF2 bootloader"
    	default y

    Kconfig.defconfig: (using 0x27000 as offset to take softdevice into account)

    config FLASH_LOAD_OFFSET
    	default 0x27000
    	depends on BOARD_HAS_UF2_BOOTLOADER && (MCUBOOT || !USE_DT_CODE_PARTITION)
    
    config BT_CTLR
    	default BT
    
    if USB_DEVICE_STACK
    
    config UART_CONSOLE
    	default CONSOLE
    
    config USB_DEVICE_INITIALIZE_AT_BOOT
    	default y

    custom_board_defconfig:

    # Enable MPU
    CONFIG_ARM_MPU=y
    
    # Enable hardware stack protection
    CONFIG_HW_STACK_PROTECTION=y
    
    # enable GPIO
    CONFIG_GPIO=y
    
    # enable uart driver
    CONFIG_SERIAL=y
    
    # enable console
    CONFIG_CONSOLE=y
    
    # Logger cannot use itself to log
    CONFIG_USB_CDC_ACM_LOG_LEVEL_OFF=y
    
    # enable USB
    CONFIG_USB_DEVICE_STACK=y
    
    # Build UF2 by default, supported by the Adafruit nRF52 Bootloader
    CONFIG_BUILD_OUTPUT_UF2=y

    The other files are similar to the nrf52840 dongle files.

Reply
  • Hi!

    I tried it with the blinky sample and I can find all three configs in the build/blinky/zephyr/.config file. But still the image starts at offset 0x0. The weird thing is though, I get the following output in the terminal:

    Converted to uf2, output size: 75776, start address: 0x27000

    But if I have a look at the image in the nRF Connect Programmer it starts at 0x0. And when I flash the UF2 image, my bootloader and softdevice are overwritten.

    This is what I specified in my board files:

    Kconfig:

    config BOARD_HAS_UF2_BOOTLOADER
    	bool "Board has Adafruit UF2 bootloader"
    	default y

    Kconfig.defconfig: (using 0x27000 as offset to take softdevice into account)

    config FLASH_LOAD_OFFSET
    	default 0x27000
    	depends on BOARD_HAS_UF2_BOOTLOADER && (MCUBOOT || !USE_DT_CODE_PARTITION)
    
    config BT_CTLR
    	default BT
    
    if USB_DEVICE_STACK
    
    config UART_CONSOLE
    	default CONSOLE
    
    config USB_DEVICE_INITIALIZE_AT_BOOT
    	default y

    custom_board_defconfig:

    # Enable MPU
    CONFIG_ARM_MPU=y
    
    # Enable hardware stack protection
    CONFIG_HW_STACK_PROTECTION=y
    
    # enable GPIO
    CONFIG_GPIO=y
    
    # enable uart driver
    CONFIG_SERIAL=y
    
    # enable console
    CONFIG_CONSOLE=y
    
    # Logger cannot use itself to log
    CONFIG_USB_CDC_ACM_LOG_LEVEL_OFF=y
    
    # enable USB
    CONFIG_USB_DEVICE_STACK=y
    
    # Build UF2 by default, supported by the Adafruit nRF52 Bootloader
    CONFIG_BUILD_OUTPUT_UF2=y

    The other files are similar to the nrf52840 dongle files.

Children
Related