123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 |
- # Project
- #-------------------------------------------------------------------------------
- TARGET = armpsu
- #
- #-------------------------------------------------------------------------------
- PROGRAMMATOR = "C:/MCU/STMicroelectronics/STM32 ST-LINK Utility/ST-LINK Utility/ST-LINK_CLI.exe"
- # Used modules of Stamdart Perephireal Library
- #-------------------------------------------------------------------------------
- # PERIPHDRIVERS += stm32f10x_adc
- # PERIPHDRIVERS += stm32f10x_bkp
- # PERIPHDRIVERS += stm32f10x_can
- # PERIPHDRIVERS += stm32f10x_cec
- # PERIPHDRIVERS += stm32f10x_crc
- # PERIPHDRIVERS += stm32f10x_dbgmcu
- # PERIPHDRIVERS += stm32f10x_exti
- # PERIPHDRIVERS += stm32f10x_flash
- # PERIPHDRIVERS += stm32f10x_fsmc
- # PERIPHDRIVERS += stm32f10x_gpio
- # PERIPHDRIVERS += stm32f10x_i2c
- # PERIPHDRIVERS += stm32f10x_iwdg
- # PERIPHDRIVERS += stm32f10x_pwr
- # PERIPHDRIVERS += stm32f10x_rcc
- # PERIPHDRIVERS += stm32f10x_rtc
- # PERIPHDRIVERS += stm32f10x_sdio
- # PERIPHDRIVERS += stm32f10x_spi
- # PERIPHDRIVERS += stm32f10x_tim
- # PERIPHDRIVERS += stm32f10x_usart
- # PERIPHDRIVERS += stm32f10x_wwdg
- # PERIPHDRIVERS += misc.c
- # Defines
- #-------------------------------------------------------------------------------
- #DEFINES += USE_STDPERIPH_DRIVER
- DEFINES += STM32F10X_LD_VL
- DEFINES += GCC_ARMCM3
- DEFINES += VECT_TAB_FLASH
- DEFINES += REAL_FLASH
- DEFINES += BIG
- DEFINES += CLOCK_ENABLED
- DEFINES += AWD_ENABLED
- # Tools
- #-------------------------------------------------------------------------------
- GCC_PREFIX = C:/MCU/gcc-arm/bin/arm-none-eabi-
- AS = $(GCC_PREFIX)gcc
- CC = $(GCC_PREFIX)gcc
- LD = $(GCC_PREFIX)gcc
- CP = $(GCC_PREFIX)objcopy
- SZ = $(GCC_PREFIX)size
- RM = rm
- # Patches
- #-------------------------------------------------------------------------------
- CMSIS_PATH = lib/CMSIS/CM3
- #STDPERIPH_INC_PATH = mcu/stdperiph/inc
- #STDPERIPH_SRC_PATH = mcu/stdperiph/src
- # Startup file
- #-------------------------------------------------------------------------------
- STARTUP = $(CMSIS_PATH)/DeviceSupport/ST/STM32F10x/startup/gcc_ride7/startup_stm32f10x_ld_vl.s
- # Sources search paths
- #-------------------------------------------------------------------------------
- SOURCEDIRS := src
- SOURCEDIRS += $(CMSIS_PATH)/CoreSupport
- #SOURCEDIRS += $(CMSIS_PATH)/DeviceSupport/ST/STM32F10x
- # Headers search paths
- #-------------------------------------------------------------------------------
- INCLUDES += inc
- #INCLUDES += $(SOURCEDIRS)
- INCLUDES += $(CMSIS_PATH)/CoreSupport
- INCLUDES += $(CMSIS_PATH)/DeviceSupport/ST/STM32F10x
- #INCLUDES += $(STDPERIPH_INC_PATH)
- # Libraries
- #-------------------------------------------------------------------------------
- LIBPATH +=
- LIBS +=
- # Compiler settings
- #-------------------------------------------------------------------------------
- CFLAGS += -mthumb -mcpu=cortex-m3 # Architecture and command system
- CFLAGS += -std=gnu11 # C language standart
- CFLAGS += -Wall -pedantic # Show all warnings
- CFLAGS += -Os # Optimization
- CFLAGS += -ggdb # Generate debugging info for gdb
- #CFLAGS += -fno-builtin
- CFLAGS += $(addprefix -I, $(INCLUDES))
- CFLAGS += $(addprefix -D, $(DEFINES))
- CFLAGS += -c
- CFLAGS += -fmessage-length=0
- CFLAGS += -ffunction-sections
- #CFLAGS += -fdata-sections
- #CFLAGS += -msoft-float
- CFLAGS += -mapcs-frame
- CFLAGS += -D__thumb2__=1
- CFLAGS += -mno-sched-prolog
- #CFLAGS += -fno-hosted
- CFLAGS += -mtune=cortex-m3
- CFLAGS += -mfix-cortex-m3-ldrd
- #CFLAGS += -fno-strict-aliasing
- CFLAGS += -ffast-math
- CFLAGS += -MD -MP -MF .dep/$(@F).d
- # Linker script
- #-------------------------------------------------------------------------------
- LDSCR_PATH = ld
- LDSCRIPT = stm32f100c6_sec.ld
- # Linker settings
- #-------------------------------------------------------------------------------
- LDFLAGS += -nostartfiles
- LDFLAGS += -L$(LDSCR_PATH)
- LDFLAGS += -T$(LDSCR_PATH)/$(LDSCRIPT)
- LDFLAGS += $(addprefix -L, $(LIBPATH))
- LDFLAGS += $(LIBS)
- LDFLAGS += -Xlinker -Map=$(TARGET).map
- LDFLAGS += -Wl,--gc-sections
- LDFLAGS += -mcpu=cortex-m3
- LDFLAGS += -mthumb
- #LDFLAGS += -static
- #LDFLAGS += -nostdlib
- # Assembler settings
- #-------------------------------------------------------------------------------
- AFLAGS += -ahls -mapcs-32
- AFLAGS = -D__ASSEMBLY__
- AFLAGS += -g $(CFLAGS)
- AFLAGS += -Iinc -x assembler-with-cpp
- # Object files list
- #-------------------------------------------------------------------------------
- OBJS += $(patsubst %.c, %.o, $(wildcard $(addsuffix /*.c, $(SOURCEDIRS))))
- #OBJS += $(addprefix $(STDPERIPH_SRC_PATH)/, $(addsuffix .o, $(PERIPHDRIVERS)))
- OBJS += $(patsubst %.s, %.o, $(STARTUP))
- # Search paths for make
- #-------------------------------------------------------------------------------
- VPATH := $(SOURCEDIRS)
- # List of files to remove with "make clean"
- #-------------------------------------------------------------------------------
- TOREMOVE += $(TARGET).elf $(TARGET).hex $(TARGET).map
- TOREMOVE += $(addsuffix /*.o, $(SOURCEDIRS))
- TOREMOVE += .dep/*.d
- #TOREMOVE += $(STDPERIPH_SRC_PATH)/*.o
- TOREMOVE += $(patsubst %.s, %.o, $(STARTUP))
- # Make all
- #-------------------------------------------------------------------------------
- all: $(TARGET).hex size
- load: $(TARGET).hex mcu_prog
- # Download firmware
- #-------------------------------------------------------------------------------
- mcu_prog:
- @$(PROGRAMMATOR) -c SWD -ME
- @$(PROGRAMMATOR) -c SWD -P "$(TARGET).hex" -V "$(TARGET).hex" -Q -Rst -Run
-
- mcu_reset:
- @$(PROGRAMMATOR) -c SWD -Rst -Run
- # Cleaning
- #-------------------------------------------------------------------------------
- clean:
- @$(RM) -f $(TOREMOVE)
- # Create .hex
- #-------------------------------------------------------------------------------
- $(TARGET).hex: $(TARGET).elf
- @$(CP) -Oihex $(TARGET).elf $(TARGET).hex
-
- # Show Size
- #-------------------------------------------------------------------------------
- size:
- @echo "---------------------------------------------------"
- @$(SZ) $(TARGET).elf
- @rm -f $(STDPERIPH_SRC_PATH)/*.o
- # Linking
- #-------------------------------------------------------------------------------
- $(TARGET).elf: $(OBJS)
- @$(LD) $(LDFLAGS) $^ -o $@
- # Compiling
- #-------------------------------------------------------------------------------
- %.o: %.c
- @echo Compiling: $<
- @$(CC) $(CFLAGS) -MD -c $< -o $@
- %.o: %.s
- @echo Compiling: $<
- @$(AS) $(AFLAGS) -c $< -o $@
- # Include the dependency files, should be the last of the makefile
- #-------------------------------------------------------------------------------
- -include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
|