STM32H745: VMA does not match actual memory address for a given variable
In my application I am using initialized data in shared memory for the use in a user interface. The memory is in the SRAM2 at 0x30020000. Both cores need to access that same data.
This code is placed in the Common directory so that it is picked up during compile time for both CM4 and for CM7 individually.
When I look at the memory details after compilation, I get the following for CM4:
For the CM7, I get:
So in both cases, the address for variable uiDisplayArea is 0x30020960 according to the memory details. Bear in mind that it doesn't matter whether I use optimization -O0 or -O3, the above two snapshots are always the same.
In my code I am using the following statement to prepare dumping the memory address of this variable:
sprintf(strg, "uiDisplayArea pointer: %p.\r\n", uiDisplayArea);If I compile with no optimization, the result printed is 0x30020960, exactly as expected. However, if I compile with optimization level -03, the CM7 gives me a different address, namely 0x300200b8 (for the CM4 it is still 0x30020960). How can that be?
What I need in the end is that the variable addresses are identical between the two cores, no matter what optimization level I am using. Given the behavior described above, I don't know how to accomplish this.
