Compiling using avr-gcc errors

Go To Last Post
14 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm trying to compile a simple project to program some of my ATMEGA uCs. When I run it I get this output:

Quote:

Build succeeded with 0 Warnings...
avr-gcc.exe -mmcu=avr5 -Wall -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT test.o -MF dep/test.o.d -c ../test.c
cc1: error: invalid option `mcu=avr5'

I'm doing this using AVR Studio 4.13 SP1 with the WinAVR 20070525 build on Windows Vista 32-bit. I've tried multiple values in make for MCU for 3 of my different uCs as well as levels like 'avr5' and none of them work. This happens on any project I try to build, including my new one, ones from this site, and even some old projects that I knew previously compiled.

Going to the \bin directory in WinAVR and running avr-gcc.exe directly with a dummy output gives the same output:

Quote:
C:\WinAVR\bin>avr-gcc -mmcu=atmega16 main.c
cc1: error: invalid option `mcu=atmega16'

Emphases are mine.

Any thoughts? Thanks in advance.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just use mfile to create a makefile for you. It will set all of the options correctly for you. Just select what you need from the menu.

Regards,
Steve A.

The Board helps those that help themselves.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for your reply, Koshchi.
I used the Python-looking mfile program to customize all of the settings and then use that makefile for my project. I get the same response

Quote:
avr-gcc -c -mmcu=atmega16 -I. -gdwarf-2 -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=./ledwalking.lst -std=gnu99 -Wundef -MMD -MP -MF .dep/ledwalking.o.d ledwalking.c -o ledwa
lking.o

