why no compilation errors?

Following a suggestion on this forum, I've tried moving some PROGMEM constants into far memory using "attribute((section(".fini7")))". Why doesn't the 3rd example here (with the obvious typing error) generate a compilation error?

const prog_char  TESTA[]      PROGMEM                               = "AAAAAAA";
const char       TESTB[]       __attribute__((section(".fini7")))   = "BBBBBBB";
const char       TESTC[]       __attribute__((secTTTion(".fini7"))) = "CCCCCCC";

Cheers

The version of GCC you are using may not support all attributes, therefore it has to expect things it doesn't know.

Attributes are a GCC specific.

Can you see if the string is placed into ram or progmem.

I'll check soon anyway.

Ok, results:

000000e4 00000008 t _ZL5TESTA

000056f2 00000008 t _ZL5TESTB

00800209 00000008 d _ZL5TESTC

TestA is placed in near memory, TestB is placed in far memory, TestC is in SRAM

So your bad spelling was ignored and, it took the default way of dealing with the data.

thanks pYro_65

version of GCC you are using

At the risk of revealing myself as an idiot, what is "GCC" ?

Can you see if the string is placed into ram or progmem I don't think it gets placed anywhere, when I print the string (as follows....)

  char cat[20];

  strcpy_P(cat,TESTA);
  Serial.println(cat);
  strcpy_P(cat,TESTB);
  Serial.println(cat);
  strcpy_P(cat,TESTC);
  Serial.println(cat);

TESTA and TESTB work fine, then I get a couple of lines of rubish.

cheers

TestA is placed in near memory, TestB is placed in far memory, TestC is in SRAM

How did you do that test?

If the TESTC did end up in memory how come in my test (see 2nd posting) I got garbage?

Because it is in sram and strcpy_P reads data from flash, so you read some mysterious part of flash that happens to have the same memory offset as TESTC in ram. The pointers however have nothing in common.

Do you run windows?

EDIT: GCC = GNU compiler collection. Which contains avr_gcc, the C++ compiler.

Do you run windows?

yes

Here is a few tools to help:

  • Type ‘windows+r’ to open run dialog.

  • Type ‘shell:sendto’ and hit enter.

  • in that folder create a text file called what ever you want.
    add a line to the text file:

D:\arduino-1.5.2\hardware\tools\avr\bin\avr-nm.exe -n -S %1 >nm_out.txt

replace the highlighted part with your version of the arduino IDE

Save the file, then rename it from ‘.txt’ to ‘.bat’

This file I called ‘avr_sram.bat’

Do the same process for this line:

D:\arduino-1.5.2\hardware\tools\avr\bin\avr-objdump.exe -S %1 > %1%.txt

This file I called ‘avr_asm.bat’

compile your program with verbose mode on.

The last sketch I compiled had output that looked like this:

D:\arduino-1.5.2\hardware\tools\avr\bin\avr-objcopy -O ihex -R .eeprom C:\Users\Chris\AppData\Local\Temp\build2298627670476152015.tmp/CrackAttack.cpp.hex
Binary sketch size: 22,338 bytes (of a 258,048 byte maximum) - 8% used

copy the folder path to the hex file, the highlighted portion. And open in explorer.

Find XXX.elf where XXX is your sketch name.

Right click on it and sendto either one of the files you just created.

The sram file produces nm_out.txt
and the asm file produes XXX.txt…

I used the sram version for the test above, it displays the memory layout of the program.
the asm file produces the asm listing of the compiled app. You can see how your code is optimised and see things like the PROGMEM data.

EDIT: changed control+r to windows+r to open run dialog.

thanks Pyro,

thats a really usefull tip, i didn't even realise there was such a thing as a 'verbose' mode.

Is there a 'dummies guide' to AVR stuff? I know there are lots of forums out there, but most of it is way above my level.

cheers