Sunday, July 29, 2012

Managed to update the usbasp with new firmware.  I used a scrap bit of veroboard to put a couple of headers on and wired them pin for pin to create a joiner from my programming cable to the usbasp cable.  I loaded up a slightly modified avrisp sketch (changed the reset pin to be D0) onto the leostick.  Oddly, I found that if I used one of the usb ports on my laptop for the leostick testing the set up by reading the firmware from the usbasp would randomly hang part way through.  When I changed to another USB port the process worked flawlessly.  Once I had read the old firmware I uploaded the new firmware to the usbasp which worked fine.  Now there are no more messages from avrdude about not being able to set sclk when I upload sketches using the usbasp.

Tuesday, July 24, 2012

More playing with arduinos.  I bought an Etherten which I plan to use for my data logger project.  It has pretty much all I need on a single board apart from the wireless interface.  I managed to source a board with a Nordic nRF905 on it for the wireless - this is the same chip used in the little monitoring display that was supplied with the solar inverter, it talks using SPI so there should be a good chance of getting it going with the arduino.

The first step was uploading sketches to the Etherten.  This proved more difficult than I thought it would be after getting the leostick working.  The Etherten steadfastly refused to be programmed in NetBSD (in Windows it was fine...).  I tried updating the firmware for the usb->serial bridge chip by mostly following the instructions https://andrewmemory.wordpress.com/2011/04/14/upgrading-the-arduino-uno-8u2-using-flip/ though I just used the raw button to get the file down and had to hold the main reset down and then short the bridge chip reset to get it into programming mode.  That didn't help me.  Next I tried updating the bootloader using optiloader on the leostick, I had to patch the optiloader code:
--- optiloader.ino      2012-07-18 20:53:16.000000000 +0930
+++ ../optiLoader.pde   2012-07-18 20:51:49.000000000 +0930
@@ -50,15 +50,6 @@
 //     9 to power more complex Arduino boards that draw more than 40mA, such
 //     as the Arduino Uno Ethernet !
 //
-// For a leostick the pins are:
-//  0: slave reset (arbitrary allocation)
-// 14: MISO
-// 15: SCK
-// 16: MOSI
-//
-// The pins are only available on the ICSP header, this header
-// also supplies the power to the other board too.
-//
 // If the aim is to reprogram the bootloader in one Arduino using another
 // Arudino as the programmer, you can just use jumpers between the connectors
 // on the Arduino board.  In this case, connect:
@@ -98,11 +89,11 @@
 /*
  * Pins to target
  */
-#define SCK 15
-#define MISO 14
-#define MOSI 16
-#define RESET 0
-#define POWER 1
+#define SCK 13
+#define MISO 12
+#define MOSI 11
+#define RESET 10
+#define POWER 9

 // STK Definitions; we can still use these as return codes
 #define STK_OK 0x10




This is due to the leostick not having the programming pins in the "normal" arduino place.  I made up a cable and managed to program the Etherten bootloader but still no joy.  While I was mucking around with this I also found an usb-asp on ebay which is an in circuit programmer for atmel chips which happens to be what the arduinos use.  The programmer and a 10 to 6 pin adaptor came to less than $7 including postage so I bought those.

The good news is that the usb-asp works fine under NetBSD with the native avrdude, I can upload sketches to the Etherten no problems.  Avrdude is complaining that the usbasp needs a firmware update which is another adventure.  I have loaded up the AVRisp sketch onto the leostick but I need to make a cross-over adaptor to connect my cable to the usbasp cable, then I can update the firmware.