Go Down

Topic: -D option during upload (Read 2579 times) previous topic - next topic


Why is there a "-D" option for AVRDUDE during uploads? How do I turn it off? It's causing verification errors and I'm forced to run AVRDUDE in another command line window to do an erase manually (with -e) before each upload.


It might be because -D (disable auto-erase) is necessary for bootloaders (like optiboot) that don't actually honor the "erase chip" command that can come from an AVR-ISP programmer.

The Rugged Circuits Yellowjacket: 802.11 WiFi module with ATmega328P microcontroller, only 1.6" x 1.2", bootloader


the bootloader should just ignore the erase command, unless the code size doesn't allow for it, but it should have been just another "V" command in the STK500v1 protocol, I don't understand why it's not handled.

how do I force a page erase when uploading?

I'm also trying to re-write ArduinoISP to perform auto erase but it is very tricky to understand when to issue the erase command.


The code size does not allow for it. To make optiboot fit into 512 bytes some aggressive cuts were made. A full-fledged bootloader that supports everything an Atmel AVR-ISP does (and all the commands) would take quite a bit more space.

You can't force a page erase unless you use an AVR-ISP to program the board -- it won't happen through the bootloader.

The QuadRAM shield: add 512 kilobytes of external RAM to your Arduino Mega/Mega2560


Feb 13, 2012, 05:43 pm Last Edit: Feb 13, 2012, 05:45 pm by frank26080115 Reason: 1
let me describe what I am doing, I am not using the bootloader

I have two devices, both use ATmega128RFA1 and communicate through the built-in radio. One device is supposed to be the remote control, and the other one is a tiny quadcopter. The remote control has a FT232 on board. The remote control connects to the quadcopter to recharge the quadcopter battery and to update the firmware.

The remote control runs the ArduinoISP sketch if it detects the activation condition on reset, that's how it updates the quadcopter firmware. Since the ArduinoISP sketch is compatible with STK500v1 and I'm tired of using the temporary build folder, I just set my board.txt to use STK500v1 instead and pretend it's another bootloader.

So I have two Arduino IDE windows open during development, one to update the remote control firmware, and another to update the quadcopter firmware, and I only need one USB connection. But this auto-erase deal makes it super annoying to update the firmware on the quad. Actually I might be exaggerating a bit but I really just wish the -D was not there, or became an option.

I already know the SPI commands to trigger the chip erase, but I'm not sure how to detect that a upload is about to happen, yes I have studied the verbose output and it doesn't appear obvious, I don't think there is a practical way to make this change in the ArduinoISP sketch.

I'll post the entire project once I'm done, here's a preview http://i.imgur.com/icASi.jpg

Coding Badly

Just to confirm... You upload ArduinoISP to the remote.  Disable auto-reset on the remote.  Use the remote to program the quad.  Get verification errors.


I hate autoreset, none of the flow-control pins are wired, the remote bootloader is activated by grounding a pin, the ArduinoISP firmware is activated by unplugging that Wii controller


The Arduino IDE uses -D because that reflects the reality of the way the bootloader works; it doesn't implement (though it WILL accept) a "chip erase" command.  It's not clear that AVRDude behaves "correctly" in these circumstances (there are bugs open that say it doesn't upload pages containing all 0xFF, for instance, and it really should, since it can't count on them being FF from the chip erase.)

I just set my board.txt to use STK500v1 instead and pretend it's another bootloader.

Have you used the new "upload using programmer" feature of V1.0 (Shift-Upload) ?  It looks like it doesn't use the -D option.

Otherwise, you're pretty far outside the envelope of normal Arduino use, so I doubt your request will get much traction.  Why don't you download the IDE source and "patch as needed" ?


err, the project is stuck using 0022 or 0023 actually

I might try hacking v1.0 with 0023 core files then

Go Up