This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

USB-Serial DFU to nRF52840 on nRF91 DK Board

Hello, thank you for taking time to review this.

I am trying to setup a serial DFU setup for the nRF52 on the nRF91 DK board. I am running into problems getting it to work and understanding it in general.
I looked at several pages trying to help myself understand it
1) https://docs.zephyrproject.org/1.12.0/samples/subsys/usb/dfu/README.html
2) https://docs.zephyrproject.org/1.13.0/devices/dts/flash_partitions.html
3) https://mcuboot.com/mcuboot/readme-zephyr.html
4) https://docs.zephyrproject.org/1.12.0/samples/subsys/mgmt/mcumgr/smp_svr/README.html
5) https://github.com/apache/mynewt-mcumgr-cli
    As well as the links on these pages

I have tried several processes, but for the sake of conversation I will explain my most recent approach.

I compiled the MCUbootloader:
-in mcuboot/boot/zephyr/build

1) cmake -GNinja -DBOARD=nrf52840_pca10090 ..
2) ninja
3) ninja flash

Once I have flashed the bootloader
-in /zephyr/samples/bluetooth/beacon/build
1) cmake -GNinja -DBOARD=nrf52840_pca10090 ..
2) ninja
3) ~/<path/to/source>/ncs/mcuboot/scripts/imgtool.py sign \
--key ~/<path/to/source>/ncs/mcuboot/root-rsa-2048.pem \
--header-size 0x200 \
--align 8 \
--version 1.0 \
--slot-size 0x69000 --pad-header \
./zephyr/zephyr.hex b_signed.hex

After both are completed:
-in above build dir
1) nrfjprog --program b_signed.hex

Error:
Parsing hex file.
Reading flash area to program to guarantee it is erased.
ERROR: The area to write is not erased.

Notes:
I have tried signing the bootloader and loading at 0xC000
I have tried adding CONFIG_BOOTLOADER_MCUBOOT=y to the beacon prj.conf

I am just having trouble putting this all together and understanding how it all works and how to do it. My goal is to load some project like bluetooth/beacon, then use a serial DFU to change the project image to like the hello_world example and have it load into slot1, then switch it to slot0 after verification and then load hellow_world on reset/boot.

Thanks for your help

Parents
  • UPDATE

    So I moved to just using cmake and noticed in the Makefile a menuconfig option existed. So I explored that and saw I could specify the offset I wanted the image to be loaded at here. I could do the same for the bootloader. I set the bootloader to not verify the image on boot (just to simplify for now) and then flashed it, an of course it prints
            ***** Booting Zephyr OS v1.13.99-ncs2 *****
    on boot. I then configured the offset on the hello_world image for slot0_partition. When I have CONFIG_BOOTLOADER_MCUBOOT enabled it acts like only the bootloader image exists, and prints the same thing. If I disable CONFIG_BOOTLOADER_MCUBOOT then it prints out my custom bootloader message and my example image. This makes me think that maybe I am uploading the image and the bootloader to the offset which would explain why it doesn't change its boot behavior when CONFIG_BOOTLOADER_MCUBOOT is enabled, because slot0 would have the new bootloader image and the application image in it. I could obviously be wrong. I also tried uploading signed both ways and got the same results as the unsigned method. I am still just trying to pass in an original image, have it execute that, then once that works pass in an image to slot1 and have it swap to that.

Reply
  • UPDATE

    So I moved to just using cmake and noticed in the Makefile a menuconfig option existed. So I explored that and saw I could specify the offset I wanted the image to be loaded at here. I could do the same for the bootloader. I set the bootloader to not verify the image on boot (just to simplify for now) and then flashed it, an of course it prints
            ***** Booting Zephyr OS v1.13.99-ncs2 *****
    on boot. I then configured the offset on the hello_world image for slot0_partition. When I have CONFIG_BOOTLOADER_MCUBOOT enabled it acts like only the bootloader image exists, and prints the same thing. If I disable CONFIG_BOOTLOADER_MCUBOOT then it prints out my custom bootloader message and my example image. This makes me think that maybe I am uploading the image and the bootloader to the offset which would explain why it doesn't change its boot behavior when CONFIG_BOOTLOADER_MCUBOOT is enabled, because slot0 would have the new bootloader image and the application image in it. I could obviously be wrong. I also tried uploading signed both ways and got the same results as the unsigned method. I am still just trying to pass in an original image, have it execute that, then once that works pass in an image to slot1 and have it swap to that.

Children
No Data
Related