Bootloading and Arduino

My USBasp programmer arrived in 3 days (wow that was fast), seems it came from a supplier just down the road from me, rather than direct from HK.

I downloaded and installed the Arduino 1.0 software, downloaded and configured the Sanguino add-on software, connected up the programmer to the breadboard, select the relevant options in Arduino and attempt to upload the bootloader.

Well it barfed a lot but I think (after much googling) that it may have worked – no “successfully uploaded” messages, just a long pause, stops and then displays a load of messages about “pipe stalled”.

I connected up the debug led to pin 1 and on power on or pressing the reset button, this flashes a couple of times – this apparently means that there is a bootloader present – yeah finally some progress.

I also located some newer information relating to using this version with an ATmega644p at maniacbug’s blog, along with a link for a version of the bootloader that will actually compile, since none of the other ones I can locate will.

Next, I download sprinter from github and attempt to compile/upload this to the newly bootloaded chip.

First hurdle – Arduino has had a major rewrite for version 1.0, and it would seem that the Sanguino and reprap community are somewhat behind the curve here.

Downloaded Arduino 0.23 as this supposedly works with the most recent version of Sanguino, more tweaking, still no joy, bootload from this version fails outright as well.

Apparently I am not alone with having issues with this version.

Downloaded Arduino 0.18 and the appropriate version of Sanguino for this, well these actually compile the sprinter software, so that in itself is progress,

The only version that seems capable of uploading the bootloader is 1.0, and the only version that will compile the software is 0.18 – oh joy.

Also version 0.18 of Arduino does not support the upload of software via the programmer unlike version 1.0, so a serial programmer is required.

I have one, a PL2303 USB to RS232, however it does not have a pin for connecting to the reset pin of the ATmega644p chip, so another programmer is required, a CP2102, that is more compatible with AVR chips:

A massive £1.82 spend on eBay and a few more days wait later and I have the item and can hook it up to the board.
My Mac does not recognise it, so a quick search for a CP2102 driver, which I located at Silicon Labs website, install and restart – hey presto we have a new serial port called SLAB_USBtoUART that I can select within Arduino.
Some minor cabling updates to the breadboard and we try again – fails with stk500 errors cannot communicate.
A bit more googling, and find a work around that suggests pressing the reset button 4 seconds after selecting the “upload to board” option from the software – this seems to have the desired effect, the debug light flashes quite a lot at varying speeds and eventually stops.
Again, no nice “your upload was successful” message, but I believe it did actually upload something, so let’s test if we can talk to it.
Locate my installation of Printrun and fire it up, then after I locate the correct syntax to connect to my specific serial port, it claims that the printer is set up – wahey looks like we made it.
Now you may ask – “why go to all this trouble and not just solder up the board already and then program it via the USB port like everyone else?”
Well, partly because I don’t actually want to use the USB connection, I want to talk to the board via bluetooth, and if I solder the USB connector, it will prevent me from soldering on the pins for the TTL header, and partly, just to see if I can.
I bought a couple of Bluetooth modules from  eBay, £11.70 for two:
so much cheaper than the BlueSMiRF items from Sparkfun Electronics at $64.95 a piece!
I may yet find that the cheaper items cause issues, but we shall see, serial communication should only need transmit and receive – hell, I used to use a broken paperclip to cross connect RX and TX between the B serial port of one Sun Microsystems Sparc 5, 10, 20, etc machine to the A serial port of another to provide a makeshift console (no other pins connected), provided you selected the correct baud, parity, data, stop bits, etc it worked just fine.
My Mac Mini and my work Windows laptop can both see the Bluetooth module quite happily, I just need to connect to it via something like putty and change the baud rate to something a bit faster than 9600, this was achieved by connecting it to my PL2303 adapter and then issuing some AT commands via copy and paste (as you can’t type them fast enough on a keyboard).
Printrun can connect to the bluetooth device, however cannot confirm the printer as online, let’s wait and see what it thinks when we actually have a FTDI TTL chip sat in between the ATmega644p and the Bluetooth module, when the Sanguinololu board is all soldered up.
As a side note, I also discovered that if I have any kind of USB connection to my breadboard and connect up the 5V line, I don’t actually need the voltage regulator circuit, as it will be provided by the USB connection.

Leave a Reply