More updating firmware without using Arduino

I realised that the Arduino Uploader (featured here earlier) doesn’t work for Mega2560s.  Easy enough to fix, but I wanted something that’d work out the box so I’m recommending XLoader instead.  Works much the same way.  In fact, I’m just going to leave you with this screenshot and a couple of links.

Download XLoader from the XLoader site.

And download the precompiled firmware you want to update to (do right-click-> save target as…):

Start XLoader, load the hex file you downloaded into it, select your device (Mega(ATMEGA2560) for PolargraphSD machines, Duemilanove/Nano (ATMEGA328) for older Polargraph machines), select your COM port and press UPLOAD.
Kongorilla points out to me that XLoader is a little unforthcoming in the event of a problem – If you load a file that isn’t a hex file, then it still goes through the charade of loading it, but then quietly announces at the end “0 bytes uploaded“.  So keep an eye on the status line to make sure it actually does what you think it’s doing.

Some interesting stuff that you probably aren’t interested in:

Note that I’m going to start uploading the compiled hex files to the SVN repository so I don’t have to faff on with updating zips and things.  The problem with this is that the hex file will not automatically be the compiled version of the code that is next to it in the repo.  I’ve still got to do that bit manually so it’ll probably be out-of-sync much of the time.

The way to check to see if the source code has been updated since the hex file has been compiled is to look at the revision numbers:

In this case, the source code (the .ino file) has been updated in the same revision as the compiled file (the .hex file).  This means that there hasn’t been any updates to the source code since the hex file was compiled.

If the source code has a higher revision number than the hex file, then the hex file is an older version and won’t reflect the changes in the source code.  You should compile it yourself (the regular way, through Arduino IDE).

Uploading firmware without Arduino

EDIT! – Use XLoader instead of this – it’s just as good and works on more boards.

Hello, a few people have had problems getting their programs uploaded to their arduinos.  I haven’t.  Not rubbing your faces in it, but if I can’t replicate it, I can’t fix it.  I think it might be something to do with bootloaders, but who knows.

EDIT! Looks like it is to do with bootloaders – Matt’s adventures confirm that.  I think it’s restricted to UNOs of a certain age.  The only UNO I ever owned I blew up literally hours after getting it, so can’t test.  And I don’t think this way of uploading will get around the issue – you might just have to reprogram your bootloader.

A second problem is that you need a couple of libraries installed, and not everybody want’s to harass themselves with that.  So I’ve made a precompiled hex file that you can load onto your arduino to save you that hassle.  You don’t even need to have arduino installed anymore.

What you need:

  1. The hex file is here.
  2. ARP-Uploader.  This is the thing that uploads the hex.  Get it from here.

And that’s it.  Unzip and startup ARP-Uploader, load up your hex file that you downloaded.

Choose the COM port that your arduino is on, and m328p as the microcontroller.

Change the baud rate from 19200 to 57600 where I’ve highlighted in the pic.

Press upload!

I’d be interested in knowing if this helps anybody who is having sketch size issues too.

OK, this hex file is good for Arduino UNO, Duemilanove, or any ATMEGA328-based arduinos.

Eclipse, Arduino 2560 and AVRDude – timeout

I’m in the process of restructuring the polargraph firmware, and the first thing I’m doing is moving most of the functions out to a library that can be used by all polargraph firmwares (uno, mega etc).  So that’s easy, you’d think.  I’m a fairly naive c++ programmer so don’t be surprised that I’m trying to get it working in eclipse so as to have a decent overview of things, function names and whathaveyou.  I find it useful when making cross-cutting changes.

So I came across Eclipse/Arduino tutorial page,  which is really good, and got it working on a Duemilanove I have – beautiful!  That said, I can quite see why the Arduino IDE is popular even though it lacks functions.  Eclipse is the archetypal jack of all trades and master of none, and requires a load of configuration to even get started on things.

But the MEGA? Not so much.  I got stuck so went to see how the Arduino IDE does it, and pulled out the AVRDude command it was using (turn verbose output on for the uploading in preferences):

c:\Dev\arduino-1.0\hardware\tools\avr\bin>avrdude -CC:\Dev\arduino-1.0\hardware/
tools/avr/etc/avrdude.conf -v -v -v -v -patmega2560 -cstk500v2 -P\\.\COM55 -b115
200 -D -Uflash:w:C:\Users\sandy\AppData\Local\Temp\build4894098567197191708.tmp\

That’s what it emits, but when I put that same text in at the command line, I am faced with

avrdude: stk500v2_ReceiveMessage(): timeout

Which is the same problem I was bumping into in Eclipse.  Well.

The fix

Turns out using the arduino or stk500v2 programmer, the board doesn’t get reset before programming.  I could get around this just by pressing the reset button and then uploading that same instant, mostly, but it’s not very clever.  Then I came across a better solution at this page discussing the error in avrdude 5.10 (I’m using 5.11 that comes with the Arduino IDE so I guess it’s still an issue), and that solution is just to use the Wiring programmer instead of the Arduino programmer that works fine on the Duemilanove, or the stk500v2 programmer that the Arduino IDE uses.

That worked fine.