Forgot your password?
No account? Register one!
January 9, 2012
Tutorial - Reinstalling your Arduino bootloader |
about 2 years ago
I got an arduino Uno SMD from Sparkfun (in the LabView bundle) that had the “blinking led” problem (http://forum.sparkfun.com/viewtopic.php?f=32&t=25611 or http://arduino.cc/forum/index.php?action=printpage;topic=51640.0). I’ve tried to upload a new bootloader with my “old” arduino Uno R3, and got it to work (in the end). It took a day of trial and error, and I’m not sure what exactly did the trick, but here’s what I did.
I wired the two arduino’s together as described here: http://arduino.cc/en/Tutorial/ArduinoISP. Cables don’t have to go to ICSP (requiring female jumpers) but can go straight from 11-11, 12-12 and 13-13, and then one from 10 to the reset of the target. I powered the target independently, or GND-GND and 5V-Vin. I also hooked up three LEDs as described in ArduinoISP, which are very helpful to know whether the source-arduino has crashed or not. And I put three 330 resistors parallel from 5V to reset on the source arduino, but I’m not sure if that was necessary.
One big issue I had was these errors when trying to upload the bootloader:
avrdude: stk500_paged_write(): (a) protocol error, expect=0x14, resp=0x64
avrdude: stk500_cmd(): programmer is out of sync
It programmed the fuses okay, so there was nothing wrong with arduino to arduino communications.
Still can’t figure out why, but what eventually helped was adding -vvvv to the command. Like:
avrdude -P com15 -b 19200 -c avrisp -p m328p -vvvv -e -U flash:w:optiboot_atmega328.hex -U lock:w:0x0F:m
I used the old (original?) optiboot bootloader because it’s really small (2K) and only instructs to write a tiny bit of hex to the very end of the flash memory. (Learned a thing or two about Intel hex in the meahwhile.) Long story short, the verbose output kept the arduino from getting out of sync. For a while at least, because I still can’t get the (larger) BootLoader328REV3_firmata.hex to load.
To check the upload, I tried reading the flash memory using :
avrdude -P com15 -b 19200 -c avrisp -p m328p -v -U flash:r:present.hex:h
present.hex should then contain the same hex values as the bootloader .hex file (only different format).
After what appeared to be a succesful attempt to upload the bootloader, my old arduino refused to talk to the arduino software. Bluntly unzipping the software (http://arduino.googlecode.com/files/arduino-1.0-windows.zip) on top of the previous installation, and reinstalling the driver for the COM port (http://arduino.cc/en/Guide/Windows#toc4) fixed that. After that, it recognized my new arduino SMD as a new device, and after installing new drivers for that one (which are not the same as for the arduino UNO R3), it now sees a COM port.
And it works, I’ve uploaded the blink example succesfully, giving me exactly the same symptoms it had before I started… But now it is responsive and I can actually load new programs. In hindsight I wonder whether I really had to spend a whole afternoon uploading a new bootloader.
Long story short: try -vvvv. I hope this boring history saves someone the trouble I went through.
No public wish lists :(