(AVR-)Dude, Arduino crashes fixed!

In anticipation of new thermoplast extruder parts, I built a Dremel toolhead for my RepRap. It should be able to do light milling, such as PCB isolation routing!

I was hoping to do some milling. But the G-Code firmware had problems, it kept crashing when I sent G-Codes. I’ve been debugging the firmware for quite a while. When I was just starting to go crazy, Wade (from the RepRap community) pointed out that it could be a compilation problem of ubuntu’s AVR compilation toolchain [edit] Is fixed on Ubuntu Intrepid (8.10), so this problem will soon be irrelevant![/edit]. And that was it… all this time it wasn’t a program bug, it was a compiler bug! The windows version of the avr-toolchain produced HEX code that DID run well! Here’s how I did it:

I used the Arduino software to compile the v.1.3 G-Code firmware (as described here). Recompiling it on Windows in a VM (I don’t have windows computers around) created a ROM file. After some searching I found that it saves ROM files in a file named:
C:\Documents and Settings\erik\Local Settings\Temp\build?????.tmp
Make sure you don’t exit the arduino software, or the build will be gone!
Since I can’t connect to the Arduino from windows (FTDI drivers won’t install, device remains unrecognized), I transfer the .HEX file to Ubuntu again. There I downloaded and installed AVRDUDE, an open source package to program AVRs such as the one Arduino is based on. This is how I programmed it:

$ wget http://download.savannah.gnu.org/releases/avrdude/avrdude-5.5.tar.gz
$ tar xzf avrdude-5.5.tar.gz
$ cd avrdude-5.5/
$ ./configure
$ make
$ sudo make install
$ cp ../windows-compiled/GCode_Interpreter.hex ./
$ ./avrdude -p m168 -c avrisp -P /dev/ttyUSB0 -b 19200 -F -U flash:w:GCode_Interpreter.hex
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.05s

avrdude: Device signature = 0x000000
avrdude: Yikes! Invalid device signature.
avrdude: Expected signature for ATMEGA168 is 1E 94 06
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file “GCode_Interpreter.hex”
avrdude: input file GCode_Interpreter.hex auto detected as Intel Hex
avrdude: writing flash (11684 bytes):

Writing | ################################################## | 100% 8.84s

avrdude: 11684 bytes of flash written
avrdude: verifying flash memory against GCode_Interpreter.hex:
avrdude: load data flash data from input file GCode_Interpreter.hex:
avrdude: input file GCode_Interpreter.hex auto detected as Intel Hex
avrdude: input file GCode_Interpreter.hex contains 11684 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 8.78s

avrdude: verifying …
avrdude: 11684 bytes of flash verified

avrdude: safemode: Fuses OK

avrdude done. Thank you.

No no no, thank you, AVRDUDE!

Dit vind je misschien ook leuk...