rust-embedded / cortex-m-rt

Minimal startup / runtime for Cortex-M microcontrollers
https://rust-embedded.github.io/cortex-m-rt/
Apache License 2.0
357 stars 85 forks source link

Different virtual and physical address for FLAH #318

Closed birktj closed 3 years ago

birktj commented 3 years ago

Please forgive my terminology if it is not entirely correct, I am not too familiar with embedded systems.

Currently I am using the XMC4500 micro controller, this mcu has a memory layout with one cached (does not support writing) and one uncached address range that points to flash memory (seen in section 8.4.3 in the reference manual). Since the cached address range does not support writing I have set up my memory.x file to point to the uncached address. However I see that the C linker scripts used for this platform are set up in such a way that on upload the flash contents are written to the uncached address, while function addresses etc use the cached address space, hence "virtual" and "physical" addresses.

Is it possible to setup flash memory in such a way in memory.x?

adamgreig commented 3 years ago

There's no easy way to do this in memory.x; our stock link.x.in is just not set up to have flash have a different virtual address than the load address. I think the best option would be to copy out link.x.in and place it into your own project as link.x, then adjust the flash section as required (you could use the .data section as a reference since it has the same property).

I'm closing this issue for now since it's old, but if you're still having this issue and need further help getting it to work please re-open and we can discuss further!