Hi,
just want to share some experiences on how I made a functional host DFU with my own light-weight serial only bootloader (bldr) for arduino nano 33 ble…
My bldr was derived directly from “GitHub - adafruit/Adafruit_nRF52_Arduino: Adafruit code for the Nordic nRF52 BLE SoC on Arduino”, I was not aware
of the “Blues” fork when I started, that is a complete bldr with plenty of options…
After some fiddling I got “outboard host DFU” working with an arduino nano 33 ble, and
apps built for arduino using mbed os, and without any softdevice in the flashmemory.
(Note, a modified Adafruit-based (Blue) bootloader must first be flashed onto the device.)
Haven’t tried to do this via an arduino app using the arduino original bootloader, which I think is possible.
Instead I’m using a J-link adapter which means that bricked devices easily may be recovered…
In order to build arduino apps:
-
Edit linker script to a suitable entry point, in my case 0x1000.
-
Must also edit variant.cpp under “…\Arduino15\packages\arduino\hardware\mbed\x.y.z\variants\ARDUINO_NANO33BLE) ,
i.e. comment out the line"while (!nrf_uarte_event_check(NRF_UARTE0, NRF_UARTE_EVENT_RXTO)) ;”, otherwise the app will hang there indefinitely when starting apps from the Adafruit-based bootloader. -
Use adafruit-nrfutil.exe to build a first zip-package: adafruit-nrfutil dfu genpkg --dev-type 0x0052 --application slow.ino.hex slow.ino.zip
-
Make a compatible binpack using notecard cli: notecard -output arduino-slow.binpack -binpack nrf52 slow.ino.zip:
(I think there is an error on one of the webpages describing this step… there is an excess “-output” parameter )
arduino-slow.binpack now incorporates 3 files and is 92740 bytes (11% saved because of compression):
HOST: nrf52
LOAD: manifest.json,0x00000000,0x1,0x1e4
LOAD: slow.ino.dat,0x00000000,0x2,0xe
LOAD: slow.ino.bin,0x00000000,0x3,0x190d8
- Follow instructions at Blues “guides-and-tutorials/notecard-guides/notecard-outboard-firmware-update/#required-wiring”,
and “github.com/blues/note-outboard-dfu/tree/main/nrf52840” to update the host connected to a notecard.
Note that a suitable DFU-pin must be configured in the blder code, and wire it up… Also make sure notecard fmw is up to date, I used 4.1.1.4015681. - Here it didn’t work at first, got error: {“text”:“outboard DFU of nrf52 firmware: Unrecognized nRF region 102616”},
I thought AUX3 (the documentation I have seen does not say!) was active low from notecard to get host to enter DFU.
Active low, it is also what’s expected in the Adafruit source, later saw that this was changed in the “Blues fork” why?
Looking at the general notecard documentation, I would suggest that the action of the AUX3 pin to be set in stage 4 above, e.g. open drain mode would come in handy in many cases…
Anyway, I put an open-drain transistor inverter in between and it worked like a charm.
Some general and specific issues:
When working with the notecard, one may sometimes be a bit unsure if a setting is sticky or not, e.g. in this case, after issuing the command below, one does not see the status of the “on or off-flag” on the host / notecard level.
{“req”:“card.dfu”,“on”:true}
{
“mode”: “aux”,
“name”: “nrf52”
}
So, I was curios if this setting was sticky or not, maybe it reset after a successful host update, problem is that the host cannot tell if this feature is on or off, or can it?
Well I found out that is was sticky.
Then I tested to set {“req”:“card.dfu”,"off ":true}, then when host firmware was downloaded from hub, it was saved in the notecard, and flashed after I set {“req”:“card.dfu”,“on”:true}. This is good, as the host might want to sync the flashing locally.
So, the host can poll the notecard for updates and activate flashing when its convenient to do so.
But this won’t work if the host app is bricked…
Hence to recover a bricked host, an “unbrick mode” may be useful to enable on the hub-side that will force a host update…
After looking at the command line options for notecard cls, I tried a shortcut for stage 4:
notecard -output arduino-slow.binpack -binpack nrf52 0x1000:slow.ino.bin
arduino-slow.binpack now incorporates 1 files and is 92338 bytes (11% saved because of compression):HOST: nrf52
LOAD: slow.ino.bin,0x00001000,0x190d8,0x190d8
Output response looked reasonable, actually more clear than under stage 4, and the file was accepted “all the way to the notecard” and its attempts to update the host.
But when the notecard tried to make the host enter DFU-mode, AUX3 was not activated at all…
Funny thing, AUX4 did reset the host, but AUX3 was “dead”…
Anders