ARM bare-metal program compilation -control flash writes

0

I'm trying to compile some C code to run on an ARMv6 simulator, with FLASH memory starting @ 0x0 and RAM starting at 0x800000. Right now, I can pass binary files off the the simulator just fine...

However, I want the instructions generated to not include any writes to flash memory, and only operate within RAM memory (after copying RAM). Is this possible?

I am using the GNU toolchain to compile.

This is my current linker script:

MEMORY
{
    rom(rx) : ORIGIN = 0x00000000, LENGTH = 0x00800000
    ram(!rx) : ORIGIN = 0x40000000, LENGTH = 0x00800000
    h : ORIGIN = 0x40000000, LENGTH = 0x00400000
}

SECTIONS
{
    .text : { *(.text*) } > rom
    .bss : { *(.bss*) } > ram
    .heap : { *(.heap*) } > h
}

    end = ORIGIN(h) + LENGTH(h);

_stacktop = ORIGIN(ram) + LENGTH(ram);
compilation
linker
arm
embedded
bare-metal
asked on Stack Overflow May 30, 2019 by person314314314 • edited May 31, 2019 by person314314314

1 Answer

1

Your build linker script (normally a .ld file) determines the locations of your device's memory and how the linker sections are mapped to that. Your link map should not include writable sections in read-only memory, that will fail.

[Added after linker script added to question]

You linker script seems unusual in lacking a .data section:

.data : { *(.data) } > ram

Without that it is not clear what the linker will do with static initialised data.

Also your question states that the RAM starts at 0x800000, but the linker script clearly locates it at 0x40000000. Perhaps this misunderstanding of your memory map is leading you to erroneously believe that writes to the ROM region are occurring?

answered on Stack Overflow May 31, 2019 by Clifford • edited Jun 1, 2019 by Clifford

User contributions licensed under CC BY-SA 3.0