Initialize flash memory portion in order to store my config file

meaepeppe
Posts: 3
Joined: Tue May 31, 2016 3:52 pm

Initialize flash memory portion in order to store my config file

Postby meaepeppe » Fri Jun 09, 2017 2:51 am

Hello everyone, I'm trying to find an affordable way to get my flash config data initialized only at firmware uploading. I'm currently using this data structure and I would like to find a known value at first startup:

Code: Select all

#define ESP_PARAM_START_SEC   0xFC
#define  DATA_POS 0

typedef struct {
   char auth[50];
   uint8 id_qty;
   uint32 id_vector[30];
   bool first_start;
} config_data;

I was thinking about flashing a blank file during firmware upload in order to get a known value in sector 0xFC. Can someone tell me how to make this or something else which will have the same result? Thanks.

User avatar
pratik
Posts: 460
Joined: Wed Jun 29, 2016 7:17 pm
Location: India
Contact:

Re: Initialize flash memory portion in order to store my config file

Postby pratik » Tue Jun 13, 2017 1:25 am

To erase a sector or to store data in a sector, you can simply use the flash download tool.
For example, if you burn a file called "data.bin" at address 0x020000, the data of the file will be placed at this location.
If the size of your BIN file is 4kB, then you can fill one whole sector with your data. This data can then be read by application in ESP8266.

For having a blank sector (all bytes read 0xFF), flash blank.bin at your sector start address.
Note that sector address is based on 4kB (kByte) sectors. Flash download tool takes absolute byte address, not sector address. :)
Regards,
Pratik Panda
Website: http://www.PratikPanda.com

Custom firmware, Knowledge base and freelancing (ESP8266/ESP32):
http://www.iot-bits.com

meaepeppe
Posts: 3
Joined: Tue May 31, 2016 3:52 pm

Re: Initialize flash memory portion in order to store my config file

Postby meaepeppe » Thu Jun 22, 2017 12:22 am

pratik wrote:To erase a sector or to store data in a sector, you can simply use the flash download tool.
For example, if you burn a file called "data.bin" at address 0x020000, the data of the file will be placed at this location.
If the size of your BIN file is 4kB, then you can fill one whole sector with your data. This data can then be read by application in ESP8266.

For having a blank sector (all bytes read 0xFF), flash blank.bin at your sector start address.
Note that sector address is based on 4kB (kByte) sectors. Flash download tool takes absolute byte address, not sector address. :)


Thank you, I will follow this method.

Who is online

Users browsing this forum: No registered users and 1 guest