[SOLVED]How does SDK1.4 determine flash size?

tve
Posts: 123
Joined: Sun Feb 15, 2015 4:33 pm

[SOLVED]How does SDK1.4 determine flash size?

Postby tve » Sat Nov 07, 2015 1:55 pm

I am trying to build firmware that will work with any flash size from 512KB to 4MB and one of the key items is how does the SDK determine the flash size for the purpose of placing the "system param" flash area?
I know that the flash size is stored in two places: in the header of the bootloader (at flash address 0) and in the header of the boot-mode 2 user1.bin/user2.bin files (this is put there by gen_appbin.py). From my tests it seems that the header of the bootloader is what the SDK uses, at least that's what system_get_flash_size_map returns. Is the flash size in the header of the user1.bin/user2.bin used for anything?

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: How does SDK1.4 determine flash size?

Postby ESP_Faye » Mon Nov 09, 2015 2:54 pm

Hi,

Yes, the system_get_flash_size_map can get the flash size & map.

Thanks for your interest in ESP8266 !

tve
Posts: 123
Joined: Sun Feb 15, 2015 4:33 pm

Re: How does SDK1.4 determine flash size?

Postby tve » Mon Nov 09, 2015 4:56 pm

Mhh, that wasn't my question, I know that.
My question is where does the SDK get the flash map from ? Is it from the header in the boot sector?

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: How does SDK1.4 determine flash size?

Postby ESP_Faye » Tue Nov 10, 2015 7:20 pm

Hi,

Start from Flash 0x00000

Code: Select all

struct flash_hdr {
   char magic;
   char blocks;
   char spi_mode;
   char spi_speed: 4;  // low
   char spi_size: 4;
   unsigned int entry_addr;
};


The "spi_size" is corresponding to the enum below:

Code: Select all

enum flash_size_map {
    FLASH_SIZE_4M_MAP_256_256 = 0,
    FLASH_SIZE_2M,
    FLASH_SIZE_8M_MAP_512_512,
    FLASH_SIZE_16M_MAP_512_512,
    FLASH_SIZE_32M_MAP_512_512,
    FLASH_SIZE_16M_MAP_1024_1024,
    FLASH_SIZE_32M_MAP_1024_1024
};


Thanks for your interest in ESP8266 !

tito
Posts: 1
Joined: Thu Oct 29, 2015 2:58 pm

Re: How does SDK1.4 determine flash size?

Postby tito » Tue Nov 10, 2015 10:47 pm

tve wrote:Mhh, that wasn't my question, I know that.
My question is where does the SDK get the flash map from ? Is it from the header in the boot sector?

I believe by reading SPI FLASH ID - spi_flash_get_id().

tve
Posts: 123
Joined: Sun Feb 15, 2015 4:33 pm

Re: How does SDK1.4 determine flash size?

Postby tve » Wed Nov 11, 2015 9:52 am

Thanks much!

Who is online

Users browsing this forum: No registered users and 26 guests