flashchip info in ROM

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
User avatar
Posts: 815
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

flashchip info in ROM

Post by Roberthh » Sat Jan 07, 2017 4:10 pm

During some inspection, what would be required to enable 16MByte flash, I came along the flashchip info, residing in rom. espressif provides a symbol called 'flashchip', which in my test has the value 0x3fffc718 and resides at address 0x3fffc714. The value is the pointer to the flashćhip structure, which is actually located in the adjoining memory location, but it does not have to. espressif's sample code uses the pointer. Two observation around that:
1. When reading the data in the structure, it told me for an ESP-01 with 1MByte flash, the the flash size is 1 MByte but the chip ID is 1640ef (which is wrong), whereas esp.flash_id() returns 1440C8 (which is right). Flashing the same device as an 4 MByte model changes the size info, which is interesting for a value which is told to reside in ROM. Since this seemed to be the major obstacle for allowing 16MByte flash.
2. The function esp_flash_size() could be simplified into:

Code: Select all

STATIC mp_obj_t esp_flash_size(void) {
    extern SpiFlashChip *flashchip;
    return mp_obj_new_int_from_uint(flashchip->chip_size);
Besides being slightly simpler, it would also cover a theoretical change that the value of 'flashchip' and the data it points to are not neighbors any more.
P.S.: I did not raise a PR because: a) it works as it is b) me and git will never git frinds
P.P.S: According to a esp8266 wiki, address 0x3fffc714 is in ETS RAM. That explains why it's value changes, but now, why it flash_id is set to a wrong value..

Post Reply