|
From: | Chris |
Subject: | [Paparazzi-devel] saving a srtucture in flash and in real time? |
Date: | Fri, 14 May 2021 19:28:50 +0300 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 |
Hi.
I am trying to transfer the openlrsng firmware to the autopilot board and i have a small problem.
Since there is no eeprom in the stm32f405 is there any way to
save a structure in the end of the flash memory in real time ie
when running the airborne code so i can store the binding data?
So far i found some code like this:
DataLogTypeDef my_data;
...
int i;
uint8_t *data_p = &my_data;
flash_address = //put first flash address here
for ( i = 0; i < sizeof(DataLogTypeDef); i++, data_p++, flash_address++ )
HAL_FLASH_Program(type_byte, flash_address, *data_p);
and
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 896K /* origin size was 1024k, subtracted size of DATA */
DATA (rx) : ORIGIN = 0x080E0000, LENGTH = 128K
SECTIONS
{
.user_data (NOLOAD):
{
. = ALIGN(4);
_user_data_start = .; /* create a global symbol at user_data start */
KEEP(*(.user_data))
. = ALIGN(4);
_user_data_end = .; /* create a global symbol at user_data end */
} >DATA
then the code
uint8_t userConfig[64] __attribute__ ((section(".user_data")));
extern uint32_t _user_data_start;
extern uint32_t _user_data_end;
uint8_t ConfArray[16];
uint32_t TestArray[2];
// Copy a part from the userConfig to variable in RAM
for (i = 0; i < 16; i++)
{
ConfArray[i] = userConfig[i];
}
// get the address of start and end of user_data in flash
// the & is importand, else you would get the value at the address _user_data_start and _user_data_end points to
TestArray[0] = (uint32_t)&_user_data_start;
TestArray[1] = (uint32_t)&_user_data_end;
Chris
[Prev in Thread] | Current Thread | [Next in Thread] |