JFlash Bootloader and Application

I’m researching alternative methods to update the application on my RACK5010. I’m using a custom firmware burned by JFlash, then Arduino IDE to put on my custom application. All that works fine.

However after building my device I do not have access to the USB port. I’ve tried to get Bluetooth OTA to work but haven’t been successful. Can the RAK5010 be updated with both the bootloader and application at the same time using JFlash?

What are my alternatives? I’d like to get Bluetooth to work but all the samples are proving not to do what I need. I can see the device but not able to put it in bootloader mode and upload an application.


What bootloader are you using for your rak5010? Is it adafruit’s bootloader?

I’ve been using the one that was recommended:


I’ve been trying to get the OTA code working w/ Bluetooth and have tried different things:

RAK5010 Arduino Bluetooth DFU - Cellular Boards / RAK5010 - RAKwireless Forum

And I implemented this code:

I think I’m close to getting this to work, but when I connect w/ the Bluefruit Android app or the nRF Connect application, I’m not able to put the device in DFU mode to upload the application.


Hi @InlineTechnology ,

There is a timeout with OTA Update via BLE. But I assume that you quickly try to upload as soon as the power is powered up. I am having issue on uploading the arduino bootloader hex on my RAK5010 board. I am getting a new RAK5010 to test. I’ll update you asap on whatever I’ll found about it and also on the DFU and FRST pins, etc. Btw, your application code runs ok right? Did you try the basic OTA Update example?

Yes my application runs ok. I did try the basic OTA example and had the same results.

Hi @InlineTechnology ,

I got a new RAK5010 and uploaded the latest Arduino_adafruit_bootloader using RAKDAP1 hardware. I tried the original hex in the RAK5010 github guide but the BLE disconnects and can’t proceed on the update.

The closest I got is when I force the DFU OTA via putting the DFU and FRST pins to low state. You can try it but you have to solder on TP5 to GND level. If you do that, you should be able to detect ADADFU. You can try to upload your .zip and see the result. It starts uploading but it stops at low percentage write. I suggest you try and see for yourself. It might give you some clue.

With regards to the DFU and FRST pins, we are using the one for the nrf52840_express from adafruit’s firmware release. You can map it to IO4 and IO3 but you need to recompile it. For quick test, I didn’t do that. Also instead of modifying the PCA10056 variants h and c file, you should update the one for the nrf52840 express and select it as board in your Arduino code. I hope you can search for possible reason why it disconnects or we can also see if it will not disconnect in your board

The DFU and FRST pins uses BUTTON_1 and BUTTON_2 in this macro definitions. Those pins are highligthed in the image above.


Carl - thanks for the assistance. With some research I was able to successfully upgrade the application OTA.

I’m also using the original Bootloader from here:

The newer bootloader may also work, however I stuck with what we have been testing with.

Instead of soldering pins and controlling the DFU and FRST pins to low state, I read this:

The GPREGRET register can also be set to force the bootloader can enter any of above modes (plus a CDC-only mode for Arduino). GPREGRET is set by the application before performing a soft reset.

#include “nrf_nvic.h”
void reset_to_uf2(void) {
NRF_POWER->GPREGRET = 0x57; // 0xA8 OTA, 0x4e Serial
NVIC_SystemReset(); // or sd_nvic_SystemReset();

On this page:

GitHub - adafruit/Adafruit_nRF52_Bootloader: USB-enabled bootloaders for the nRF52 BLE SoC chips

In the Setup() function I read the state of one of the IO ports. If it is “engaged”, then I run the above code and put the device in OTA/Update mode.

The nRFConnect Android application will NOT work (as it is today). It’ll connect to the RAK5010, however it will not correctly upload the ZIP package.

I’m using the BlueFruit Android application. (Adafruit, Bluefruit LE Connect v3.3.2). I can connect to the RAK5010, then click on Update, select a custom firmware, select the .HEX and .DAT files and upload to the RAK5010. It reboots and has the most current version of my application!

Almost there… two final questions (I hope).

  • What is the best way to add a pushbutton switch to the RAK5010? Currently I’m using IO4 pinMode(PIN_NRF_IO4, INPUT); and putting the button between the IO4 PIN and VDD. When connected to VDD I get a TRUE, disconnected I get a FALSE.

  • Do you want me to write this up? If so, send me a private email.


That’s good news Carlton that you got some progress.

Regarding the pushbutton, what issue do you encounter with IO4?

Shorting IO4 to Ground seems to be flakey. Sometimes it works or sometimes it works once, then fails to return a change:

void bg96_init()
pinMode(PIN_BG96_DTR, OUTPUT);

pinMode(PIN_NRF_IO4, INPUT);

// Defaults
digitalWrite(PIN_RESET, 0);
digitalWrite(PIN_W_DISABLE, 0);
digitalWrite(PIN_BG96_DTR, 0);

bool isButtonPressed(void) {
return digitalRead(PIN_NRF_IO4) ? 1 : 0;

I can sort of get it to work if I short GND and IO4, then IO4 and VREF.

Do I need to put a pullup resistor between IO4 and VREF and the pushbutton switch between IO4 and GND? If so, what size resistor should I use?

The VREF should be connected to a external positive voltage source higher than 1.8V. It can be to VBAT or 3.3V whatever VDD level you use for the pull-up resistor.

  1. Connect VREF to VBAT.
  2. Connect IO4 → 10K Resistor → VREF
  3. Connect push button switch to IO4 and GND

Would that work?

Yes. That should work :+1: