update freertos example to build with iar

This commit is contained in:
hathach 2023-01-17 23:38:10 +07:00
parent c86e628a4c
commit 8df2fd1916
8 changed files with 40 additions and 23 deletions

View File

@ -4,13 +4,14 @@ include ../../../tools/top.mk
include ../../make.mk include ../../make.mk
FREERTOS_SRC = lib/FreeRTOS-Kernel FREERTOS_SRC = lib/FreeRTOS-Kernel
FREERTOS_PORTABLE_SRC= $(FREERTOS_SRC)/portable/$(if $(USE_IAR),IAR,GCC)/$(FREERTOS_PORT)
INC += \ INC += \
src \ src \
src/FreeRTOSConfig \ src/FreeRTOSConfig \
$(TOP)/hw \ $(TOP)/hw \
$(TOP)/$(FREERTOS_SRC)/include \ $(TOP)/$(FREERTOS_SRC)/include \
$(TOP)/$(FREERTOS_SRC)/portable/GCC/$(FREERTOS_PORT) $(TOP)/$(FREERTOS_PORTABLE_SRC)
# Example source # Example source
EXAMPLE_SOURCE = \ EXAMPLE_SOURCE = \
@ -27,17 +28,20 @@ SRC_C += \
$(FREERTOS_SRC)/queue.c \ $(FREERTOS_SRC)/queue.c \
$(FREERTOS_SRC)/tasks.c \ $(FREERTOS_SRC)/tasks.c \
$(FREERTOS_SRC)/timers.c \ $(FREERTOS_SRC)/timers.c \
$(subst ../../../,,$(wildcard ../../../$(FREERTOS_SRC)/portable/GCC/$(FREERTOS_PORT)/*.c)) $(subst ../../../,,$(wildcard ../../../$(FREERTOS_PORTABLE_SRC)/*.c))
SRC_S += \
$(subst ../../../,,$(wildcard ../../../$(FREERTOS_PORTABLE_SRC)/*.s))
# include heap manage if configSUPPORT_DYNAMIC_ALLOCATION = 1 # include heap manage if configSUPPORT_DYNAMIC_ALLOCATION = 1
# SRC_C += $(FREERTOS_SRC)/portable/MemMang/heap_1.c # SRC_C += $(FREERTOS_SRC)/portable/MemMang/heap_1.c
# CFLAGS += -Wno-error=sign-compare # CFLAGS += -Wno-error=sign-compare
# Suppress FreeRTOSConfig.h warnings # Suppress FreeRTOSConfig.h warnings
CFLAGS += -Wno-error=redundant-decls GCC_CFLAGS += -Wno-error=redundant-decls
# Suppress FreeRTOS source warnings # Suppress FreeRTOS source warnings
CFLAGS += -Wno-error=cast-qual GCC_CFLAGS += -Wno-error=cast-qual
# FreeRTOS (lto + Os) linker issue # FreeRTOS (lto + Os) linker issue
LDFLAGS += -Wl,--undefined=vTaskSwitchContext LDFLAGS += -Wl,--undefined=vTaskSwitchContext

View File

@ -42,6 +42,9 @@
* See http://www.freertos.org/a00110.html. * See http://www.freertos.org/a00110.html.
*----------------------------------------------------------*/ *----------------------------------------------------------*/
// skip if is compiled with assembler
#if !defined(__ASSEMBLER__) && !defined(__IASMARM__)
// Include MCU header // Include MCU header
#include "bsp/board_mcu.h" #include "bsp/board_mcu.h"
@ -57,6 +60,8 @@
extern uint32_t SystemCoreClock; extern uint32_t SystemCoreClock;
#endif #endif
#endif
/* Cortex M23/M33 port configuration. */ /* Cortex M23/M33 port configuration. */
#define configENABLE_MPU 0 #define configENABLE_MPU 0
#define configENABLE_FPU 1 #define configENABLE_FPU 1
@ -166,7 +171,7 @@
#elif defined(__ECLIC_INTCTLBITS) #elif defined(__ECLIC_INTCTLBITS)
// RISC-V Bumblebee core from nuclei // RISC-V Bumblebee core from nuclei
#define configPRIO_BITS __ECLIC_INTCTLBITS #define configPRIO_BITS __ECLIC_INTCTLBITS
#else #elif !defined(__ASSEMBLER__) && !defined(__IASMARM__)
#error "FreeRTOS configPRIO_BITS to be defined" #error "FreeRTOS configPRIO_BITS to be defined"
#endif #endif

View File

@ -4,13 +4,14 @@ include ../../../tools/top.mk
include ../../make.mk include ../../make.mk
FREERTOS_SRC = lib/FreeRTOS-Kernel FREERTOS_SRC = lib/FreeRTOS-Kernel
FREERTOS_PORTABLE_SRC= $(FREERTOS_SRC)/portable/$(if $(USE_IAR),IAR,GCC)/$(FREERTOS_PORT)
INC += \ INC += \
src \ src \
src/FreeRTOSConfig \ src/FreeRTOSConfig \
$(TOP)/hw \ $(TOP)/hw \
$(TOP)/$(FREERTOS_SRC)/include \ $(TOP)/$(FREERTOS_SRC)/include \
$(TOP)/$(FREERTOS_SRC)/portable/GCC/$(FREERTOS_PORT) $(TOP)/$(FREERTOS_PORTABLE_SRC)
# Example source # Example source
EXAMPLE_SOURCE = \ EXAMPLE_SOURCE = \
@ -26,17 +27,20 @@ SRC_C += \
$(FREERTOS_SRC)/queue.c \ $(FREERTOS_SRC)/queue.c \
$(FREERTOS_SRC)/tasks.c \ $(FREERTOS_SRC)/tasks.c \
$(FREERTOS_SRC)/timers.c \ $(FREERTOS_SRC)/timers.c \
$(subst ../../../,,$(wildcard ../../../$(FREERTOS_SRC)/portable/GCC/$(FREERTOS_PORT)/*.c)) $(subst ../../../,,$(wildcard ../../../$(FREERTOS_PORTABLE_SRC)/*.c))
SRC_S += \
$(subst ../../../,,$(wildcard ../../../$(FREERTOS_PORTABLE_SRC)/*.s))
# include heap manage if configSUPPORT_DYNAMIC_ALLOCATION = 1 # include heap manage if configSUPPORT_DYNAMIC_ALLOCATION = 1
# SRC_C += $(FREERTOS_SRC)/portable/MemMang/heap_1.c # SRC_C += $(FREERTOS_SRC)/portable/MemMang/heap_1.c
# CFLAGS += -Wno-error=sign-compare # CFLAGS += -Wno-error=sign-compare
# Suppress FreeRTOSConfig.h warnings # Suppress FreeRTOSConfig.h warnings
CFLAGS += -Wno-error=redundant-decls GCC_CFLAGS += -Wno-error=redundant-decls
# Suppress FreeRTOS source warnings # Suppress FreeRTOS source warnings
CFLAGS += -Wno-error=cast-qual GCC_CFLAGS += -Wno-error=cast-qual
# FreeRTOS (lto + Os) linker issue # FreeRTOS (lto + Os) linker issue
LDFLAGS += -Wl,--undefined=vTaskSwitchContext LDFLAGS += -Wl,--undefined=vTaskSwitchContext

View File

@ -42,6 +42,9 @@
* See http://www.freertos.org/a00110.html. * See http://www.freertos.org/a00110.html.
*----------------------------------------------------------*/ *----------------------------------------------------------*/
// skip if is compiled with assembler
#if !defined(__ASSEMBLER__) && !defined(__IASMARM__)
// Include MCU header // Include MCU header
#include "bsp/board_mcu.h" #include "bsp/board_mcu.h"
@ -57,6 +60,8 @@
extern uint32_t SystemCoreClock; extern uint32_t SystemCoreClock;
#endif #endif
#endif
/* Cortex M23/M33 port configuration. */ /* Cortex M23/M33 port configuration. */
#define configENABLE_MPU 0 #define configENABLE_MPU 0
#define configENABLE_FPU 1 #define configENABLE_FPU 1
@ -166,7 +171,7 @@
#elif defined(__ECLIC_INTCTLBITS) #elif defined(__ECLIC_INTCTLBITS)
// RISC-V Bumblebee core from nuclei // RISC-V Bumblebee core from nuclei
#define configPRIO_BITS __ECLIC_INTCTLBITS #define configPRIO_BITS __ECLIC_INTCTLBITS
#else #elif !defined(__ASSEMBLER__) && !defined(__IASMARM__)
#error "FreeRTOS configPRIO_BITS to be defined" #error "FreeRTOS configPRIO_BITS to be defined"
#endif #endif

View File

@ -48,8 +48,11 @@ CFLAGS += $(addprefix -I,$(INC))
ifdef USE_IAR ifdef USE_IAR
IAR_CFLAGS += $(CFLAGS) -e --debug IAR_CFLAGS += $(CFLAGS) -e --debug --silent
IAR_LDFLAGS += --config $(TOP)/$(IAR_LD_FILE) IAR_LDFLAGS += --config $(TOP)/$(IAR_LD_FILE)
IAR_ASFLAGS += $(CFLAGS) -S
SRC_S += $(IAR_SRC_S)
else else
@ -73,7 +76,9 @@ endif
ASFLAGS += $(CFLAGS) ASFLAGS += $(CFLAGS)
endif SRC_S += $(GCC_SRC_S)
endif # USE_IAR
# Verbose mode # Verbose mode
ifeq ("$(V)","1") ifeq ("$(V)","1")
@ -84,17 +89,11 @@ endif
# Assembly files can be name with upper case .S, convert it to .s # Assembly files can be name with upper case .S, convert it to .s
SRC_S := $(SRC_S:.S=.s) SRC_S := $(SRC_S:.S=.s)
IAR_SRC_S := $(IAR_SRC_S:.S=.s)
# Due to GCC LTO bug https://bugs.launchpad.net/gcc-arm-embedded/+bug/1747966 # Due to GCC LTO bug https://bugs.launchpad.net/gcc-arm-embedded/+bug/1747966
# assembly file should be placed first in linking order # assembly file should be placed first in linking order
# '_asm' suffix is added to object of assembly file # '_asm' suffix is added to object of assembly file
ifdef USE_IAR
OBJ += $(addprefix $(BUILD)/obj/, $(IAR_SRC_S:.s=_asm.o))
else
OBJ += $(addprefix $(BUILD)/obj/, $(SRC_S:.s=_asm.o)) OBJ += $(addprefix $(BUILD)/obj/, $(SRC_S:.s=_asm.o))
endif
OBJ += $(addprefix $(BUILD)/obj/, $(SRC_C:.c=.o)) OBJ += $(addprefix $(BUILD)/obj/, $(SRC_C:.c=.o))
# --------------------------------------- # ---------------------------------------
@ -156,11 +155,11 @@ else
$(BUILD)/$(PROJECT).bin: $(BUILD)/$(PROJECT).elf $(BUILD)/$(PROJECT).bin: $(BUILD)/$(PROJECT).elf
@echo CREATE $@ @echo CREATE $@
@$(OBJCOPY) --bin $^ $@ @$(OBJCOPY) --silent --bin $^ $@
$(BUILD)/$(PROJECT).hex: $(BUILD)/$(PROJECT).elf $(BUILD)/$(PROJECT).hex: $(BUILD)/$(PROJECT).elf
@echo CREATE $@ @echo CREATE $@
@$(OBJCOPY) --ihex $^ $@ @$(OBJCOPY) --silent --ihex $^ $@
$(BUILD)/$(PROJECT).elf: $(OBJ) $(BUILD)/$(PROJECT).elf: $(OBJ)
@echo LINK $@ @echo LINK $@

View File

@ -1,6 +1,6 @@
CFLAGS += -DSTM32F070xB -DCFG_EXAMPLE_VIDEO_READONLY CFLAGS += -DSTM32F070xB -DCFG_EXAMPLE_VIDEO_READONLY
SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f070xb.s GCC_SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f070xb.s
LD_FILE = $(BOARD_PATH)/stm32F070rbtx_flash.ld LD_FILE = $(BOARD_PATH)/stm32F070rbtx_flash.ld
IAR_SRC_S += $(ST_CMSIS)/Source/Templates/iar/startup_stm32f070xb.s IAR_SRC_S += $(ST_CMSIS)/Source/Templates/iar/startup_stm32f070xb.s

View File

@ -1,6 +1,6 @@
CFLAGS += -DSTM32F072xB -DCFG_EXAMPLE_VIDEO_READONLY CFLAGS += -DSTM32F072xB -DCFG_EXAMPLE_VIDEO_READONLY
SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f072xb.s GCC_SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f072xb.s
LD_FILE = $(BOARD_PATH)/STM32F072RBTx_FLASH.ld LD_FILE = $(BOARD_PATH)/STM32F072RBTx_FLASH.ld
IAR_SRC_S += $(ST_CMSIS)/Source/Templates/iar/startup_stm32f072xb.s IAR_SRC_S += $(ST_CMSIS)/Source/Templates/iar/startup_stm32f072xb.s

View File

@ -1,6 +1,6 @@
CFLAGS += -DSTM32F072xB -DLSI_VALUE=40000 -DCFG_EXAMPLE_VIDEO_READONLY CFLAGS += -DSTM32F072xB -DLSI_VALUE=40000 -DCFG_EXAMPLE_VIDEO_READONLY
SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f072xb.s GCC_SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32f072xb.s
LD_FILE = $(BOARD_PATH)/STM32F072VBTx_FLASH.ld LD_FILE = $(BOARD_PATH)/STM32F072VBTx_FLASH.ld
IAR_SRC_S += $(ST_CMSIS)/Source/Templates/iar/startup_stm32f072xb.s IAR_SRC_S += $(ST_CMSIS)/Source/Templates/iar/startup_stm32f072xb.s