Upload Arduino sketch from Raspberrypi to RPICT

From lechacal
Jump to navigation Jump to search

This article will guide you to upload an Arduino sketch from the raspberrypi directly to the RPICT units.

Prerequisite

This only works with RPICT units having an atmega328p chip and with autoreset support.

Suitable units are any RPICT version 5.

This won't work with any RPICT unit version 3.0 and RPICT3V1/RPICT3T1.

The atmega328p chip must have bootloader enabled. If not then the bootloader should be burnt with the NanoProg first.

Installation

First of all install avrdude.

sudo apt-get -y install avrdude

Get the package from our server.

wget lechacal.com/RPICT/tools/lcl-upload-sketch_v2.zip

deflate the file.

unzip lcl-upload-sketch_v2.zip

get inside.

cd lcl-upload-sketch

run the installation script.

sudo ./install.sh

legacy

If you had already installed this tool before the 26th September 2022 you should uninstall and re-install avrdude first before running the above.

sudo apt-get remove avrdude

Then run the installation steps as above from the beginning.

Operation

The firmware to upload is a hex file. Usually with .ino.hex extension. In our wiki you should always find the hex file for the firmware.

Upload the file to the RPICT units using the command below:

lcl-upload-sketch.sh sketch.ino.hex

A successful flash will show three progress bars like shown below.

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: safemode: lfuse reads as 0
avrdude: safemode: hfuse reads as 0
avrdude: safemode: efuse reads as 0
avrdude: reading input file "IDCode/QC_02.ino.hex"
avrdude: input file IDCode/QC_02.ino.hex auto detected as Intel Hex
avrdude: writing flash (6718 bytes):

Writing | ################################################## | 100% 0.96s

avrdude: 6718 bytes of flash written
avrdude: verifying flash memory against IDCode/QC_02.ino.hex:
avrdude: load data flash data from input file IDCode/QC_02.ino.hex:
avrdude: input file IDCode/QC_02.ino.hex auto detected as Intel Hex
avrdude: input file IDCode/QC_02.ino.hex contains 6718 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.71s

avrdude: verifying ...
avrdude: 6718 bytes of flash verified


If you are writing the firmware from an arduino sketch (.ino file)

Open your sketch with the Arduino IDE. (This might be on a separate computer, not necessarily on the Raspberrypi).

Run Sketch | Verify/Compile.

This creates a file in the temporary directory of the Arduino software.
On a linux system this is inside /tmp/arduino_build_xxxxxx.
On windows this could be somewhere like C:\Users\user\AppData\Local\Temp\build4436557367508469592.tmp

If your sketch is named sketch then take the sketch.ino.hex file and copy it over to the raspberrypi.

Credits

Credits go to the SpellFoundry on Github who has well inspired this.