Arduino Forum

Using Arduino => Microcontrollers => Topic started by: cowasaki on Mar 31, 2012, 04:24 pm

Title: Programming using AVRDUDE / unix help
Post by: cowasaki on Mar 31, 2012, 04:24 pm
If I perform the following command:

bin/avrdude -Cbin/avrdude.conf -patmega328p -carduino -P/dev/cu.usbserial-A50066PH -b115200 -Uflash:w:hex/Controller_V092.hex:i

it programs the hex file "Controller_V092.hex" to the chip

BUT

I want to erase the EEPROM storage area at the same time in case the variables have changed.....

I've read AVRDUDE's manual but everything I've tried fails to work.


Also anyone know how I could create a unix batch file to do the following:

list the ".hex" files in the "hex" directory
allow the user to type one of them by name
check the existence of the filename they type
use that filename in the above command


Many thanks....
Title: Re: Programming using AVRDUDE / unix help
Post by: madworm on Mar 31, 2012, 06:37 pm
Code: [Select]

-e      Causes a chip erase to be executed.  This will reset the contents of the flash ROM and EEPROM to the value '0xff',
          and clear all lock bits. [...]


And to be sure that the EEPROM data says sayonara, you must make sure that the 'preserve EEPROM data' fuse is not active.
Title: Re: Programming using AVRDUDE / unix help
Post by: bperrybap on Mar 31, 2012, 07:13 pm
From looking at the command line options you are using, it looks like you are using the arduino bootloader
on the serial port.

While it works good enough to upload application images,
the arduino bootloader does not fully support all the stk500 commands.
(It cheats/lies in some cases)
There are things that simply don't work (and sometimes can't -  like fuses) when using a bootloader
that will work if using an ISP programmer.

I ran into a similar problem when I attempted to use the erase cycle option in avrdude
which tracks erase cycles in EEPROM. Because the bootloader doesn't support EEPROM updates
it can't be used.

While I don't have a board set up at this moment, I'd hope that the -e option fails when using the "arduino"
protocol. But after a quick look at the avrdude source code, it looks like it may silently fail.

--- bill
Title: Re: Programming using AVRDUDE / unix help
Post by: cowasaki on Apr 01, 2012, 01:00 am
Thanks. Sounds about right. I tried -e and anything else. Will just have to do it another way ie write version number to EPROM and on boot if current version number doesn't match call EPROM reset routine :-)
Title: Re: Programming using AVRDUDE / unix help
Post by: cowasaki on Apr 05, 2012, 10:30 pm
Well I created a script that does as much as I can...

http://arduino.cc/forum/index.php/topic,99590.0.html