2021-05-11 16:12:06 +08:00
|
|
|
# FreeRTOS/{FreeRTOS-Kernel V10.4.3,FreeRTOS-Plus-TCP V2.3.2}
|
|
|
|
PROG = firmware
|
|
|
|
ARCH ?= stm32f1
|
|
|
|
ROOT = $(realpath $(CURDIR)/../..)
|
2021-05-12 01:05:03 +08:00
|
|
|
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
|
2021-05-11 16:12:06 +08:00
|
|
|
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
|
2021-05-12 01:05:03 +08:00
|
|
|
CFLAGS = -W -Wall -Os -g $(MCU) -fdata-sections -ffunction-sections $(INCS) $(MONGOOSE_OPTS) $(EXTRA)
|
|
|
|
LDFLAGS = $(MCU) -specs=nano.specs -Tobj/link.ld -nostartfiles -nostdlib -lc -lm -lnosys -lgcc #-Wl,-Map=obj/$(PROG).map,--cref -Wl,--gc-sections
|
|
|
|
SRCS = main.c # $(wildcard freertos-tcp/*.c)
|
|
|
|
# SRCS += freertos-kernel/portable/MemMang/heap_4.c $(ARCH)/port.c
|
|
|
|
# SRCS += freertos-kernel/list.c freertos-kernel/tasks.c freertos-kernel/queue.c
|
|
|
|
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
|
|
|
|
2021-05-12 01:05:03 +08:00
|
|
|
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 $@
|
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
|
|
|
|
st-flash 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' \
|
|
|
|
-ex 'b main' \
|
|
|
|
-ex 'r' \
|
|
|
|
$<
|
2021-05-11 16:12:06 +08:00
|
|
|
|
|
|
|
clean:
|
|
|
|
@rm -rf *.{bin,elf,map,lst,tgz,zip,hex} obj
|