#error "You must define USB_CFG_IOPORTNAME in usbconfig.h.."

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
madscientist
Posts: 6
Joined: Fri Feb 11, 2011 4:32 pm

#error "You must define USB_CFG_IOPORTNAME in usbconfig.h.."

Post by madscientist » Fri Feb 11, 2011 4:43 pm

Hi all,

I just started with V-USB and trying to compile the HID Mouse example to give me a starting point. I am using AVRStudio 4.16 with AVR Libc 1.6.6.

I get one error message: ../usbdrv/usbdrv.h:538:2: error: #error "You must define USB_CFG_IOPORTNAME in usbconfig.h, see usbconfig-prototype.h"

Its usbconfig.h is included (otherwise it would be an other error) and I have defined my I/O pins:

Code: Select all

/* ---------------------------- Hardware Config ---------------------------- */
#define USB_CFG_IOPORTNAME      D
/* This is the port where the USB bus is connected. When you configure it to
 * "B", the registers PORTB, PINB and DDRB will be used.
 */
#define USB_CFG_DMINUS_BIT      0
/* This is the bit number in USB_CFG_IOPORT where the USB D- line is connected.
 * This may be any bit in the port.
 */
#define USB_CFG_DPLUS_BIT       1
...


I have no idea why this error message comes up, I have tried defining the port with D, B, 0, 1 etc, same error message.

I would greatly appreciate any pointers and suggestions to solve this. It is probably something simple, or a weird bug?

madscientist
Posts: 6
Joined: Fri Feb 11, 2011 4:32 pm

Re: #error "You must define USB_CFG_IOPORTNAME in usbconfig.h.."

Post by madscientist » Fri Feb 11, 2011 9:21 pm

I commented out the error message in usbdrv.h, which revealed a load of assembler errors:

../usbdrv/usbdrvasm12.inc: Assembler messages:
../usbdrv/usbdrvasm12.inc:57: Error: constant value required
...
../usbdrv/usbdrvasm12.inc:393: Error: constant value required
make: *** [usbdrvasm.o] Error 1
Build failed with 1 errors and 0 warnings...

All these errors correlate to USBMINUS, USBDDR, USBOUT, and USBIN macros.

maxi
Rank 3
Rank 3
Posts: 122
Joined: Fri Jul 24, 2009 6:13 pm

Re: #error "You must define USB_CFG_IOPORTNAME in usbconfig.h.."

Post by maxi » Sat Feb 12, 2011 12:25 am

madscientist wrote:I commented out the error message in usbdrv.h, which revealed a load of assembler errors:
../usbdrv/usbdrvasm12.inc: Assembler messages:
../usbdrv/usbdrvasm12.inc:57: Error: constant value required

