2020-11-23 21:48:35 -05:00
|
|
|
# Makefile -- stm32bringup
|
2021-02-12 21:47:22 -05:00
|
|
|
# Copyright (c) 2020-2021 Renaud Fivet
|
2020-11-23 21:48:35 -05:00
|
|
|
|
|
|
|
### Build environment selection
|
|
|
|
|
|
|
|
ifeq (linux, $(findstring linux, $(MAKE_HOST)))
|
2021-02-12 21:47:22 -05:00
|
|
|
INSTALLDIR = $(HOME)/Packages
|
2021-02-24 21:15:55 -05:00
|
|
|
#REVDIR = gcc-arm-none-eabi-9-2019-q4-major
|
|
|
|
#REVDIR = gcc-arm-none-eabi-9-2020-q2-update
|
|
|
|
REVDIR = gcc-arm-none-eabi-10-2020-q4-major
|
2020-11-23 21:48:35 -05:00
|
|
|
else
|
2021-02-24 21:15:55 -05:00
|
|
|
DRIVE = d
|
2021-02-12 21:47:22 -05:00
|
|
|
ifeq (cygwin, $(findstring cygwin, $(MAKE_HOST)))
|
2021-02-24 21:15:55 -05:00
|
|
|
OSDRIVE = /cygdrive/$(DRIVE)
|
2021-02-12 21:47:22 -05:00
|
|
|
else ifeq (msys, $(findstring msys, $(MAKE_HOST)))
|
2021-02-24 21:15:55 -05:00
|
|
|
OSDRIVE = /$(DRIVE)
|
2021-02-12 21:47:22 -05:00
|
|
|
else
|
2021-02-24 21:15:55 -05:00
|
|
|
OSDRIVE = $(DRIVE):
|
2021-02-12 21:47:22 -05:00
|
|
|
endif
|
2021-02-24 21:15:55 -05:00
|
|
|
INSTALLDIR = $(OSDRIVE)/Program Files (x86)
|
|
|
|
#REVDIR = GNU Tools ARM Embedded/5.4 2016q2
|
|
|
|
#REVDIR = GNU Tools ARM Embedded/6 2017-q2-update
|
|
|
|
#REVDIR = GNU Tools ARM Embedded/7 2017-q4-major
|
|
|
|
#REVDIR = GNU Tools ARM Embedded/7 2018-q2-update
|
|
|
|
#REVDIR = GNU Tools ARM Embedded/9 2019-q4-major
|
|
|
|
#REVDIR = GNU Arm Embedded Toolchain/9 2020-q2-update
|
|
|
|
REVDIR = GNU Arm Embedded Toolchain/10 2020-q4-major
|
2020-11-23 21:48:35 -05:00
|
|
|
endif
|
|
|
|
|
2021-02-24 21:15:55 -05:00
|
|
|
GCCDIR = $(INSTALLDIR)/$(REVDIR)
|
2021-02-12 21:47:22 -05:00
|
|
|
export PATH := $(GCCDIR)/bin:$(PATH)
|
|
|
|
|
|
|
|
BINPFX = @arm-none-eabi-
|
2020-12-05 05:08:25 -05:00
|
|
|
AR = $(BINPFX)ar
|
2020-11-23 21:48:35 -05:00
|
|
|
CC = $(BINPFX)gcc
|
|
|
|
OBJCOPY = $(BINPFX)objcopy
|
|
|
|
OBJDUMP = $(BINPFX)objdump
|
|
|
|
SIZE = $(BINPFX)size
|
|
|
|
|
|
|
|
### STM32F030F4P6 based board
|
|
|
|
|
|
|
|
PROJECT = f030f4
|
|
|
|
#SRCS = boot.c
|
|
|
|
#SRCS = ledon.c
|
|
|
|
#SRCS = blink.c
|
|
|
|
#SRCS = ledtick.c
|
|
|
|
#SRCS = cstartup.c
|
2020-11-27 23:54:11 -05:00
|
|
|
#SRCS = startup.c init.c success.c
|
2020-11-27 23:58:58 -05:00
|
|
|
#SRCS = startup.c board.c success.c
|
2020-12-02 22:15:47 -05:00
|
|
|
#SRCS = startup.c usart1tx.c hello.c
|
2020-12-04 19:13:29 -05:00
|
|
|
#SRCS = startup.c uplow.1.c uptime.1.c
|
2020-12-05 05:08:25 -05:00
|
|
|
#SRCS = startup.c uplow.2.c uptime.c printf.c putchar.c
|
|
|
|
#SRCS = startup.c uplow.2.c uptime.c
|
2020-12-07 04:36:11 -05:00
|
|
|
#SRCS = startup.c uplow.2.c hello.c
|
2020-12-08 03:45:48 -05:00
|
|
|
#SRCS = startup.c clocks.c uptime.c
|
2020-12-14 20:41:12 -05:00
|
|
|
#SRCS = startup.txeie.c txeie.c uptime.c
|
2020-12-18 19:39:18 -05:00
|
|
|
#SRCS = startup.txeie.c gpioa.c dht11main.c dht11.c
|
2020-12-29 01:26:39 -05:00
|
|
|
#SRCS = startup.txeie.c gpioa.c ds18b20main.c ds18b20.c
|
2021-02-09 02:36:03 -05:00
|
|
|
#SRCS = startup.txeie.c adc.c adcmain.c
|
|
|
|
SRCS = startup.txeie.c adc.c adccalib.c ds18b20.c
|
2020-11-23 21:48:35 -05:00
|
|
|
OBJS = $(SRCS:.c=.o)
|
2021-02-12 21:47:22 -05:00
|
|
|
LIBOBJS = printf.o putchar.o puts.o memset.o
|
2020-11-23 21:48:35 -05:00
|
|
|
CPU = -mthumb -mcpu=cortex-m0
|
|
|
|
CFLAGS = $(CPU) -g -Wall -Wextra -Os
|
|
|
|
LD_SCRIPT = $(PROJECT).ld
|
2020-12-05 05:08:25 -05:00
|
|
|
LIBSTEM = stm32
|
2021-02-12 21:47:22 -05:00
|
|
|
LIBS = -l$(LIBSTEM)
|
2020-11-23 21:48:35 -05:00
|
|
|
|
|
|
|
### Build rules
|
|
|
|
|
2021-02-24 21:15:55 -05:00
|
|
|
.PHONY: clean all version
|
2020-11-23 21:48:35 -05:00
|
|
|
|
|
|
|
all: $(PROJECT).hex $(PROJECT).bin
|
|
|
|
|
2021-02-24 21:15:55 -05:00
|
|
|
version:
|
|
|
|
@echo make $(MAKE_VERSION) $(MAKE_HOST)
|
|
|
|
@echo PATH="$(PATH)"
|
|
|
|
|
2020-11-23 21:48:35 -05:00
|
|
|
clean:
|
|
|
|
@echo CLEAN
|
2020-12-05 05:08:25 -05:00
|
|
|
@rm -f *.o *.elf *.map *.lst *.bin *.hex *.a
|
2020-11-23 21:48:35 -05:00
|
|
|
|
2020-12-05 05:08:25 -05:00
|
|
|
$(PROJECT).elf: $(OBJS) lib$(LIBSTEM).a
|
2020-11-23 21:48:35 -05:00
|
|
|
@echo $@
|
2021-02-12 21:47:22 -05:00
|
|
|
$(CC) $(CPU) -T$(LD_SCRIPT) -L. -Wl,-Map=$(PROJECT).map,-cref \
|
|
|
|
-nostartfiles -o $@ $(OBJS) $(LIBS)
|
2020-11-23 21:48:35 -05:00
|
|
|
$(SIZE) $@
|
|
|
|
$(OBJDUMP) -hS $@ > $(PROJECT).lst
|
|
|
|
|
2021-02-12 21:47:22 -05:00
|
|
|
%.elf: %.o lib$(LIBSTEM).a
|
2020-11-23 21:48:35 -05:00
|
|
|
@echo $@
|
2021-02-12 21:47:22 -05:00
|
|
|
$(CC) $(CPU) -T$(LD_SCRIPT) -L. -Wl,-Map=$*.map,-cref -nostartfiles \
|
|
|
|
-o $@ $< $(LIBS)
|
2020-11-23 21:48:35 -05:00
|
|
|
$(SIZE) $@
|
|
|
|
$(OBJDUMP) -hS $@ > $*.lst
|
|
|
|
|
|
|
|
%.bin: %.elf
|
|
|
|
@echo $@
|
|
|
|
$(OBJCOPY) -O binary $< $@
|
|
|
|
|
|
|
|
%.hex: %.elf
|
|
|
|
@echo $@
|
|
|
|
$(OBJCOPY) -O ihex $< $@
|
2020-12-05 05:08:25 -05:00
|
|
|
|
|
|
|
lib$(LIBSTEM).a: $(LIBOBJS)
|
|
|
|
$(AR) rc $@ $?
|