@@ -48,7 +48,7 @@ extern void (*__init_array_end)(void);
4848/* Not static, used in Esp.cpp */
4949struct rst_info resetInfo;
5050
51- /* Not static, used in core_esp8266_postmortem.c.
51+ /* Not static, used in core_esp8266_postmortem.c and other places .
5252 * Placed into noinit section because we assign value to this variable
5353 * before .bss is zero-filled, and need to preserve the value.
5454 */
@@ -175,10 +175,15 @@ void init_done() {
175175
176176 WPS beeing flawed by its poor security, or not beeing used by lots of
177177 users, it has been decided that we are still going to use that memory for
178- user's stack and disable the use of WPS, with an option to revert that
179- back at the user's discretion. This selection can be done with the
180- global define NO_EXTRA_4K_HEAP. An option has been added to the board
181- generator script.
178+ user's stack and disable the use of WPS.
179+
180+ app_entry() jumps to app_entry_custom() defined as "weakref" calling
181+ itself a weak customizable function, allowing to use another one when
182+ this is required (see core_esp8266_app_entry_noextra4k.cpp, used by WPS).
183+
184+ (note: setting app_entry() itself as "weak" is not sufficient and always
185+ ends up with the other "noextra4k" one linked, maybe because it has a
186+ default ENTRY(app_entry) value in linker scripts).
182187
183188 References:
184189 https://github.com/esp8266/Arduino/pull/4553
@@ -188,31 +193,25 @@ void init_done() {
188193
189194*/
190195
191- #ifdef NO_EXTRA_4K_HEAP
192- /* this is the default NONOS-SDK user's heap location */
193- cont_t g_cont __attribute__ ((aligned (16 )));
194- #endif
195-
196- extern " C" void ICACHE_RAM_ATTR app_entry (void )
196+ extern " C" void ICACHE_RAM_ATTR app_entry_redefinable (void ) __attribute__((weak));
197+ extern " C" void ICACHE_RAM_ATTR app_entry_redefinable (void )
197198{
198- #ifdef NO_EXTRA_4K_HEAP
199-
200- /* this is the default NONOS-SDK user's heap location */
201- g_pcont = &g_cont;
202-
203- #else
204-
205199 /* Allocate continuation context on this SYS stack,
206200 and save pointer to it. */
207201 cont_t s_cont __attribute__ ((aligned (16 )));
208202 g_pcont = &s_cont;
209203
210- #endif
211-
212204 /* Call the entry point of the SDK code. */
213205 call_user_start ();
214206}
215207
208+ static void ICACHE_RAM_ATTR app_entry_custom (void ) __attribute__((weakref(" app_entry_redefinable" )));
209+
210+ extern " C" void ICACHE_RAM_ATTR app_entry (void )
211+ {
212+ return app_entry_custom ();
213+ }
214+
216215extern " C" void user_init (void ) {
217216 struct rst_info *rtc_info_ptr = system_get_rst_info ();
218217 memcpy ((void *) &resetInfo, (void *) rtc_info_ptr, sizeof (resetInfo));
0 commit comments