Commenting out debug messages is really not a good idea! The assembler *errors* are because, among other things, you must define USB_CFG_IOPORTNAME in usbconfig.h. I can only guess that Studio is not reading all of usbconfig.h (or not the right one) properly, perhaps a mis-placed /* somewhere?

Try instead to #define USB_CFG_IOPORTNAME at the top of usbdrv.h and tell us what the compiler reports then. Also, just try compiling using the makefile instead of AVR Studio and see if that makes any difference. (See Readme.txt)

madscientist
Posts: 6
Joined: Fri Feb 11, 2011 4:32 pm

Re: #error "You must define USB_CFG_IOPORTNAME in usbconfig.h.."

Post by madscientist » Sat Feb 12, 2011 4:35 am

I started everything from the beginning, using the makefile I get this:

Code: Select all

Loaded plugin STK500
Loaded plugin AVR GCC
Loaded partfile: C:\Program Files\Atmel\AVR Tools\PartDescriptionFiles\
Error Code: -2147467259:
gcc plug-in: Error: Object file not found on expected location C:\MouseTest\MouseTest.elf
Make sure your makefile specifies the output .elf file as MouseTest.elf



Setting up the compiler for Atmega16, 12MHz, -0s:

Code: Select all

rm -rf MouseTest_main.o usbdrvasm.o usbdrv.o  MouseTest.elf dep/* MouseTest.hex MouseTest.eep MouseTest.lss MouseTest.map
Build succeeded with 0 Warnings...
avr-gcc  -mmcu=atmega16 -Wall -gdwarf-2 -std=gnu99         -DF_CPU=12000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT MouseTest_main.o -MF dep/MouseTest_main.o.d  -c  ../MouseTest_main.c
../MouseTest_main.c: In function 'main':
../MouseTest_main.c:160: warning: implicit declaration of function 'usbInterruptIsReady'
../MouseTest_main.c:164: warning: implicit declaration of function 'usbSetInterrupt'
../MouseTest_main.c:167: warning: function declared 'noreturn' has a 'return' statement
avr-gcc  -mmcu=atmega16 -mmcu=atmega16 -Wall -gdwarf-2 -std=gnu99         -DF_CPU=12000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT usbdrvasm.o -MF dep/usbdrvasm.o.d  -x assembler-with-cpp -Wa,-gdwarf2 -c  ../usbdr
v/usbdrvasm.s

In file included from ../usbdrv/usbdrvasm.s:20:
../usbdrv/usbdrv.h:539:3: error: #error "You must define USB_CFG_IOPORTNAME in usbconfig.h, see usbconfig-prototype.h"
make: *** [usbdrvasm.o] Error 1
Build failed with 1 errors and 3 warnings...


I also tried defining it before the error message in usbdrv.h:

Code: Select all

#ifndef USB_CFG_IOPORTNAME
   #define USB_CFG_IOPORTNAME      D
   #error "You must define USB_CFG_IOPORTNAME in usbconfig.h, see usbconfig-prototype.h"
#endif


Thank you for the prompt reply!



Also: copying or moving the #define to usbdrv.h, I get the same assembler error:

Code: Select all

../usbdrv/usbdrvasm12.inc: Assembler messages:
../usbdrv/usbdrvasm12.inc:57: Error: constant value required
...
../usbdrv/usbdrvasm12.inc:312: Error: constant value required
make: *** [usbdrvasm.o] Error 1
Build failed with 1 errors and 3 warnings...

maxi
Rank 3
Rank 3
Posts: 122
Joined: Fri Jul 24, 2009 6:13 pm

Re: #error "You must define USB_CFG_IOPORTNAME in usbconfig.h.."

Post by maxi » Sat Feb 12, 2011 9:45 pm

You need to run the makefile from a console (eg MSYS) as the ones provided are not intended for use with AVRStudio. I suggest you forget about AVRStudio for now, start again with a fresh copy of V-USB and follow the instructions in Readme.txt.
BUILDING THE FIRMWARE
=====================
Change to the "firmware" directory and modify Makefile according to your
architecture (CPU clock, target device, fuse values) and ISP programmer. Then
edit usbconfig.h according to your pin assignments for D+ and D-. The default
settings are for the metaboard hardware.

Type "make hex" to build main.hex, then "make flash" to upload the firmware
to the device. Don't forget to run "make fuse" once to program the fuses. If
you use a prototyping board with boot loader, follow the instructions of the
boot loader instead.

Please note that the first "make hex" copies the driver from the top level
into the firmware directory. If you use a different build system than our
Makefile, you must copy the driver by hand.

madscientist
Posts: 6
Joined: Fri Feb 11, 2011 4:32 pm

Re: #error "You must define USB_CFG_IOPORTNAME in usbconfig.h.."

Post by madscientist » Sun Feb 13, 2011 2:19 am

Others have successfully used AVRStudio without makefiles, I would like to do the same.

I'm positive that this problem can be solved without going in circles around it. If I can't use V-USB with AVRStudio, I'm afraid I won't use it at all.

maxi
Rank 3
Rank 3
Posts: 122
Joined: Fri Jul 24, 2009 6:13 pm

Re: #error "You must define USB_CFG_IOPORTNAME in usbconfig.h.."

Post by maxi » Sun Feb 13, 2011 6:34 pm

With respect, this is a support forum for V-USB, not AVRStudio. It amazes me why so many people insist on using it when they clearly do not know how to set it up properly.

The advice I have given would atleast confirm that this is indeed an AVRStudio setup issue and not a problem with V-USB or your compiler.

For help with AVRStudio in general you could try here http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewforum&f=7 where, incidentally, someone posted a very similar question only yesterday.

madscientist
Posts: 6
Joined: Fri Feb 11, 2011 4:32 pm

Re: #error "You must define USB_CFG_IOPORTNAME in usbconfig.h.."

Post by madscientist » Sun Feb 13, 2011 11:44 pm

Believe me maxi, I did search for the problems, in fact I searched for too specific problems and didn't come across that topic.

I will try different things when I get some time on the weekend and see where it gets me.

Thank you for your comments!

maxi
Rank 3
Rank 3
Posts: 122
Joined: Fri Jul 24, 2009 6:13 pm

Re: #error "You must define USB_CFG_IOPORTNAME in usbconfig.h.."

Post by maxi » Mon Feb 14, 2011 12:00 am

A quick search for the keyword "Studio" would have uncovered this recent thread http://forums.obdev.at/viewtopic.php?f=8&t=5290&start=0&hilit=studio where I advised the OP to check out the AVR-CDC project that comes with AVRStudio project files. Maybe you can see where you went wrong.

BTW there is a big hint in the last paragraph of the passage I quoted from the readme ;)

Hope it helps.

madscientist
Posts: 6
Joined: Fri Feb 11, 2011 4:32 pm

Re: #error "You must define USB_CFG_IOPORTNAME in usbconfig.h.."

Post by madscientist » Thu Feb 17, 2011 4:22 pm

I managed to build the project with "make hex", and I could program the .hex from AVRStudio.

I tried AVR Poject IDE from Frank of USnooBie and managed to compile the code again. However, the mouse in this compilation behaves differently, which could be related to the math function and it's interpretation at compile time.

AVRStudio is still giving me errors no matter what I do.

Unfortunately I am getting sidetracked with other firmwares, but I will definitely play around and do more research on this V-USB/AVRStudio combination.

Thanks!

Augend
Posts: 3
Joined: Sat Feb 26, 2011 9:32 am

Re: #error "You must define USB_CFG_IOPORTNAME in usbconfig.h.."

Post by Augend » Sat Feb 26, 2011 9:53 am

An advice: I have spent many years of my life insisting on Assembly and things like AVRStudio and spoilng every second in codes. I really advise you to use WinAVR. you can also use it in Visual Studio and benefit from its strong Intellisense and so on.

Post Reply