Boot loader and avrdude

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

Greetings,
I am hoping to use the Arduino Bootloader (on a ATmega168) but not use the Arduino environment. I am running WinAVR-20080430

I am getting nearly nowhere.

Details of what I am trying to do:
* Arduino docs say they use avrdude. Cool
* I can not find the avrdude command line that the Arduino environment invokes.
* According to http://www.ladyada.net/library/a... "The bootloader is an 'stk500'-compatible, which means you can use good ol' AVRDUDE to program the arduino"

Details of what I have done:
* I can program the chip in the Arduino environment. No Problems.
*

avrdude -p atmega168 -P COM12 -c avrisp    -U flash:w:main.hex
avrdude: ser_open(): can't open device "COM12": The system cannot find the file specified.

Rats, Arduino environment can do it. I thought perhaps they have a newer avrdude than WINavr but going to their directory with .\ before the command above gives the same result.
* Change the FTDI chip to COM1 then I get

avrdude -p atmega168 -P COM1 -c avrisp    -U flash:w:main.hex 
avrdude: stk500_getsync(): not in sync: resp=0x00

* OK I forgot the serial rate

avrdude -p atmega168 -P COM1 -b19200 -c avrisp    -U flash:w:main.hex 
avrdude: stk500_getsync(): not in sync: resp=0x18
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51

the frustrating thing id that it seemed to work once. I got the usual loading messages and no errors. Now I just get the errors above.

Any Ideas??

Thanks
Kirk

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

Hello Kirk,
So why do you want to use the boot loader? (I know nothing about it so i'm curious.)

Why are you telling avrdude to use the avrisp as the programmer? Wouldn't you want to tell it to use the stk500? ie: form http://www.ladyada.net/learn/avr/avrdude.html

Quote:
-c
: Here is where we specify the programmer type, If you're using an STK500 use stk500, if you're using a DT006 programmer use dt006, etc.

just a WAG, after all I am a NOOoo000b!!!!!! :P

link

i am a NOOO00B!!

Don’t let that undermine what I just said.

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

Kirk, I think you will want to use a newer version of avrdude ( >= 5.10). Then you can just use the option -c arduino. IIRC the latest version is 5.11.1.

The arduino hardware connect the reset line to the DTR output of the ft232. The STK500 protocol needs reset immediately before it tries to contact the bootloader. Only newer versions of avrdude support this. On older varsions the arduino IDE sent that reset command before starting avrdude.

It is possible to use older version of avrdude and press the reset button just before starting avrdude. After som practice I hed success in 1 ot of 3 tries. The newer version of avrdude solves this.

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

You can see the command line that Arduino uses by turning on "verbose" mode for the upload (shift-upload in 0022, use the preferences menu in 1.0)
For optiboot it looks like:

Quote:
/Applications/arduino/Arduino-1rc2/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avrdude -C/Applications/arduino/Arduino-1rc2/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328p -carduino -P/dev/tty.usbmodemfd3141 -b115200 -D -Uflash:w:/var/folders/Xw/XwjZcQ842RWmnU+8ZSLT7U+++TI/-Tmp-/build2710441434337606310.tmp/Blink.cpp.hex:i

Or for the older Arduino bootloader:

Quote:
/Applications/arduino/Arduino-1rc2/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avrdude -C/Applications/arduino/Arduino-1rc2/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega168 -carduino -P/dev/tty.usbmodemfd3141 -b19200 -D -Uflash:w:/var/folders/Xw/XwjZcQ842RWmnU+8ZSLT7U+++TI/-Tmp-/build2710441434337606310.tmp/Blink.cpp.hex:i

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

Kirk,

I guess you haven't read Joe Pardue's excellent work on the subject yet?

http://smileymicros.com/blog/201...

Cliff

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

Thanks all for your comments and the suggested reading. At the moment I am so far behind on this particular project I am abandoning the bootloader in favor of attempting to meet schedule. I will dig into your suggestions soon.
KWC

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

itai_n wrote:
Kirk, I think you will want to use a newer version of avrdude ( >= 5.10). Then you can just use the option -c arduino. IIRC the latest version is 5.11.1.

The arduino hardware connect the reset line to the DTR output of the ft232. The STK500 protocol needs reset immediately before it tries to contact the bootloader. Only newer versions of avrdude support this. On older varsions the arduino IDE sent that reset command before starting avrdude.

It is possible to use older version of avrdude and press the reset button just before starting avrdude. After som practice I hed success in 1 ot of 3 tries. The newer version of avrdude solves this.

This is not totally correct.
"reset" is not really a "command".
resetting the arduino board is performed by controlling a hardware signal line to the board.
The DTR signal often used to control this line but RTS can be used as well.

While it is correct that the AVR must be reset to kick
it into the bootloader so that avrdude can talk to it,
and that the latest avrdude has a new "arduino" protocol that has special hooks for arduino-reset,
it is not correct that this is needed to initiate an auto-reset when DTR is used to reset the AVR.

DTR is controlled by the OS *before* avrdude runs.
It drops from high to low whenever the serial port is opened
and raised back to high when the port is closed.
(ok s/w can control it in some OS's but this is normally the default behavior)
Most of the Arduino boards have a capacitor between the DTR signal input and the reset circuitry of the board
so that this falling edge turns into a pulse when
the serial port is opened.
This is what resets the AVR to kick it into the bootloader so that avrdude can start talking to the bootloader.

Some boards and USB to Serial cables use RTS instead.
It is when RTS is used that actually requires a pulse
which must be done in software.
The Arduino IDE toggles RTS before calling avrdude
so that boards/cables that use RTS can still auto-reset
when using the older avrdude that is not arduino aware.

But as long as there is a capacitor inline between the DTR
signal and the AVR reset pin and there is a pullup resistor
on the AVR reset pin.
Auto-reset should work "auto-magically" whenever the serial
port is opened and there is no need to use the newer avrdude and the arduino protocol.

--- bill