Страница 1 из 1

Портирование USBHidGenericDemo (AVR328) в Atmel Studio 6.1

Добавлено: Вт апр 08, 2014 23:16:12
greend
Доброго времени суток. Столкнулся с проблемой невозможности портирования атмеловских примеров кода из AS4 в AS6. Аппноут AVR328, по всей видимости, писался под старые редакции AVR-GCC. В соответствии с этим документом импортирую проект и получаю на выходе следующие ошибки:
СпойлерError 1 variable 'usb_dev_desc' must be const in order to be put into read-only section by means of '__attribute__((progmem))' C:\Users\Ivan\Desktop\STK526-series2-hidio-2_0_2-doc\demo\STK526-series2-hidio\usb_specific_request.h 54 39 STK526-series2-hidio
Error 2 variable 'usb_conf_desc' must be const in order to be put into read-only section by means of '__attribute__((progmem))' C:\Users\Ivan\Desktop\STK526-series2-hidio-2_0_2-doc\demo\STK526-series2-hidio\usb_specific_request.h 55 51 STK526-series2-hidio
Error 3 variable 'usb_user_manufacturer_string_descriptor' must be const in order to be put into read-only section by means of '__attribute__((progmem))' C:\Users\Ivan\Desktop\STK526-series2-hidio-2_0_2-doc\demo\STK526-series2-hidio\usb_specific_request.h 56 52 STK526-series2-hidio
Error 4 variable 'usb_user_product_string_descriptor' must be const in order to be put into read-only section by means of '__attribute__((progmem))' C:\Users\Ivan\Desktop\STK526-series2-hidio-2_0_2-doc\demo\STK526-series2-hidio\usb_specific_request.h 57 47 STK526-series2-hidio
Error 5 variable 'usb_user_language_id' must be const in order to be put into read-only section by means of '__attribute__((progmem))' C:\Users\Ivan\Desktop\STK526-series2-hidio-2_0_2-doc\demo\STK526-series2-hidio\usb_specific_request.h 61 33 STK526-series2-hidio

С этим все, вроде, понятно. Указываю модификатор const в каждом случае... и получаю ошибки несоответствия типов (conflicting type qualifiers):
СпойлерError 1 variable 'usb_dev_desc' must be const in order to be put into read-only section by means of '__attribute__((progmem))' C:\Users\Ivan\Desktop\STK526-series2-hidio-2_0_2-doc\demo\STK526-series2-hidio\usb_descriptors.c 69 30 STK526-series2-hidio
Error 2 conflicting type qualifiers for 'usb_dev_desc' C:\Users\Ivan\Desktop\STK526-series2-hidio-2_0_2-doc\demo\STK526-series2-hidio\usb_descriptors.c 69 30 STK526-series2-hidio
Error 4 variable 'usb_conf_desc' must be const in order to be put into read-only section by means of '__attribute__((progmem))' C:\Users\Ivan\Desktop\STK526-series2-hidio-2_0_2-doc\demo\STK526-series2-hidio\usb_descriptors.c 88 42 STK526-series2-hidio
Error 5 conflicting type qualifiers for 'usb_conf_desc' C:\Users\Ivan\Desktop\STK526-series2-hidio-2_0_2-doc\demo\STK526-series2-hidio\usb_descriptors.c 88 42 STK526-series2-hidio
Error 7 variable 'usb_user_manufacturer_string_descriptor' must be const in order to be put into read-only section by means of '__attribute__((progmem))' C:\Users\Ivan\Desktop\STK526-series2-hidio-2_0_2-doc\demo\STK526-series2-hidio\usb_descriptors.c 143 43 STK526-series2-hidio
Error 8 conflicting type qualifiers for 'usb_user_manufacturer_string_descriptor' C:\Users\Ivan\Desktop\STK526-series2-hidio-2_0_2-doc\demo\STK526-series2-hidio\usb_descriptors.c 143 43 STK526-series2-hidio
Error 10 variable 'usb_user_product_string_descriptor' must be const in order to be put into read-only section by means of '__attribute__((progmem))' C:\Users\Ivan\Desktop\STK526-series2-hidio-2_0_2-doc\demo\STK526-series2-hidio\usb_descriptors.c 152 38 STK526-series2-hidio
Error 11 conflicting type qualifiers for 'usb_user_product_string_descriptor' C:\Users\Ivan\Desktop\STK526-series2-hidio-2_0_2-doc\demo\STK526-series2-hidio\usb_descriptors.c 152 38 STK526-series2-hidio
Error 13 variable 'usb_user_language_id' must be const in order to be put into read-only section by means of '__attribute__((progmem))' C:\Users\Ivan\Desktop\STK526-series2-hidio-2_0_2-doc\demo\STK526-series2-hidio\usb_descriptors.c 175 24 STK526-series2-hidio
Error 14 conflicting type qualifiers for 'usb_user_language_id' C:\Users\Ivan\Desktop\STK526-series2-hidio-2_0_2-doc\demo\STK526-series2-hidio\usb_descriptors.c 175 24 STK526-series2-hidio
Error 16 variable 'usb_hid_report_descriptor' must be const in order to be put into read-only section by means of '__attribute__((progmem))' C:\Users\Ivan\Desktop\STK526-series2-hidio-2_0_2-doc\demo\STK526-series2-hidio\usb_descriptors.c 182 34 STK526-series2-hidio

В приведенном архиве файлы проекта находятся во вложенном архиве STK526-series2-hidio-2_0_2-doc.
Буду крайне признателен за любую помощь в устранении ошибок, а так же за пояснения по конструкциям языка (особенно интересуют ключевые слова code и принцип, по которому переопределяются типы в строках, вызвавших ошибки).

Re: Портирование USBHidGenericDemo (AVR328) в Atmel Studio 6

Добавлено: Ср апр 09, 2014 00:06:14
greend
greend писал(а):Указываю модификатор const в каждом случае... и получаю ошибки несоответствия типов (conflicting type qualifiers).

Проблема решилась. В случае с этим проектом и остальными, основанными на нем, правки требует как заголовок usb_specific_request.h, так и файл кода usb_descriptors.c
Для каждой из ошибок требуется применить такие правки:

Код: Выделить всё

usb_specific_request.h:

extern code S_usb_device_descriptor const usb_dev_desc;

usb_descriptors.c:

const code S_usb_device_descriptor usb_dev_desc =
{
...
};