user_rf_cal_sector_set and Espressif reserved flash sectors

Inquisitor
Posts: 22
Joined: Thu Dec 14, 2017 10:53 am
Contact:

user_rf_cal_sector_set and Espressif reserved flash sectors

Postby Inquisitor » Sun Nov 14, 2021 2:05 am

I've been inspecting the flash sectors reserved by the system...
(1) The 0 sector
(2) The last 4 sectors - on a 4MB board, this will be sectors 1020-1023.

When using a native, NonOS we need to expose something like this

Code: Select all

uint32 ICACHE_FLASH_ATTR user_rf_cal_sector_set(void)
{
    enum flash_size_map size_map = system_get_flash_size_map();
    uint32 rf_cal_sec = 0;

    switch (size_map) {
        case FLASH_SIZE_4M_MAP_256_256:
            rf_cal_sec = 128 - 5;
            break;

        case FLASH_SIZE_8M_MAP_512_512:
            rf_cal_sec = 256 - 5;
            break;

        case FLASH_SIZE_16M_MAP_512_512:
        case FLASH_SIZE_16M_MAP_1024_1024:
            rf_cal_sec = 512 - 5;
            break;

        case FLASH_SIZE_32M_MAP_512_512:
        case FLASH_SIZE_32M_MAP_1024_1024:
            rf_cal_sec = 1024 - 5;
            break;

        case FLASH_SIZE_64M_MAP_1024_1024:
            rf_cal_sec = 2048 - 5;
            break;
        case FLASH_SIZE_128M_MAP_1024_1024:
            rf_cal_sec = 4096 - 5;
            break;
        default:
            rf_cal_sec = 0;
            break;
    }
    return rf_cal_sec;
}


Where it clearly puts rf cal stuff in sector -5 (the 5th sector from the end). Looking into the Arduino code base, Arduino appears to put it in sector -4 and use sector -5 for simulating the EEPROM.

Code: Select all

uint32_t user_rf_cal_sector_set(void)
{
    spoof_init_data = true;
    return flashchip->chip_size/SPI_FLASH_SEC_SIZE - 4;
}


When I tried to use sector -4 in NonOS, I get continuous reboots. My questions are...

  1. What is user_rf_cal_sector_set() sector contain / used for?
  2. Why is it variable for us developers to place in the flash?
  3. Since its required why is it not just part of the 4 end sectors already reserved? They are sparsely used and seem like they could easily hold the data placed in this user_rf_cal_sector_set sector.
  4. Arduino seems to use this, but puts it in a place where it is reserved by Espressif.
  5. Where is the Arduino version putting it so it can use sector -5 for EEPROM?

Thanks.
3 lines of code = App/Web Server w/ GUI Admin, File Mngr, OTA, AP Mgr, Perf Metrics, WebSocket Comms, App API, All running on ESP8266... Even usable on ESP-01S
https://www.esp8266.com/viewtopic.php?f=11&t=23535
https://InqOnThat.com

Who is online

Users browsing this forum: No registered users and 186 guests