avr-gcc:变量必须是const才能通过'__attribute __((progmem))'被放入只读区段中 [英] avr-gcc: variable must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’

查看:895
本文介绍了avr-gcc:变量必须是const才能通过'__attribute __((progmem))'被放入只读区段中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试复制此四键式键盘,以及我试图通过编译其源来编译它在我的Linux机器上安装了avr-gcc。

我设法解决了编译器抛出的一些错误,通过用参数扩展命令行,但现在我坚持使用下面的错误。事情是, V-USB 上的很多演示项目都使用相同的库和抛出相同的错误,我不想通过所有的代码来尝试修复它们,以解决我想要检查的每个项目。我意识到最好的方法是修复源代码中的错误,但尽管下面的错误可以被轻易地解决,但新的错误被抛出,要解决更复杂的我的问题是:avr-gcc是否有一些兼容性命令行参数可以让代码编译就像它是旧版本的gcc一样?



这是我用来编译源代码的命令:

  avr-gcc main.c -I / usr / lib / avr / include / -mmcu = attiny85 -DF_CPU = 16000000 -Os -I ./usbdrv 

这些是由avr-gcc抛出的错误:

 在main.c中包含的文件中:32:0:
./usbdrv/usbdrv.h:455:6:错误:变量'usbDescriptorDevice'必须是const才能放入只读文件中只有部分通过'__attribute __((progmem))'
./usbdrv/usbdrv.h:461:6:error:vari为了通过'__attribute __((progmem))'
./usbdrv/usbdrv.h:467:6:error:变量'usbDescriptorHidReport'将'usbDescriptorConfiguration'设置为只读属性,必须是常量才能通过'__attribute __((progmem))'
./usbdrv/usbdrv.h:473:6:error:变量'usbDescriptorString0'必须为常量通过'__attribute __((progmem))'
./usbdrv/usbdrv.h:479:5:error:变量'usbDescriptorStringVendor'必须是常量才能被放入只读部分通过'__attribute __((progmem))'
./usbdrv/usbdrv.h:485:5:error:变量'usbDescriptorStringDevice'必须为常量才能被置于只读区域部分通过'__attribute __((progmem))'
./usbdrv/usbdrv.h:491:5:error:变量'usbDescriptorStringSerialNumber'必须为常量,以便通过__attrib ute __((progmem))'
main.c:105:14:error:变量'usbDescriptorHidReport'必须是常量才能通过'__attribute __((progmem))'

我的配置:


Ubuntu 13.10

avr-gcc(GCC)4.7.2 h2_lin>解决方案

usbdrv / 目录需要更新到最新版本。下载V-USB tarball或zip文件,并将项目的 usbdrv / 替换为归档文件。您可能需要对项目的 usbconfig.h >进行一点处理,以便使新的V-USB能够与现有项目一起工作,但大多数时候它应该可以正常工作。

I am trying to reproduce this 4-key-keyboard and for that I am trying to compile its source by compiling it with avr-gcc on my Linux box.

I managed to solve a couple errors thrown by the compiler by extending the command line with paramaters, but now I am stuck with the errors below. Thing is that quite a few demo projects on V-USB use the same libraries and throw the same errors and I don't want to wrestle through all the code to try and fix them for every project I want to check out. I realize the best way to go is to fix the errors in the source code, but although the errors below can trivially be solved, new errors are thrown that are much more complicated to solve and with all changes to the source code I have no guarantee that the resulting program will still actually work.

My question is: Does avr-gcc have some compatibility command line parameter that makes the code compile as if it was an older version of gcc?

This is the command I use to compile the sources:

avr-gcc main.c -I /usr/lib/avr/include/ -mmcu=attiny85 -DF_CPU=16000000 -Os -I ./usbdrv

These are the errors thrown by avr-gcc:

In file included from main.c:32: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))’
main.c:105:14: error: variable ‘usbDescriptorHidReport’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’

My configuration:

Ubuntu 13.10

avr-gcc (GCC) 4.7.2

解决方案

The usbdrv/ directory needs to be updated to the latest version. Download the V-USB tarball or zip file and replace the project's usbdrv/ with the one from the archive. You may need to massage the project's usbconfig.h a bit in order to make the new V-USB work with the existing project, although most of the time it should just work.

这篇关于avr-gcc:变量必须是const才能通过'__attribute __((progmem))'被放入只读区段中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