Arduino AVRDude -D option

Hello,

trying to program an ATtiny2313 with a metaboard-programmer (arduino clone) and the Arduino-IDE runnig avr-developers special core, I have a problem with the -D option in AVRDude, that is the default (disable chip erase). A naked chip is programmed with no problems, but the second try ends up in a verify-error. I had to do a chip erase "manually" (-e) and it worked.

Is there a method to overwrite the -D option from the Arduino-IDE? I dind´t find it in the AVRDudeconfig or Arduino-Preference.

Thanks for Help
Themroc

I have a problem with the -D option in AVRDude, that is the default (disable chip erase)

Disable chip erase is the default? Doesn't seem to be for my version (5.10). Which version are you using?

I meant the Arduino-IDE calling AVRDude default. I´m using 022. AVR-Dude is ok:)

The command line when I upload an empty Sketch...

C:\arduino-0022\hardware/tools/avr/bin/avrdude -CC:\arduino-0022\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328p -cavrispv2 -P\\.\COM8 -Uflash:w:C:\Users\CODEB~1.001\AppData\Local\Temp\build1468340934531411719.tmp\sketch_mar22b.cpp.hex:i

Broken into separate lines...

C:\arduino-0022\hardware/tools/avr/bin/avrdude 
-CC:\arduino-0022\hardware/tools/avr/etc/avrdude.conf 
-v -v -v -v 
-patmega328p 
-cavrispv2 
-P\\.\COM8 
-Uflash:w:C:\Users\CODEB~1.001\AppData\Local\Temp\build1468340934531411719.tmp\sketch_mar22b.cpp.hex:i

There is no dash-D. I suspect the problem is something else.

Oh sorry my version contains the -D option and I can´t get it away:)

D:\arduino-0022\hardware/tools/avr/bin/avrdude
-CD:\arduino-0022\hardware/tools/avr/etc/avrdude.conf -v -v -v -v
-pattiny2313
-cusbasp
-P\.\COM12
-b19200
-D
-Uflash:w:C:\DOKUME~1\Me\LOKALE~1\Temp\build1303
597068202028020.tmp\BlinkWithoutDelay.cpp.hex:i

thanks themroc

I tested it with the same command ommitting the -D and it worked. But it´s boring to copy the command from the Arduino-IDE and deleting -D.

Any idea, how to set (or to find) the right preference file?

T

Do you have an "upload.using" entry in "boards.txt" for the ATtiny2313 section? It should be something like this...

myboardname.upload.using=myprogrammer

NO I didn´t, but the other boards don´t have this option. I only specified the upload.protocol=usbasp. The Problem is, that the upload works once. It is definitly the -D option. Iwrote a batchfile to erase the chip before.

Regards
T

Ok Iwould like to know what this using does.

When a section in "boards.txt" does not have an "upload.using" entry, the Arduino IDE performs a "bootloader upload". For you, that means the dash-D option is added when AVRDUDE is run.

When you want to upload using an ICSP (in your case the "metaboard-programmer") you have to either add an entry to "programmers.txt" or select a close match. As far as I can tell, this is what you should add "programmers.txt"...

metaboard.name=USBasp
metaboard.protocol=usbasp

You then need to update "boards.txt" so that uploading to your board is performed through the "metaboard" programmer. Something like this should work...

attiny2313at8.name=ATtiny2313 @ 8 MHz
attiny2313at8.upload.using=metaboard
attiny2313at8.upload.maximum_size=2048
attiny2313at8.bootloader.low_fuses=0xE4
attiny2313at8.bootloader.high_fuses=0x9F
attiny2313at8.bootloader.extended_fuses=0xFF
attiny2313at8.bootloader.path=empty
attiny2313at8.bootloader.file=empty2313at8.hex
attiny2313at8.bootloader.unlock_bits=0x3F
attiny2313at8.bootloader.lock_bits=0x3F
attiny2313at8.build.mcu=attiny2313
attiny2313at8.build.f_cpu=8000000L
attiny2313at8.build.core=CoreSubdirectoryGoesHere

Thanks for explanation. I ´will try this. Did you work with the special cores from AVR-developers? With the attiny2313 I got it working, but not with an Atmega48 or 8. Uploading the bootloader works with the Atmega8, sketches are uploaded correctly, but don´t work.

T

Did you work with the special cores from AVR-developers?

No, I haven't.

Thanks a lot coding badly. With your "using" modification it worked fine. The terrible -D option disappeared. :slight_smile:

I used the following code:

programmers.txt
usbasp.name=USBasp
usbasp.communication=usb
usbasp.protocol=usbasp

boards.txt
...
atmega8.name=Arduino ATmega8
atmega8.upload.using=usbasp
atmega8.upload.protocol=usbasp #maybe this is double?
...

The avr-developers files support many of the other avrs, so that you can programm it with the Arduino IDE. Although the blink-sketch uses nearly half the flash of a Tiny2313:( Unfortunately Atmega48 doesn´t work. Maybe it is the fuses-section.

T

For the ATtiny2313, give this core a try...
http://code.google.com/p/arduino-tiny/

Oh thanks. Does this core generate an optimized version for the tinys (to fit in the small flashes). The documentation in the boards.txt is really good (especially the fuse-settings). What about the "empty" bootloader specification? Is this only to set the right fuses, not to upload a bootloader?

T

themroc:
Does this core generate an optimized version for the tinys (to fit in the small flashes).

That's the goal.

The documentation in the boards.txt is really good (especially the fuse-settings).

Thanks!

What about the "empty" bootloader specification? Is this only to set the right fuses, not to upload a bootloader?

Exactly. The "empty" bootloaders serve two purposes: a convenient way to change the fuses from the Arduion IDE; clear out the current Sketch so the hardware can be safely changed.

Fine, you are the programmer? Your core is really better the code is smaller. Now I unaderstand a bit more AVR-language.

Thanks.
T

Fine, you are the programmer?

Yup. Other folks are certainly welcome to participate!

Your core is really better the code is smaller.

Excellent! For the ATtiny85 processor, the next update will be even better. My programs have been 3.5% to 5% smaller with it. In addition, for the digital functions, if the parameters are compile-time constants, they reduce to single machine instruction. The code is a variation of the digital*Fast functions.

There are some options in the "core_build_options.h" that can be used to shave a tiny bit off the program size.

For the ATtiny2313, if you're doing write-only serial, using Tiny Debug Serial instead of HardwareSerial reduces the program size.

Now I unaderstand a bit more AVR-language.

Glad to hear it!