2015-06-18 05:51 AM
I am working with the
Discovery development board
STM32F407 microcontroller and building using Eclipse/GNU. My project has a bootloader and an application and I would like to have a variable in RAM that both the bootloader and the application can access and pass information to each other. I tried to tell the linker that the RAM is smaller than it actually is and then store my variable in the ''outside'' area:
MEMORY
{
/* Pretend that the RAM is only 127 kByte even though in reality it is 128 kByte */
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 127K
CCMRAM (xrw) : ORIGIN = 0x10000000, LENGTH = 64K
.
.
.
}
// Store a variable in the RAM area the linker doesn't think exist
*((uint32_t*) (127 * 1024 + 16)) = 0xAABBCCDD;
However, it doesn't work, I seem to always read 0xFFFFFFFF, even if I store it in bootloader mode and immediately read it in bootloader mode again. Can anybody please help me?
2015-06-18 05:59 AM
I figured it out, I was using the wrong address (need an offset of0x20000000 to get to the RAM area):
*((uint32_t*) (0x20000000 + 127 * 1024 + 16)) = 0xAABBCCDD;
2015-06-18 06:03 AM
The RAM doesn't have a zero basis, it starts at 0x20000000
Consider using a structure, and casting a pointer at that.typedef struct _FOO { int bar;//...} FOO;FOO *foo = (FOO *)0x2001FC00; // 0x20000000 + 127 * 1024foo->bar = 123456;