Using my raspberry pi 4 with Arduino IDE to upload sketches to my Arduino Uno. Raspberry Pi 4 is encased in an Argon Neo (in case that's important).
At first I tried to get the board info and received the response, "Native Serial Port, can't obtain info". I then tried uploading the Blink example sketch to Arduino and received a generic "upload failed" error. I switched usb and tried again but received the same error. I also switched ports and received the same error (/dev/ttyAMA0 & /dev/ttyS0). I did some searching online and enabled verbose output. The error output roughly says that it cannot locate the configuration file.
I am a complete newbie to raspberry pi but I have experience with using terminal. The point is that I want to use this to learn more about raspberry pi and not just get an answer. Will post error output later once I get to my pi-4.
Edit 1: Error output added and port names
User configuration file is "/home/pi/.avrduderc"
User configuration file does not exist or is not a regular file, skipping
Edit 2: Fixed port names
Arduino output after trying sudo usermod -aG dialout pi
System wide configuration file is "/opt/arduino-1.8.13/hardware/tools/avr/etc/avrdude.conf"
User configuration file is "/home/pi/.avrduderc"
User configuration file does not exist or is not a regular file, skipping
Using Port : /dev/ttyAMA0
Using Programmer : arduino
Overriding Baud Rate : 115200
dmesg
output (wasn't sure how back to copy, but i saved the whole dmesg log in a separate file.
[ 19.914478] Voltage normalised (0x00000000)
[ 38.634664] Under-voltage detected! (0x00050005)
[ 65.674553] Voltage normalised (0x00000000)
[ 69.834601] Under-voltage detected! (0x00050005)
[ 82.321811] Voltage normalised (0x00000000)
[ 338.116949] rpi_firmware_get_throttled: 2 callbacks suppressed
[ 338.116958] Under-voltage detected! (0x00050005)
[ 342.278510] rpi_firmware_get_throttled: 2 callbacks suppressed
[ 342.278517] Voltage normalised (0x00000000)
[ 350.601983] Under-voltage detected! (0x00050005)
[ 354.763011] Voltage normalised (0x00000000)
[ 369.326954] Under-voltage detected! (0x00050005)
[ 373.487373] Voltage normalised (0x00000000)
[ 679.259193] rpi_firmware_get_throttled: 10 callbacks suppressed
[ 679.259201] Under-voltage detected! (0x00050005)
[ 687.580258] rpi_firmware_get_throttled: 10 callbacks suppressed
[ 687.580261] Voltage normalised (0x00000000)
[ 714.622795] Under-voltage detected! (0x00050005)
[ 720.862650] Voltage normalised (0x00000000)
[ 737.503185] Under-voltage detected! (0x00050005)
[ 741.662884] Voltage normalised (0x00000000)
[ 976.004220] usb 1-1.3: new full-speed USB device number 3 using xhci_hcd
[ 976.149437] usb 1-1.3: New USB device found, idVendor=2341, idProduct=0043, bcdDevice= 0.01
[ 976.149462] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=220
[ 976.149481] usb 1-1.3: Manufacturer: Arduino (www.arduino.cc)
[ 976.149499] usb 1-1.3: SerialNumber: 954373133353516141A2
[ 976.219972] cdc_acm 1-1.3:1.0: ttyACM0: USB ACM device
[ 976.223204] usbcore: registered new interface driver cdc_acm
[ 976.223223] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
Tried updating Raspberry Pi 4, just in case, output from Arduino IDE with some more lines
Linking everything together...
/opt/arduino-1.8.13/hardware/tools/avr/bin/avr-gcc -w -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=atmega328p -o /tmp/arduino_build_445772/Blink.ino.elf /tmp/arduino_build_445772/sketch/Blink.ino.cpp.o /tmp/arduino_build_445772/../arduino_cache_161333/core/core_arduino_avr_uno_cfd507e26af5a1235d5f5c8586d9a1e3.a -L/tmp/arduino_build_445772 -lm
/opt/arduino-1.8.13/hardware/tools/avr/bin/avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 /tmp/arduino_build_445772/Blink.ino.elf /tmp/arduino_build_445772/Blink.ino.eep
/opt/arduino-1.8.13/hardware/tools/avr/bin/avr-objcopy -O ihex -R .eeprom /tmp/arduino_build_445772/Blink.ino.elf /tmp/arduino_build_445772/Blink.ino.hex
/opt/arduino-1.8.13/hardware/tools/avr/bin/avr-size -A /tmp/arduino_build_445772/Blink.ino.elf
Sketch uses 924 bytes (2%) of program storage space. Maximum is 32256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
An error occurred while uploading the sketch
/opt/arduino-1.8.13/hardware/tools/avr/bin/avrdude -C/opt/arduino-1.8.13/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -carduino -P/dev/ttyAMA0 -b115200 -D -Uflash:w:/tmp/arduino_build_445772/Blink.ino.hex:i
avrdude: Version 6.3-20190619
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "/opt/arduino-1.8.13/hardware/tools/avr/etc/avrdude.conf"
User configuration file is "/home/pi/.avrduderc"
User configuration file does not exist or is not a regular file, skipping
Using Port : /dev/ttyAMA0
Using Programmer : arduino
Overriding Baud Rate : 115200
SOLUTION: Raspberry Pi 4 was not receiving sufficient voltage and therefore the Arduino USB connection was not stable. Once raspberry pi 4 was connected directly to wall power the issue was resolved and sketches were succesfully uploaded.
Thank you all for your answers and comments
-
Are you sure you got the port names correct? The two you mention for example don't end with the capital letter o, but with a zeroDirk– Dirk2021年09月07日 16:33:37 +00:00Commented Sep 7, 2021 at 16:33
-
Pardon me, I am not sure what they end with. Are you saying they should end with zeros?AppliedPhysicist– AppliedPhysicist2021年09月07日 16:37:21 +00:00Commented Sep 7, 2021 at 16:37
-
just checked via the Terminal, those ports should end in zeros but on the Arduino IDE they look like capital o's.AppliedPhysicist– AppliedPhysicist2021年09月07日 17:02:36 +00:00Commented Sep 7, 2021 at 17:02
-
You have failed to explain what YOU did or how connected. Try the Arduino site.Milliways– Milliways2021年09月07日 22:40:14 +00:00Commented Sep 7, 2021 at 22:40
-
1Does this answer your question? Just installed Arduino IDE 1.8.4 and want to program Arduino via a USB portMilliways– Milliways2021年09月08日 23:53:33 +00:00Commented Sep 8, 2021 at 23:53
2 Answers 2
Start by finding out which device file you really need. This can be done by observing which file appears/disappears as you connect/disconnect the Arduino, or by inspecting kernel messages with dmesg
immediately after the Arduino was connected.
Lines you have posted are not error messages. Go to File-> Preferences in Arduino IDE and check the corresponding options:
Show verbose output during: ☑ compilation ☑ upload
-
1I don't understand what you mean by observing which file appears/disappears. I apologize, I'm not trying to be difficult. The sketch output I have pasted is all the red text after attempting sketch upload with the verbose output options checked.AppliedPhysicist– AppliedPhysicist2021年09月08日 18:20:42 +00:00Commented Sep 8, 2021 at 18:20
-
@Pierre (1) open Arduino IDE, check the available serial ports, (2) plug in the Arduino board, (3) check the available serial ports again and compare with step 1. The added device file is the one you need.Dmitry Grigoryev– Dmitry Grigoryev2021年09月09日 06:57:11 +00:00Commented Sep 9, 2021 at 6:57
-
@Pierre Looking at the
dmesg
log you posted, your device is/dev/ttyACM0
. And the problems you are having are probably due to a poor power supply: those undervoltage events can easily lead to Arduino board getting sporadically disconnected (not physically of course, just USB communication is interrupted), that's why/dev/ttyACM0
is not even getting listed in Arduino IDE.Dmitry Grigoryev– Dmitry Grigoryev2021年09月09日 07:03:10 +00:00Commented Sep 9, 2021 at 7:03 -
1that was indeed the issue. I used a direct power cable to power the raspberry pi 4 from the outlet. Once I did that I was able to see
/dev/ttyACM0
from both the terminal and Arduino IDE. Thank you for your help.AppliedPhysicist– AppliedPhysicist2021年09月10日 00:29:57 +00:00Commented Sep 10, 2021 at 0:29
You probably don't have write access to the port.
Run sudo usermod -aG dialout pi
in the terminal, log out and in again, and then switch to /dev/ttyAMA0
(the /dev/ttyS0
port is for serial, not USB).
The config warning is expected behavior if you haven't made that config file.
-
I'll try this and let you know what happens.I'm assuming usermod is a command to change permissions? What does the -aG flag do? Why are you calling it to dial out pi?AppliedPhysicist– AppliedPhysicist2021年09月07日 22:12:18 +00:00Commented Sep 7, 2021 at 22:12
-
dial out is a standard group that allows access to serial ports. you can run "man usermod" to get a full explination of what those arguments do,as well as what usermod is used for. running "man COMMANDNAME" is the way of pulling up the MANual of the command.Chad G– Chad G2021年09月07日 23:58:12 +00:00Commented Sep 7, 2021 at 23:58
-
The
pi
user is included in this group by default, as well as other useful groups such assudo
orgpio
.Dmitry Grigoryev– Dmitry Grigoryev2021年09月10日 08:15:29 +00:00Commented Sep 10, 2021 at 8:15