esp-open-sdk icon indicating copy to clipboard operation
esp-open-sdk copied to clipboard

Regarding system and RF parameters on esp-open-sdk

Open FlynnMa opened this issue 7 years ago • 3 comments

Seems esp-open-sdk does not load such parameters equal as ESP8266_RTOS_SDK,

In "esp-open-sdk/common.mk", the "bootloader/firmware_prebuilt/blank_config.bin" is hardcoded to flash to 0x1000, while the RF parameter "esp_init_data_default.bin" is not included.

According with documents from ESP8266 "2A-ESP8266__IOT_SDK_User_Manual__EN_v1.3.0.pdf", in section 6.1 mentioned that: blank.bin shall be programmed to the second section from the end of flash esp_init_data_default.bin stores default RF parameter values and to be written to the forth sector from the end of flash

The physical address is different according with flash size.

I am very curious that why does esp-open-sdk has this different settings? And the RF parameter is ignored? Does anyone know that? @pfalcon

FlynnMa avatar Apr 09 '17 07:04 FlynnMa

Can anyone please response? Thanks!

FlynnMa avatar Apr 12 '17 11:04 FlynnMa

Things have changed since sdk v1.3. The SDK attempts to load the RF calibration data from a sector of flash. Supposedly that should be done automatically if you flash it to the correct sector, but I've never been able to get it to work like that with esp-open-sdk, at least not with my project. The other thing is that init data default has configuration info that may not work for every esp, or you may want to change some of the things.

What I do:

  • Add this PR
  • Add -Wl,--wrap=user_rf_cal_sector_set to your link flags somewhere
  • Then put in user main:
uint32 TEXT_SECTION_ATTR __wrap_user_rf_cal_sector_set(void)
{
   return 1024 - 5; // sector you have rf cal data
}

Also, for init_data_default, I copied the relevant parts from nodemcu. This injects the init_data_default into a known part of the program binary.

someburner avatar Apr 12 '17 15:04 someburner

em... interesting, I have found this function under "esp_open_sdk/user_rf_cal_sector_set.c", the default loading sector is to the forth from the end of flash.


`#include <c_types.h>
#include <spi_flash.h>

uint32 user_rf_cal_sector_set(void) {
    extern char flashchip;
    SpiFlashChip *flash = (SpiFlashChip*)(&flashchip + 4);  
    // We know that sector size in 4096
    //uint32_t sec_num = flash->chip_size / flash->sector_size;
    uint32_t sec_num = flash->chip_size >> 12;
    return sec_num - 5;
}
`

BTW, I am very interested in how do you find this function, I tried to search about this on internet for long, but couldn't found a document explain it well. I am still not clear about how do I include it in a project like "esp_open_rtos"?

Thanks very much @someburner .

FlynnMa avatar Apr 17 '17 12:04 FlynnMa