3

I have already spent a couple of days by trying to upload a sketch onto my Arduino Uno R3 board and now it's time to give up, so I'm trying to ask some more experienced developers.

My hardware and software configuration is:

  • FreeBSD-14.0-RELEASE
  • Arduino Uno R3 with Atmega16u2 USB-to-Serial chip
  • avrdude 7.2

The sketch is just empty and compiles without any problem:

#include <Arduino.h>
void setup() {}
void loop() {}

My kldstat output is:

aperechnev@home-pc:~/Projects/stepper-test $ kldstat 
Id Refs Address                Size Name
 1   45 0xffffffff80200000  1d34598 kernel
 2    1 0xffffffff81f35000     7718 cryptodev.ko
 3    1 0xffffffff81f3d000     4370 uarduno.ko
 4    2 0xffffffff81f42000     a088 ucom.ko
 5    1 0xffffffff81f4e000   5d51c8 zfs.ko
 6    1 0xffffffff82524000   daa430 nvidia.ko
 7    3 0xffffffff832cf000    1e6a8 linux_common.ko
 8    2 0xffffffff832ee000    6a068 linux.ko
 9    1 0xffffffff83c20000     3250 ichsmb.ko
10    1 0xffffffff83c24000     2178 smbus.ko
11    1 0xffffffff83c27000     2a68 mac_ntpd.ko
12    1 0xffffffff83c2a000    12e08 fusefs.ko
13    1 0xffffffff83c3d000     4d64 geom_uzip.ko

The short description of the problem is avrdude: ser_recv(): programmer is not responding.

Now I'm revealing the detailed description.

I'm uploading my sketch with the following command:

avrdude -v -v -v -v -p atmega328p -c arduino -b 115200 -P /dev/cuaU0 -U flash:w:/home/aperechnev/Projects/stepper-test/firmware.hex:i

And I receive the next output:

avrdude: Version 7.2
         Copyright the AVRDUDE authors;
         see https://github.com/avrdudes/avrdude/blob/main/AUTHORS

         System wide configuration file is /usr/local/etc/avrdude.conf
         User configuration file is /home/aperechnev/.avrduderc
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/cuaU0
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
avrdude: send: 0 [30]   [20] 
avrdude: send: 0 [30]   [20] 
avrdude: send: 0 [30]   [20] 
avrdude: recv: . [14] 
avrdude: recv: . [10] 
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : possible i/o
         RETRY pulse                   : SCK
         Serial program mode           : yes
         Parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                           Block Poll               Page                       Polled
           Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom                 65    20     4    0 no       1024    4      0  3600  3600 0x00 0x00
                                           Block Poll               Page                       Polled
           Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           flash                  65    10   128    0 yes     32768  128    256  4500  4500 0x00 0x00
                                           Block Poll               Page                       Polled
           Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           lfuse                   0     0     0    0 no          1    1      0  4500  4500 0x00 0x00
                                           Block Poll               Page                       Polled
           Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           hfuse                   0     0     0    0 no          1    1      0  4500  4500 0x00 0x00
                                           Block Poll               Page                       Polled
           Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           efuse                   0     0     0    0 no          1    1      0  4500  4500 0x00 0x00
                                           Block Poll               Page                       Polled
           Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           lock                    0     0     0    0 no          1    1      0  4500  4500 0x00 0x00
                                           Block Poll               Page                       Polled
           Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           signature               0     0     0    0 no          3    1      0     0     0 0x00 0x00
                                           Block Poll               Page                       Polled
           Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           calibration             0     0     0    0 no          1    1      0     0     0 0x00 0x00

         Programmer Type : Arduino
         Description     : Arduino for bootloader using STK500 v1 protocol
avrdude: send: A [41] . [80]   [20] 
avrdude: recv: . [14] 
avrdude: recv: . [03] 
avrdude: recv: . [10] 
avrdude: send: A [41] . [81]   [20] 
avrdude: recv: . [14] 
avrdude: recv: . [04] 
avrdude: recv: . [10] 
avrdude: send: A [41] . [82]   [20] 
avrdude: recv: . [14] 
avrdude: recv: . [04] 
avrdude: recv: . [10] 
avrdude: send: A [41] . [98]   [20] 
avrdude: recv: . [14] 
avrdude: recv: . [03] 
avrdude: recv: . [10] 
         Hardware Version: 3
         Firmware Version: 4.4
