PROGMEM issue with avr-gcc 4.6.2

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This used to work fine with avr-gcc 4.3.3, but now I get

error: variable 'all_tables' must be const in order to be put into read-only section by means of '__attribute__((progmem))'

#include 
#include 

const uint16_t table0[] PROGMEM = {0,1,2};
const uint16_t table1[] PROGMEM = {0,1,2};
const uint16_t* all_tables[] PROGMEM = {table0, table1};

int main()
{
  return 1;
}
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Almost everything has been asked and discussed before. You could have had the answer directly if you had used the forum search function, had entered "must be const in order to be put into read-only section" and ticked "Search for all terms".

The fifth hit for this search is https://www.avrfreaks.net/index.p... where I believe you will find the solution to your problem.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for taking the time to help. I was trying to search for it in the forum, but not doing a good job of it I see.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

kayrock wrote:
Thanks for taking the time to help. I was trying to search for it in the forum, but not doing a good job of it I see.
To be fair, the search facility on the site is a bit weak. The quick-search field in the left-hand margin is especially poor.

It's not obvious, but the better search option is the 'search forum' button at the top of each forum page. Follow @JohanEkdahl's advice on how to use it.

Alternately, and often better, is a google search with site:www.avrfreaks.net tacked onto the end.

JJ

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You can read the GCC release notes:

    "On AVR, variables with the progmem attribute to locate data in flash memory must be qualified as const."
In your case the object is all_tables. Just add a const to it.

avrfreaks does not support Opera. Profile inactive.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So write

const uint16_t* const all_tables[] PROGMEM = {table0, table1};

with `const` twice.