From 0e8280e1dc4befdc3557edeb8170848e6e2b50e6 Mon Sep 17 00:00:00 2001 From: Wu Jian Gang Date: Fri, 27 Apr 2018 21:56:36 +0800 Subject: [PATCH] feat(freertos): Put freertos in flash by default --- components/esp8266/ld/eagle.app.v6.common.ld | 1 - components/freertos/freertos/tasks.c | 2 +- components/freertos/port/port.c | 42 +++++++++----------- 3 files changed, 20 insertions(+), 25 deletions(-) diff --git a/components/esp8266/ld/eagle.app.v6.common.ld b/components/esp8266/ld/eagle.app.v6.common.ld index 3eab735f..00a94ee4 100644 --- a/components/esp8266/ld/eagle.app.v6.common.ld +++ b/components/esp8266/ld/eagle.app.v6.common.ld @@ -93,7 +93,6 @@ SECTIONS *(.entry.text) *(.init.literal) *(.init) - *libfreertos.a:(.literal .text .literal.* .text.*) *libcore.a:spi_flash.o(.literal .text .literal.* .text.*) *(.literal .text .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*) *(.fini.literal) diff --git a/components/freertos/freertos/tasks.c b/components/freertos/freertos/tasks.c index 4325c9b1..7571d23a 100644 --- a/components/freertos/freertos/tasks.c +++ b/components/freertos/freertos/tasks.c @@ -2848,7 +2848,7 @@ BaseType_t xSwitchRequired = pdFALSE; #endif /* configUSE_APPLICATION_TASK_TAG */ /*-----------------------------------------------------------*/ -void vTaskSwitchContext( void ) +void IRAM_ATTR vTaskSwitchContext( void ) { if( uxSchedulerSuspended != ( UBaseType_t ) pdFALSE ) { diff --git a/components/freertos/port/port.c b/components/freertos/port/port.c index 22c023cf..2be0fcdc 100644 --- a/components/freertos/port/port.c +++ b/components/freertos/port/port.c @@ -93,8 +93,7 @@ void vPortExitCritical(void); /* * See header file for description. */ -portSTACK_TYPE* ICACHE_FLASH_ATTR -pxPortInitialiseStack(portSTACK_TYPE* pxTopOfStack, pdTASK_CODE pxCode, void* pvParameters) +portSTACK_TYPE* pxPortInitialiseStack(portSTACK_TYPE* pxTopOfStack, pdTASK_CODE pxCode, void* pvParameters) { #define SET_STKREG(r,v) sp[(r) >> 2] = (portSTACK_TYPE)(v) portSTACK_TYPE* sp, *tp; @@ -125,7 +124,7 @@ pxPortInitialiseStack(portSTACK_TYPE* pxTopOfStack, pdTASK_CODE pxCode, void* pv return sp; } -void PendSV(char req) +void IRAM_ATTR PendSV(char req) { if (req == 1) { vPortEnterCritical(); @@ -138,14 +137,14 @@ void PendSV(char req) } } -void HDL_MAC_SIG_IN_LV1_ISR(void) +void IRAM_ATTR HDL_MAC_SIG_IN_LV1_ISR(void) { PendSV(2); } extern portBASE_TYPE MacIsrSigPostDefHdl(void); -void SoftIsrHdl(void* arg) +void IRAM_ATTR SoftIsrHdl(void* arg) { ETS_NMI_LOCK(); @@ -164,7 +163,7 @@ void SoftIsrHdl(void* arg) ETS_NMI_UNLOCK(); } -void xPortSysTickHandle(void) +void IRAM_ATTR xPortSysTickHandle(void) { if (xTaskIncrementTick() != pdFALSE) { vTaskSwitchContext(); @@ -174,8 +173,7 @@ void xPortSysTickHandle(void) /* * See header file for description. */ -portBASE_TYPE ICACHE_FLASH_ATTR -xPortStartScheduler(void) +portBASE_TYPE xPortStartScheduler(void) { /* * TAG 1.2.3 FreeRTOS call "portDISABLE_INTERRUPTS" at file tasks.c line 1973, this is not at old one. @@ -203,8 +201,7 @@ xPortStartScheduler(void) return pdTRUE; } -void ICACHE_FLASH_ATTR -vPortEndScheduler(void) +void vPortEndScheduler(void) { /* It is unlikely that the CM3 port will require this function as there is nothing to return to. */ @@ -215,7 +212,7 @@ vPortEndScheduler(void) static char ClosedLv1Isr = 0; -void vPortEnterCritical(void) +void IRAM_ATTR vPortEnterCritical(void) { if (NMIIrqIsOn == 0) { if (ClosedLv1Isr != 1) { @@ -227,7 +224,7 @@ void vPortEnterCritical(void) } /*-----------------------------------------------------------*/ -void vPortExitCritical(void) +void IRAM_ATTR vPortExitCritical(void) { if (NMIIrqIsOn == 0) { if (uxCriticalNesting > 0) { @@ -246,7 +243,7 @@ void vPortExitCritical(void) } } -void ICACHE_FLASH_ATTR ShowCritical(void) +void ShowCritical(void) { os_printf("ShowCritical:%d\n", uxCriticalNesting); os_printf("HdlMacSig:%d\n", HdlMacSig); @@ -255,17 +252,17 @@ void ICACHE_FLASH_ATTR ShowCritical(void) ets_delay_us(50000); } -void vPortETSIntrLock(void) +void IRAM_ATTR vPortETSIntrLock(void) { ETS_INTR_LOCK(); } -void vPortETSIntrUnlock(void) +void IRAM_ATTR vPortETSIntrUnlock(void) { ETS_INTR_UNLOCK(); } -void PortDisableInt_NoNest(void) +void IRAM_ATTR PortDisableInt_NoNest(void) { if (NMIIrqIsOn == 0) { if (ClosedLv1Isr != 1) { @@ -275,7 +272,7 @@ void PortDisableInt_NoNest(void) } } -void PortEnableInt_NoNest(void) +void IRAM_ATTR PortEnableInt_NoNest(void) { if (NMIIrqIsOn == 0) { if (ClosedLv1Isr == 1) { @@ -286,7 +283,7 @@ void PortEnableInt_NoNest(void) } /*-----------------------------------------------------------*/ -void ICACHE_FLASH_ATTR ResetCcountVal(unsigned int cnt_val) +void ResetCcountVal(unsigned int cnt_val) { asm volatile("wsr a2, ccount"); } @@ -294,14 +291,13 @@ void ICACHE_FLASH_ATTR ResetCcountVal(unsigned int cnt_val) _xt_isr_entry isr[16]; char _xt_isr_status = 0; -void ICACHE_FLASH_ATTR -_xt_isr_attach(uint8 i, _xt_isr func, void* arg) +void _xt_isr_attach(uint8 i, _xt_isr func, void* arg) { isr[i].handler = func; isr[i].arg = arg; } -uint16 _xt_isr_handler(uint16 i) +uint16 IRAM_ATTR _xt_isr_handler(uint16 i) { uint8 index; @@ -332,12 +328,12 @@ void vApplicationStackOverflowHook(xTaskHandle xTask, signed char *pcTaskName) os_printf("task [%s] stask overflow\n", pcTaskName); } -void __taskEXIT_CRITICAL(void) +void IRAM_ATTR __taskEXIT_CRITICAL(void) { portEXIT_CRITICAL(); } -void __taskENTER_CRITICAL(void) +void IRAM_ATTR __taskENTER_CRITICAL(void) { portENTER_CRITICAL(); }