mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Update Makefile
This commit is contained in:
@@ -15,6 +15,7 @@ HAL_INC_DIR = ./Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc
|
|||||||
HAL_LEGACY_INC_DIR = ./Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/Legacy
|
HAL_LEGACY_INC_DIR = ./Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/Legacy
|
||||||
FRTOS_CMIS_INC_DIR = ./Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS
|
FRTOS_CMIS_INC_DIR = ./Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS
|
||||||
FRTOS_INC_DIR = ./Middlewares/Third_Party/FreeRTOS/Source/include
|
FRTOS_INC_DIR = ./Middlewares/Third_Party/FreeRTOS/Source/include
|
||||||
|
MINIWARE_STARTUP_DIR = ./Startup
|
||||||
DRIVER_INC_DIR =./Core/Drivers
|
DRIVER_INC_DIR =./Core/Drivers
|
||||||
BSP_INC_DIR = ./Core/BSP
|
BSP_INC_DIR = ./Core/BSP
|
||||||
THREADS_INC_DIR = ./Core/Threads
|
THREADS_INC_DIR = ./Core/Threads
|
||||||
@@ -39,15 +40,22 @@ DEVICE_INCLUDES = -I$(MINIWARE_INC_DIR) \
|
|||||||
-I$(HAL_LEGACY_INC_DIR) \
|
-I$(HAL_LEGACY_INC_DIR) \
|
||||||
-I$(INC_PD_DRIVERS_DIR)
|
-I$(INC_PD_DRIVERS_DIR)
|
||||||
DEVICE_BSP_DIR = ./Core/BSP/Miniware
|
DEVICE_BSP_DIR = ./Core/BSP/Miniware
|
||||||
S_SRCS := ./Startup/startup_stm32f103t8ux.S
|
S_SRCS := $(shell find $(MINIWARE_STARTUP_DIR) -type f -name '*.S')
|
||||||
LDSCRIPT=stm32f103.ld
|
LDSCRIPT=stm32f103.ld
|
||||||
DEV_GLOBAL_DEFS= -D STM32F103T8Ux -D STM32F1 -D STM32 -D USE_HAL_DRIVER -D STM32F103xB -D USE_RTOS_SYSTICK -D GCC_ARMCM3 \
|
DEV_GLOBAL_DEFS= -D STM32F103T8Ux -D STM32F1 -D STM32 -D USE_HAL_DRIVER -D STM32F103xB -D USE_RTOS_SYSTICK -D GCC_ARMCM3 \
|
||||||
-D ARM_MATH_CM3 \
|
-D ARM_MATH_CM3 \
|
||||||
-D STM32F10X_MD
|
-D STM32F10X_MD
|
||||||
DEV_LDFLAGS=-lm -Wl,--gc-sections -flto
|
DEV_LDFLAGS=-lm -Wl,--gc-sections -flto
|
||||||
DEV_AFLAGS=
|
DEV_AFLAGS=
|
||||||
DEV_CFLAGS=-flto
|
DEV_CFLAGS=-flto -D GCC_ARMCM3 \
|
||||||
DEV_CXXFLAGS=-flto
|
-D ARM_MATH_CM3 \
|
||||||
|
-D STM32F10X_MD
|
||||||
|
DEV_CXXFLAGS=-flto -D GCC_ARMCM3 \
|
||||||
|
-D ARM_MATH_CM3 \
|
||||||
|
-D STM32F10X_MD
|
||||||
|
CPUFLAGS= -mcpu=cortex-m3 \
|
||||||
|
-mthumb \
|
||||||
|
-mfloat-abi=soft
|
||||||
flash_size=64k
|
flash_size=64k
|
||||||
bootldr_size=0x4000
|
bootldr_size=0x4000
|
||||||
endif
|
endif
|
||||||
@@ -62,15 +70,24 @@ DEVICE_INCLUDES = -I$(PINE_INC_DIR) \
|
|||||||
-I$(INC_PD_DRIVERS_DIR)
|
-I$(INC_PD_DRIVERS_DIR)
|
||||||
|
|
||||||
DEVICE_BSP_DIR = ./Core/BSP/Pine64
|
DEVICE_BSP_DIR = ./Core/BSP/Pine64
|
||||||
S_SRCS := $(shell find $(PINE_INC_DIR) -type f -name '*.S')
|
S_SRCS := ./Core/BSP/Pine64/N200/portasm.S
|
||||||
|
$(info $(S_SRCS) )
|
||||||
ASM_INC = -I$(PINE_RISCV_INC_DIR)
|
ASM_INC = -I$(PINE_RISCV_INC_DIR)
|
||||||
LDSCRIPT=GD32VF103xB.ld
|
LDSCRIPT=GD32VF103xB.ld
|
||||||
DEV_LDFLAGS=-nostartfiles -Xlinker --gc-sections
|
flash_size=128k
|
||||||
|
bootldr_size=0x0
|
||||||
|
# Flags
|
||||||
|
CPUFLAGS= -march=rv32imac \
|
||||||
|
-mabi=ilp32 \
|
||||||
|
-mtune=size \
|
||||||
|
-mcmodel=medany \
|
||||||
|
-DGD32VF103C_START \
|
||||||
|
-DUSE_STDPERIPH_DRIVER
|
||||||
|
DEV_LDFLAGS= -nostartfiles -Xlinker --gc-sections
|
||||||
|
DEV_AFLAGS= -nostartfiles -ffreestanding
|
||||||
DEV_GLOBAL_DEFS=-msmall-data-limit=8 -mno-save-restore -Os -fmessage-length=0 -fabi-version=0
|
DEV_GLOBAL_DEFS=-msmall-data-limit=8 -mno-save-restore -Os -fmessage-length=0 -fabi-version=0
|
||||||
DEV_CFLAGS= -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)"
|
DEV_CFLAGS= -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)"
|
||||||
DEV_CXXFLAGS= -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)"
|
DEV_CXXFLAGS= -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)"
|
||||||
flash_size=128k
|
|
||||||
bootldr_size=0x0
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
INCLUDES = -I$(APP_INC_DIR) \
|
INCLUDES = -I$(APP_INC_DIR) \
|
||||||
@@ -95,15 +112,14 @@ $(shell find $(SOURCE_MIDDLEWARES_DIR) -type f -name '*.cpp')
|
|||||||
HEXFILE_DIR=Hexfile
|
HEXFILE_DIR=Hexfile
|
||||||
|
|
||||||
# temporary objects folder
|
# temporary objects folder
|
||||||
OUTPUT_BASE_DIR=Objects
|
OUTPUT_DIR=Objects
|
||||||
OUTPUT_DIR=$(OUTPUT_BASE_DIR)/$(model)
|
|
||||||
# code optimisation ------------------------------------------------------------
|
# code optimisation ------------------------------------------------------------
|
||||||
OPTIM_AS= -Wall
|
|
||||||
OPTIM=-Os -finline-small-functions -findirect-inlining -fdiagnostics-color -ffunction-sections -fdata-sections
|
OPTIM=-Os -finline-small-functions -findirect-inlining -fdiagnostics-color -ffunction-sections -fdata-sections
|
||||||
|
|
||||||
|
|
||||||
# global defines ---------------------------------------------------------------
|
# global defines ---------------------------------------------------------------
|
||||||
GLOBAL_DEFINES += -D LANG_$(lang) -D LANG -D MODEL_$(model) $(DEV_GLOBAL_DEFS)
|
GLOBAL_DEFINES += $(DEV_GLOBAL_DEFS) -D USE_RTOS_SYSTICK -D LANG_$(lang) -D LANG -D MODEL_$(model) -D VECT_TAB_OFFSET=$(bootldr_size)U
|
||||||
|
|
||||||
ifdef swd_enable
|
ifdef swd_enable
|
||||||
GLOBAL_DEFINES += -DSWD_ENABLE
|
GLOBAL_DEFINES += -DSWD_ENABLE
|
||||||
@@ -111,11 +127,13 @@ endif
|
|||||||
|
|
||||||
# Enable debug code generation
|
# Enable debug code generation
|
||||||
DEBUG=-g3
|
DEBUG=-g3
|
||||||
|
# Without debug code
|
||||||
|
#DEBUG=
|
||||||
|
|
||||||
|
|
||||||
# libs -------------------------------------------------------------------------
|
# libs -------------------------------------------------------------------------
|
||||||
LIBS=
|
LIBS=
|
||||||
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
COMPILER=gcc
|
COMPILER=gcc
|
||||||
# arm-none-eabi is the general ARM compiler,
|
# arm-none-eabi is the general ARM compiler,
|
||||||
@@ -136,51 +154,26 @@ SIZE=$(COMPILER_PREFIX)-size
|
|||||||
SREC=srec_cat
|
SREC=srec_cat
|
||||||
SREC_INFO=srec_info
|
SREC_INFO=srec_info
|
||||||
|
|
||||||
|
# For the Pinecil, use GCC rather than as? (Copying other makefiles)
|
||||||
ifeq ($(model),Pinecil)
|
ifeq ($(model),Pinecil)
|
||||||
AS=$(COMPILER_PREFIX)-gcc -x assembler-with-cpp
|
AS=$(COMPILER_PREFIX)-gcc -x assembler-with-cpp
|
||||||
endif
|
endif
|
||||||
# compiler flags ---------------------------------------------------------------
|
|
||||||
ifeq ($(model),$(filter $(model),TS100 TS80 TS80P))
|
|
||||||
CPUFLAGS= -mthumb \
|
|
||||||
-mcpu=cortex-m3 \
|
|
||||||
-mfloat-abi=soft
|
|
||||||
endif
|
|
||||||
ifeq ($(model),Pinecil)
|
|
||||||
CPUFLAGS= -march=rv32imac \
|
|
||||||
-mabi=ilp32 \
|
|
||||||
-mtune=size \
|
|
||||||
-mcmodel=medany \
|
|
||||||
-DGD32VF103C_START \
|
|
||||||
-DUSE_STDPERIPH_DRIVER
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# linker flags -----------------------------------------------------------------
|
# linker flags -----------------------------------------------------------------
|
||||||
LINKER_FLAGS=$(CPUFLAGS) \
|
LINKER_FLAGS= -Wl,--gc-sections \
|
||||||
$(GLOBAL_DEFINES) \
|
-Wl,--wrap=malloc \
|
||||||
-D${COMPILER} \
|
-Wl,--wrap=free \
|
||||||
-MMD \
|
-o$(OUT_HEXFILE).elf \
|
||||||
-std=c++11 \
|
-Wl,-Map=$(OUT_HEXFILE).map \
|
||||||
$(OPTIM) \
|
-lm \
|
||||||
-ffreestanding \
|
-Wl,--undefined=vTaskSwitchContext \
|
||||||
-fno-common \
|
-Wl,--undefined=pxCurrentTCB \
|
||||||
-fno-rtti \
|
-Wl,--defsym=__FLASH_SIZE__=$(flash_size) \
|
||||||
-fno-exceptions \
|
-Wl,--defsym=__BOOTLDR_SIZE__=$(bootldr_size) \
|
||||||
-fno-non-call-exceptions \
|
$(DEV_LDFLAGS) \
|
||||||
-fno-strict-aliasing \
|
--specs=nano.specs
|
||||||
-fno-threadsafe-statics \
|
|
||||||
-Wl,--wrap=malloc \
|
|
||||||
-Wl,--wrap=free \
|
|
||||||
-Wl,-Map=$(OUT_HEXFILE).map \
|
|
||||||
-Wl,--undefined=vTaskSwitchContext \
|
|
||||||
-T $(LDSCRIPT) \
|
|
||||||
-Wl,--defsym=__FLASH_SIZE__=$(flash_size) \
|
|
||||||
-Wl,--defsym=__BOOTLDR_SIZE__=$(bootldr_size) \
|
|
||||||
--specs=nano.specs \
|
|
||||||
$(DEV_LDFLAGS) \
|
|
||||||
-o$(OUT_HEXFILE).elf \
|
|
||||||
|
|
||||||
|
# compiler flags ---------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
CHECKOPTIONS= -Wall \
|
CHECKOPTIONS= -Wall \
|
||||||
@@ -210,13 +203,15 @@ CHECKOPTIONS= -Wall \
|
|||||||
-Wshadow \
|
-Wshadow \
|
||||||
-Wno-unused-parameter \
|
-Wno-unused-parameter \
|
||||||
-Wdouble-promotion \
|
-Wdouble-promotion \
|
||||||
-Werror
|
-Werror
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CHECKOPTIONS_C= -Wbad-function-cast
|
CHECKOPTIONS_C= -Wbad-function-cast
|
||||||
|
|
||||||
|
|
||||||
CXXFLAGS=$(CPUFLAGS) \
|
CXXFLAGS=$(DEV_CXXFLAGS) \
|
||||||
|
$(CPUFLAGS) \
|
||||||
$(DEBUG) \
|
$(DEBUG) \
|
||||||
$(INCLUDES) \
|
$(INCLUDES) \
|
||||||
$(GLOBAL_DEFINES) \
|
$(GLOBAL_DEFINES) \
|
||||||
@@ -225,39 +220,44 @@ CXXFLAGS=$(CPUFLAGS) \
|
|||||||
$(CHECKOPTIONS) \
|
$(CHECKOPTIONS) \
|
||||||
-std=c++11 \
|
-std=c++11 \
|
||||||
$(OPTIM) \
|
$(OPTIM) \
|
||||||
-ffreestanding \
|
|
||||||
-fno-common \
|
-fno-common \
|
||||||
|
-ffreestanding \
|
||||||
-fno-rtti \
|
-fno-rtti \
|
||||||
-fno-exceptions \
|
-fno-exceptions \
|
||||||
-fno-non-call-exceptions \
|
-fno-non-call-exceptions \
|
||||||
-fno-use-cxa-atexit \
|
-fno-use-cxa-atexit \
|
||||||
-fno-strict-aliasing \
|
-fno-strict-aliasing \
|
||||||
|
-fno-rtti \
|
||||||
|
-fno-exceptions \
|
||||||
-fno-threadsafe-statics \
|
-fno-threadsafe-statics \
|
||||||
$(DEV_CXXFLAGS)
|
-T$(LDSCRIPT)
|
||||||
|
|
||||||
|
|
||||||
CFLAGS=$(CPUFLAGS) \
|
CFLAGS=$(DEV_CFLAGS) \
|
||||||
|
$(CPUFLAGS) \
|
||||||
$(DEBUG) \
|
$(DEBUG) \
|
||||||
$(INCLUDES) \
|
$(INCLUDES) \
|
||||||
$(CHECKOPTIONS_C) \
|
$(CHECKOPTIONS_C) \
|
||||||
$(GLOBAL_DEFINES) \
|
$(GLOBAL_DEFINES) \
|
||||||
-D${COMPILER} \
|
-D${COMPILER} \
|
||||||
-MMD \
|
-MMD \
|
||||||
-ffreestanding \
|
|
||||||
-std=gnu99 \
|
-std=gnu99 \
|
||||||
$(OPTIM) \
|
$(OPTIM) \
|
||||||
$(DEV_CFLAGS) \
|
|
||||||
-fno-common \
|
-fno-common \
|
||||||
-c
|
-ffreestanding \
|
||||||
|
-T$(LDSCRIPT) \
|
||||||
|
-c
|
||||||
|
|
||||||
|
|
||||||
AFLAGS=$(CPUFLAGS) \
|
AFLAGS= $(CPUFLAGS) \
|
||||||
$(OPTIM_AS) \
|
$(DEV_AFLAGS) \
|
||||||
$(DEBUG) \
|
$(DEBUG) \
|
||||||
$(ASM_INC) \
|
$(ASM_INC) \
|
||||||
$(DEV_AFLAGS)
|
$(INCLUDES)
|
||||||
|
|
||||||
|
|
||||||
|
CFLAGS += -ffunction-sections -fdata-sections
|
||||||
|
CXXFLAGS += -ffunction-sections -fdata-sections
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -284,13 +284,14 @@ all: $(OUT_HEXFILE).hex $(OUT_HEXFILE).bin
|
|||||||
$(OBJCOPY) $^ -O ihex $@
|
$(OBJCOPY) $^ -O ihex $@
|
||||||
|
|
||||||
%.bin : %.elf
|
%.bin : %.elf
|
||||||
|
$(SIZE) $^
|
||||||
$(OBJCOPY) $^ -O binary $@
|
$(OBJCOPY) $^ -O binary $@
|
||||||
|
|
||||||
$(OUT_HEXFILE).elf : $(OUT_OBJS_S) $(OUT_OBJS) $(OUT_OBJS_CPP) Makefile $(LDSCRIPT)
|
$(OUT_HEXFILE).elf : $(OUT_OBJS_S) $(OUT_OBJS) $(OUT_OBJS_CPP) Makefile $(LDSCRIPT)
|
||||||
@test -d $(@D) || mkdir -p $(@D)
|
@test -d $(@D) || mkdir -p $(@D)
|
||||||
@echo Linking $(OUTPUT_EXE).elf
|
@echo Linking $(OUTPUT_EXE).elf
|
||||||
@echo $(CPP) $(LINKER_FLAGS)
|
@echo $(LINKER_FLAGS)
|
||||||
@$(CPP) $(LINKER_FLAGS) $(OUT_OBJS) $(OUT_OBJS_CPP) $(OUT_OBJS_S) $(LIBS)
|
@$(CPP) $(CXXFLAGS) $(OUT_OBJS_S) $(OUT_OBJS) $(OUT_OBJS_CPP) $(LIBS) $(LINKER_FLAGS)
|
||||||
|
|
||||||
$(OUT_OBJS): $(OUTPUT_DIR)/%.o : %.c Makefile
|
$(OUT_OBJS): $(OUTPUT_DIR)/%.o : %.c Makefile
|
||||||
@test -d $(@D) || mkdir -p $(@D)
|
@test -d $(@D) || mkdir -p $(@D)
|
||||||
@@ -303,21 +304,21 @@ $(OUT_OBJS_CPP): $(OUTPUT_DIR)/%.o : %.cpp Makefile
|
|||||||
@echo Compiling ${<}
|
@echo Compiling ${<}
|
||||||
@$(CPP) -c $(CXXFLAGS) $< -o $@
|
@$(CPP) -c $(CXXFLAGS) $< -o $@
|
||||||
@$(OBJDUMP) -d -S $@ > $@.lst
|
@$(OBJDUMP) -d -S $@ > $@.lst
|
||||||
|
|
||||||
$(OUT_OBJS_S): $(OUTPUT_DIR)/%.o: %.S Makefile
|
$(OUT_OBJS_S): $(OUTPUT_DIR)/%.o: %.S Makefile
|
||||||
@test -d $(@D) || mkdir -p $(@D)
|
@test -d $(@D) || mkdir -p $(@D)
|
||||||
@echo 'Building file: $<'
|
@echo 'Building file: $<'
|
||||||
@echo 'Invoking: MCU GCC Assembler'
|
@echo 'Invoking: MCU GCC Assembler'
|
||||||
@$(AS) -c $(AFLAGS) $< -o $@
|
@echo @$(AS) -c $(AFLAGS) $< -o $@
|
||||||
|
@$(AS) -c $(AFLAGS) $< -o $@
|
||||||
@echo 'Finished building: $<'
|
@echo 'Finished building: $<'
|
||||||
@echo ' '
|
@echo ' '
|
||||||
|
|
||||||
|
|
||||||
clean :
|
clean :
|
||||||
rm -Rf $(OUTPUT_BASE_DIR)
|
rm -Rf $(OUTPUT_DIR)
|
||||||
rm -Rf $(HEXFILE_DIR)
|
rm -Rf $(HEXFILE_DIR)
|
||||||
|
|
||||||
|
|
||||||
# pull in dependency info for *existing* .o files
|
# pull in dependency info for *existing* .o files
|
||||||
-include $(OUT_OBJS:.o=.d)
|
-include $(OUT_OBJS:.o=.d)
|
||||||
-include $(OUT_OBJS_CPP:.o=.d)
|
-include $(OUT_OBJS_CPP:.o=.d)
|
||||||
|
|||||||
Reference in New Issue
Block a user