random_number
Member
Hello,
I am a new Teensy 3.2 owner and Im just getting started understanding how to use this amazing little guy.
I am on Ubuntu trying to compile the blinky example, but this error was appearing.
I searched and found this reference:
https://github.com/arduino/Arduino/wiki/1.6-Frequently-Asked-Questions
which says :
So I added const... Seems to compile:
I was able to compile a hex file and load it.. unfortunately, I don't know Morse code... so I'm not sure if the blink pattern is correct.
I am a new Teensy 3.2 owner and Im just getting started understanding how to use this amazing little guy.
I am on Ubuntu trying to compile the blinky example, but this error was appearing.
Code:
blinky$ make
-------- begin --------
avr-gcc (GCC) 5.4.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Compiling C: blinky.c
avr-gcc -c -mmcu=atmega32u4 -I. -gdwarf-2 -DF_CPU=16000000UL -Os -funsigned-char -funsigned-bitfields -ffunction-sections -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=./blinky.lst -std=gnu99 -MMD -MP -MF .dep/blinky.o.d blinky.c -o blinky.o
Compiling C: usb_debug_only.c
avr-gcc -c -mmcu=atmega32u4 -I. -gdwarf-2 -DF_CPU=16000000UL -Os -funsigned-char -funsigned-bitfields -ffunction-sections -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=./usb_debug_only.lst -std=gnu99 -MMD -MP -MF .dep/usb_debug_only.o.d usb_debug_only.c -o usb_debug_only.o
usb_debug_only.c:96:24: error: variable ‘device_descriptor’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’
static uint8_t PROGMEM device_descriptor[] = {
^
usb_debug_only.c:113:24: error: variable ‘hid_report_descriptor’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’
static uint8_t PROGMEM hid_report_descriptor[] = {
^
usb_debug_only.c:128:24: error: variable ‘config1_descriptor’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’
static uint8_t PROGMEM config1_descriptor[CONFIG1_DESC_SIZE] = {
^
usb_debug_only.c:175:52: error: variable ‘string0’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’
static struct usb_string_descriptor_struct PROGMEM string0 = {
^
usb_debug_only.c:180:52: error: variable ‘string1’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’
static struct usb_string_descriptor_struct PROGMEM string1 = {
^
usb_debug_only.c:185:52: error: variable ‘string2’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’
static struct usb_string_descriptor_struct PROGMEM string2 = {
^
usb_debug_only.c:198:11: error: variable ‘descriptor_list’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’
} PROGMEM descriptor_list[] = {
^
make: *** [Makefile:550: usb_debug_only.o] Error 1
Code:
blinky$ avr-gcc -v
Using built-in specs.
Reading specs from /usr/lib/gcc/avr/5.4.0/device-specs/specs-avr2
COLLECT_GCC=avr-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/avr/5.4.0/lto-wrapper
Target: avr
Configured with: ../gcc/configure -v --enable-languages=c,c++ --prefix=/usr/lib --infodir=/usr/share/info --mandir=/usr/share/man --bindir=/usr/bin --libexecdir=/usr/lib --libdir=/usr/lib --enable-shared --with-system-zlib --enable-long-long --enable-nls --without-included-gettext --disable-libssp --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=avr CFLAGS='-g -O2 -fdebug-prefix-map=/build/gcc-avr-cb8hC_/gcc-avr-5.4.0+Atmel3.6.1=. -fstack-protector-strong -Wformat ' CPPFLAGS='-Wdate-time -D_FORTIFY_SOURCE=2' CXXFLAGS='-g -O2 -fdebug-prefix-map=/build/gcc-avr-cb8hC_/gcc-avr-5.4.0+Atmel3.6.1=. -fstack-protector-strong -Wformat ' FCFLAGS='-g -O2 -fdebug-prefix-map=/build/gcc-avr-cb8hC_/gcc-avr-5.4.0+Atmel3.6.1=. -fstack-protector-strong' FFLAGS='-g -O2 -fdebug-prefix-map=/build/gcc-avr-cb8hC_/gcc-avr-5.4.0+Atmel3.6.1=. -fstack-protector-strong' GCJFLAGS='-g -O2 -fdebug-prefix-map=/build/gcc-avr-cb8hC_/gcc-avr-5.4.0+Atmel3.6.1=. -fstack-protector-strong' LDFLAGS='-Wl,-Bsymbolic-functions -Wl,-z,relro' OBJCFLAGS='-g -O2 -fdebug-prefix-map=/build/gcc-avr-cb8hC_/gcc-avr-5.4.0+Atmel3.6.1=. -fstack-protector-strong -Wformat ' OBJCXXFLAGS='-g -O2 -fdebug-prefix-map=/build/gcc-avr-cb8hC_/gcc-avr-5.4.0+Atmel3.6.1=. -fstack-protector-strong -Wformat '
Thread model: single
gcc version 5.4.0 (GCC)
I searched and found this reference:
https://github.com/arduino/Arduino/wiki/1.6-Frequently-Asked-Questions
which says :
A: The latest avr-gcc compiler (used by Arduino 1.6.x) requires that variables in PROGMEM to be declared as const.
So I added const... Seems to compile:
Code:
blinky$ diff usb_debug_only.c usb_debug_only.c-original
96c96
< const static uint8_t PROGMEM device_descriptor[] = {
---
> static uint8_t PROGMEM device_descriptor[] = {
113c113
< const static uint8_t PROGMEM hid_report_descriptor[] = {
---
> static uint8_t PROGMEM hid_report_descriptor[] = {
128c128
< const static uint8_t PROGMEM config1_descriptor[CONFIG1_DESC_SIZE] = {
---
> static uint8_t PROGMEM config1_descriptor[CONFIG1_DESC_SIZE] = {
175c175
< const static struct usb_string_descriptor_struct PROGMEM string0 = {
---
> static struct usb_string_descriptor_struct PROGMEM string0 = {
180c180
< const static struct usb_string_descriptor_struct PROGMEM string1 = {
---
> static struct usb_string_descriptor_struct PROGMEM string1 = {
185c185
< const static struct usb_string_descriptor_struct PROGMEM string2 = {
---
> static struct usb_string_descriptor_struct PROGMEM string2 = {
198c198
< } const PROGMEM descriptor_list[] = {
---
> } PROGMEM descriptor_list[] = {
I was able to compile a hex file and load it.. unfortunately, I don't know Morse code... so I'm not sure if the blink pattern is correct.