Go Down

Topic: How to upload Nordic compiled .hex file to a Nano 33 BLE (Read 522 times) previous topic - next topic

jerteach

Does anyone know if it is compatible and the steps to use the Arduino IDE to upload a Nordic compiled nRF52840 .hex file to a Nano 33 BLE?


After a bit of searching I have found this


Just watch the output console when the Arduino IDE compiles and uploads the file. For me using an Arduino Uno it looks like


Code: [Select]
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM15 -b115200 -D -Uflash:w:C:\Users\[username~1]\AppData\Local\Temp\arduino_build_23163/Blink2.ino.hex:i

So a .hex file can be uploaded. The next issue is if a Nordic generated .hex file be compatible with the nano 33 BLE.

Another issue is if the nano 33 bootloader needs is fine or if it has to be changed.

pert

After a bit of searching I have found this


Just watch the output console when the Arduino IDE compiles and uploads the file. For me using an Arduino Uno it looks like


Code: [Select]
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM15 -b115200 -D -Uflash:w:C:\Users\[username~1]\AppData\Local\Temp\arduino_build_23163/Blink2.ino.hex:i
You're on the right track. You can't use the Arduino IDE to upload a pre-compiled .hex file, but you can copy the upload command the Arduino IDE generates, modify it to point to your .hex file, and run that from the command line. But that avrdude command is for uploading to the Uno. The command to upload to the Nano 33 BLE will be different. You should do an upload with the Nano 33 BLE selected from the Tools > Board menu and then copy the upload command the IDE generates.

It looks like you already know this, but for anyone else trying to do the same thing, note that you need to turn on File > Preferences > Show verbose output during: Upload in order to see the upload command in the Arduino IDE's console.

jerteach

Thanks Pert. I am making some progress. I exported to binary my Nano 33 BLE code and then got this .cmd file working to load the code without having to recompile it. Unlike the UNO, the nano 33 BLE seems to only generate a .bin file instead of a bootloader and .hex file. I assume the .bin file is a bootloader and .hex file combined. Any suggestions for how I would take a Nordic .hex file and a bootloader and combine them into a .bin file? I guess the first step would be how to generate a nano 33 BLE bootloader?

The website for the bossac.exe program is here


Code: [Select]
echo "double push reset for bootloader, uploading blink3 fast after enter"
pause
"C:\Users\[my user name]\AppData\Local\Arduino15\packages\arduino\tools\bossac\1.9.1-arduino1/bossac.exe" -d --port=COM17 -U -i -e -w "C:\Users\[my user name]\Documents\Arduino\myStuff\blin3fast\blin3fast.ino.ARDUINO_NANO33BLE.bin" -R

kevingre

@Jerteach,
Not sure if you've solved this or not but I too had to ditch the mbedos and arduino core for the 33 BLE since they chose not to implement some very basic features (act as a slave in an I2C or SPI circuit).

As such, I went with the native NRF5 sdk and am running things quite nicely.

To upload a BIN file generated from the armgcc using the sdk, I simply run make and use the following command to upload:

Code: [Select]
<my_path_to_bossac> -d --port=<my_usb_port> -U -i -e -w <path_to_my_bin_file> -R

This will keep the arduino bootloader in place, which is what I wanted so I could switch back easily if needed.

The key here is you have to build the BIN file with the proper application code offset in memory.  To do that, you have to edit the LD file in your armgcc directory for your project.  To do that, simply replace the MEMORY section:

Code: [Select]
MEMORY
{
  FLASH (rx) : ORIGIN = 0x10000, LENGTH = 0xf0000
  RAM (rwx) :  ORIGIN = 0x20000000, LENGTH = 0x40000
}


The above will position your application code past the bootloader and adjust the memory available as appropriate.

IMPORTANT:  In order to upload using bossac, your board must be in bootloader mode by pressing the reset button twice (yellow light cycling on/off).

I hope that helps!

jerteach

Wow @kevingre

That is exactly what I needed! I even found the .LD file.

I knew the .bin file needed the flash ram location but had no idea how to find what it was or how to set it. I will be trying your solution, but really want to express how helpful your post has been.


... about 30 minutes later ...


So I managed to generate a .bin file. Managed to upload it to the Nano 33 BLE Sense, without obvious errors. It did not work, (Not that big a deal) but the real positive is that I did not brick my Nano. I managed to flash blink back on the nano and it worked again. Yeh!


P.S. I will next try a simple Nordic SDK example instead of the full OpenThread.io example I tried that did not work.



...  2 days later...



So I have updated my online docker that ran Openthread.io to also include the nordic-sdk.

This is a large file (few minutes to load) that runs on Gitpod, which needs a github login. Running complex installs in the browser is amazing.



https://gitpod.io#snapshot/e709c382-8574-4775-876c-002bfeecc374


The github is at https://github.com/hpssjellis/my-gitpod-of-openthread it has a .gitpod.yml file which is like a bash automated program and a Dockerfile that does the installs.


The gitpod auto compiles both a starter openthread .hex file and a starter nordic-sdk perpheral blinky program. Finding the correct folders and how to run stuff is fairly confusing. Have a look in the .gitpod.yml file for ideas. I will try to make a video if I can get it working on the Nano 33 BLE Sense.



... next day ...


So excited that things were working and Nordic actually generates a .bin file instead of just a .hex file. This video was helpful https://www.youtube.com/watch?v=kyPKIRQIacI

and I used his code

Code: [Select]
#include "boards.h"



int main() {
    bsp_board_init(BSP_INIT_LEDS | BSP_INIT_BUTTONS);
    while (true) {
        if (bsp_board_button_state_get(BSP_BUTTON_0)) {
             bsp_board_led_on(BSP_BOARD_LED_2);
       } else {
            bsp_board_led_off(BSP_BOARD_LED_2);
       }
    }
}


 I loaded it on the Nano 33 BLE, and it works! I push the button and the orange LED goes on , push the button again and it goes off. Only one little detail, I forgot to change the memory address, LOL, (Actually I am really sad)  :'(  I bricked my new Nano!

Not a big issue, I am buying a lot more Nano's in a few days. I did start the following post for obvious reasons.

Nano 33 BLE Arduino as ISP Programmer



Side note: Has anyone purchased a Segger J-Link EDU mini - JTAG/SWD Debugger with positive results? https://www.segger.com/


jerteach

Looks like this segger edu mini is cheaper  from sparkfun (of course I just ordered the more expensive one yesterday),  curious about the wiring connections. I can solder wires to the 5 pins on the back of the Nano 33 BLE, but does anyone know of a pogo 5 pin cable that works with this board? Or can some of the 5 pins on the back be connected at the front using regular pins?


Does all the back of the board pins need to be connected at that location or can some of them be connected using regular pins on the front of the board?
 
1 +3V3 (Top left, looking at back of board, USB connector on the left. See attached image)
2 PA31_SWDIO
3 PA30_SWCLK,
4 not connected (or even present)
5 GND
6 resetIN


 

Go Up