avrdude: send: A [41] . [81]   [20] 
avrdude: recv: . [14] 
avrdude: recv: . [04] 
avrdude: recv: . [10] 
avrdude: send: A [41] . [82]   [20] 
avrdude: recv: . [14] 
avrdude: recv: . [04] 
avrdude: recv: . [10] 
avrdude: send: B [42] . [86] . [00] . [00] . [01] . [01] . [01] . [01] . [03] . [00] . [00] . [00] . [00] . [00] . [80] . [04] . [00] . [00] . [00] . [80] . [00]   [20] 
avrdude: recv: . [14] 
avrdude: recv: . [10] 
avrdude: send: E [45] . [05] . [04] . [d7] . [c2] . [01]   [20] 
avrdude: recv: . [14] 
avrdude: recv: . [10] 
avrdude: send: P [50]   [20] 
avrdude: recv: . [14] 
avrdude: recv: . [10] 
avrdude: AVR device initialized and ready to accept instructions
Reading |                                                    | 0% 0.00 s 
avrdude: send: u [75]   [20] 
avrdude: recv: . [14] . [1e] . [95] . [0f] . [10] 
Reading | ################################################## | 100% 0.00 s 
avrdude: device signature = 0x1e950f (probably m328p)
avrdude: Note: flash memory has been specified, an erase cycle will be performed.
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: send: V [56] . [ac] . [80] . [00] . [00]   [20] 
avrdude: recv: . [14] 
avrdude: recv: . [00] 
avrdude: recv: . [10] 
avrdude: send: A [41] . [81]   [20] 
avrdude: recv: . [14] 
avrdude: recv: . [04] 
avrdude: recv: . [10] 
avrdude: send: A [41] . [82]   [20] 
avrdude: recv: . [14] 
avrdude: recv: . [04] 
avrdude: recv: . [10] 
avrdude: send: B [42] . [86] . [00] . [00] . [01] . [01] . [01] . [01] . [03] . [00] . [00] . [00] . [00] . [00] . [80] . [04] . [00] . [00] . [00] . [80] . [00]   [20] 
avrdude: recv: . [14] 
avrdude: recv: . [10] 
avrdude: send: E [45] . [05] . [04] . [d7] . [c2] . [01]   [20] 
avrdude: recv: . [14] 
avrdude: recv: . [10] 
avrdude: send: P [50]   [20] 
avrdude: recv: . [14] 
avrdude: recv: . [10] 

avrdude: processing -U flash:w:/home/aperechnev/Projects/stepper-test/firmware.hex:i
avrdude: reading input file /home/aperechnev/Projects/stepper-test/firmware.hex for flash
         with 3472 bytes in 1 section within [0, 0xd8f]
         using 28 pages and 112 pad bytes
avrdude: writing 3472 bytes flash ...
Writing |                                                    | 0% 0.00 s 
avrdude: send: U [55] . [c0] . [06]   [20] 
avrdude: recv: . [14] 
avrdude: recv: . [10] 
avrdude: send: t [74] . [00] . [80] F [46]   [20] 
avrdude: recv: . [14] 
avrdude: ser_recv(): programmer is not responding
Writing | -------------------------------------------------- | 0% 5.05 s 
avrdude stk500_recv() [stk500.c:75] error: programmer is not responding

As I can see, avrdude successfully determines my board, reads its configuration and so on. But then it can't read the response from the board right after it starts uploading the sketch.

I looked at the code of the bootloader (Optiboot) and found the lines that are responsible to process the 0x74 request and it seems like the problem is not in the bootloader.

Even more, my Arduino Board is blinking with TX/RX LEDs, as well as with L LED during the start of uploading, at the stage where avrdude reads its configuration.

And one more interesting thing is that some sketches were successfully uploaded when I pressed the RESET button on my Arduino board during the process of uploading. But it happened just for two times. I've read about this trick somewhere on Stackoverflow, but it's really hard to catch the moment when I must press the reset button.

And one more interesting fact is that my sketches upload without any problem from my MacBook Pro driven by MacOS and Arduino IDE 2.x. So I'm sure that the board isn't burned and the bootloader works okay.

And one more important fact is the output of dmesg when I connect my Arduino board to a USB port of my PC:

ugen1.2: <Arduino Uno Arduino Uno> at usbus1
uarduno0 on uhub4
uarduno0: <Arduino Uno> on usbus1

I have no idea what's the problem and I'm kindly asking for any help.

Many thanks, Alexander.

3
  • 1
    Did you check different bootloader protocols, as there are "flavors" of them? If it works with your MacBook, did you look at that command line? (In the Arduino IDE 1 there is an option to enable the upload log.) Commented Apr 4 at 5:30
  • Hi @thebusybee! Thank you for being interested in my problem. Yes, I've just tried another programmer and my sketch was successfully uploaded. So I'll post my own answer to this question. Commented Apr 4 at 11:32
  • Please see if it helps: forum.arduino.cc/t/cannot-upload-sketch-to-arduino-uno/1220498
    – tepalia
    Commented Apr 6 at 10:38

1 Answer 1

2

Finally I resolved the issue. I used arduino programmer as a parameter to avrdude ... -c arduino, but it can't work with the newer Arduino boards. It was written for the boards that use optiboot as a bootloader, but these days Arduino boards are shipped with urboot bootloader. So to be able to upload sketches onto the newer Arduino boards you should use urclock programmer: avrdude ... -c urclock. And since bootloaders can vary in the size of flash memory they fit in, you also need to pass -xbootsize=<N> parameter to avrdude to avoid bootloader override.

So to upload your sketch you should use something like:

avrdude ... -c urclock ... -xbootsize=1024 ...

I'm going to review existing manuals and suggest some additions, so people will be able to save their time working with Arduino on FreeBSD, Linux and other platforms that aren't Windows or MacOS.

2
  • This issue is independent of the OS of the PC. ;-) I'm running Arch-Linux and use the Arduino IDE as well as avrdude directly. One needs to know what options to use, this is the secret. As always. :-D Commented Apr 4 at 13:03
  • 1
    "but these days Arduino boards are shipped with urboot bootloader" To be clear, this is not the case for official AVR based Arduinos or faithful clones of them. The current official 1.8.7 AVR board package doesn't even ship with a new enough version of avrdude to support -c urclock. If someone wants that, it looks like the various MCUdude packages will do -c urclock, MiniCore or MightyCore, etc.
    – timemage
    Commented Apr 4 at 16:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.