ESP8266 Developer Zone The Official ESP8266 Forum 2021-11-14T02:05:45+08:00 https://bbs.espressif.com:443/feed.php?f=7&t=75254 2021-11-14T02:05:45+08:00 2021-11-14T02:05:45+08:00 https://bbs.espressif.com:443/viewtopic.php?t=75254&p=100364#p100364 <![CDATA[user_rf_cal_sector_set and Espressif reserved flash sectors]]> (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:

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:

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.

Statistics: Posted by Inquisitor — Sun Nov 14, 2021 2:05 am


]]>