Constant variable at a fixed address in Flash

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

Hi,

I would like to have a constant string at a certain address in flash. It looks like this:

const prog_uchar hex_file_signature[8]="MoinMoin";

But How can I locate this string at a certain address? This does not work:

hex_file_signature[8]="MoinMoin"   __attribute__((section(".hexfilesignature")));

Any ideas?

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

Have you added a -Wl,--section-start=.hexfilesignature=0x80????,...
to your linker command in the makefile?

Knut

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

Sorry, there is a typo above. I would like to have something like this which does not work (does not compile):

const prog_uchar hex_file_signature[8]="MoinMoin"   __attribute__((section(".hexfilesignature")));

@Knut: This means it does not pass the compiler. Linking would be the next step.

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

But you don't want to retain the prog_uchar in there if you plan to put it into your OWN named section. Just make that uint8_t. The fact that it's going to a named code section means that its implicit that it will be in code flash and not copied to .data anyway.

Cliff

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

ce wrote:

const prog_uchar hex_file_signature[8]="MoinMoin"   __attribute__((section(".hexfilesignature")));

A working string-example in the flash a is defined like this:

static char s12[] __attribute__ ((progmem)) = "Set: ";

try to replace ((progmem)) with ((section(".hexfilesignature"))) and it should work.

Knut

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

Thanks to Cliff and Knut. I got stuck on the 'prog_...' stuff. But now it works:

char hex_file_signature[] __attribute__ ((section(".hexfilesignature"))) = "MoinMoin";

Additionally I added this linker flag:
,-section-start=.hexfilesignature=0x7B00

So I placed this string at the end of my Flash memory!