flaky avrdude operation with arduino micro on linux

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have an atmega32u4.  When programming with avrdude

1) I need to hit the reset button on the board before /dev/ttyACM0 becomes available, and then set the baud rate to 9600 before running avrdude.  I think this is normal.

2) The run of avrdude is a bit flaky.  It may take three tries to get my code written.  But the read-back for verify never works.  

 

Does anyone have better experience with this setup (arduino micro, linux, avrdude)?

 

Here is the script to run avrdude.   The while loop is waiting for me to push the reset button on the board.

#!/bin/sh

dev=/dev/ttyACM0
while [ ! -c $dev ]; do
  echo -n "."
  sleep 1
done
echo ""

stty -F /dev/ttyACM0 1200

memop="-U flash:w:main.hex"
memop="-U lock:r:lock.out"
#memop=""

avrdude -v -p m32u4 -c avr109 -P /dev/ttyACM0 -b 115200 -v -U flash:w:main.hex -V

 

Here is the output of a "sucessful run".  I hit Ctrl-C to kill it when stuck in the read.

 

avrdude -v -p m32u4 -c avr109 -P /dev/ttyACM0 b -b 115200 -U flash:w:main.hex -V

avrdude: Version 6.3
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

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

         Using Port                    : /dev/ttyACM0
         Using Programmer              : avr109
         Overriding Baud Rate          : 115200
         AVR Part                      : ATmega32U4
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PA0
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

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

         Programmer Type : butterfly
         Description     : Atmel AppNote AVR109 Boot Loader

Connecting to programmer: .
Found programmer: Id = "CATERIN"; type = S
    Software Version = 1.0; No Hardware Version given.
Programmer supports auto addr increment.
Programmer supports buffered memory access with buffersize=128 bytes.

Programmer supports the following devices:
    Device code: 0x44

avrdude: devcode selected: 0x44
avrdude: AVR device initialized and ready to accept instructions

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

avrdude: Device signature = 0x1e9587 (probably m32u4)
avrdude: safemode: hfuse reads as D8
avrdude: safemode: efuse reads as CB
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: reading input file "main.hex"
avrdude: input file main.hex auto detected as Intel Hex
avrdude: writing flash (848 bytes):

Writing | ################################################## | 100% 0.07s

avrdude: 848 bytes of flash written
avrdude: verifying flash memory against main.hex:
avrdude: load data flash data from input file main.hex:
avrdude: input file main.hex auto detected as Intel Hex
avrdude: input file main.hex contains 848 bytes
avrdude: reading on-chip flash data:

Reading |                                                    | 0% 0.00savrdude: butterfly_recv(): programmer is not responding
Reading | #######                                            | 14% 5.00savrdude: butterfly_recv(): programmer is not responding
Reading | #####################                              | 42% 10.00savrdude: butterfly_recv(): programmer is not responding
Reading | #############################                      | 57% 15.01s  ^C

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

MattRW wrote:

avrdude -v -p m32u4 -c avr109 -P /dev/ttyACM0 b -b 115200 -U flash:w:main.hex -V

 

You have: "flaky avrdude operation with arduino micro on linux"

Does the chip have the arduino bootloader?

If so, instead of "-c avr109" try using "-c arduino"

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I had tried arduino and it did not work.   Searching the interweb gave me the avr109 hint.

 

avrdude -v -p m32u4 -c arduino -P /dev/ttyACM0 b -b 115200 -U flash:w:main.hex -V

avrdude: Version 6.3
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "/etc/avrdude.conf"
         User configuration file is "/home/mwette/.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
ioctl("TIOCMSET"): Broken pipe
ioctl("TIOCMSET"): Broken pipe
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x3f
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x3f
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x3f
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x3f
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x3f
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x3f
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x3f
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x3f
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x3f
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x3f

avrdude done.  Thank you.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You are using an ATmega32U4 e.g. like Arduino Leonardo, Micro.

 

I suggest that you install Arduino Bootloader.   Run Arduino sketches.

Then observe the Avrdude commands by enabling "Verbose upload" in File->Preferences.

 

Copy the same sequence in your shell-script.

It involves changing the Baud-Rate to 1200.

 

-c arduino is for different Bootloader e.g. Optiboot

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm down another rabbit hole.  I've hooked up a pololu 1300 and have avrdude hooked up.   I'm gonna start digging in.

I am able to talk to the board via the popolu and "avrdude -t" to read memory.   Here goes ...

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Start with a tried and trusted solution.  e.g. Arduino Leonardo/Micro

 

You can always experiment with square wheels after you have verified that round ones work.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:

Start with a tried and trusted solution.  e.g. Arduino Leonardo/Micro

 

You can always experiment with square wheels after you have verified that round ones work.

 

David.

 

I appreciate your point.  I just wanted to avoid downloading bloatware.  If I don't make progress here, I guess that is my next step.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 2

I would not categorise Arduino IDE as bloatware.   It looks like 704MB folder in my Win10-64 Program Files.

Rowley ARM Crossworks is 972MB folder

Atmel Studio is 3440MB folder

 

In today's world anything is 100s of MB

 

I would just install Arduino.   You have enough disk space.   It will run the same on Linux, Windoze or Mac.

You already have Java.

It is useful to have.   Especially for a job like "how does Caterina bootloader get used?"

 

David.