diff --git a/README.md b/README.md index d490f855..31ea23c6 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # ESP8266_RTOS_SDK # - + ---------- ESP8266 SDK based on FreeRTOS. @@ -10,6 +10,20 @@ APIs of "ESP8266_RTOS_SDK" are same as "ESP8266_NONOS_SDK" More details in "Wiki" ! +### about user_rf_cal_sector_set ### + +Use this function to set the target flash sector to store RF_CAL parameters. + +The user_rf_cal_sector_set has to be added in application, but need NOT to be called. It will be called inside the SDK. +The system parameter area (4 flash sectors) has already been used, so the RF_CAL parameters will be stored in the target sector set by user_rf_cal_sector_set. Since we do not know which sector is available in user data area, users need to set an available sector in the user_rf_cal_sector_set for the SDK to store RF_CAL parameter. If the user_rf_cal_sector_set is not added in the application, the compilation will fail in link stage. + +For example, refer to user_rf_cal_sector_set in SDK/examples/project_template/user/user_main.c + +Note: + +1. esp_init_data.bin has to be downloaded into flash at least once. +2. Download blank.bin to initialize the sector stored RF_CAL parameter (set by user_rf_cal_sector_set), and download esp_init_data.bin into flash, when the system needs to be initialized, or RF needs to be calibrated again. + ## Requrements ## You can use both xcc and gcc to compile your project, gcc is recommended. diff --git a/examples/project_template/user/user_main.c b/examples/project_template/user/user_main.c index d0fabaf9..d9e6132e 100644 --- a/examples/project_template/user/user_main.c +++ b/examples/project_template/user/user_main.c @@ -24,6 +24,50 @@ #include "esp_common.h" +/****************************************************************************** + * FunctionName : user_rf_cal_sector_set + * Description : SDK just reversed 4 sectors, used for rf init data and paramters. + * We add this function to force users to set rf cal sector, since + * we don't know which sector is free in user's application. + * sector map for last several sectors : ABCCC + * A : rf cal + * B : rf init data + * C : sdk parameters + * Parameters : none + * Returns : rf cal sector +*******************************************************************************/ +uint32 user_rf_cal_sector_set(void) +{ + 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; + + default: + rf_cal_sec = 0; + break; + } + + return rf_cal_sec; +} + /****************************************************************************** * FunctionName : user_init * Description : entry of user application, init user function here diff --git a/examples/smart_config/user/user_main.c b/examples/smart_config/user/user_main.c index d924e5b7..00ad62c6 100644 --- a/examples/smart_config/user/user_main.c +++ b/examples/smart_config/user/user_main.c @@ -204,6 +204,49 @@ smartconfig_task(void *pvParameters) vTaskDelete(NULL); } +/****************************************************************************** + * FunctionName : user_rf_cal_sector_set + * Description : SDK just reversed 4 sectors, used for rf init data and paramters. + * We add this function to force users to set rf cal sector, since + * we don't know which sector is free in user's application. + * sector map for last several sectors : ABCCC + * A : rf cal + * B : rf init data + * C : sdk parameters + * Parameters : none + * Returns : rf cal sector +*******************************************************************************/ +uint32 user_rf_cal_sector_set(void) +{ + 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; + + default: + rf_cal_sec = 0; + break; + } + + return rf_cal_sec; +} /****************************************************************************** * FunctionName : user_init diff --git a/examples/spiffs_test/user/test_main.c b/examples/spiffs_test/user/test_main.c index be3bbc85..29b9a924 100644 --- a/examples/spiffs_test/user/test_main.c +++ b/examples/spiffs_test/user/test_main.c @@ -49,6 +49,50 @@ void spiffs_fs1_init(void) esp_spiffs_init(&config); } +/****************************************************************************** + * FunctionName : user_rf_cal_sector_set + * Description : SDK just reversed 4 sectors, used for rf init data and paramters. + * We add this function to force users to set rf cal sector, since + * we don't know which sector is free in user's application. + * sector map for last several sectors : ABCCC + * A : rf cal + * B : rf init data + * C : sdk parameters + * Parameters : none + * Returns : rf cal sector +*******************************************************************************/ +uint32 user_rf_cal_sector_set(void) +{ + 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; + + default: + rf_cal_sec = 0; + break; + } + + return rf_cal_sec; +} + void user_init(void) { spiffs_fs1_init(); diff --git a/examples/websocket_demo/user/user_main.c b/examples/websocket_demo/user/user_main.c index ea48b4a0..971ea173 100644 --- a/examples/websocket_demo/user/user_main.c +++ b/examples/websocket_demo/user/user_main.c @@ -26,6 +26,50 @@ char test_mode = 4; +/****************************************************************************** + * FunctionName : user_rf_cal_sector_set + * Description : SDK just reversed 4 sectors, used for rf init data and paramters. + * We add this function to force users to set rf cal sector, since + * we don't know which sector is free in user's application. + * sector map for last several sectors : ABCCC + * A : rf cal + * B : rf init data + * C : sdk parameters + * Parameters : none + * Returns : rf cal sector +*******************************************************************************/ +uint32 user_rf_cal_sector_set(void) +{ + 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; + + default: + rf_cal_sec = 0; + break; + } + + return rf_cal_sec; +} + /****************************************************************************** * FunctionName : user_init * Description : entry of user application, init user function here diff --git a/lib/libmain.a b/lib/libmain.a old mode 100644 new mode 100755 index c953a8c0..f6e31582 Binary files a/lib/libmain.a and b/lib/libmain.a differ diff --git a/lib/libpp.a b/lib/libpp.a old mode 100644 new mode 100755 index e205dd67..650611dc Binary files a/lib/libpp.a and b/lib/libpp.a differ