Skip to content

Commit 05c078b

Browse files
committed
Don't set RF mode on boot unless it was overridden
The change in 297bb17 enabled RF after deep sleep, even if deep sleep was done with RF_DISABLED option (thanks @vlast3k for pointing this out). Now we check the value returned by __get_rf_mode, and only call system_phy_set_rfoption if RF_MODE override was provided by user.
1 parent dd061c8 commit 05c078b

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

cores/esp8266/core_esp8266_phy.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,8 @@ static const uint8_t ICACHE_FLASH_ATTR phy_init_data[128] =
251251
#define __run_user_rf_pre_init _Z22__run_user_rf_pre_initv
252252

253253
extern int __real_register_chipv6_phy(uint8_t* init_data);
254-
extern int __wrap_register_chipv6_phy(uint8_t* init_data) {
254+
extern int __wrap_register_chipv6_phy(uint8_t* init_data)
255+
{
255256
if (init_data != NULL) {
256257
memcpy(init_data, phy_init_data, sizeof(phy_init_data));
257258
init_data[107] = __get_adc_mode();
@@ -262,7 +263,7 @@ extern int __wrap_register_chipv6_phy(uint8_t* init_data) {
262263
extern int __get_rf_mode(void) __attribute__((weak));
263264
extern int __get_rf_mode(void)
264265
{
265-
return 0; // default mode
266+
return -1; // mode not set
266267
}
267268

268269
extern int __get_adc_mode(void) __attribute__((weak));
@@ -277,7 +278,8 @@ extern void __run_user_rf_pre_init(void)
277278
return; // default do noting
278279
}
279280

280-
void user_rf_pre_init() {
281+
void user_rf_pre_init()
282+
{
281283
// *((volatile uint32_t*) 0x60000710) = 0;
282284

283285
volatile uint32_t* rtc_reg = (volatile uint32_t*) 0x60001000;
@@ -287,6 +289,9 @@ void user_rf_pre_init() {
287289
}
288290

289291
system_set_os_print(0);
290-
system_phy_set_rfoption(__get_rf_mode());
292+
int rf_mode = __get_rf_mode();
293+
if (rf_mode >= 0) {
294+
system_phy_set_rfoption(rf_mode);
295+
}
291296
__run_user_rf_pre_init();
292297
}

0 commit comments

Comments
 (0)