store an array of variables in flash memory

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

I have an array which i want to put it in the flash.
That is an array of static const uint32_t variable.
How do i check that it is in flash? I tried to find it in the map file. I could not find my array.

static const prog_uint32_t  array[10] = {
10, 20, 30, 40, 50, 60, 70, 80, 90, 100};

But When i change the declaration as

const prog_uint32_t  array[10] = {
10, 20, 30, 40, 50, 60, 70, 80, 90, 100};
I found my  array in progmem.data 

Can't we store an static const array in flash? any help???

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

Use the PROGMEM attribute.

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

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

I tried that. But I cound not find my variable in my map file when it is declared with static .I can see the array only when it's without static declaration. Where it is stored when declared with static?

static const unsigned int  array[10] PROGMEM = {
10, 20, 30, 40, 50, 60, 70, 80, 90, 100}; 

MBedder wrote:
Use the PROGMEM attribute.

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

There's a tutorial on the use of progmem in the tutorials section.

Edit: that's where mbedder linked you to! Progmem attribute goes before the var name.

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

I see no mention of what compiler we're talking about, and we're in the general AVR Forum. W/o that info there is no definite answer to the original question.

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

I am trying to put an array in atmega169 flash.

JohanEkdahl wrote:
I see no mention of what compiler we're talking about, and we're in the general AVR Forum. W/o that info there is no definite answer to the original question.

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

JohanEkdahl wrote:
I see no mention of what compiler we're talking about, and we're in the general AVR Forum. W/o that info there is no definite answer to the original question.

as we still do not know what toolchain(compiler) you are using.... we have to now asume you use the world famous 'joppie' compiler.
If you use that why then not follow the tutorial mbedder send you to to see how you can put all you want in flash?
If you use any other compiler then you need to see its manual too to see what the differences are in the tutorial compared to the tool chain you are using.

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

In genral, How do I make sure my array in stored in Flash memory after using PROGMEM?

dolphin@gmx.com wrote:
I am trying to put an array in atmega169 flash.
JohanEkdahl wrote:
I see no mention of what compiler we're talking about, and we're in the general AVR Forum. W/o that info there is no definite answer to the original question.

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

I am using avr-gcc compiler.

meslomp wrote:
JohanEkdahl wrote:
I see no mention of what compiler we're talking about, and we're in the general AVR Forum. W/o that info there is no definite answer to the original question.

as we still do not know what toolchain(compiler) you are using.... we have to now asume you use the world famous 'joppie' compiler.
If you use that why then not follow the tutorial mbedder send you to to see how you can put all you want in flash?
If you use any other compiler then you need to see its manual too to see what the differences are in the tutorial compared to the tool chain you are using.

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

Do you use it for anything dynamic?
If you don't use it or only with a [const] the compiler/optimizer will remove it.

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

dolphin@gmx.com wrote:
In genral, How do I make sure my array in stored in Flash memory after using PROGMEM?

with this question I really ask myself if you even took one split second in looking at the tutorial that we now point you to for the third time......

!!!! READ THE TUTORIAL !!!!

and then come back and ask this question again........

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

Why would you ever expect to "see" a 'static' listed in the .map file? The whole point of using 'static' is to limit its name scope so it's not "public" in the link. And the .map file just reports the public symbols the linker has seen.

If you want to check whether things are located where you expect in the .map file then temporarily remove the 'static' modifier.

BTW as it's now established that this thread is about GCC/PROGMEM I'll move this to the GCC forum where it belongs.

Cliff

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

I understand now. I tried to find my array in program memory window by loading the disassembler.
I couldn't find my array. How do I find my array is in Flash?

clawson wrote:
Why would you ever expect to "see" a 'static' listed in the .map file? The whole point of using 'static' is to limit its name scope so it's not "public" in the link. And the .map file just reports the public symbols the linker has seen.

If you want to check whether things are located where you expect in the .map file then temporarily remove the 'static' modifier.

BTW as it's now established that this thread is about GCC/PROGMEM I'll move this to the GCC forum where it belongs.

Cliff

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

I read the tutorial. I followed the same procedure.Since I don't know how to make sure my array in flash, I posted it here.any help??
fm

sparrow2 wrote:
Do you use it for anything dynamic?
If you don't use it or only with a [const] the compiler/optimizer will remove it.

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

Quote:

How do I find my array is in Flash?

One way is to look at the .lss, for example:

  2e:	10 c0       	rjmp	.+32     	; 0x50 <__bad_interrupt>
  30:	0f c0       	rjmp	.+30     	; 0x50 <__bad_interrupt>
  32:	0e c0       	rjmp	.+28     	; 0x50 <__bad_interrupt>

00000034 :
  34:	48 65 6c 6c 6f 20 57 6f 72 6c 64 00                 Hello World.


00000040 <__ctors_end>:
  40:	11 24       	eor	r1, r1
  42:	1f be       	out	0x3f, r1	; 63

from:

#include 

const char string[] PROGMEM = "Hello World";


int main(void) { 
	while(1) {

Or if you prefer, "Hello World" is 48 65 6c 6c 6f.. and in the .hex file:

Quote:
:100030000FC00EC0 48 65 6C 6C 6F 20576F726C640007

Last Edited: Wed. Nov 10, 2010 - 07:21 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for your help. I found my array in .lss file & in program memory window also by loading the .elf file.

clawson wrote:
Quote:

How do I find my array is in Flash?

One way is to look at the .lss, for example:

  2e:	10 c0       	rjmp	.+32     	; 0x50 <__bad_interrupt>
  30:	0f c0       	rjmp	.+30     	; 0x50 <__bad_interrupt>
  32:	0e c0       	rjmp	.+28     	; 0x50 <__bad_interrupt>

00000034 :
  34:	48 65 6c 6c 6f 20 57 6f 72 6c 64 00                 Hello World.

Or if you prefer, "Hello World" is 48 65 6c 6c 6f.. and in the .hex file:
Quote:
:100030000FC00EC0 48 65 6C 6C 6F 20576F726C640007
00000040 <__ctors_end>: 40: 11 24 eor r1, r1 42: 1f be out 0x3f, r1 ; 63

from:

#include 

const char string[] PROGMEM = "Hello World";


int main(void) { 
	while(1) {