Custom bootloader with nrf52832 dk

Hello,

We have been trying to develop a custom bootloader, with ncs v2.3.0

As a starting point. we use a nrf52832 dk

1) I made a copy of the bootloader from the samples dir in ncs.  which I renamed "my_bootloader", in my apps local dir.

2) I use a very simple app ( which is named my_app ), as well located in my local apps dir.

I need "my_app" to be  built with "my_bootloader".

The config I have is, for my_ap is

prj.conf

CONFIG_CPLUSPLUS=y

# Logging with Uart0 on Putty
CONFIG_CONSOLE=y
CONFIG_SERIAL=y
CONFIG_UART_CONSOLE=y

CONFIG_SECURE_BOOT=y
CONFIG_B0_BUILD_STRATEGY_FROM_SOURCE=y
CONFIG_SB_SIGNING_KEY_FILE="melifloBootPrivateKey.pem"

This actually uses the bootloader located in ncs/samples. I do not want to modify the code in my ncs dirs.

I tested different strategies to use my_custombootloader instead, but with no success. ( ie: add_child )

Could you please tell me the modifications I should make in my_app/prj.conf and my_app/CMakeLists.txt  to make this happen?

Thanks in advance,

M Martin

Parents
  • Hi Marte,

    Our app is 350k, and we want to do remote upgrades. 350k is too big for the 52832, so we want to transfer the update in BLE, store it on a separate flash, and use a custom bootloader to verify and swap the images. Customizing the bootloader seems to me to be the simplest way to do this.

    I think in theory, it would also be possible to just specify an external flash in the dts, but I did not find enough information to do this, using the pins I want and the flash mem I want.

    I will have a look again at "adding a child image using the zephyr modules" .

    I will get back to you in 2 weeks ( after my vacation)

    Thanks and talk to you soon.

Reply
  • Hi Marte,

    Our app is 350k, and we want to do remote upgrades. 350k is too big for the 52832, so we want to transfer the update in BLE, store it on a separate flash, and use a custom bootloader to verify and swap the images. Customizing the bootloader seems to me to be the simplest way to do this.

    I think in theory, it would also be possible to just specify an external flash in the dts, but I did not find enough information to do this, using the pins I want and the flash mem I want.

    I will have a look again at "adding a child image using the zephyr modules" .

    I will get back to you in 2 weeks ( after my vacation)

    Thanks and talk to you soon.

Children
  • Hi,

    Enjoy your vacation!

    You can use external flash for the secondary slot with the default bootloader. We do not have this by default for nRF52832, but we do have for other devices.

    I made a simple example showing how to configure this in devicetree for nRF52832. Since we are using mx25r64 for external flash on other boards I used the same in the example.The example is configured to use SPI2 for external flash, but this can be changed. By default it uses SPI, but I have added the configurations for using SPIM as comments, so all you need to do is uncomment the configurations.

    One thing to note is that child images do not inherit configurations in devicetree overlays or project configurations from the parent image, so I added mx25r64 to the boards devicetree instead (zephyr/boards/arm/nrf52dk_nrf52832/nrf52dk_nrf52832.dts). Normally, I would not recommend changing the dts files in the SDK, but if you are creating a custom board you would most likely put the external flash in the boards devicetree anyway. Another way is to add mx25r64 in both the projects and MCUboots overlays. You can see the changes I made to nrf52dk_nrf52832.dts in nrf52dk_nrf52832_dts_diff.txt.

    Please be aware that I have not tested the code. only that it builds, so I cannot guarantee that it works as it is. There might be some wrong configurations of the mx25r64 devicetree node, as I took it directly from a different overlay.
    Let me know if you run into any issues or have any questions!

    hello_world_nrf52832_mcuboot_ext_flash.zip

    Best regards,
    Marte

Related