Upload custom bootloader to feather nrf52832 boards through jlink

Hello!

I have been working on developing firmware for feather nrf52832 boards using platformio in conjunction with vscode. I have recently figured out that the upload protocol for this board does not check nor update the bootloader present in the device’s flash (upload protocol I am using is JLINK). I was wondering if there is a way to upload only the bootloader through platformio

Yes, the platform implements the “Burn Bootloader” target.

If you have a standard

[env:adafruit_feather_nrf52832]
platform = nordicnrf52
board = adafruit_feather_nrf52832
framework = arduino

environment you can clearly see it in the available platform project tasks.

grafik

And since you named the topic “Upload custom bootloader”, you can change the bootloader file (aka DFUBOOTHEX) and the BOOT_SETTING_ADDR (the address of the page that it will erase and write 1 into) via a simple extra script.

[env:adafruit_feather_nrf52832]
platform = nordicnrf52
board = adafruit_feather_nrf52832
framework = arduino
extra_scripts = change_bootloader.py

change_bootloader.py in the root of the directory

Import("env")

# example values.
env.Replace(DFUBOOTHEX="ABC.hex")
env.Replace(BOOT_SETTING_ADDR=0x7F000)

You’ll see that a pio run -t bootloader -v -e adafruit_feather_nrf52832 now gives

...
Building in release mode
nrfjprog --program ABC.hex -f nrf52 --chiperase
..
2 Likes

Thanks for the reply! I did reopen platformio on vscode today and was able to see the option “Burn Bootloader” as you mentioned. But not sure what happened, after a while the option disappeared; no changes were made between these scenario.

What’s your current full platformio.ini?
Did you try to press the refresh button that appears in the upper right corner of the project tasks panel when you hover over it?

I did try the refresh button on panel, but it doesn’t seem to work; but I think I have figured out the reason. I was playing around with the flash file present in the USER.platformio\packages\framework-arduinoadafruitnrf52\bootloader\feather_nrf52832 location. Changing the name of the file from feather_nrf52832_bootloader-0.3.2_s132_6.1.1.hex to anything else seems to remove the option.
I have attached the config snippet here:
platformio_config
Bootloader file:
bootloader
nrf52832_custom_bootloader.hex is also present in the root folder. Not sure why the script doesn’t seem to update the Upload Bootloader option.

Making sure if the filename of the default bootloader is unaltered, fixed the issue where the bootloading option disappeared from the PIO tab. I think the Burn Bootloader option should be visible in the case where the default bootloader in pio library is altered or doesn’t exist AND the bootloader is present in the script’s location. Thanks @maxgerhardt !!