Building firmware for RAK4631

Just a question: How do i build the firmware for the RAK4631?

Following Building Meshtastic Firmware | Meshtastic worked well for the T-Beam for example. At the end of the build process, something like firmware.factory.bin is produced, which i can rename to say 2.0.12_TBeam.bin and flash that to my T-Beam. Fine.

However the RAK4631 (tutorial) asks for a .uf2 file.
I do not find that file. VSC generates a .zip file at the end of the build process which contains a file firmware.bin. Uploading this firmware to the 4631 does not work and also renaming to firmware.uf2 does not work.

Any advice?

Typically a ZIP file is flashed via “adafruit-nrfutil” such as done when updating the bootloader on NRF52 devices as covered here on RAK documentation

*in DFU mode over a Serial port

adafruit-nrfutil.exe --verbose dfu serial --package WisCore_RAK4631_Board_Bootloader.zip --port COM19 -b 115200 --singlebank --touch 1200

However the process of creating a UF2 file is derived from a HEX or BIN file and requires the use of a special command called uf2conv.py with specifc parameters

  • Copied onto the RAK FAT fs volume

BIN file

If using a .bin file with the conversion script you must specify application address with the -b switch, this address depend on the SoftDevice size/version e.g S140 v6 is 0x26000, v7 is 0x27000

nRF52840
uf2conv.py firmware.bin -c -b 0x26000 -f 0xADA52840

from

Running uf2conv.py requires the file uf2families.json

Refer to my GitHub page for the UF2 erase i created for NRF52 devices

Compile with Arduino selecting a Adafruit nRF52 Board eg Nordic nRF82540 DK

Screenshot_20220506_225929

Find the created hex file in your temp folder e.g (under Linux)

find /tmp -name Meshtastic_nRF52_factory_erase.ino.hex

Convert the hex file to uf2


./uf2conv.py Meshtastic_nRF52_factory_erase.ino.hex -c -f 0xADA52840; cp flash.uf2 Meshtastic_nRF52_factory_erase.uf2

Other useful links

While I’m sure the above method also works, I usually use the ‘Upload’ button of the PlatformIO extension in VSCode (step 5 in your link). Just make sure the RAK is in bootloader mode by double-pressing the reset button after you connect it.

also worth noting @mark.birss is absolutely right. The uf2 file is generated from the hex file in our build process within gitlab. the right uf2conv.py is included in the firmware bin filder and you can have a peek in bin/build-nrf52.sh for the right parameter

SRCHEX=.pio/build/$1/firmware.hex
bin/uf2conv.py $SRCHEX -c -o $OUTDIR/$basename.uf2 -f 0xADA52840
1 Like

Great, thanks. It works!
Also thanks for the other contributions.
A great project. Just flashed my 6th node!