Compiling a C++ project for STM32F4 Discovery with RAW GCC Toolchain and without any IDE

Makefile


STLINK_PATH=<PathTo "ST-LINK Utility"> GCC_PATH=<PathTo "GCC"> DICOVERY_FIRMWARE_PATH=<PathTo "DisoceryFirmware"> CMSIS_PATH=$(DICOVERY_FIRMWARE_PATH)/Libraries/CMSIS
CMSIS_DEVICE_PATH=$(CMSIS_PATH)/ST/STM32F4xx/
DISCOVERY_PATH=$(DICOVERY_FIRMWARE_PATH)/Utilities/STM32F4-Discovery
STDPERIPH_PATH=$(DICOVERY_FIRMWARE_PATH)/Libraries/STM32F4xx_StdPeriph_Driver
STARTUP=startup_stm32f4xx.S
FILES="$(STDPERIPH_PATH)/src/stm32f4xx_rcc.c" $(STDPERIPH_PATH)/src/stm32f4xx_gpio.c $(STDPERIPH_PATH)/src/stm32f4xx_exti.c $(STDPERIPH_PATH)/src/stm32f4xx_syscfg.c $(STDPERIPH_PATH)/src/misc.c $(DISCOVERY_PATH)/stm32f4_discovery.c $(CMSIS_DEVICE_PATH)/Source/Templates/system_stm32f4xx.c

OPTIONS=-nostartfiles -mfpu=fpv4-sp-d16 -mthumb –specs=nosys.specs -ffunction-sections -fdata-sections -Os -flto -T STM32F407VG_FLASH.ld –std=c++11 -v -Wall
LIBRARIES=-I“.“ -I$(CMSIS_PATH)/Include -I$(STDPERIPH_PATH)/inc -I$(DISCOVERY_PATH) -I$(CMSIS_DEVICE_PATH)/Include
DEFINES=-DUSE_STDPERIPH_DRIVER -DUSE_STM32_DISCOVERY -DHSE_VALUE=8000000

%.elf : main.c $(STARTUP)
„$(GCC_PATH)“\arm-none-eabi-g++.exe $(OPTIONS) $(DEFINES) $(LIBRARIES) -o $@ $? $(FILES)

%.bin : %.elf
„$(GCC_PATH)“\arm-none-eabi-objcopy.exe -O binary $< $@

%.upload : %.bin
$(STLINK_PATH)/ST-LINK_CLI.exe -V -P $< 0x08000000
$(STLINK_PATH)/ST-LINK_CLI.exe -Rst

all: blinky.upload

Ein Gedanke zu „Compiling a C++ project for STM32F4 Discovery with RAW GCC Toolchain and without any IDE

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

Please enter the captcha *