paparazzi-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Paparazzi-devel] saving a srtucture in flash and in real time?


From: Gautier Hattenberger
Subject: Re: [Paparazzi-devel] saving a srtucture in flash and in real time?
Date: Wed, 19 May 2021 22:29:14 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0

Hello Chris,

It should be possible to read and write from flash. This is done by the "persistent settings" (not sure this is used a lot by the way).

You can check the files
subsystems/settings.c
arch/stm32/subsystems/settings_arch.c

You will also probably need to adapt the ld script to leave space for read/write, see arch/stm32/lisa-mx.ld

Gautier

Le 14/05/2021 à 18:28, Chris a écrit :

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


_______________________________________________
Paparazzi-devel mailing list
Paparazzi-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/paparazzi-devel

reply via email to

[Prev in Thread] Current Thread [Next in Thread]