mongoose/examples/stm32-freertos-tcp/Makefile

62 lines
2.7 KiB
Makefile
Raw Normal View History

2021-05-11 16:12:06 +08:00
# FreeRTOS/{FreeRTOS-Kernel V10.4.3,FreeRTOS-Plus-TCP V2.3.2}
PROG = firmware
ARCH = stm32f7
2021-05-11 16:12:06 +08:00
ROOT = $(realpath $(CURDIR)/../..)
2021-05-12 01:05:03 +08:00
DOCKER ?= docker run -it --rm -v $(ROOT):$(ROOT) -w $(CURDIR) mdashnet/armgcc
2021-05-14 05:03:46 +08:00
MONGOOSE_OPTS = -DMG_ARCH=MG_ARCH_FREERTOS_TCP -DMG_ENABLE_FS=0 -DMG_ENABLE_LINES=1
2021-05-11 16:12:06 +08:00
MCU = -mcpu=cortex-m7 -mthumb -mfpu=fpv5-sp-d16 -mfloat-abi=hard
2021-05-14 05:03:46 +08:00
INCS = -I. -I$(ROOT) -I$(ARCH) -I$(ROOT)/test/freertos-kernel/include -I$(ROOT)/test/freertos-tcp/include -I$(ROOT)/test/freertos-tcp/portable/Compiler/GCC -I$(ROOT)/test/freertos-tcp/portable/NetworkInterface/include -IHAL
NETFLAGS = -DSEMIHOSTING -DSTM32F7xx -DSTM32F746xx -Wno-sign-compare -Wno-unused-function -Wno-cpp
CFLAGS = -W -Wall -Werror -Wno-format -Wno-address-of-packed-member -Os -g $(MCU) -fdata-sections -ffunction-sections $(INCS) $(MONGOOSE_OPTS) $(NETFLAGS) $(EXTRA)
#LFLAGS = $(MCU) --static -Wl,-Map=$(TARGET).map -Wl,--gc-sections -lc -lgcc -T$(ARCH)/link.ld #-nostartfiles -lgcc #-Wl,-Map=obj/$(PROG).map,--cref -Wl,--gc-sections
LFLAGS = $(MCU) --static -Wl,-Map=$(TARGET).map -Wl,--gc-sections -specs rdimon.specs -lrdimon -lc -lgcc -T$(ARCH)/link.ld #-nostartfiles -lgcc #-Wl,-Map=obj/$(PROG).map,--cref -Wl,--gc-sections
SRCS = main.c $(wildcard $(ROOT)/test/freertos-kernel/*.c) $(wildcard $(ROOT)/test/freertos-tcp/*.c)
SRCS += $(ROOT)/test/freertos-kernel/portable/MemMang/heap_4.c $(ARCH)/port.c
2021-05-14 05:03:46 +08:00
SRCS += $(ROOT)/test/freertos-tcp/portable/BufferManagement/BufferAllocation_2.c
SRCS += $(wildcard $(ROOT)/test/freertos-tcp/portable/NetworkInterface/STM32Fxx/*.c)
SRCS += $(wildcard $(ROOT)/test/freertos-tcp/portable/NetworkInterface/Common/*.c)
SRCS += $(wildcard HAL/*.c)
2021-05-12 15:43:34 +08:00
OBJS = obj/boot.o $(SRCS:%.c=obj/%.o) obj/mongoose.o # ORDER MATTERS - boot (vector table) first!
2021-05-11 16:12:06 +08:00
all: $(PROG).hex
$(PROG).bin: $(PROG).elf
2021-05-12 01:05:03 +08:00
$(DOCKER) arm-none-eabi-objcopy -O binary $< $@
2021-05-11 16:12:06 +08:00
$(PROG).hex: $(PROG).bin
2021-05-12 01:05:03 +08:00
$(DOCKER) arm-none-eabi-objcopy -I binary -O ihex --change-address 0x8000000 $< $@
2021-05-11 16:12:06 +08:00
$(PROG).elf: $(OBJS)
2021-05-14 05:03:46 +08:00
$(DOCKER) arm-none-eabi-gcc $(OBJS) $(LFLAGS) -o $@
2021-05-11 16:12:06 +08:00
obj/%.o: %.c
@mkdir -p $(dir $@)
2021-05-12 01:05:03 +08:00
$(DOCKER) arm-none-eabi-gcc $(CFLAGS) -c $< -o $@
2021-05-11 16:12:06 +08:00
2021-05-12 01:05:03 +08:00
obj/boot.o:
2021-05-11 16:12:06 +08:00
@mkdir -p $(dir $@)
2021-05-12 01:05:03 +08:00
$(DOCKER) arm-none-eabi-as --warn --fatal-warnings $(MCU) $(ARCH)/boot.s -o $@
2021-05-11 16:12:06 +08:00
obj/mongoose.o:
2021-05-12 01:05:03 +08:00
$(DOCKER) arm-none-eabi-gcc $(CFLAGS) -c ../../mongoose.c -o $@
flash: $(PROG).bin
2021-05-12 03:44:14 +08:00
st-flash --reset write $< 0x8000000
2021-05-12 01:05:03 +08:00
2021-05-14 05:03:46 +08:00
openocd:
openocd -f openocd.cfg
2021-05-12 01:05:03 +08:00
gdb: $(PROG).elf
arm-none-eabi-gdb \
-ex 'set confirm off' \
2021-05-14 05:03:46 +08:00
-ex 'target extended-remote :3333' \
-ex 'monitor arm semihosting enable' \
2021-05-12 01:05:03 +08:00
-ex 'monitor reset halt' \
2021-05-14 05:03:46 +08:00
-ex 'load' \
2021-05-12 01:05:03 +08:00
-ex 'monitor reset init' \
2021-05-14 05:03:46 +08:00
-ex 'r' \
2021-05-12 01:05:03 +08:00
$<
2021-05-11 16:12:06 +08:00
clean:
@rm -rf *.{bin,elf,map,lst,tgz,zip,hex} obj