won't compile - variable must be const

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
funkenregen
Posts: 2
Joined: Sat Feb 04, 2012 6:13 pm

won't compile - variable must be const

Post by funkenregen » Sat Feb 04, 2012 6:19 pm

hi i am trying to compile an example but i get errors when executing 'make hex'.
the machine is fedora f16, avr-gcc (Fedora 4.6.2-1.fc16) 4.6.2

output:

Code: Select all


[...]vusb-20120109/examples/hid-data/firmware % make hex
avr-gcc -Wall -Os -DF_CPU=16500000    -Iusbdrv -I. -DDEBUG_LEVEL=0 -mmcu=attiny45 -c usbdrv/usbdrv.c -o usbdrv/usbdrv.o
In file included from usbdrv/usbdrv.c:12:0:
usbdrv/usbdrv.h:455:6: error: variable 'usbDescriptorDevice' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
usbdrv/usbdrv.h:461:6: error: variable 'usbDescriptorConfiguration' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
usbdrv/usbdrv.h:467:6: error: variable 'usbDescriptorHidReport' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
usbdrv/usbdrv.h:473:6: error: variable 'usbDescriptorString0' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
usbdrv/usbdrv.h:479:5: error: variable 'usbDescriptorStringVendor' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
usbdrv/usbdrv.h:485:5: error: variable 'usbDescriptorStringDevice' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
usbdrv/usbdrv.h:491:5: error: variable 'usbDescriptorStringSerialNumber' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
usbdrv/usbdrv.c:70:14: error: variable 'usbDescriptorString0' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
usbdrv/usbdrv.c:80:14: error: variable 'usbDescriptorStringVendor' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
usbdrv/usbdrv.c:89:14: error: variable 'usbDescriptorStringDevice' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
usbdrv/usbdrv.c:111:14: error: variable 'usbDescriptorDevice' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
usbdrv/usbdrv.c:142:14: error: variable 'usbDescriptorConfiguration' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
make: *** [usbdrv/usbdrv.o] Error 1


is this a beginners mistake or is something broken on my machine?

thanks in advance,
funkenregen
Last edited by funkenregen on Mon Feb 06, 2012 7:38 pm, edited 1 time in total.

funkenregen
Posts: 2
Joined: Sat Feb 04, 2012 6:13 pm

Re: won't compile

Post by funkenregen » Mon Feb 06, 2012 7:37 pm

i fixed it myself with some help of the trusty interwebs.

newer avr-gcc versions demand that everything put in progmem is defined const [1].
so i just put a const in front of every PROGMEM line where the compiler complained. changes were necessary in usbdrv.h, usbdrv.c and the main program (the usbHidReportDescriptor is in progmem too).

now everything works fine.
i think this change would be very easy to implement and would not break backwards compatibility.

i hope this helps anyone who encounters this problem sometime in the future.

regards, funkenregen

----
[1] http://old.nabble.com/VUSB-problem-td32560584.html

trmcderm

Re: won't compile - variable must be const

Post by trmcderm » Mon Aug 13, 2012 3:30 am

Thanks! Just had the same problem.

abd_rmdn

Re: won't compile - variable must be const

Post by abd_rmdn » Thu Aug 23, 2012 11:29 am

i had this problem and i did what u did....but the problem is that the circuit isnt working
i check my circuit like 200 times ..... i tried every possible circuit and still no changes ...
could it be because of the "const"...!!?!
i mean i even bought another MCU "atmega8" instead of the one i have "atmega32A".... and still nothing is working ??!
it keeps saying ::
-----------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------"USB Device not Recognized"-------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------
i'm really kind of desperate right now !!....
do u have any suggestion .....?!
im not using the makeFile .... does this effects my code ....?!

hope u've got any new ideas i can benefit of ... :)
thanks in advance.

Post Reply