Welcome! Log In Create A New Profile

Advanced

programming the Sanguino using the Decimilla as an ICSP.

Posted by jgilmore 
programming the Sanguino using the Decimilla as an ICSP.
February 15, 2010 11:19PM
I've got a basic breadboard atmel644PU, it seems to be OK. Now I'm trying to upload the bootloader and set the fuses, using a ICSP made from my old brain, a atmel168-20PU. No luck so far, just recording progress or lack thereof. Mostly so I can remember what I tried later.

Programmed arduino with command:
avrdude -F -p m168 -P /dev/ttyUSB0 -c stk500 -b 19200 -U flash:w:avrusb500.hex
avrusb500.hex was in the file avrusb500-1.5-arduino.zip downloaded from [tinker.it]

Didn't work.

Tried AVRISP from [code.google.com]
Got it compiled from the command line using a variation of the makefile I used for my gcode. I wish arduino came with a working makefile, it's stupid that it doesn't. Huh, I guess I didn't try the makefile from 0017, which I just downloaded. Maybe later.
Fiddled with the speed, ran several variations of
avrdude -F -p m644p -b 57600 -c avrisp -P /dev/ttyUSB0 -e -U flash:w:../arduino-0017/hardware/bootloaders/atmega644p/ATmegaBOOT_644P.hex
Couldn't get it to work... Kept getting "avrdude: stk500_recv(): programmer is not responding" and sometimes a variation of that. I was trying to run it faster than recommended. I don't want to try to run it at the 19200 speed for fear I'll overwrite my decimilla's bootloader. That would be very, very bad.

It seems that the fuses must be set seperately. There's no real direction that I saw on the subject on the sanguino website... Not really worried about it until I can get SOMETHING to load. Not much point till then!

So, try again tomorrow night.


--
I'm building it with Baling Wire
Re: programming the Sanguino using the Decimilla as an ICSP.
February 16, 2010 12:48AM
The mega644 needs a clock source to program it. Some of the megas have an internal rc occilator. If this fuse gets set off, and there is no crystal then you get the error noted.

There are a lot of threads on avrfreaks,net forums. This issue comes up a lot. Getting the fuses set is a bit of an art.

-julie
Re: programming the Sanguino using the Decimilla as an ICSP.
February 17, 2010 12:04AM
OK, some successes. I wired a LED to the hearbeat, so I could tell for sure that the avrisp "sketch" was running, and with that tried to use avr in terminal mode to verify the fuses. Which, unfortunately, always read as "00" even when I used the "send" command to directly issue the spi command to write to them.

For some reason, avrisp doesn't implement the fuse write commands.

