It’s a long and winding road, that path to finding an easy way to program the JeeNode Micro v3, as mentioned two days ago. With emphasis on the “easy” adjective…
Let me at least describe the process details of what I’ve been using so far:
- A custom cable to connect the JNµ to an ISP programmer
- Installed copy of the “arduino-tiny” project from Google Code
- A trick to get the Arduino IDE compile the sketch into a HEX file
- Setting up the JeeNode + Flash Board as an ISP programmer
- Using avrdude directly, to set the fuses and upload the sketch into the JNµ
It works, in fact it works fine once you’ve set it all up – but easy? Hm…
Let’s go through each of these in turn.
1. Custom cable
It’s all a matter of gently lifting the plastic tabs, then the wires come sliding out. Note that this is the wrong end of the cable for our case – but the other end works the same.
These files on Google Code contain all the necessary code to trick the Arduino IDE into compiling for ATtiny processors, including the ATtiny84 used in the JNµ.
It works with IDE 1.0.x as is, if you follow the instructions, but I’ve been reorganising it to meet the requirements of the new multi-architecture IDE 1.5.x series, which would support this as a straight drop-in. I’m still working on it, but it means you can then just press the “Upload” button – a lot simpler than the process being described in this post!
3. Hex files
Normally, the Arduino IDE takes care of everything: compilation as well as uploading. However, for this setup, we need to get hold of the raw HEX file that gets generated before uploading. There’s a preference in the IDE for that:
Now the nasty bit: you have to compile (“run” in Arduino IDE terms, go figure!) the sketch to see the output that gets generated, and then copy the full path from the output window:
In this case, it’s that “/var/folders/…/radioBlip2.cpp.hex” thing.
4. ISP programmer
To turn the JeeNode + Flash Board combo into an ISP programmer, upload the isp_flash.ino to it. Make sure you get the very latest version, which uses 9600 Baud for communication, as that makes it compatible with the “Arduino as ISP” programmer:
As mentioned before, you don’t really need the Flash Board at this stage – a couple of wires will also work fine (see these posts about all the ways this can be done).
The last step is to call the “avrdude” uploader from the command line, specifying all the arguments needed, and pasting in that full file name. In my case, it was something like:
avrdude -v -v -pattiny84 -cstk500v1 -P/dev/tty.usbserial-A600K04C \ -b9600 -D -Uflash:w:/var/folders/.../radioBlip2.cpp.hex:i
Oh, and if this is the first time you’re programming this ATtiny84 chip, then you also have to first set the fuses properly, as follows:
avrdude -v -v -pattiny84 -cstk500v1 -P/dev/tty.usbserial-A600K04C \ -b9600 -e -U lfuse:w:0xC2:m -U hfuse:w:0xDF:m -U efuse:w:0xFF:m
That’s the internal RC oscillator with fastest startup, and the brown-out level set to 1.8V.
As I said, this is the messy way to do things. I’ll try to have something simpler soon!