From 487b887f80f1b73a72a627a21b12c1185a147104 Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 11 Mar 2020 00:09:37 +0700 Subject: [PATCH] freertos demo use static only for most optmized sram --- .../.skip.MCU_VALENTYUSB_EPTRI | 0 examples/device/cdc_msc_freertos/Makefile | 1 - .../cdc_msc_freertos/src/FreeRTOSConfig.h | 58 +++++++++++++++++-- examples/device/cdc_msc_freertos/src/main.c | 7 ++- hw/bsp/ea4357/board.mk | 2 +- hw/bsp/fomu/board.mk | 3 + hw/bsp/lpcxpresso54114/board.mk | 2 +- hw/bsp/ngx4330/board.mk | 2 +- hw/bsp/nutiny_sdk_nuc505/board.mk | 2 +- hw/bsp/samg55xplained/samg55xplained.c | 1 - 10 files changed, 66 insertions(+), 12 deletions(-) create mode 100644 examples/device/cdc_msc_freertos/.skip.MCU_VALENTYUSB_EPTRI diff --git a/examples/device/cdc_msc_freertos/.skip.MCU_VALENTYUSB_EPTRI b/examples/device/cdc_msc_freertos/.skip.MCU_VALENTYUSB_EPTRI new file mode 100644 index 000000000..e69de29bb diff --git a/examples/device/cdc_msc_freertos/Makefile b/examples/device/cdc_msc_freertos/Makefile index f92613102..da6044c1d 100644 --- a/examples/device/cdc_msc_freertos/Makefile +++ b/examples/device/cdc_msc_freertos/Makefile @@ -19,7 +19,6 @@ SRC_C += \ $(FREERTOS_SRC)/queue.c \ $(FREERTOS_SRC)/tasks.c \ $(FREERTOS_SRC)/timers.c \ - $(FREERTOS_SRC)/portable/MemMang/heap_4.c \ $(FREERTOS_SRC)/portable/GCC/$(FREERTOS_PORT)/port.c # FreeRTOS (lto + Os) linker issue diff --git a/examples/device/cdc_msc_freertos/src/FreeRTOSConfig.h b/examples/device/cdc_msc_freertos/src/FreeRTOSConfig.h index 0697bfca9..309a9a01b 100644 --- a/examples/device/cdc_msc_freertos/src/FreeRTOSConfig.h +++ b/examples/device/cdc_msc_freertos/src/FreeRTOSConfig.h @@ -45,10 +45,60 @@ // for OPT_MCU_ #include "tusb_option.h" -#if CFG_TUSB_MCU == OPT_MCU_NRF5X +#if CFG_TUSB_MCU == OPT_MCU_LPC11UXX || CFG_TUSB_MCU == OPT_MCU_LPC13XX || \ + CFG_TUSB_MCU == OPT_MCU_LPC15XX || CFG_TUSB_MCU == OPT_MCU_LPC175X_6X || \ + CFG_TUSB_MCU == OPT_MCU_LPC177X_8X || CFG_TUSB_MCU == OPT_MCU_LPC18XX || \ + CFG_TUSB_MCU == OPT_MCU_LPC40XX || CFG_TUSB_MCU == OPT_MCU_LPC43XX + #include "chip.h" + +#elif CFG_TUSB_MCU == OPT_MCU_LPC51UXX || CFG_TUSB_MCU == OPT_MCU_LPC54XXX || \ + CFG_TUSB_MCU == OPT_MCU_LPC55XX + #include "fsl_device_registers.h" + +#elif CFG_TUSB_MCU == OPT_MCU_NRF5X #include "nrf.h" -#elif CFG_TUSB_MCU == OPT_MCU_SAMD21 || CFG_TUSB_MCU == OPT_MCU_SAMD51 + +#elif CFG_TUSB_MCU == OPT_MCU_SAMD21 || CFG_TUSB_MCU == OPT_MCU_SAMD51 || \ + CFG_TUSB_MCU == OPT_MCU_SAMG #include "sam.h" + +#elif CFG_TUSB_MCU == OPT_MCU_STM32F0 + #include "stm32f0xx.h" + +#elif CFG_TUSB_MCU == OPT_MCU_STM32F1 + #include "stm32f1xx.h" + +#elif CFG_TUSB_MCU == OPT_MCU_STM32F2 + #include "stm32f2xx.h" + +#elif CFG_TUSB_MCU == OPT_MCU_STM32F3 + #include "stm32f3xx.h" + +#elif CFG_TUSB_MCU == OPT_MCU_STM32F4 + #include "stm32f4xx.h" + +#elif CFG_TUSB_MCU == OPT_MCU_STM32F7 + #include "stm32f7xx.h" + +#elif CFG_TUSB_MCU == OPT_MCU_STM32H7 + #include "stm32h7xx.h" + +#elif CFG_TUSB_MCU == OPT_MCU_STM32L0 + #include "stm32l0xx.h" + +#elif CFG_TUSB_MCU == OPT_MCU_STM32L1 + #include "stm32l1xx.h" + +#elif CFG_TUSB_MCU == OPT_MCU_STM32L4 + #include "stm32l4xx.h" + +#elif CFG_TUSB_MCU == OPT_MCU_MIMXRT10XX + #include "fsl_device_registers.h" + +#elif CFG_TUSB_MCU == OPT_MCU_NUC120 || CFG_TUSB_MCU == OPT_MCU_NUC121 || \ + CFG_TUSB_MCU == OPT_MCU_NUC126 || CFG_TUSB_MCU == OPT_MCU_NUC505 + #include "NuMicro.h" + #else #error "FreeRTOSConfig.h need to include low level mcu header for configuration" #endif @@ -59,7 +109,7 @@ #define configTICK_RATE_HZ ( 1000 ) #define configMAX_PRIORITIES ( 5 ) #define configMINIMAL_STACK_SIZE ( 128 ) -#define configTOTAL_HEAP_SIZE ( 4*1024 ) +#define configTOTAL_HEAP_SIZE ( 0*1024 ) // dynamic is not used #define configMAX_TASK_NAME_LEN 16 #define configUSE_16_BIT_TICKS 0 #define configIDLE_SHOULD_YIELD 1 @@ -73,7 +123,7 @@ #define configENABLE_BACKWARD_COMPATIBILITY 1 #define configSUPPORT_STATIC_ALLOCATION 1 -#define configSUPPORT_DYNAMIC_ALLOCATION 1 +#define configSUPPORT_DYNAMIC_ALLOCATION 0 /* Hook function related definitions. */ #define configUSE_IDLE_HOOK 0 diff --git a/examples/device/cdc_msc_freertos/src/main.c b/examples/device/cdc_msc_freertos/src/main.c index e4d8264e6..704d0803b 100644 --- a/examples/device/cdc_msc_freertos/src/main.c +++ b/examples/device/cdc_msc_freertos/src/main.c @@ -51,13 +51,16 @@ enum { BLINK_SUSPENDED = 2500, }; +// static timer +StaticTimer_t static_blink; TimerHandle_t blink_tm; -// static task +// static task for usbd #define USBD_STACK_SIZE 150 StackType_t stack_usbd[USBD_STACK_SIZE]; StaticTask_t static_task_usbd; +// static task for cdc #define CDC_STACK_SZIE 128 StackType_t stack_cdc[CDC_STACK_SZIE]; StaticTask_t static_task_cdc; @@ -73,7 +76,7 @@ int main(void) board_init(); // soft timer for blinky - blink_tm = xTimerCreate(NULL, pdMS_TO_TICKS(BLINK_NOT_MOUNTED), true, NULL, led_blinky_cb); + blink_tm = xTimerCreateStatic(NULL, pdMS_TO_TICKS(BLINK_NOT_MOUNTED), true, NULL, led_blinky_cb, &static_blink); xTimerStart(blink_tm, 0); tusb_init(); diff --git a/hw/bsp/ea4357/board.mk b/hw/bsp/ea4357/board.mk index ff7b7a151..d79cf1411 100644 --- a/hw/bsp/ea4357/board.mk +++ b/hw/bsp/ea4357/board.mk @@ -35,7 +35,7 @@ VENDOR = nxp CHIP_FAMILY = transdimension # For freeRTOS port source -FREERTOS_PORT = ARM_CM4 +FREERTOS_PORT = ARM_CM4F # For flash-jlink target JLINK_DEVICE = LPC4357 diff --git a/hw/bsp/fomu/board.mk b/hw/bsp/fomu/board.mk index 8687cf41a..b824b6979 100644 --- a/hw/bsp/fomu/board.mk +++ b/hw/bsp/fomu/board.mk @@ -25,6 +25,9 @@ INC += \ VENDOR = valentyusb CHIP_FAMILY = eptri +# For freeRTOS port source +FREERTOS_PORT = RISC-V + # flash using dfu-util flash: $(BUILD)/$(BOARD)-firmware.dfu dfu-util -D $^ diff --git a/hw/bsp/lpcxpresso54114/board.mk b/hw/bsp/lpcxpresso54114/board.mk index 474a1ac5b..2bab0340f 100644 --- a/hw/bsp/lpcxpresso54114/board.mk +++ b/hw/bsp/lpcxpresso54114/board.mk @@ -39,7 +39,7 @@ VENDOR = nxp CHIP_FAMILY = lpc_ip3511 # For freeRTOS port source -FREERTOS_PORT = ARM_CM4 +FREERTOS_PORT = ARM_CM4F # For flash-jlink target JLINK_DEVICE = LPC54114J256_M4 diff --git a/hw/bsp/ngx4330/board.mk b/hw/bsp/ngx4330/board.mk index d95aaf056..df9df63a1 100644 --- a/hw/bsp/ngx4330/board.mk +++ b/hw/bsp/ngx4330/board.mk @@ -33,7 +33,7 @@ VENDOR = nxp CHIP_FAMILY = transdimension # For freeRTOS port source -FREERTOS_PORT = ARM_CM4 +FREERTOS_PORT = ARM_CM4F # For flash-jlink target JLINK_DEVICE = LPC4330 diff --git a/hw/bsp/nutiny_sdk_nuc505/board.mk b/hw/bsp/nutiny_sdk_nuc505/board.mk index 68dea63a9..1c1cbcf0d 100644 --- a/hw/bsp/nutiny_sdk_nuc505/board.mk +++ b/hw/bsp/nutiny_sdk_nuc505/board.mk @@ -40,7 +40,7 @@ VENDOR = nuvoton CHIP_FAMILY = nuc505 # For freeRTOS port source -FREERTOS_PORT = ARM_CM4 +FREERTOS_PORT = ARM_CM4F # For flash-jlink target JLINK_DEVICE = NUC505YO13Y diff --git a/hw/bsp/samg55xplained/samg55xplained.c b/hw/bsp/samg55xplained/samg55xplained.c index 66a3d137f..1eb5105b9 100644 --- a/hw/bsp/samg55xplained/samg55xplained.c +++ b/hw/bsp/samg55xplained/samg55xplained.c @@ -42,7 +42,6 @@ #define BUTTON_PIN GPIO(GPIO_PORTA, 2) #define BUTTON_STATE_ACTIVE 0 - #define UART_TX_PIN GPIO(GPIO_PORTA, 28) #define UART_RX_PIN GPIO(GPIO_PORTA, 27)