RAK4631 J-link programming problem

Hello,

I have two Rak4631 modules. One is the WisBlock Starter Kit and the other is on a pcb. Rak4631 module on the pcb, I can only program from the SWDIO port. Because the USB port connection of the module is not made on the PCB. There is only SWDIO output for programming. I use Segger J-link V9 for this.

My question is:

I wrote a program in Arduino IDE and I send it directly to the Starter Kit via USB and it connects to TheThingsNetwork immediately. I send the same program in Hex format with J-link to Rak4631 on the pcb, but it does not connect to TTN.

The module on the PCB previously had a Hello World program. I’ve backed it up before. To check the stability of the module, I am sending that HEX File back to the module via J-link. This time it connects to TTN without any problem and sends Hello World.

I have tried to power it by another source.

Where am I doing wrong?

Welcome to the forum @KKOC

Two things that could have gone wrong

  • The hex file that Arduino produces is only the application, it does not include the bootloader and the softdevice of the nRF52. If you erased the chip and then flash the hex file, the nRF52 will not boot because the bootloader is missing

  • If your code is waiting for USB with

while (!Serial){};

it will not continue to finish the setup() ever, because Serial USB will never be available.

Hello @KKOC

I guess you contacted us as well in our support center. I answered you there, but for the public, I want to repeat the steps here again.

What you need to do is to combine the bootloader and the application file into one hex file. I am using the Python library IntelHex to do it.

  1. install Intelhex with pip install IntelHex
  2. get the python script called hexmerge.py from the IntelHex repo and save it in a new folder
  3. copy the generated firmware.hex from Arduino into the same folder
  4. get the RAK4630 bootloader from our Gitlab repo WisCore_RAK4631_Board_Bootloader.hex and copy it into the same folder
  5. run python hexmerge.py --overlap=replace firmware.hex WisCore_RAK4631_Board_Bootloader.hex -o flashme.hex
  6. flash the generated file with pyocd flash -t nrf52840 flashme.hex