Tuesday 2 April 2013

Olimex AVR Programmer

A bit of a Heads up!

Whilst messing around with this programmer, I found you can accidentally over-write the boot-loader on the Arduino by uploading your program through the ICSP header!

SO YOU HAVE BEEN WARNED IF YOU PLANNING ON DOING THIS! I DID NOT BREAK YOUR ARDUINO! It just needs the boot-loader re-loading! See below

Bit of Background

So with some up and coming Arduino project coming to a close, I want them to become stand alone widgets, where they can be soldered onto a strip board and utilise a controller of their own, like the ATtiny range of micro controllers.

ATtiny85 - Small, dip-8 package, really useful
You can program chips on breadboards using the Ardunino as a ICSP (In Circuit Serial Programmer: ICSP wiki definition)

I found this Link: Programming an ATtiny with arduino, a while back and managed to program an ATtiny85V with the Blink sketch in the Arduino IDE, which as proof enough that it could be done for me. Big thanks to those guys at High Low Tech, MIT!

However, this kinda makes your Arduino tied up doing tasks that something else can do. So I purchased an Olimex AVR-ISP-MKII.

Unpacking and Setup

Device comes in a cardboard box with company decals on it. Inside there are 2 ribbon cables: 1x 10way & 1x 6way, and the programmer itself.

As you can see from above they have managed to squeeze the whole thing in a 25way D-sub, what I call "gender-bender" housing (usually cos I find this type of housing is used for swapping sex's of D-Sub's).

There are 4 connections on the device:
  • USB
  • TPI - Atmel's Tiny Programming Interface - for programming ATtiny's
  • PDI - Program & Debug Interface
  • ICSP10 - In Circuit Serial Programming

I'll mostly be focusing on the ICSP port here.

There is also a pin header that allows you to switch power to the target device on or off and either 5V or 3V3.

There are 2 LED's too to show the status of the programmer. 1 orange LED and one bi-colour LED.

After a quick skim read of the manual off the the suppliers website, I realised to use this programmer with AVRDude or the Arduino IDE, I had to reflash the firmware on the programmer.

Manual is: Here

Installing the drivers went well and the firmware re-flash went as per the instructions described.

Bloody Teething Troubles

As with all hardware you except to work out of the box, it didn't, nor was the Manual helpful beyond this. instead of a Green LED coming on, it was now red and the orange LED was on.

First thing was to see if i could program the arduino board through the ISP 6-pin header on the edge of the board.
ISP header shown below the reset button
 Given the ICSP header on the programmer was a 10 way, I assumed it was the other 2 headers, which were 6-way, meant I should use either of them.

With the 6-way cable in the TPI programming port and the other end connected to the Arduino (target), I loaded the Arduino IDE, and made sure that the right programmer was selected:

I then opened the blink sketch and uploaded the sketch like so:

However it didn't work and got the following error:

First thought was that the upgrade went tits up! The manual told me everything about when it should work, but not when it doesn't & the trouble shooting section was quite short!

After some rummaging around on the Arduino forums, I found the error is an indicator that the programmer can't "see" the target board. I've seen warnings on forums that under no circumstances must the -F command be used in the AVRDude command line as the warning suggests! So I didn't bother poking around with that!

After some digging around it transpires that the 10-way ICSP header must use a 10-way to 6-way converter PCB to program ICSP with 6-way headers! Yours from Olimex for £2.00 less P&P.......you got to be F*@KING Kidding me.
Extras sold separately! Typical!
To make me feel more like a complete Burke, I found out the manual on the SUPPLIERS website was out of date compared to the Manufacturers copy, which gave me more information on what status LED's should be!

Let this be a lesson: RTFM - but make sure its off the Manufacturers website! That way its more likely to be up to date!

So with that fresh information, I was relieved that the LED's were correct (they change status meaning after firmware upgrade), but now knew I had another obstacle in the way! 

No dice Olimex, I ain't forking out more cash! I'll build my own! Dug around for some parts and came up with a homemade solution!

Header Converter



Using the diagram, I basically connected all the identical pins together on the 10-way to the 6-way, like below:
I quickly threw it on a scrap bit of strip board

You can't see it but I placed a dot near the middle pin on the 6-way to signify the place where the keying tab on the cable goes, so as not to connect it up the wrong way round.

Programming the Arduino through the ISCP, Take 2

I STRONGLY ADVISE YOU TO READ THIS SECTION CAREFULLY IF YOUR PLANNING ON DOING THIS, AS THERE ARE SOME VITAL THINGS YOU NEED TO KNOW!

It will be explained later, but when you program the Arduino with the ICSP programmer, it appears to over-write the boot-loader on the micro controller.

THIS MEANS ONCE YOU UPLOAD YOUR PROGRAM VIA ICSP, AND YOU TRY TO UPLOAD WITH YOUR USB CABLE AS STANDARD LATER, IT WILL NOT WORK.

I connected up the Arduino with an LED hanging off pin 13 and the ICSP programmer connected Via my homemade converter, I then tried to load the blink sketch as before, aaaanannnnnnnddddd.......(drum roll):
SUCCESS!!!

It worked! But I had then hit another snag!

I Tired uploading a different sketch to the Arduino and the IDE was acting like it wasn't there.
Typical fault of wrong port selected or not plugged in, or in this case no boot loader!
The only thing I could think of was that I had overwritten the boot-loader when I programmed the Arduino! Using the programmer connected to the same header on the Arduino again. I then proceeded to re-burn the boot-loader to the Arduino:

The programming was successful and managed to use it normally again.

Also if you getting this error on your Arduino, and you have tried ALL other solutions and still nothing, then AND ONLY THEN should you look at re-loading the boot-loader. Don't go spending 17 quid on an ICSP programmer and find out it selected the wrong serial port on the IDE!

So.... what Did I reckon?

Well the Olimex AVR-ICSP-MKII is one 1 of many ICSP programmers out there, and you get what you pay for.

Kudos on design for sticking it in a D-sub housing, but a must try harder on the manual.

Overall I'd say good purchase for beginner, and if you don't want to fork out for a converter then make one yourself like me!

Anyway, I have managed t get my head round on Programming boards with ICSP and the Arduino IDE. This should free up my arduino when it comes to strip boarding and prototyping my future designs

I'll be looking further into ICSP design considerations when prototyping up a project. Will leave that for another entry hopefully.

Laters!