2023-11-29 15:41:18 +08:00
|
|
|
ROOT ?= $(realpath $(PWD)/../../..)
|
|
|
|
PREFIX ?= riscv-none-elf
|
|
|
|
#PREFIX ?= docker run --platform linux/amd64 --rm -it -v$(ROOT):$(ROOT) -w $(PWD) mdashnet/riscv riscv64-unknown-elf
|
|
|
|
|
2023-11-22 12:23:34 +08:00
|
|
|
CFLAGS = -W -Wall -Wextra -Wno-error -Wundef -Wshadow -Wdouble-promotion
|
|
|
|
CFLAGS += -Wformat-truncation -fno-common -Wconversion -Wno-sign-conversion
|
2023-11-27 10:50:46 +08:00
|
|
|
CFLAGS += -ffunction-sections -fdata-sections
|
|
|
|
CFLAGS += -march=rv32imafc -mabi=ilp32f
|
2023-11-22 12:23:34 +08:00
|
|
|
CFLAGS += -DSYSCLK_FREQ_144MHz_HSE -I. -Ivendor -g3 -Os $(CFLAGS_EXTRA)
|
|
|
|
|
2023-11-29 15:41:18 +08:00
|
|
|
LDFLAGS = -T link.ld -nostartfiles --specs=nano.specs
|
|
|
|
LDFLAGS += -lc -lgcc -Wl,--gc-sections #-Wl,-Map=$@.map
|
2023-11-22 12:23:34 +08:00
|
|
|
|
2023-11-29 15:41:18 +08:00
|
|
|
SOURCES = main.c mongoose.c net.c packed_fs.c
|
|
|
|
SOURCES += vendor/system_ch32v30x.c vendor/startup_ch32v30x_D8C.S
|
2023-11-27 10:50:46 +08:00
|
|
|
CFLAGS += -DHTTP_URL=\"http://0.0.0.0/\" -DHTTPS_URL=\"https://0.0.0.0/\"
|
2023-11-22 12:23:34 +08:00
|
|
|
|
|
|
|
ifeq ($(OS),Windows_NT)
|
|
|
|
RM = cmd /C del /Q /F /S
|
|
|
|
else
|
|
|
|
RM = rm -rf
|
|
|
|
endif
|
|
|
|
|
|
|
|
all: firmware.bin
|
|
|
|
|
|
|
|
firmware.bin: firmware.elf
|
2023-11-29 15:41:18 +08:00
|
|
|
$(PREFIX)-objcopy -O binary $< $@
|
2023-11-22 12:23:34 +08:00
|
|
|
ls -l firmware.*
|
|
|
|
|
2023-11-29 15:41:18 +08:00
|
|
|
firmware.elf: $(SOURCES) link.ld hal.h mongoose_custom.h Makefile
|
|
|
|
$(PREFIX)-gcc $(SOURCES) $(CFLAGS) $(LDFLAGS) -o $@
|
2023-11-22 12:23:34 +08:00
|
|
|
|
|
|
|
flash: firmware.bin
|
|
|
|
wchisp flash $<
|
2023-11-29 15:41:18 +08:00
|
|
|
# @echo; echo "IMPORTANT: configure device to 96k RAM / 224k Flash"
|
2023-11-22 12:23:34 +08:00
|
|
|
|
2023-12-01 08:03:31 +08:00
|
|
|
zip: firmware.bin
|
2023-12-01 16:36:18 +08:00
|
|
|
zip -r ch32v307.modbus.firmware.`date +%Y-%m-%d`.zip firmware.*
|
2023-12-01 08:02:48 +08:00
|
|
|
|
2023-11-22 12:23:34 +08:00
|
|
|
clean:
|
2023-12-01 08:02:48 +08:00
|
|
|
$(RM) firmware.* *.zip
|