Anyway, I wasn't able to verify that the fuses where correctly written, so I thought I'd fire it up and see if the bootloader had actually loaded (avrdude got a verification error when loading the sketch, but the address it's complaining about is 0000, while the bootloader is in the HIGH part of memory, not the low part. So I'm not going to assume it's actually failed)

That's when I realized that my CA-42 derived USB-TTL cable doesn't have 5v power. And I'd been using the decimilla to power the atmel644P. And I only have 1 USB port on my laptop, and don't have a USB hub.

Huh. Guess that does it for tonight.


--
I'm building it with Baling Wire
jgilmore,

my setup is slightly different to yours;
I have AVRISP MKII with windows7.
To load the bootloader, I had several issues;
1. Incorrect CPU pin orientation. My AtMega644P was facing the wrong way!
2. Short-circuits/Open-circuits between the ICSP and CPU. PCB is homemade.
3. AVR programmer does not support target board power. For this I had to mod the programmer.

Have a look at my blog for further reference; [mariushermanbotha.wordpress.com]

I really hope this helps.

Cheers.
Marius Botha
Pretoria, South Africa
Re: programming the Sanguino using the Decimilla as an ICSP.
February 17, 2010 05:28AM
Howzit Marius.

I also have a MKII, but i can't get it to work with arduino software on win7, so I decided to use avrstudio. I want to burn a bootloader. Have you got any experience in that?

Thanks,
Matthew
South African in Belgim
Matthew,

For the most part, please refer to my blog (http://mariushermanbotha.wordpress.com) for specific URL related links. In this reply, I will just loosely refer to internet-site "names".

1. You have to install the arduino software, as per [reprap.org]
2. You will also need to install libusb-win32. Again, links are on my blog.
NB!!!! Remove any other pre-installed usb drivers, notably from AVRStudio. You should be able to do the uninstall in DeviceManager.
3. Also note that the libusb-win32 installation should be done "in a particular way" for Windows7, refer to youtube link on blog. winking smiley
4. If your arduino s/w was installed correctly, you should have the sanguino board-option , as a menu-item.
5. The arduino s/w should also display "bootload w/ AVRISP MKii" as a menu option.
6. There is another trick to watch out for w/ the MKII programmer - IT DOES NOT POWER THE TARGET BOARD. You have two options:
6.1. Power target board seperately with 5V, or
6.2. Do the h/w mod on the AVRISP MKII, as per my blog. Note, that this mod will void your warrantee on your programmer, and you do it entirely at own risk! (Obligatory legalese smiling smiley
If your board is short-circuit/open-circuit free, and you have checked your ICSP pin-out from connector to CPU, you should be ready to roll.

If you get stuck, or you are unsure of anything that I wrote here, drop me a line. I will be more than happy to respond smiling smiley

Keep well, my South-African/Belgian friend smiling smiley
Marius Botha
Pretoria, South Africa
Re: programming the Sanguino using the Decimilla as an ICSP.
February 17, 2010 08:07AM
Thanks Marius!

I installed the libusb-win32 and I got a blue screen! But now i see that you have to remove the avrstudio drivers first. I hope this helps (I followed the video instructions).

Does this mean that I won't be able to avrstudio any more is the libusb just a replacement for the drivers that avrstudio installs?

Thanks again.
Matthew,

I have not tried to use AVRStudio with the libusb-win32 drivers. So, I am not really sure if that will work. At a guess, I do not think it will work. My guess would be that AVRStudio will look for its own usb driver.....Jungo (I think)

Yep, you have to uninstall the AVRStudio usb-driver. I made the same mistake of installing libusb-win32, w/o jungo de-install, and spent the next few hours scratching my head, as to why ALL of my usb ports were suddenly non-functional!
I am hoping you can avoid some of this pain......

Let me know how things go for you......

Keep well,
Marius Botha
Pretoria, South Africa
Re: programming the Sanguino using the Decimilla as an ICSP.
February 17, 2010 11:27PM
I'm still stuck in the "no way to power the board if I can communicate with it" thing caused by the simple lack of a USB hub. I visited radio shack, and they had hubs starting at $29 - a bit too pricey when I have one sitting at home somewhere.

So I spent the evening dissecting my CA-42 el cheapo USB-TTL converter cable I got off ebay from some guy in Taiwan for $3 including shipping.

First, I carefully cut off the molded plastic connector, exposing the small PCB (I'd include photos, buy my cell phone doesn't take useful pictures of small things.) with a chip epoxied to the board, two SMT capacitors, an SMT resistor, and what I think is just a blob of solder as a junction of some sort. It also has a small crystal, and was wrapped in masking tape along with the ends of the wires coming in.

I had previously identified the three wires coming as RX, TX, and GND. TX was the only one with a voltage on it, and RX was the one that caused my terminal program to echo when it was twisted to TX. GND was the only other wire, which is why I cut the stupid thing open. Hopefully I'll be able to get a multi-wire TTL cable that can power my boards.

Using a voltmeter to the shield of the USB connector after plugging the bare PCB into the only USB socket on my laptop, I saw only two pads that had voltage.

TX 3.3v
#2 5v

So I have my 5v, and could now reassemble it and power my board. I was about to do just that, but thought - hey, why not fiddle a bit more and see if I can usefully hook up anything else while I'm fooling with it?

So I did a little googleing, and didn't find anything that looked useful, til I remembered RepRapArduinoSerialSender.py which comes with skienforge. Googling python serial led me to the documentation, which gave me a quick list of functions:
setRTS
setDTR
getCTS
getDSR
getRI
getCD

I started python, re-inserted the bare PCB (I'd removed it to avoid bending it, and to plug in my mouse to do the browsing.) and typed:
import serial
ser=serial.Serial("/dev/ttyUSB0")
setDTR(1)

I probed the pads again, and didn't see a difference, so I typed "setDTR(0)" and saw 3.3v on pad #11. Yay! I then typed setRTS(0) and saw 3.3v on pads 9, 10, and 11. So either 9 or 10 is RTS, I don't know which. I guess they both are?

Then comes the tricky bit. I dug into my supplies, and found a smallish (about 560Ohms) resistor, and typed into python the following:
print("CTS:",ser.getCTS(),"DSR",ser.getDSR(),"RI",ser.getRI(),"CD",ser.getCD())
That printed out four "trues" without probing any pad.
I started by hitting 12 and 8 together. I figured that 12 (TX) is a steady enough voltage, and I was right, when I hit enter it showed a "false" on CD. In this manner I was able to determine RI, CD, and DSR. None of them where positive for CTS, which was disappointing.

So all in all, I determined the following:
1 ???
2 +5v
3 RI
4 RX
5 ???
6 GND
7 DSR
8 CD
9 RTS?
10 RTS?
11 DTR
12 TX

This is my last night this week, next monday hopefully I'll get it wired back up and get power and comms to my breadboard sanguino at the same time!

But maybe not. I got a bonus today at work (4 12v lead acid car batteries in good condition) and also got the fuses for the line to my inverter. I plan on buying a battery isolator on Saturday, and so I'll probably spend Monday night installing the lines, fuse, inverter, isolator, and batteries. Finally I'll be able to use lights and run my laptop without having the car on without worrying about running the battery down. Which would be really, really bad and might get me fired. (for failure to show up at work) And then I'd be back to having lots of time to work on my repstrap but no money at all for parts. Instead of almost none like I have now.

And I'm starting to ramble, so it must be time to go to bed?

Just hit preview, and this sig still makes me laugh when I read it.


--
I'm building it with Baling Wire
Re: programming the Sanguino using the Decimilla as an ICSP.
February 19, 2010 08:38PM
Hi

Rather then try to cordinate firmware on two seperate computers. Use the serial chip in bit banging mode.

[www.geocities.jp]

[exmrclean.blogspot.com]
Re: programming the Sanguino using the Decimilla as an ICSP.
February 19, 2010 09:47PM
Using bit banging mode is a possibility. I didn't want to do that directly both because I have the decimilla, and my understanding of the bit bang mode is that it can easily take several hours to program the simple bootloader.

To do the bit banging, you need four wires - two sends, a recieve, and ground. I think. Haven't read up enough on it, but from reading the specs from Atmel's datasheet, you'd hook up DTR to MOSI, RTS to SCK, and one of the "read status bits" probably normally CTS, to MISO. Hook up a clock source, GND, and 5v to VCC & AVCC and you're goot to go. (Edit: The precise definitions are in /etc/avrdude.conf, around line 730. It does use CTS in all pre-defined setups, but it looks totally trivial to add one. RX cannot be used, and RI can't be used under windows.)

The TTL cable had only three wires (RX,TX,GND), which isn't sufficient to do the bit banging. I didn't want to pull it apart if I didn't have to.

Now, however, I have had to pull it apart in order to get the 5v power, and I'm planning on pulling the other useful signals out too. So if it still doesn't work I may very well use the bit banging mode.

I still hope not to... Maybe the bootloader is already loaded? It did claim a mismatch, but hopefully that's a bug in avrdude where it checks memory that it didn't write to.

Edited 1 time(s). Last edit at 02/19/2010 10:59PM by jgilmore.


--
I'm building it with Baling Wire
Re: programming the Sanguino using the Decimilla as an ICSP.
February 20, 2010 02:05AM
This thread on AVRFreaks with input from the maintainer of AVR dude has a clear description of the LIB USB drivers which conflict with the Jungo drivers.


-julie
Re: programming the Sanguino using the Decimilla as an ICSP.
February 20, 2010 10:17AM
To power your board from a 3v USB/Serial cable open up the shell on the USB plug end and using a spare conductor on the cable (disconect the one that provides 3v) and tag it straight onto the 5v feed on the USB plug connections where they join the PCB.


Necessity hopefully becomes the absentee parent of successfully invented children.
Re: programming the Sanguino using the Decimilla as an ICSP.
February 20, 2010 10:07PM
aka47 Wrote:
-------------------------------------------------------
> To power your board from a 3v USB/Serial cable
> open up the shell on the USB plug end and using a
> spare conductor on the cable (disconect the one
> that provides 3v) and tag it straight onto the 5v
> feed on the USB plug connections where they join
> the PCB.

Sounds like a great idea, except that the cheap cable has only three conductors in it. The "3.3v" line is actually the TX pin, which I need. I already took apart the plug, noted which pads the cables where connected to, and will be replacing the cheap cable with some cat5 and the molded plug with some hand-molded shapelock plastic I have laying around. Soon I will have it working!


--
I'm building it with Baling Wire
Re: programming the Sanguino using the Decimilla as an ICSP.
February 21, 2010 06:51AM
Job Sorted, good oh.


Necessity hopefully becomes the absentee parent of successfully invented children.
Re: programming the Sanguino using the Decimilla as an ICSP.
February 21, 2010 07:46PM
jgilmore Wrote:
-------------------------------------------------------
> Using bit banging mode is a possibility. I didn't
> want to do that directly both because I have the
> decimilla, and my understanding of the bit bang
> mode is that it can easily take several hours to
> program the simple bootloader.
>

I have done it, takes a couple minutes at the most, once you have the connector made. If you follow the links I gave it shows you how to do it with the Decimilla that you have onhand.
Re: programming the Sanguino using the Decimilla as an ICSP.
March 06, 2010 07:13PM
Must admit I have used a diecimilla as an AVRISP for quite some time now and it works great.

V18 of the arduino IDE even ash the sketch for ti in the examples section now.

It works better under windows because the dicimilla programmer does'nt auto reset.

I work from Linux and use avrdude form a command line to get around the rest thing. (or disable the auto reset. it is a pain in the neck).

Only thin you need to watch particularly with the 644 is which version of avrdude you are using and is it finding the correct config file (which has the specs for the micros in it, and you can tweak it to add more or change them)

When using avrdude fro the command line under ubuntu with the avrdud package installed I needed to make sure the paths tot he version of avrdude I wanted to run and the config file I wanted that version of avrdude to use were correct.

Other than this it has been realy great. So much so that I built a dedicated AVRISP programmer using a spare 168 and purposely built it with a manual reset so it would work from the Arduino IDE.


Necessity hopefully becomes the absentee parent of successfully invented children.
Re: programming the Sanguino using the Decimilla as an ICSP.
March 07, 2010 03:44AM
you can use stty command to enable and disable the auto reset in linux-

stty hup < /dev/arduino turns it on, and stty -hup < /dev/arduino turns it off.

Also, I re-flashed my diecimila with adaboot and now I can use the normal version of avrdude without issue.

On a totally unrelated note, I also re-flashed the ft232r to ask for 500mA, and report itself as an arduino diecimila smiling smiley


-----------------------------------------------
Wooden Mendel
Teacup Firmware
Sorry, only registered users may post in this forum.

Click here to login