mongoose/examples/stm32-freertos-tcp/Makefile
2021-05-12 08:44:16 +01:00

56 lines
2.0 KiB
Makefile

# FreeRTOS/{FreeRTOS-Kernel V10.4.3,FreeRTOS-Plus-TCP V2.3.2}
PROG = firmware
ARCH ?= stm32f1
ROOT = $(realpath $(CURDIR)/../..)
DOCKER ?= docker run -it --rm -v $(ROOT):$(ROOT) -w $(CURDIR) mdashnet/armgcc
MONGOOSE_OPTS = -DMG_ENABLE_LINES=1 -DMG_ARCH=MG_ARCH_FREERTOS_TCP -DMG_ENABLE_FS=0
ifeq "$(ARCH)" "stm32f1"
MCU = -mcpu=cortex-m3 -mthumb -mfloat-abi=soft
else ifeq "$(ARCH)" "stm32f7"
MCU = -mcpu=cortex-m7 -mthumb -mfpu=fpv5-sp-d16 -mfloat-abi=hard
endif
INCS = -I$(ARCH) -I. -I../.. -Ifreertos-kernel/include -Ifreertos-tcp/include -Ifreertos-tcp/portable/Compiler/GCC
CFLAGS = -W -Wall -Werror -Wno-format -Wno-address-of-packed-member -Os -g $(MCU) -fdata-sections -ffunction-sections $(INCS) $(MONGOOSE_OPTS) $(EXTRA)
LDFLAGS = $(MCU) -specs=nano.specs -Tobj/link.ld -nostartfiles -lgcc #-Wl,-Map=obj/$(PROG).map,--cref -Wl,--gc-sections
SRCS = main.c $(wildcard freertos-tcp/*.c) $(wildcard freertos-kernel/*.c)
SRCS += freertos-kernel/portable/MemMang/heap_4.c $(ARCH)/port.c
OBJS = obj/boot.o $(SRCS:%.c=obj/%.o) obj/mongoose.o # ORDER MATTERS - boot (vector table) first!
all: $(PROG).hex
$(PROG).bin: $(PROG).elf
$(DOCKER) arm-none-eabi-objcopy -O binary $< $@
$(PROG).hex: $(PROG).bin
$(DOCKER) arm-none-eabi-objcopy -I binary -O ihex --change-address 0x8000000 $< $@
obj/link.ld: $(ARCH)/link.ld
$(DOCKER) arm-none-eabi-cpp -P -imacros $(ARCH)/device.h $< > $@
$(PROG).elf: $(OBJS) obj/link.ld
$(DOCKER) arm-none-eabi-gcc $(OBJS) $(LDFLAGS) -o $@
obj/%.o: %.c
@mkdir -p $(dir $@)
$(DOCKER) arm-none-eabi-gcc $(CFLAGS) -c $< -o $@
obj/boot.o:
@mkdir -p $(dir $@)
$(DOCKER) arm-none-eabi-as --warn --fatal-warnings $(MCU) $(ARCH)/boot.s -o $@
obj/mongoose.o:
$(DOCKER) arm-none-eabi-gcc $(CFLAGS) -c ../../mongoose.c -o $@
flash: $(PROG).bin
st-flash --reset write $< 0x8000000
gdb: $(PROG).elf
arm-none-eabi-gdb \
-ex 'set confirm off' \
-ex 'target extended-remote :4242' \
-ex 'monitor reset halt' \
-ex 'monitor reset init' \
$<
clean:
@rm -rf *.{bin,elf,map,lst,tgz,zip,hex} obj