2024-01-21 12:49:57 +00:00
|
|
|
# By default, this firmware is built with 288/32 flash/ram device configuration
|
|
|
|
# To build it with 256/64 configuration, run the following:
|
|
|
|
# make CFLAGS_EXTRA="-Wl,--defsym -Wl,RAM_64K=1"
|
|
|
|
|
2023-11-29 07:41:18 +00:00
|
|
|
ROOT ?= $(realpath $(PWD)/../../..)
|
|
|
|
PREFIX ?= riscv-none-elf
|
2023-12-27 15:38:41 +00:00
|
|
|
#PREFIX ?= docker run --platform linux/amd64 --rm -it -v$(ROOT):$(ROOT) -w $(PWD) mdashnet/riscv riscv-none-elf
|
|
|
|
CFLAGS = -W -Wall -Wextra -Wundef -Wshadow -Wdouble-promotion
|
|
|
|
CFLAGS += -Wformat-truncation -Wconversion -Wno-sign-conversion
|
|
|
|
CFLAGS += -ffunction-sections -fdata-sections -fno-common
|
|
|
|
CFLAGS += -DSYSCLK_FREQ_144MHz_HSE -I. -Ivendor -g3 -Os
|
2024-01-21 12:49:57 +00:00
|
|
|
CFLAGS += -march=rv32imafc -mabi=ilp32
|
2023-12-27 15:38:41 +00:00
|
|
|
LDFLAGS = -T vendor/link.ld -nostartfiles --specs=nano.specs --specs=nosys.specs -Wl,--gc-sections
|
2024-01-17 18:07:25 +00:00
|
|
|
SOURCES = hal.c main.c mongoose.c net.c packed_fs.c
|
2023-11-29 07:41:18 +00:00
|
|
|
SOURCES += vendor/system_ch32v30x.c vendor/startup_ch32v30x_D8C.S
|
2023-11-27 02:50:46 +00:00
|
|
|
CFLAGS += -DHTTP_URL=\"http://0.0.0.0/\" -DHTTPS_URL=\"https://0.0.0.0/\"
|
2023-11-22 04:23:34 +00: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 07:41:18 +00:00
|
|
|
$(PREFIX)-objcopy -O binary $< $@
|
2023-12-27 15:38:41 +00:00
|
|
|
$(PREFIX)-size --format=berkeley $<
|
2023-11-22 04:23:34 +00:00
|
|
|
|
2023-12-27 22:45:02 +00:00
|
|
|
firmware.elf: $(SOURCES) hal.h mongoose_custom.h Makefile
|
2024-01-21 12:49:57 +00:00
|
|
|
$(PREFIX)-gcc $(SOURCES) $(CFLAGS) $(LDFLAGS) $(CFLAGS_EXTRA) -o $@
|
2023-11-22 04:23:34 +00:00
|
|
|
|
|
|
|
flash: firmware.bin
|
|
|
|
wchisp flash $<
|
2023-11-29 07:41:18 +00:00
|
|
|
# @echo; echo "IMPORTANT: configure device to 96k RAM / 224k Flash"
|
2023-11-22 04:23:34 +00:00
|
|
|
|
2023-12-01 00:03:31 +00:00
|
|
|
zip: firmware.bin
|
2023-12-01 08:36:18 +00:00
|
|
|
zip -r ch32v307.modbus.firmware.`date +%Y-%m-%d`.zip firmware.*
|
2023-12-01 00:02:48 +00:00
|
|
|
|
2023-11-22 04:23:34 +00:00
|
|
|
clean:
|
2023-12-01 00:02:48 +00:00
|
|
|
$(RM) firmware.* *.zip
|