Upload Arduino sketch from Raspberrypi to RPICT: Difference between revisions
Line 4: | Line 4: | ||
==Prerequisite== | ==Prerequisite== | ||
'''DO NOT USE THIS''' | '''DO NOT USE THIS''' if you have just acquired a RPICT card and trying to get it worked for the first time. This will make things worse for you to troubleshoot.<br> | ||
If you have landed here after a first purchase you are on the wrong path. Take a good read at the links below first.<br> | If you have landed here after a first purchase you are on the wrong path. Take a good read at the links below first.<br> | ||
[[Raspberrypi_Current_and_Temperature_Sensor_Adaptor#First_time_use]]<br> | [[Raspberrypi_Current_and_Temperature_Sensor_Adaptor#First_time_use]]<br> |
Revision as of 12:37, 18 March 2023
This article will guide you to upload an Arduino sketch from the raspberrypi directly to the RPICT units.
Prerequisite
DO NOT USE THIS if you have just acquired a RPICT card and trying to get it worked for the first time. This will make things worse for you to troubleshoot.
If you have landed here after a first purchase you are on the wrong path. Take a good read at the links below first.
Raspberrypi_Current_and_Temperature_Sensor_Adaptor#First_time_use
Howto setup Raspbian for serial read
This only works with RPICT units having an atmega328p chip and with autoreset support. Commonly any units being RPICT version 5 and 4.
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. If you have acquired the card in or after 2022 this is most probably already enabled.
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
You will also see a bunch of these lines below which you should ignore. They have no negative impact on the process.
strace: |autoreset: Broken pipe
A failing flash will show this type of message below.
avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00 avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00 avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00 avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00 avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00
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.