fix makefiles and cleanup dirs
This commit is contained in:
		
							parent
							
								
									c1b2bd232d
								
							
						
					
					
						commit
						ef6106d17c
					
				
					 14 changed files with 7 additions and 3 deletions
				
			
		|  | @ -1,154 +0,0 @@ | |||
| ######################################
 | ||||
| # target
 | ||||
| ######################################
 | ||||
| TARGET = stm32g0_blinky | ||||
| PART = STM32G030xx | ||||
| PYOCD_TARGET = stm32g030f6px | ||||
| 
 | ||||
| 
 | ||||
| ######################################
 | ||||
| # building variables
 | ||||
| ######################################
 | ||||
| # debug build?
 | ||||
| DEBUG = 1 | ||||
| # optimization for size
 | ||||
| OPT = -Os | ||||
| 
 | ||||
| 
 | ||||
| #######################################
 | ||||
| # paths
 | ||||
| #######################################
 | ||||
| # Build path
 | ||||
| BUILD_DIR = build | ||||
| VND_DIR = ../../vendor | ||||
| 
 | ||||
| ######################################
 | ||||
| # source
 | ||||
| ######################################
 | ||||
| # C sources
 | ||||
| include hal.mk | ||||
| C_SOURCES += \
 | ||||
| $(VND_DIR)/STM32CubeG0/Drivers/CMSIS/Device/ST/STM32G0xx/Source/Templates/system_stm32g0xx.c \ | ||||
| src/main.c | ||||
| 
 | ||||
| 
 | ||||
| # ASM sources
 | ||||
| ASM_SOURCES =  \
 | ||||
| $(VND_DIR)/STM32CubeG0/Drivers/CMSIS/Device/ST/STM32G0xx/Source/Templates/gcc/startup_stm32g030xx.s | ||||
| 
 | ||||
| #######################################
 | ||||
| # binaries
 | ||||
| #######################################
 | ||||
| PREFIX = arm-none-eabi- | ||||
| 
 | ||||
| CC = $(PREFIX)gcc | ||||
| CP = $(PREFIX)objcopy | ||||
| #SZ = $(PREFIX)size
 | ||||
| 
 | ||||
| BIN = $(CP) -O binary -S | ||||
| 
 | ||||
| #######################################
 | ||||
| # CFLAGS
 | ||||
| #######################################
 | ||||
| 
 | ||||
| ifeq ($(DEBUG), 1) | ||||
| DEBUG_FLAGS = -gdwarf-3 | ||||
| endif | ||||
| 
 | ||||
| # cpu
 | ||||
| CPU = \
 | ||||
|  -mcpu=cortex-m0plus | ||||
| 
 | ||||
| DEFINES = -D$(PART) | ||||
| 
 | ||||
| # fpu
 | ||||
| FPU =  | ||||
| 
 | ||||
| # float-abi
 | ||||
| FLOAT-ABI = | ||||
| 
 | ||||
| # mcu
 | ||||
| MCU = $(CPU) $(FPU) $(FLOAT-ABI) | ||||
| 
 | ||||
| # C includes
 | ||||
| C_INCLUDES +=  \
 | ||||
|  -Isrc/inc \
 | ||||
|  -I$(VND_DIR)/STM32CubeG0/Drivers/CMSIS/Core/Include \
 | ||||
|  -I$(VND_DIR)/STM32CubeG0/Drivers/CMSIS/Device/ST/STM32G0xx/Include | ||||
| 
 | ||||
| # compile gcc flags
 | ||||
| ADDN_CFLAGS = \
 | ||||
|  -Wall \
 | ||||
|  -fdata-sections \
 | ||||
|  -ffunction-sections | ||||
| 
 | ||||
| CFLAGS = $(MCU) $(ADDN_CFLAGS) $(C_INCLUDES) $(DEBUG_FLAGS) $(OPT) $(DEFINES) | ||||
| 
 | ||||
| 
 | ||||
| # Generate dependency information
 | ||||
| #CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
 | ||||
| 
 | ||||
| 
 | ||||
| ASFLAGS = $(MCU) $(DEBUG_FLAGS) $(OPT) -Wa,--warn | ||||
| 
 | ||||
| #######################################
 | ||||
| # LDFLAGS
 | ||||
| #######################################
 | ||||
| # link script
 | ||||
| LDSCRIPT = $(VND_DIR)/Ld/STM32G030F6MX_FLASH.ld | ||||
| 
 | ||||
| LIBDIR =  | ||||
| LDFLAGS =  \
 | ||||
|  $(MCU)  \
 | ||||
|  -T $(LDSCRIPT) \
 | ||||
|  --specs=nano.specs \
 | ||||
|  -specs=nosys.specs -lc -lm \
 | ||||
|  -Wl,--gc-sections \
 | ||||
|  -Wl,--print-memory-usage \
 | ||||
|  -Wl,--no-warn-rwx-segments | ||||
| 
 | ||||
| # default action: build all
 | ||||
| all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).bin | ||||
| 
 | ||||
| 
 | ||||
| #######################################
 | ||||
| # build the application
 | ||||
| #######################################
 | ||||
| # list of objects
 | ||||
| OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o))) | ||||
| vpath %.c $(sort $(dir $(C_SOURCES))) | ||||
| 
 | ||||
| # list of ASM program objects
 | ||||
| OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o))) | ||||
| vpath %.s $(sort $(dir $(ASM_SOURCES))) | ||||
| 
 | ||||
| $(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR) | ||||
| 	$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@ | ||||
| 
 | ||||
| $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR) | ||||
| 	$(CC) -c $(ASFLAGS) $< -o $@ | ||||
| 
 | ||||
| #$(LUAOBJECTS) $(OBJECTS)
 | ||||
| $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile | ||||
| 	$(CC) $(OBJECTS) $(LDFLAGS) -o $@ | ||||
| 
 | ||||
| $(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR) | ||||
| 	$(BIN) $< $@	 | ||||
| 	 | ||||
| $(BUILD_DIR): | ||||
| 	mkdir $@		 | ||||
| 
 | ||||
| #######################################
 | ||||
| # Program
 | ||||
| #######################################
 | ||||
| 
 | ||||
| flash: $(BUILD_DIR)/$(TARGET).bin | ||||
| 	pyocd load --target $(PYOCD_TARGET) $(BUILD_DIR)/$(TARGET).bin | ||||
| 
 | ||||
| #######################################
 | ||||
| # clean up
 | ||||
| #######################################
 | ||||
| clean: | ||||
| 	-rm -fR $(BUILD_DIR) | ||||
|    | ||||
| # *** EOF ***
 | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue