Skip to content

Commit 671bbac

Browse files
committed
weak hook early_setup() esp8266#2111 esp8266#2133 esp8266#2136
1 parent 1fb9b4e commit 671bbac

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

cores/esp8266/Arduino.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder);
219219
void attachInterrupt(uint8_t pin, void (*)(void), int mode);
220220
void detachInterrupt(uint8_t pin);
221221

222+
void early_setup(void);
222223
void setup(void);
223224
void loop(void);
224225

cores/esp8266/core_esp8266_main.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static uint32_t s_micros_at_task_start;
6363

6464
extern "C" {
6565
extern const uint32_t __attribute__((section(".ver_number"))) core_version = ARDUINO_ESP8266_GIT_VER;
66-
const char* core_release =
66+
const char* core_release =
6767
#ifdef ARDUINO_ESP8266_RELEASE
6868
ARDUINO_ESP8266_RELEASE;
6969
#else
@@ -145,6 +145,7 @@ void init_done() {
145145
system_set_os_print(1);
146146
gdb_init();
147147
do_global_ctors();
148+
early_setup(); // <-- here after global constructors, or in user_init() ?
148149
esp_schedule();
149150
}
150151

@@ -212,13 +213,19 @@ extern "C" void ICACHE_RAM_ATTR app_entry (void)
212213
return app_entry_custom();
213214
}
214215

216+
extern "C" void early_setup (void) __attribute__((weak));
217+
extern "C" void early_setup (void)
218+
{
219+
/* do nothing by default */
220+
}
221+
215222
extern "C" void user_init(void) {
216223
struct rst_info *rtc_info_ptr = system_get_rst_info();
217224
memcpy((void *) &resetInfo, (void *) rtc_info_ptr, sizeof(resetInfo));
218225

219226
uart_div_modify(0, UART_CLK_FREQ / (115200));
220227

221-
init();
228+
init(); // in core_esp8266_wiring.c
222229

223230
initVariant();
224231

0 commit comments

Comments
 (0)