Trying to use the Adafruit UF2 bootloader so that in my product I can drag & drop new firmware images

Hi

On Github I have found  https://github.com/adafruit/Adafruit_nRF52_Bootloader  and at https://github.com/adafruit/Adafruit_nRF52_Bootloader/tree/master/src/boards I have found a release image for pca10056 devkit at https://github.com/adafruit/Adafruit_nRF52_Bootloader/releases

The release image contains the softdevice.

I think that the bootloader leverages the Nordic MBR so the softdevice starts at 0x1000.
The secondary uf2 bootloader is at the top end of the flash space.

I have built my application to start at 0x1000 as I don't need the softdevice as I plan to leverage the Zephyr based stack.
When I load that application using the debugger I do not get to my main().

BTW: I loaded the UF2 bootlaoder release image HEX file using Programmer launched from nRF Connect for DEsktop v4.1.2 and I did  complain that there was content beyond the flash size and I notice that the hex file writes to 0x10001014 which I recall from my Laird days is the start address where the bootloader jumps to.
It must have programmed it, because when I plug the USB of the nrf52840 into my PC I do get a flash drive appear (I disconnected the cable from the Segger chip usb just to be sure I was seeing the correct flash drive).

As a sanity check, I am now going to try and build my image at the end of the SD to see if it fires up into my app.

I will be most grateful for any assistance, and if it is from non-Nordic developers I am even will to pay for the help :-)

I look forward to hearing from anyone out there.

KInd regards
Mahendra

PS: in a previous job I worked on nordic BLE since 2012 to 2020 so not a newbie and in the early days I even developed my own bootloader.


  • Hi Mahendra,

    Even though Adafruit based their bootloader on the nRF5 SDK bootloader from Nordic there are quite a few changes, so I would suggest that you ask in the Adafruit forum.

    Ignoring that (and any potential differences from the nRF5 SDK bootloader I am not aware of), I wonder if you have done any debugging to learn more about what is happening (other than that it seems the bootloader does not start your application)? If so, what have you found?

  • I had a similar issue on a 'adafruit_feather_nrf52840' board, also described in this devzone post.

    I believe the issue is the default Zephyr memory map collides with the Adafruit bootloader layout (see diagram here). 

    So, I modified the dts file like this:

    &flash0 {
    
    	partitions {
    		compatible = "fixed-partitions";
    		#address-cells = <1>;
    		#size-cells = <1>;
    
    		sd_partition: partition@0 {
    			label = "softdevice";
    			reg = <0x00000000 0x00026000>;
    		};
    		slot0_partition: partition@26000 {
    			label = "image-0";
    			reg = <0x00026000 0x00067000>;
    		};
    
    		/* Storage partition will be used by FCB/NFFS/NVS if enabled. */
    		storage_partition: partition@e5000 {
    			label = "storage";
    			reg = <0x000e5000 0x00008000>;
    		};
    	};
    };

    And then added these to my prj.conf:

    CONFIG_BUILD_OUTPUT_UF2=y
    CONFIG_USE_DT_CODE_PARTITION=y

    At the end of the 'west build' line, the uf2 start address matches the dts: 

    Converting to uf2, output size: 415744, start address: 0x26000
    Wrote 415744 bytes to zephyr.uf2

    And now I'm able to load the uf2 file successfully via drag-and-drop. Hope that helps!

  • Using  the same flash0 configuration I get an error " region `FLASH' overflowed by 30676 bytes"

    Fixed that by increasing the image-0 region by that size

    It seems to be working - i.e the updated image is loaded and runs just fine but I always get an error copying the uf2 image

    When I click "Skip" it continues and I get "Upload complete" message and the updated image is loaded on the board

    I'm using adm_b_nrf52840_1_bootloader-0.7.0_s140_6.1.1.hex which I uploaded on the board with this command
     nrfjprog --program adm_b_nrf52840_1_bootloader-0.7.0_s140_6.1.1.hex --chiperase -f nrf52 --verify --reset

    Has anyone seen this ?

Related