Files
@ 988bab1cb593
Branch filter:
Location: therm/Makefile
988bab1cb593
3.2 KiB
text/x-makefile
Got things mostly compiling, disabled SPI and USB for now because of RAM overflow
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | TARGET:=therm
TOOLCHAIN_PATH:=/usr/bin
TOOLCHAIN_PREFIX:=arm-none-eabi
OPTLVL:=3 # Optimization level, can be [0, 1, 2, 3, s].
#PROJECT_NAME:=$(notdir $(lastword $(CURDIR)))
TOP:=$(shell readlink -f "../..")
LIBDIR:=libraries
HAL_LIB:=$(LIBDIR)/STM32F0xx_HAL_Driver
USB_LIB:=$(LIBDIR)/STM32_USB_Device_Library
STARTUP:=$(LIBDIR)/CMSIS/Device/ST/STM32F0xx/Source/Templates/gcc
SYSTEMDIR:=$(LIBDIR)/CMSIS/Device/ST/STM32F0xx/Source/Templates # Houses system_STM32f0xx.c
LINKER_SCRIPT:=$(CURDIR)/stm32-flash.ld
# Local libs
INCLUDE=-I$(CURDIR)
# CMSIS
INCLUDE+=-I$(LIBDIR)/CMSIS/Include
INCLUDE+=-I$(LIBDIR)/CMSIS/Device/ST/STM32F0xx/Include
# USB
INCLUDE+=-I$(USB_LIB)/Class/CDC
INCLUDE+=-I$(USB_LIB)/Core
# HAL
INCLUDE+=-I$(HAL_LIB)/Inc
# vpath is used so object files are written to the current directory instead
# of the same directory as their source files
vpath %.c $(HAL_LIB)/Src \
$(USB_LIB) \
$(USB_LIB)/Class/CDC \
$(USB_LIB)/Core \
$(SYSTEMDIR)
vpath %.s $(STARTUP)
ASRC=$(STARTUP)/startup_stm32f042x6.s
# Project Source Files
SRC=main.c
SRC+=ssd1306.c
SRC+=eeprom_min.c
SRC+=gpio.c
SRC+=spi.c
SRC+=clock.c
SRC+=stringhelpers.c
SRC+=stm32f0xx_it.c
SRC+=stm32f0xx_hal_msp.c
SRC+=usb_device.c
SRC+=usbd_cdc_if.c
SRC+=usbd_conf.c
SRC+=usbd_desc.c
# Standard Peripheral Source Files
SRC+=system_stm32f0xx.c
SRC+=stm32f0xx_hal.c
SRC+=stm32f0xx_hal_spi.c
SRC+=stm32f0xx_hal_pcd.c
SRC+=stm32f0xx_hal_pcd_ex.c
SRC+=stm32f0xx_hal_cortex.c
SRC+=stm32f0xx_hal_dma.c
SRC+=stm32f0xx_hal_flash.c
SRC+=stm32f0xx_hal_flash_ex.c
SRC+=stm32f0xx_hal_gpio.c
SRC+=stm32f0xx_hal_pwr.c
SRC+=stm32f0xx_hal_pwr_ex.c
SRC+=stm32f0xx_hal_rcc.c
SRC+=stm32f0xx_hal_rcc_ex.c
# USB Source Files
SRC+=usbd_cdc.c
SRC+=usbd_core.c
SRC+=usbd_ctlreq.c
SRC+=usbd_ioreq.c
CDEFS=-DUSE_STDPERIPH_DRIVER
CDEFS+=-DSTM32F0XX
CDEFS+=-DMANGUSTA_DISCOVERY
#CDEFS+=-DUSE_USB_OTG_FS
# EMZ FIXME
CDEFS+=-DHSE_VALUE=8000000
#EMZ Optimized:
MCUFLAGS=-mcpu=cortex-m3 -mthumb -ffunction-sections -fdata-sections -mfloat-abi=soft
# Default: MCUFLAGS=-mcpu=cortex-m3 -mthumb -ffunction-sections -fdata-sections
#MCUFLAGS=-mcpu=cortex-m4 -mthumb -mlittle-endian -mfpu=fpa -mfloat-abi=hard -mthumb-interwork
#MCUFLAGS=-mcpu=cortex-m4 -mfpu=vfpv4-sp-d16 -mfloat-abi=hard
COMMONFLAGS=-O$(OPTLVL) -g -Wall
CFLAGS=$(COMMONFLAGS) $(MCUFLAGS) $(INCLUDE) $(CDEFS)
LDLIBS=
LDFLAGS=$(COMMONFLAGS) -fno-exceptions -ffunction-sections -fdata-sections \
-nostartfiles -Wl,--gc-sections,-T$(LINKER_SCRIPT)
#####
#####
OBJ = $(SRC:%.c=%.o) $(ASRC:%.s=%.o)
CC=$(TOOLCHAIN_PATH)/$(TOOLCHAIN_PREFIX)-gcc
LD=$(TOOLCHAIN_PATH)/$(TOOLCHAIN_PREFIX)-gcc
OBJCOPY=$(TOOLCHAIN_PATH)/$(TOOLCHAIN_PREFIX)-objcopy
AS=$(TOOLCHAIN_PATH)/$(TOOLCHAIN_PREFIX)-as
AR=$(TOOLCHAIN_PATH)/$(TOOLCHAIN_PREFIX)-ar
GDB=$(TOOLCHAIN_PATH)/$(TOOLCHAIN_PREFIX)-gdb
SIZE=$(TOOLCHAIN_PATH)/$(TOOLCHAIN_PREFIX)-size
all: $(OBJ)
$(CC) -o $(TARGET).elf $(LDFLAGS) $(OBJ) $(LDLIBS)
$(OBJCOPY) -O ihex $(TARGET).elf $(TARGET).hex
$(OBJCOPY) -O binary $(TARGET).elf $(TARGET).bin
.PHONY: clean
clean:
rm -f $(OBJ)
rm -f $(TARGET).elf
rm -f $(TARGET).hex
rm -f $(TARGET).bin
# Display size
size: $(TARGET).elf
@echo Invoking: ARM GNU Print Size
$(SIZE) --format=berkeley $<
@echo
|