Compiling Source Code for AVR-CAN

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
I am working with the free WinAVR software, currently the "Portable" version (no install needed). It is all just unzipped (or copied) to the ROOT of some drive, hard or flash.

I have mine on a USB Flash Drive, and have been using it on a Windows 32-bit Vista system.

The code is ".c", and I edit with their "Programmers Notepad". Then, using a properly-prepared "Makefile" file, it compiles, assembles, and links to make a ".hex" file, all with just one menu click.

Then, I use their AVRdude program (via a ".bat" file modified for the specific programmer I decide to use) to flash the AVR-CAN board.

I have been told that I can post the source folder, with all of its many supporting programs. I will try to remove some of the unused programs to an "Unused" sub-folder, for clarity. Then, I will zip the folder (containing SOC Meter version F1.07) and post the zip file.

NOTE: This SAME firmware is used to send CAN messages (binary, not ASCII) to the PC for viewing and logging using CAN-Do.
 
Getting WinAVR:
see
http://www.webring.org/l/rd?ring=avr;id=59;url=http%3A%2F%2Fwinavr%2Esourceforge%2Enet%2F" onclick="window.open(this.href);return false;

Prepare to use:
 
Compile ... and make Hex file:

1. Open the WinAVR "Programmers Notepad":

2. Edit: Not Yet! Get the standard SOC-Meter release version F1.07 (or later) working FIRST.

3. Make Clean: This function (on the Tool menu) erases old files that were produced by previous Compile-Link attempts. Try it to see that it works, it takes only a couple of seconds. Note the "results" down below the Edit Panel.

4. Make All: This powerful function (also on the Tool menu) also gets its instructions from the "Makefile" file (no file extension). Basically it starts with your source code (spy.c and spy.h), adds other programs and libraries, compiles, assembles, and links everything, and finally produces a "spy.hex" file that you can use to flash the AVR-CAN board. If this step completes without error, you can move on to the "flashing" step, otherwise you edit (or whatever is needed) to correct the "errors".
 
Flashing AVR-CAN with Spy.hex

1. Using "mini USB AVR JTAG" from Ebay:

2. Using AVR-Dragon:

3. Using RS232 AVR-JTAG-ICE from Ebay:
The problem here, is a "sufficiently good" RS232 port is needed. MANY of the inexpensive, easy-to-find USB-to-RS232 adapters are NOT "good enough". I have two "brands" (long ago, forgotten sources) that work 100%. However, I have purchased and tried two other sources, and one works 2% of the time, the other works 50% to 80% ... neither is recommended.
 
I have just been told that I can post our source-code folder, with
the needed supporting programs that are not in the library.

I will try to move some of the unused programs to an "Unused" sub-folder, for clarity.
Then, I will zip the folder (containing SOC Meter version F1.07) and post the zip file.

NOTE: This SAME firmware is used to send CAN messages (binary, not ASCII)
to the PC for viewing and logging using CAN-Do.

IMPORTANT:
If you change the program for your own uses, PLEASE DISPLAY a different
version number
when the program starts. I am using the F1.xx series.
For Home-Made versions, I suggest the "H" series, something like "H0.01".

If you do NOT do this, and there are several/many different "F1.07" (etc.)
versions floating around, it will be IMPOSSIBLE to help people with problems.
 
I was always getting an error in AVR Studio 4 (which uses WinAVR) when compiling. A bit of searching led me to this important piece of information.

The error I got on Win 7 64 bit was this.

make: Interrupt/Exception caught (code = 0xc00000fd, addr = 0x4217b3

In a 64 bit OS, 23 bit software should be installed under "Program Files (x86)" directory. Turns out, WinAVR doesn't like brackets and other stuff in the directory path. Here is the solution that worked. Now I can build, deploy & debug using AVR Studio 4.

http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=64657

CMD with "Run As Administrator"
cd C:\Program Files
mklink /D WinAVR "..\Program Files (x86)\WinAVR"

Change the reg key @
"HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\WinAVR" to the new reference.

UninstallString = c:\Program Files\WinAVR\WinAVR-20090313-uninstall.exe

After that... I can build WinAvr GCC from AVRStudio on x64 Windows 7.

Alternatively, you could install WinAVR under the suggested c:\winavr directly. But that idea doesn't agree with me - aesthetically. I like to keep my directory structures clean :lol:

ps : Moving my post to keep Gary's posts in the beginning.
 
evnow,
Thanks for moving the post.

I used "WinAVR Portable" which needs NO install at all.

One just unzips "Portable" to the root of some drive,
and I used a USB flash drive.
 
evnow said:
Turns out, WinAVR doesn't like brackets and other stuff in the directory path.

Wow! What a POS. Nobody updated it even for Windows XP? Is it a ported Win16 program, using short names? Or is it just not using a Windows Installer compatible installer?

One thing you can do with programs like this (and programs that want to run "at the root" rather than just figuring out where they run using GetModuleInformation()) is to use the DOS "Subst" command.

Open a Command Prompt window (perhaps in administrative mode) and give the command:

SUBST Q: "C:\Program Files (x86)\YourProgram"

Now, the "drive" Q: shows up, and contains anything in YourProgram. Hopefully, it should be able to deal with that...
 
jwatte said:
Now, the "drive" Q: shows up, and contains anything in YourProgram. Hopefully, it should be able to deal with that...
The problem is the directory name "(86)" than being in the route. Anyway, it is an open source pgm ... I guess nobody wants to clean it up.
 
Right!

Subst will let the program see the path "Q:\" which hopefully is to its liking...

Jw
 
If you are having difficulties, you might want to try "Portable WinAVR" on a flash drive. It has been working just fine for me on 32-bit Vista, from the root of a flash drive, no install needed.

From your comments, it is not clear what program/version/system/install you are having problems with.
 
Back
Top