cc1: error: invalid option `mcu=atmega16'

Which is to be expected I guess because the parameter "mmcu=blah" is still passed to avr-gcc.exe. Is there a better way to compile it without specifying the target architecture?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It looks like a Vista type of problem. Maybe do a search here on Vista and WinAvr.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I see nothing obvious wrong. My guess is that something is not set up correctly for avr-gcc. atmega16 is certainly the correct value to pass for mcu.

Regards,
Steve A.

The Board helps those that help themselves.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Add a -v to the list of compiler options. I guess it's somehow calling
the wrong compiler backend (in the assumption you've got more than one
cc1.exe on your system).

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Maybe also try typing the command "which cc1.exe" at a command prompt as this will tell you which copy MS-DOS (oops, sorry, Windows Vista) will run - in other words which one is found first in the PATH.

Cliff

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm on XP and not running the Vista + Avr Studio + WinAvr20070525 combo (although I have it on a Vista pc, but don't use it), but does Avr Studio (or avr-gcc and make) even need PATH? I'm not so sure.

The reason I say that is I use both 20070525 and 20060421 in a 'portable' directory (not c:\winavr), and use a 'subst' batch file to map a drive to the one I want to use. In Avr Studio under Custom Options->External tools, I have both avr-gcc.exe and make.exe pointing to the folders in the 'subst' drive. I switch back and forth and compile for each version of gcc without leaving Studio. No system PATH set to anything to do with winavr. I can also drop to a command prompt (with quick path command to set to the bin + bin/util on the subst drive) and do the same thing.

I think I also tried this on Vista, but didn't get very far of course, because the older version will not work anyway (although I was switching back and forth, would just get errors on the older version).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You guys nailed it. Another version of cc1 left over from MSYS was higher up in the path.

Now I'm getting this problem at the linking stage:

Quote:

ld -o ledwalking.elf crtm161.o -LC:/WinAVR/avr/lib -LC:/WinAVR/avr/lib/avr5 ledwalking.o -Map=ledwalking.map --cref -lm -lgcc -lc -lgcc
ld: crtm161.o: No such file: No such file or directory

crtm161.o is in the C:/WinAVR/avr/lib/avr5
and "which ld" points me to the WinAVR one. I'm really at a loss for what's going on. I think my environment variables may still be screwed up. Should I just uninstall MSYS and cygwin at this point and try to reinstall WinAVR?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You shouldn't have to uninstall MSYS and Cygwin to use WinAVR. I have both MSYS and Cygwin on my system and I *build* and use WinAVR all the time without problems.

Are you calling the ld program directly? Or are you linking via an avr-gcc command line (in a Makefile)?

What environment variables do you have?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm calling ld from avr-gcc in a makefile, what I was pasting is the console output of just that portion. Here is the avr-gcc line:

avr-gcc -mmcu=avr5 -I. -gdwarf-2 -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=ledwalking.o -IC:/WinAVR/avr/include -std=gnu99 -Wundef -MMD -MP -MF .dep/ledwalking.elf.d ledwalk
ing.o --output ledwalking.elf -Wl,-Map=ledwalking.map,--cref  -L"C:/WinAVR/avr/lib" -L"C:/WinAVR/avr/lib/avr5"   -lm --verbose

Here are my environment variables:

Quote:
ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\Steve\AppData\Roaming
ASCODIR=C:\Program Files\Qucs
CDSROOT=C:\OrCAD\OrCAD_10.5
CDS_LIC_FILE=27001@stevep4
CommonProgramFiles=C:\Program Files\Common Files
COMPUTERNAME=steveP4
ComSpec=C:\Windows\system32\cmd.exe
CPATH=c:\usr\local\include;c:\usr\include;c:\mingw\include
FP_NO_HOST_CHECK=NO
GCC_EXEC_PREFIX=C:\MinGW
HOME=c:\home\Steve
HOMEDRIVE=C:
HOMEPATH=\Users\Steve
LIBRARY_PATH=C:\WinAVR\avr\lib;c:\usr\local\lib;C:\WinAVR\avr\lib;c:\usr\local\lib\avr5;c:\usr\lib;c:\mingw\lib
LOCALAPPDATA=C:\Users\Steve\AppData\Local
LOGONSERVER=\\steveP4
NUMBER_OF_PROCESSORS=1
OS=Windows_NT
PALMSOURCE_PODS_1_1=C:\Program Files\ACCESS\Garnet OS Development Suite\
Path=C:\WinAVR\bin;C:\WinAVR\utils\bin;C:\WinAVR\avr\bin;C:\WinAVR\avr\lib;C:\WinAVR\libexec\gcc\avr\4.1.2;C:\Windows\system32;C:\Windows;C:\Windws\system32\wbem;c:\progra~1\securefx;C:\MinGW\bin;C:\MinGW\libexec\gcc\mingw32\3.4.2;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Python25;C:\WinAVR\bin;C:\WinAVR\utils\bin;c:\usr\local\bin;c:\usr\bin;c:\mingw\bin
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PROCESSOR_ARCHITECTURE=x86
PROCESSOR_IDENTIFIER=x86 Family 15 Model 2 Stepping 4, GenuineIntel
PROCESSOR_LEVEL=15
PROCESSOR_REVISION=0204
ProgramData=C:\ProgramData
ProgramFiles=C:\Program Files
PROMPT=$P$G
PUBLIC=C:\Users\Public
QUCSDIR=C:\Program Files\Qucs
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\Windows
TEMP=C:\Users\Steve\AppData\Local\Temp
TMP=C:\Users\Steve\AppData\Local\Temp
USERDOMAIN=stevep4
USERNAME=Steve
USERPROFILE=C:\Users\Steve
windir=C:\Windows

EW at least your setup gives me confidence that I can make them coexist in harmony without too much more effort. That's good, it's not like uninstalling Cygwin is easy anyway :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
GCC_EXEC_PREFIX=C:\MinGW

Blow that away.

Quote:
That's good, it's not like uninstalling Cygwin is easy anyway

Actually, it's fairly easy to uninstall Cygwin. It's just *very* time-consuming. And then if you want to *re-install* Cygwin, well... ;)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Try this if you want-

change this to point to avr-gcc/make (copy/paste the whole winavr folder to some other location), then create a little test app and also use the avr studio generated makefile.

I only know that I can put winavr anywhere I want and point to those 2 files in the custom options, and compile away. No PATH. No winavr install. And on a Vista laptop.

On another PC, I do the same thing, but have an install of winavr (20060424) so if I don't change the custom options, I'm using the 'old' version.

Dropping to the command line works also. I just create a batch file with the needed path command, and run it. The path is local to the cmd process, so does not 'interfere' with anything else.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It works! IT Works!!! Thanks EW, clearing that statement made it build successfully!