Flashing the AVR-CAN board

My Nissan Leaf Forum

Help Support My Nissan Leaf Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

garygid

Well-known member
Joined
Apr 21, 2010
Messages
12,469
Location
Laguna Hills, Orange Co, CA
-------------- Software --------------
The two main (free) software choices are:

1. AVR Studio 5 from http://www.Atmel.com" onclick="window.open(this.href);return false; (you need to Register to download it).
I have installed this, but not yet figured out how to use it to flash anything.

2. WinAVR (an open source project, I believe) that contains AVRdude for flashing the ".hex" file. I am using this, and it sems to work well.

------------- mini USB AVR-JTAG -------------
This seems to be a good (maybe even a "better") solution.
Usually available on eBay, mostly from Hong Kong or China.

I bought from this seller "seller25812", and just got and tested this one:
http://www.ebay.com/itm/260853683073" onclick="window.open(this.href);return false; ... bid $5 (plus $10 S&H)
or, a Buy-it-Now at
http://www.ebay.com/itm/250597883758" onclick="window.open(this.href);return false; .. for $17 (free S&H)

However, there appears to be one source in the USA, in CA. They are a bit more expensive (maybe $26 instead of $17), but their delivery is usually a lot quicker. I also bought from them.

This programmer attaches directly to a USB port, and it POWERS the board being programmed.

------------- SparkFun PGM-00012 -------------
From http://www.SparkFun.com" onclick="window.open(this.href);return false; for about $60, this JTAG programmer is connected via a USB A to B cable (not included). I have not tried it, but another member has ordered it, and will try it on the AVR-CAN board. This appears to have the right specs, so it SHOULD work, I think.

