How to upload a pre-compiled file to an Arduino IoT33

This is a short description of methods to upload compiled Arduino .bin code to an IoT33 Arduino module. This is done to facilitate updating to newer versions of the code without requiring total recompilation.

Before installing new code, backup any existing code. Failure to do so may result in a non-useful unit since return to an earlier working version may not be possible !!! You have been warned. Backup is accomplished through use of the same ‘bossac‘ tool and method described for uploading new code below but with a ‘change of direction’ set. This tool is a comand line version of ‘BOSSA’.



One Method is to install the BOSSA tool and use it for both downloading existing code and uploading new code. See documentation linked to above for using this method from your particular OS of choice. Make sure you are comfortable with it first since it appears to be possible to erase the boot loader in an IoT33.

Another method is essentially to install and configure the Arduino IDE to successfully compile and upload any Arduino ‘sketch’ to the target Arduino board type, here an IoT33. This process sets up the entire environment complete with all the necessary Arduino tools. Once the IDE is installed and the particular [IoT33] board is supported and it is possible to compile and upload any file, turning on the verbose output during the upload reveals the command line instruction that can upload any valid previously compiled Arduino .bin file. That command line is then modified to point to a different .bin file of the user’s choice. When the modified line is executed the desired .bin file should upload to the target IoT33.

The IDE method also allows backing up the FW through use of an ‘-r’. On a Mac, the first line is the upload to the IoT 33 the second line is the equivalent to download/save/backup to a file, the lower case -r before the file name being the key:

...bossac -i -d --port=/dev/cu.usbmodem14201 -U true -i -e -w -v "uploadfile.ino.bin" -R

...bossac --port=cu.usbmodem14201 -r downloadfile.bin

The download process for other OSes is similar. Make sure you are successful in downloading and saving previous code before going on to uploading new code.



Step 1 of what follows is the IDE setup instructions and may be bypassed if the IDE is already present and able to compile for the Arduino IoT33.

Step2 obtains the command line that was used by the IDE to upload a compiled binary. Make sure you can accomplish a download /b ackup before you do this though.

Step3 describes the modification and execution of the command line that was discovered from Step 2 to upload a different compiled .bin


IMPORTANT! Before uploading new code, download and save the existing code. Otherwise you may not be able to return to a previous, operational state.

Step 1

Download and Install the Arduino IDE for your computer: PC, Linux or Mac OS. (takes a while)


Click the “upload” tick next to “Show verbose output during…”

Connect the host computer to the IoT33 with a cable.

Under Tools:Port verify that you see the IoT33 listed and check it if it’s not already checked.

Select the IoT33 under Tools:Board:Arduino SAMDBOARDS:Arduino NANO33 IoT

Click Tools:Get Board Info to verify that the IoT33 is identified


In the upper left of the IDE window under “File” click the ‘tick’ icon to compile the Blink.ino and verify that it compiles successfully and produces a summary in the lower IDE (black background) output window

Again in the upper left of the IDE immediately to the right of the previous tick icon click the right pointing arrow. This should force a re-compile followed by an upload to the Iot33 which after completion should blink it’s LED at a 1/pps rate.


Step 2

After the successful upload, look in the output window at the bottom of the IDE window and scroll upward. Near the top find the command line that performed the upload.

This should look something like the following examples, where the text in bold is the target Blink .bin file being uploaded and the example port number is in red showing the number of the UPLOAD port (boot-loader port), not necessarily the name of the port that you normally connect to from the IDE.

Linux:

/home/ge/.arduino15/packages/arduino/tools/bossac/1.7.0-arduino3/bossac -i -d --port=ttyACM0 -U true -i -e -w -v /tmp/arduino_build_442293/Blink.ino.bin -R

Windows:

"C:\Users\ge\AppData\Local\Arduino15\packages\arduino\tools\bossac\1.7.0-arduino3/bossac.exe" -i -d --port=COM4 -U true -i -e -w -v "C:\Users\ge\AppData\Local\Temp\arduino\sketches\2AEA30BE00619CF8E44D792779649125/Blink.ino.bin" -R

Mac:

"/Users/gxg/Library/Arduino15/packages/arduino/tools/bossac/1.7.0-arduino3/bossac" -i -d --port=cu.usbmodem14201 -U true -i -e -w -v "/private/var/folders/vf/9xkv03g53j7fgmj32cqmhpl40000gq/T/arduino/sketches/D7227502A164B96CB8E070D436C04068/Blink.ino.bin" -R


Step 3

Synopses:

a. Modify the command line to use the new .bin file

b. Enter boot-loader mode on the Arduino Nano 33 IoT (double click on the IoT33 reset button should accomplish this) and verify the port number in the IDE

c. Open a Terminal window (cmd in Windows) and run the modified command line to load the new .bin file into the 33 IoT

Detail:

A. (Using an editor, if you prefer) Copy the line from the Arduino IDE and replace the name and location of the Blink.bin file with that of the new .bin file you want to load.

Modify the full path name you found to be that of the desired .bin file you want to upload. As an example, the original line produced was:

Example Linux:

/home/ge/.arduino15/packages/arduino/tools/bossac/1.7.0-arduino3/bossac -i -d --port=ttyACM0 -U true -i -e -w -v /tmp/arduino_build_442293/Blink.ino.bin -R

and the modified file became

/home/ge/.arduino15/packages/arduino/tools/bossac/1.7.0-arduino3/bossac -i -d --port=ttyACM0 -U true -i -e -w -v /home/ge/Desktop/TR02.1e.ino.bin -R

B. To get the 33 IoT into boot-loader mode and check that the port in the command line matches the port where the operating system sees the IoT33:

- Disconnect the IoT USB cable.

- Close the Arduino IDE.

- Reconnect the IoT USB cable.

- Enter boot-loader mode on the 33 IoT by pressing the white button (RST-reset) on it twice in close succession. This stops the Blink program that was executing and causes the LED to slowly fade in and out, indicating that the 33 IoT is ready to receive a new .bin file.

Verify that the Port number the system associates with the 33 IoT in boot-loader mode matches the port number in the modified command line. Some OSes may have assigned a NEW port number. In Windows especially, use Device Manager to be certain the indicated COM port is the same as that in the command line.


In Linux “ls -rtl /dev/tty*” should list the Ports with the last one likely to be the IoT33. On a Mac “ls  /dev/tty.*. “ may do the same thing.

The first output after execution might look like:


Important: On a Windows or Mac OS, there may have been quotation marks around the executable, which in this case was 'bossac'. When executed in a Mac Terminal app THESE NEED TO BE REMOVED !

C. The modified command line is then run from a terminal window, called a ‘Command Line’ in Windows, to upload TR02.1e.ino.bin, in the previous examples.

Once the new uploaded code is running if that Arduino code happens to use the Serial class to communicate, it should be possible to interact with it, either by restarting the Arduino IDE and using it for a serial port or by connecting to it using some other terminal emulator such as puTTy. This will probably require connecting to the Port number discovered above and perhaps also setting the baud to whatever the .ino sketch expected, though for USB <==> interface this may not be necessary because port speed has little meaning. This connection can be done with the IDE again but other tools can work also.

Note that once the Arduino IDE and all its tools are present on a system, then it is actually not required to ever run the IDE again since all the steps required can be done with a Terminal (command line) to execute any new .bin upload and any Serial/USB communication could be done with a different tool, puTTy for example instead of the IDE using its Serial Monitor.