avr-gcc: variable must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’

给你一囗甜甜゛ 提交于 2019-12-04 21:23:08

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.

I know this post is a bit hold. But this may help someone.

The reason for that error is that new avr-gcc needs PROGMEM to be const. You just need to put const in front of every line that begins with PROGMEM .

Sed fixes this nicely with sed -i 's/^PROGMEM/const PROGMEM/g' usbdrv/*.

You have not given the code where the error comes out but by just seeing the error message, the problem is very clear

./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))’

you can only put constants in the read-only section (flash for example). All variables go to RAM. Therefore if you want that "usbDescriptorDevice" (which I dont know what it does) goes in the read only section (because you are putting "progrmem") you should declare that as constant.

The problem usually appears with old libraries that don't comply with this simple rule.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!