I think this is more related to GCC rather than ESP8266. I have been trying to put in a constant variable in read only memory section of ESP. The idea is to change the value directly in the binary image before flashing it on a new chip. In the code section, I have added,
const uint32_t device_address __attribute__((section(".device_addr"))) = 0x12345678;
The changes to the linker script in program.ld is; created a new memory region
device_addr_section : org = 0x40202100, len = 0x04
In the SECTIONS region, added a new section
.addr_section: ALIGN(4)
{
KEEP(*(.device_addr))
} >device_addr_section
When I compile the code with the new linker, I see the changes and allocation in the map file, but I cannot find the hex value 0x12345678 in the generated binary image. When I remove the attribute from the variable device_address, I do see that hex value in the generated binary image. The full memory region breakdown:
MEMORY
{
dport0_0_seg : org = 0x3FF00000, len = 0x10
dram0_0_seg : org = 0x3FFE8000, len = 0x14000
iram1_0_seg : org = 0x40100000, len = 0x08000
/* irom0 section, mapped from SPI flash
- Origin is offset by 0x2010 to create spacer for second stage bootloader image,
header.
- Length is max 8Mbit of mappable flash, minus start offset
*/
irom0_0_seg : org = 0x40202010, len = (1M - 0x2020)
device_addr_seg (rx): org = 0x40202100, len = 0x04
}
I haven't used GCC in the past any ideas and help would be appreciated.
Thanks, Nishant