0
votes

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);
1
I do not fully understand what the problem is. Is it not so that you have to deliberately call functions that write to flash. Is the solution not just not to call those functions?Bart
So 0x00000000 is the read-only (code) region, 0x800000 is the read-write (data) region. This should be common in almost every bare metal example for arm...Sean Houlihane
Did you check this post? stackoverflow.com/questions/15137214/…Jose
@Bart My problem is that when I compile the C code, I'm not sure whether or not there are ARM instructions that write to flash in the simulator.person314314314
It would be useful at this point if you were to include your evidence that this is actually happening together with the code that is causing it.Clifford

1 Answers

1
votes

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?