Skip to content

Commit dc919a0

Browse files
committed
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.
1 parent 84a59aa commit dc919a0

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

cores/esp8266/core_esp8266_main.cpp

+19-2
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,8 @@ extern "C" uint8_t uart_rx_one_char_block();
424424
#include "flash_hal.h"
425425
#endif
426426

427+
extern "C" void user_rf_pre_init();
428+
427429
extern "C" void ICACHE_FLASH_ATTR user_pre_init(void)
428430
{
429431
const char *flash_map_str = NULL;
@@ -623,14 +625,29 @@ extern "C" void ICACHE_FLASH_ATTR user_pre_init(void)
623625
uart_rx_one_char_block(); // Someone said hello - repeat message
624626
} while(true);
625627
}
628+
/*
629+
The function user_rf_pre_init() is no longer called from SDK 3.0 and up.
630+
The SDK manual and release notes skipped this detail. The 2023 ESP-FAQ
631+
hints at the change with "* Call system_phy_set_powerup_option(3) in
632+
function user_pre_init or user_rf_pre_init"
633+
https://docs.espressif.com/_/downloads/espressif-esp-faq/en/latest/pdf/#page=14
634+
635+
Add call to user_rf_pre_init(), so we can still perform early calls like
636+
system_phy_set_rfoption(rf_mode), system_phy_set_powerup_option(2), etc.
637+
638+
Placement, should this be at the beginning or end of user_pre_init()?
639+
By the end, we have already registered the PHY_DATA partition.
640+
SDK v2.2 called user_rf_pre_init() after reading PHY_DATA.
641+
*/
642+
user_rf_pre_init();
626643
}
627644
#endif // #if (NONOSDK >= (0x30000))
628645

629646
extern "C" void user_init(void) {
630647

631648
#if (NONOSDK >= (0x30000))
632-
extern void user_rf_pre_init();
633-
user_rf_pre_init(); // Stop spoofing logic
649+
extern void sdk3_end_phy_data_spoof(void);
650+
sdk3_end_phy_data_spoof();
634651
#endif
635652

636653
struct rst_info *rtc_info_ptr = system_get_rst_info();

cores/esp8266/core_esp8266_phy.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,11 @@ void sdk3_begin_phy_data_spoof(void)
348348
{
349349
spoof_init_data = true;
350350
}
351+
352+
void sdk3_end_phy_data_spoof(void)
353+
{
354+
spoof_init_data = false;
355+
}
351356
#else
352357
uint32_t user_rf_cal_sector_set(void)
353358
{
@@ -359,7 +364,9 @@ uint32_t user_rf_cal_sector_set(void)
359364
void user_rf_pre_init()
360365
{
361366
// *((volatile uint32_t*) 0x60000710) = 0;
367+
#if (NONOSDK < (0x30000))
362368
spoof_init_data = false;
369+
#endif
363370

364371
int rf_mode = __get_rf_mode();
365372
if (rf_mode >= 0) {

0 commit comments

Comments
 (0)