mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-21 10:26:06 +03:00
Support user_rf_pre_init() for SDK v3.0 (#8888)
* For SDK v3.0+, early system calls that were called from user_rf_pre_init (SDK v2.2) need to now be called from user_pre_init. Moved user_rf_pre_init() call to the end of user_pre_init() so we can still perform early calls like: system_phy_set_rfoption(rf_mode), system_phy_set_powerup_option(2), etc. * Update comment * Improve "spoof_init_data" enable/disable logic. Out of an overabundance of caution, limit logic change to the experimental SDK v3.0.5.
This commit is contained in:
parent
97018a5bbf
commit
a76ef290ea
@ -424,6 +424,8 @@ extern "C" uint8_t uart_rx_one_char_block();
|
|||||||
#include "flash_hal.h"
|
#include "flash_hal.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
extern "C" void user_rf_pre_init();
|
||||||
|
|
||||||
extern "C" void ICACHE_FLASH_ATTR user_pre_init(void)
|
extern "C" void ICACHE_FLASH_ATTR user_pre_init(void)
|
||||||
{
|
{
|
||||||
const char *flash_map_str = NULL;
|
const char *flash_map_str = NULL;
|
||||||
@ -623,16 +625,26 @@ extern "C" void ICACHE_FLASH_ATTR user_pre_init(void)
|
|||||||
uart_rx_one_char_block(); // Someone said hello - repeat message
|
uart_rx_one_char_block(); // Someone said hello - repeat message
|
||||||
} while(true);
|
} while(true);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
The function user_rf_pre_init() is no longer called from SDK 3.0 and up.
|
||||||
|
The SDK manual and release notes skipped this detail. The 2023 ESP-FAQ
|
||||||
|
hints at the change with "* Call system_phy_set_powerup_option(3) in
|
||||||
|
function user_pre_init or user_rf_pre_init"
|
||||||
|
https://docs.espressif.com/_/downloads/espressif-esp-faq/en/latest/pdf/#page=14
|
||||||
|
|
||||||
|
Add call to user_rf_pre_init(), so we can still perform early calls like
|
||||||
|
system_phy_set_rfoption(rf_mode), system_phy_set_powerup_option(2), etc.
|
||||||
|
|
||||||
|
Placement, should this be at the beginning or end of user_pre_init()?
|
||||||
|
By the end, we have registered the PHY_DATA partition; however, PHY_DATA
|
||||||
|
read occurs after return and before user_init() is called.
|
||||||
|
*/
|
||||||
|
user_rf_pre_init();
|
||||||
}
|
}
|
||||||
#endif // #if (NONOSDK >= (0x30000))
|
#endif // #if (NONOSDK >= (0x30000))
|
||||||
|
|
||||||
extern "C" void user_init(void) {
|
extern "C" void user_init(void) {
|
||||||
|
|
||||||
#if (NONOSDK >= (0x30000))
|
|
||||||
extern void user_rf_pre_init();
|
|
||||||
user_rf_pre_init(); // Stop spoofing logic
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct rst_info *rtc_info_ptr = system_get_rst_info();
|
struct rst_info *rtc_info_ptr = system_get_rst_info();
|
||||||
memcpy((void *) &resetInfo, (void *) rtc_info_ptr, sizeof(resetInfo));
|
memcpy((void *) &resetInfo, (void *) rtc_info_ptr, sizeof(resetInfo));
|
||||||
|
|
||||||
|
@ -320,6 +320,9 @@ extern int IRAM_ATTR __wrap_spi_flash_read(uint32_t addr, uint32_t* dst, size_t
|
|||||||
return __real_spi_flash_read(addr, dst, size);
|
return __real_spi_flash_read(addr, dst, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if (NONOSDK >= (0x30000))
|
||||||
|
spoof_init_data = false;
|
||||||
|
#endif
|
||||||
memcpy(dst, phy_init_data, sizeof(phy_init_data));
|
memcpy(dst, phy_init_data, sizeof(phy_init_data));
|
||||||
((uint8_t*)dst)[107] = __get_adc_mode();
|
((uint8_t*)dst)[107] = __get_adc_mode();
|
||||||
return 0;
|
return 0;
|
||||||
@ -340,13 +343,13 @@ extern int __get_adc_mode(void)
|
|||||||
extern void __run_user_rf_pre_init(void) __attribute__((weak));
|
extern void __run_user_rf_pre_init(void) __attribute__((weak));
|
||||||
extern void __run_user_rf_pre_init(void)
|
extern void __run_user_rf_pre_init(void)
|
||||||
{
|
{
|
||||||
return; // default do noting
|
return; // default do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (NONOSDK >= (0x30000))
|
#if (NONOSDK >= (0x30000))
|
||||||
void sdk3_begin_phy_data_spoof(void)
|
void sdk3_begin_phy_data_spoof(void)
|
||||||
{
|
{
|
||||||
spoof_init_data = true;
|
spoof_init_data = true;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
uint32_t user_rf_cal_sector_set(void)
|
uint32_t user_rf_cal_sector_set(void)
|
||||||
@ -359,7 +362,9 @@ uint32_t user_rf_cal_sector_set(void)
|
|||||||
void user_rf_pre_init()
|
void user_rf_pre_init()
|
||||||
{
|
{
|
||||||
// *((volatile uint32_t*) 0x60000710) = 0;
|
// *((volatile uint32_t*) 0x60000710) = 0;
|
||||||
|
#if (NONOSDK < (0x30000))
|
||||||
spoof_init_data = false;
|
spoof_init_data = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
int rf_mode = __get_rf_mode();
|
int rf_mode = __get_rf_mode();
|
||||||
if (rf_mode >= 0) {
|
if (rf_mode >= 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user