------------- AVR-Dragon --------------
I bought an AVR-Dragon (as I recall, for around $60 from http://www.Atmel.com" onclick="window.open(this.href);return false;) and found that it works well in its JTAG mode with the AVRdude software in Windows. However, it apparently REQUIRES use/help of the "libusb" software before AVRdude will recognize it.

In using AVRdude (AFTER connecting AVR-Dragon to a USB port, letting Windows find and install a driver for it, AND using libusb), the command-line parm "dragon-jtag" is used to identify the device, and "usb" is used for the port. Works well.

------------- AVR-JTAG-ICE -----------------
The other programmer I bought (from ebay) is supposed to be an AVR-JTAG-ICE "clone/copy/compatible" device, connected to a serial Comm Port.
Even a USB to RS232 adapter is supposed to work, using a virtual Comm Port.

However, it turns out that not all USB-to-RS232 adapters are suitable.
With the "worse" adapter, AVRdude could not establish communication/sync
with this "jtag1" device. :(

However, using two different brands of "better" adapter, it works flawlessly. :D

------------- USB-to-RS232 ------------------
Guess which USB-to-RS232 adapter I have ten of! :lol:

Fortunately, these adapters seem to work OK when connected to the AVR-CAN
to do CAN-Capture into the PC. I will experiment more when I have time.

I will order more adapters from a different source to try and get a current
source of "better" adapters. More on that later when they arrive and I test them.
 
Here is an option for programmin that I posted in another thread.

PGM-09825
Pocket AVR Programmer
$14.95

http://www.sparkfun.com/products/9825

This new version uses an SMD 5x2 header. This is a simple to use USB AVR programmer. It is low cost, easy to use, works great with AVRDude, and is tested extensively on a Windows desktop.

09825-01b.jpg
 
What is the firmware you are using ? I'm assuming it is a modified version of some open source ...?
 
The Spy.c program apparently started as
main_can_spy_echo_example.c

It appears to be a 2007 Amtel example program that would read the CAN bus using their AT90CAN128 chip.

At least two others changed it to the form I first saw, where it would output fast binary-formatted CAN messages, with a sync-byte added, via the RS232 port. This was a very short program, and I have not actually seen the original "sample" code.

I re-wrote some, added comments, and added the watch-for-SOC raw data. I then format and display the raw or percentage SOC for the 7-segment serial-input display from SparkFun.

We are still evolving the firmware, but I will probably consider this "version 4.09" to be my first Beta-release version for the LEAF SOC-Meter project.

So far, it appears to be working OK, but no guarantee or warranties. Use entirely at your own risk.

I compile, asm, and link with WinAVR, and use AVRdude (currently through AVR-Dragon) to flash the AVR-CAN.
 
garygid said:
Good suggestion, but apparently this Adafruit's USBtinyISP
cannot program via the JTAG port that the AVR-CAN uses.
Are you sure ? The Pocket programmer I posted above is based on the tiny usb - and avrdude should work with that. We need to use the correct avr-can parameter for the avrdude.

I've ordered the parts from sparkfun - once I get it we'll know for sure.
 
Not "sure", but that is what it says in the description
paragraphs right below the picture: no JTAG.

I have ordered the other USB to JTAG mentioned above,
and one from EBAY that has an RS232 interface to the PC.

I need a 9v dc power supply (maybe 12v will do) so
that I do not have to go out into the car to power the
AVR-CAN ... whose 5v also powers the EBAY JTAG card.

The USB to JTAG card gets power from the USB port, but
I still need power for the AVR-CAN before I can actually flash.
 
garygid said:
I need a 9v dc power supply (maybe 12v will do) so
that I do not have to go out into the car to power the
AVR-CAN ... whose 5v also powers the EBAY JTAG card.

The USB to JTAG card gets power from the USB port, but
I still need power for the AVR-CAN before I can actually flash.
Oh no - I never thought of that. So, we need to add a suitable power supply to the list.

edit :

http://www.ioffer.com/i/avr-can-atmel-at90can128-prototype-board-uart-jtag-isp-150548801

POWER SUPPLY CIRCUIT :
Power should be applied to power supply connector. AVR-CAN could be powered by applying up to 9VDC (5 to 9 VDC) to EXT1-1 and EXT1-2 and GND to EXT1-3 and EXT1-4 or if you supply 5 to 9 VDC to central pin of POWER SUPPLY connector and GND to external pin of this connector
The consumption of AVR-CAN is about 40-50 mA.

So, just need any ordinary small power supply. May be you can try an old cell phone / cordless phone charger.
 
Yes, the 10 to 14v of the Vehicle "12v" system is really too much for the AVR-CAN, so we will probably add a 7808 (8v) regulator or a 5-volt zener diode.

A typical "5v" USB source is a bit low, and a 9v source is a bit high. Maybe a 9v source with a 2v or 3v zener diode?
 
garygid said:
Yes, the 10 to 14v of the Vehicle "12v" system is really too much for the AVR-CAN, so we will probably add a 7808 (8v) regulator or a 5-volt zener diode.

A typical "5v" USB source is a bit low, and a 9v source is a bit high. Maybe a 9v source with a 2v or 3v zener diode?
I was actually just referring to flashing the avr-can when away from the car - in that case we can use one of those phone chargers.

Is the overheating happening in your avr-can alone or others as well ?
 
The "overheating" is just a very-hot small regulator chip on one corner of the board.

We think it happens on all/most boards, because we are feeding 14v (from the OBD connector) rather than 9v or less as stated in the specifications.

It is aggravated by adding the LED display board that essentially doubles (?) the current draw from the card's regulated 5-volts.

We should check the voltage and current ratings of that regulator chip itself.
 
DRAT!
The programmer board PGM-09825 from www.SparkFun.com that evnow suggested is an ISP programmer, not a JTAG programmer! The 2x5 pin header socket made me think it was for JTAG, and I did not read closely enough, I guess.

So, I have two of these $15 boards. If anybody can use them, please let me know.
 
YEA!
I got the AVR-JTAG boards from Ebay to work, using AVRdude. They use an RS232 connection to the PC, and some USB-to-RS232 cables only work (connect with this card) about 1 out of 42 times. Unknown why, perhaps a byte-timing issue.

However, my two "better" USB-to-RS232 adapters work EVERY time.

The "don't-work-with-PGM-09825-board" USB-to-RS232 adapters appear to work fine with transporting CAN-message data from the AVR-CAN board to the PC, which is what we originally got them for.
 
garygid said:
DRAT!
The programmer board PGM-09825 from http://www.SparkFun.com that evnow suggested is an ISP programmer, not a JTAG programmer! The 2x5 pin header socket made me think it was for JTAG, and I did not read closely enough, I guess.

So, I have two of these $15 boards. If anybody can use them, please let me know.
Hmmm .... I just got the board as well. :(
 
As it is, configured for ISP instead of TJAG, do NOT plug its 10-pin connector into the AVR-CAN board and try to apply power! The +5v of one or both cards will be shorted to ground. :(
 
I got my Olimex AVR-CAN board from Sparkfun on Wednesday. Cathy had a JTAG ICE (one of the original models before Mark II), so I thought I was set for a programmer. It can talk to the chip and read/write fuse bytes, but every attempt to program the flash using avrdude version 5.10 (Mac OS X) fails with a content mismatch message at offset 0x0000. If I dump the flash memory, it's all zeros. I tried everything: powering it from the board, from an external source at various voltages, messing with the bit rate, and using multiple different binary file formats. They all fail with the same problem: all zeros.

I am able to program it with an AVR ISP programmer by pulling all of the needed pins out of the various headers. That didn't work at first because the ISP progamming doesn't use the MOSI and MISO pins, instead it uses PE0 for MOSI and PE1 for MISO. (See the AT90CAN manual, section 25.7.2. Cathy is a genius for figuring this out.)

Unfortunately, the six pins you have to pull out are spread across all three of the breakout headers, so it's a bit of a rat's nest when it's all wired up.

Code:
ISP signal  header   pin
----------  ------   ---
GND         JTAG      2
+5V         JTAG      4
!RESET      JTAG      6
MISO (PE1)  EXT1     14
MOSI (PE0)  EXT1     15
SCK (PB1)   EXT2     33
Using the same avrdude command (with just the programmer part changed) works perfectly every time.
 
davewill said:
tomsax said:
...They all fail with the same problem: all zeros...
It's a kind of a dumb question, but could it possibly be skipping the erase? Can you try doing a separate erase first?
I tried, that's not the problem. The erase always happens when you write flash, if you don't ask for it avrdude warns you it's doing it anyway, and you always get a message while the erase is happening. There's definitely something wrong with the JTAG ICE Mark I and the AT90CAN128 (or perhaps the AVR-CAN board).

Really I just posted to let people know it can be programmed from an ISP programmer since I saw that a number of people bought an ISP programmer.
 
Back
Top