Page 1 of 1

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

Posted: Fri Feb 11, 2011 4:43 pm
by madscientist
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?

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

Posted: Fri Feb 11, 2011 9:21 pm
by madscientist
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.

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

Posted: Sat Feb 12, 2011 12:25 am
by maxi
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)

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

Posted: Sat Feb 12, 2011 4:35 am
by madscientist
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...

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

Posted: Sat Feb 12, 2011 9:45 pm
by maxi
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.

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

Posted: Sun Feb 13, 2011 2:19 am
by madscientist
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.

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

Posted: Sun Feb 13, 2011 6:34 pm
by maxi
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.

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

Posted: Sun Feb 13, 2011 11:44 pm
by madscientist
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!

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

Posted: Mon Feb 14, 2011 12:00 am
by maxi
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.

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

Posted: Thu Feb 17, 2011 4:22 pm
by madscientist
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!

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

Posted: Sat Feb 26, 2011 9:53 am
by Augend
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.