@@ -40,6 +40,9 @@ extern "C" {
4040
4141#define OPTIMISTIC_YIELD_TIME_US 16000
4242
43+
44+ extern " C" void call_user_start ();
45+
4346struct rst_info resetInfo;
4447
4548extern " C" {
@@ -76,14 +79,14 @@ void preloop_update_frequency() {
7679extern void (*__init_array_start)(void );
7780extern void (*__init_array_end)(void );
7881
79- cont_t g_cont __attribute__ ((aligned ( 16 )));
82+ cont_t * g_pcont __attribute__ ((section( " .noinit " )));
8083static os_event_t g_loop_queue[LOOP_QUEUE_SIZE];
8184
8285static uint32_t g_micros_at_task_start;
8386
8487extern " C" void esp_yield () {
85- if (cont_can_yield (&g_cont )) {
86- cont_yield (&g_cont );
88+ if (cont_can_yield (g_pcont )) {
89+ cont_yield (g_pcont );
8790 }
8891}
8992
@@ -92,7 +95,7 @@ extern "C" void esp_schedule() {
9295}
9396
9497extern " C" void __yield () {
95- if (cont_can_yield (&g_cont )) {
98+ if (cont_can_yield (g_pcont )) {
9699 esp_schedule ();
97100 esp_yield ();
98101 }
@@ -104,7 +107,7 @@ extern "C" void __yield() {
104107extern " C" void yield (void ) __attribute__ ((weak, alias(" __yield" )));
105108
106109extern " C" void optimistic_yield (uint32_t interval_us) {
107- if (cont_can_yield (&g_cont ) &&
110+ if (cont_can_yield (g_pcont ) &&
108111 (system_get_time () - g_micros_at_task_start) > interval_us)
109112 {
110113 yield ();
@@ -126,8 +129,8 @@ static void loop_wrapper() {
126129static void loop_task (os_event_t *events) {
127130 (void ) events;
128131 g_micros_at_task_start = system_get_time ();
129- cont_run (&g_cont , &loop_wrapper);
130- if (cont_check (&g_cont ) != 0 ) {
132+ cont_run (g_pcont , &loop_wrapper);
133+ if (cont_check (g_pcont ) != 0 ) {
131134 panic ();
132135 }
133136}
@@ -146,6 +149,12 @@ void init_done() {
146149}
147150
148151
152+ extern " C" void ICACHE_RAM_ATTR app_entry (void ) {
153+ cont_t s_cont __attribute__ ((aligned (16 )));
154+ g_pcont = &s_cont;
155+ call_user_start ();
156+ }
157+
149158extern " C" void user_init (void ) {
150159 struct rst_info *rtc_info_ptr = system_get_rst_info ();
151160 memcpy ((void *) &resetInfo, (void *) rtc_info_ptr, sizeof (resetInfo));
@@ -156,7 +165,7 @@ extern "C" void user_init(void) {
156165
157166 initVariant ();
158167
159- cont_init (&g_cont );
168+ cont_init (g_pcont );
160169
161170 ets_task (loop_task,
162171 LOOP_TASK_PRIORITY, g_loop_queue,
0 commit comments