Uploading sketch to Arduino Uno from Raspberry Pi 4

Hi,

I wonder if anyone can help me. I’ve just got a new Arduino Uno R3 which I’m trying to connect to a Raspberry Pi 4 (Raspbian Buster).

I have the IDE working (1.8.19), however I am unable to upload any sketches (many focusing on Blink). I receive the message ‘An error occurred while uploading the sketch’.

Also, when I click on ‘Tools’> ‘Get Info’ I get ‘Native serial port, can’t obtain info’. I’ve tried some Googling but have been unable to resolve this. My user has dialout rights- Also, when I run dmesg immediately after connecting the Arduino I can see a new device connected an ‘ATMeda16u2 DFU’ which I assume is the Arduino. I can also see it with lsusb.
In the IDE it is configured to use port /dev/ttyAMA0, which is the only option given.

Can anyone give me any pointers?

Thanks,
David.

1 Like

Check to make sure that is the port of your Uno:

  1. Unplug your Arduino board from the computer.
  2. Select Tools > Port from the Arduino IDE menus.
  3. Note the ports, if any, listed in the menu.
  4. Close the Tools menu.
    The ports list is only updated when the Tools menu is re-opened, so this step is essential.
  5. Plug your Arduino board into the computer.
  6. Select Tools > Port from the Arduino IDE menus.

The new port listed in the menu is the one for your Arduino board.

If there was no new port, then the first task will be to figure out how to get the IDE to offer a port selection for the Uno, since this is essential for an upload to be successful.

Wow, that was quick. Thanks very much.
OK, without the Arduino plugged in the only port offered is /dev/ttyAMA0. This does not change when I plug it back in. So, it looks as if the IDE is only offering a default.

I have a vague recollection of setting up the IDE on a Ubuntu system and I think that there's a need to add your userid to a group that permits use of the serial ports.

Thanks wildbill, but I've already tried that.

Please post the lsusb output

Hi ino, sorry for the delay in replying (the day job got in the way) lsusb gives:

Bus 001 Device 003: ID 03eb:2fef Atmel Corp. atmega16u2 DFU bootloader.

I've also tried, unsuccessfully to connect it to a Windows 10 machine. In device manager it appears under 'Other devices' as 'ATMega 16u2 DFU'. When I try and install the drivers I get the message 'Windows could not find drivers for your device'.
The device is an Arduino Uno R3, I believe it is not a clone.

OK, I believe these things both are signs that Arduino forgot to put the firmware on the ATmega16U2 chip that acts as the USB interface between the primary ATmega328P microcontroller of the Uno and your computer.

The ATmega16U2 ships from the IC manufacturer pre-loaded with a Device Firmware Upgrade ("DFU") bootloader that allows firmware to be flashed to it over a USB connection. Arduino's own special firmware which causes the Uno to show up as a serial port is supposed to be added to that chip, but it seems sometimes that step gets skipped somehow and people end up with these boards.

I would guess you are eligible for a replacement Uno, and you could contact the seller of your board if you want to go that route (if bought directly from the Arduino Store, use this form).

However, you also have the option of fixing the problem yourself if you don't want to go throught the whole RMA rigamarole. Fortunately, the DFU bootloader on the ATmega16U2 makes it possible to install the missing firmware without the need for any special hardware or circuitry.

Arduino provides instructions for doing this here:

That tutorial mentions the need to solder a resistor on certain models of Uno boards. But those are very old boards and I can see you have a recent model, so please just ignore that step.

Please let us know if you have any questions or problems.

Thanks in0.
I'll give that a try and post the result.

Hi, I've followed the instructions and the situation is definitely better.
lsusb shows Bus 001 Device 005: ID 2341:0001 Arduino SA Uno (CDC ACM).
On the RPi the IDE (1.8.19) shows the Arduino and board info returns
Capture

But (isn't there always) when I just and upload a sketch (Blink) I get
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00
After 10 attempts it stops. I've looked at the help, and the Arduino does appear to be connected to a serial port.

From the PC it's essentially the same story. The device is found, the board info returned, but it is not possible to upload the sketch.

Have you any ideas?

Best wishes,

David

This shows that you have successfully installed the firmware on the ATmega16U2, so everything is fine with that chip now.

Sometimes there is a situation where we have a stack of problems. In this case, fixing one only gets us to the next problem. That can make it difficult to perceive that any progress is being made, but I do think this is progress.

This is more likely to be related to the primary ATmega328P microcontroller. In order to gather more information that might help us to troubleshoot your problem, I'm going to ask you to post the full output from an upload attempt when in verbose mode.

Please do this:

  1. Select File > Preferences from the Arduino IDE menus.
  2. Uncheck the checkbox next to Show verbose output during: 🗹 compilation
  3. Check the checkbox next to Show verbose output during: ☐ upload.
  4. Click the OK button.
  5. Attempt an upload, as you did before.
  6. After the upload fails, you'll see a button on the right side of the orange bar in the Arduino IDE: Copy error messages. Click that button.
    This copies the full output to the clipboard.
  7. Open a forum reply here by clicking the Reply button.
  8. Click the </> icon on the post composer toolbar.
    This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
    Code block
  9. Press Ctrl+V.
    This will paste the error output from the upload into the code block.
  10. Move the cursor outside of the code tags before you add any additional text to your reply.
  11. Click the Reply button to post the output.

Hi in0,

Thanks for the wise words of encouragement.
Here is the full error message. I notice that each attempt seems to be accompanied by a flash of the RX LED on the Uno.

Thanks for your help, David

Arduino: 1.8.19 (Linux), Board: "Arduino Uno"

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.
/home/pi/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/bin/avrdude -C/home/pi/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf -v -patmega328p -carduino -P/dev/ttyACM0 -b115200 -D -Uflash:w:/tmp/arduino_build_169887/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 "/home/pi/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/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/ttyACM0
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
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
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00

avrdude done.  Thank you.

Problem uploading to board.  See https://support.arduino.cc/hc/en-us/sections/360003198300 for suggestions.


This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Hi, A quick update to give closure to this. It turned out that the Arduino was faulty. The supplier replaced it free of charge. Now I'm ready to move forwards.
Thanks to everyone who helped on this.
Best wishes,
David

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.