avr109 bootloader fails half way with avrdude

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

Hello,

I am using version 0.85 bootloader installed on an AVRMega32 from here: http://www.siwawi.arubi.uni-kl.de/avr_projects/#bf_boot set to 19200 baud. It works fine with Avrprog.exe under wine on the same machine, same port and cables. I would like to be able to use it with avrdude. I am having the following troube:

With the command (avrdude ver 5.11)

./avrdude -C avrdude.conf -p m32 -P /dev/ttyS1 -c avr109 -v -U flash:w:indicator-19.hex:i -U eeprom:w:eemem19.hex:i

It fails writing the flash at 46% The bootloder gets overwritten too, I have to re-install it with the ISP to get going again. I looked for an avrdude switch for avr109 that I might need, but found nothing. Other suggestions?

I did try a slower baud rate (9600) and it fails at the same %, just takes twice as long.

I'd be open to another command line linux avr109 compatible programmer if someone knows one.

Output:

avrdude: Version 5.11svn, compiled on Sep 16 2012 at 17:23:02
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

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

         Using Port                    : /dev/ttyS1
         Using Programmer              : avr109
         AVR Part                      : ATMEGA32
         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         4    10    64    0 no       1024    4      0  9000  9000 0xff 0xff
           flash         33     6    64    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  2000  2000 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  2000  2000 0x00 0x00
           lock           0     0     0    0 no          1    0      0  2000  2000 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00
           calibration    0     0     0    0 no          4    0      0     0     0 0x00 0x00

         Programmer Type : butterfly
         Description     : Atmel AppNote AVR109 Boot Loader

Connecting to programmer: .
Found programmer: Id = "AVRBOOT"; type = S
    Software Version = 0.8; 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: 0x73

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

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

avrdude: Device signature = 0x1e9502
avrdude: safemode: Fuse reading not support by programmer.
              Safemode disabled.
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 "indicator-19.hex"
avrdude: writing flash (23480 bytes):

Writing | #######################                            | 46% 9.77savrdude: butterfly_recv(): programmer is not responding
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I do not use the 109 protocol but it seems to me if your bootloader is being overwritten that the fuses are not set correctly.

Have you checked the BOOTxxx fuse settings? the calculator below is helpful
http://www.engbedded.com/fusecalc/

regards
Greg

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

Thanks for the quick reply. I double checked the fuse bits, and they are correct for bootloader reset and 1024 size.

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

More clues: I tried a much smaller program (1260 bytes) and avrdude avr109 programs the flash all the way, then programs the eemem ok too. The flash is wrong though, doesn't function, and doesn't verify correctly with AVRprog.exe. The eemem is correct, and verifies with AVRprog.

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

Quote:

The bootloder gets overwritten too,

Can you post the indicator-19.hex file or are the contents secret? I have an Intel Hex editor I'd like to use to look at it with which would show if there's any part of it that would deliver code to overlay the bootloader section.

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

I'll upload the hex file here soon, I'm not seeing an attach, bit I may be blind.
Keep im mind that it does load and function using Avrprog.exe, but not avrdude, so I suspect it is not the problem. It loads with avrosp, but does not verify. avrosp reports that

Quote:
"Writing Flash block failed! "
"Programmer did not return CR after 'BxxF'-command."

but it (avrosp) goes on to use block mode.

I am suspecting that the bootloader has a problem and avrprog.exe falls back to a byte (?) mode. I think I need to try another bootloader on the AVR.

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

From memory, avrdude sends "generic" AVR109 commands for reading fuses etc.

Bootloaders tend to implement a castrated version of any particular protocol. However, I would guess that it would work ok with the Butterfly bootloader.

I would tend to go for a stk500v1 or stk500v2 protocol. What size do you want your bootloader to be?

David.

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

Quote:
Bootloaders tend to implement a castrated version of any particular protocol.

I'm seeing that in my reading. No sense in adding anything you don't need, so bootloaders are sort of paired with the PC side software for which they were written.

Yes, so a stk500 bootloader that works with avrdude, and can be configured for a m32, uses a pin to gnd as a start condition, and fits in 1024 bytes would be my next try.

--Karl

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

Quote:

uses a pin to gnd as a start condition,

I wouldn't tie that down as part of your search. Such trivial details are easy to implement once you have a generic bootloading code.

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

Got stk500v2 bootloader working. So basically probem worked-around. I'm still a little mystified as the avr109 bootloader was reproted working in this thread: https://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&p=883333 and I can't get it to work. --Karl

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

Well, I just had to know. In case somebody is curious, I got the avr109 bootloader going by making some changes in avrdude. In butterfly.c, the function butterfly_paged_write was sending an address set command after each page loaded. OK for the eemem, but not flash. I changed it to set it only once to 0 at the start.

if ((!(addr>0))||(!strcmp(m->desc, "eeprom")) )   // for first address, or for eemem only
		{butterfly_set_addr(pgm, addr);}

Similar for butterfly_paged_load, for both eemem and flash.

if (!(addr>0))
		{butterfly_set_addr(pgm, addr);}

--Karl

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

I would have changed the bootloader instead of avrdude !

Then your device would work with anyone's PC or any new avrdude release.

If you would prefer avr109 to stk500 protocol, shout. Your bootloader should be easy enough to fix. (unless you have got a 512 byte bootloader)

David.

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

Quote:
I would have changed the bootloader instead of avrdude !
Yeh, that would make sense wouldn't it... :lol: Actually, I have a whole bunch of these boards with qfp mega 32's on them and no ISP, AND the reset is connected to V+ (here is why not to do this). At first I thought I could get the bootloader that was programmed to overwrite itself with the stk500 bootloader, but it will allow, but won't run. So this exercise was a way to save these boards. Plus I got a good lesson into the inner workings of bootloaders and Avrdude. There is no such thing as useless knowledge. --Karl

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

Hey, look what I found :D

Quote:
bug #38952: AVR109 (butterfly) auto-increment functionnality is ignored

https://savannah.nongnu.org/bugs/?38952
--Karl