Files
STM8_Mesh_Control/Makefile
T
十七 ebef6a8694 feat: complete assembly mesh relay control path
- synchronize STM8 application and external flash layout updates\n- add assembly bootloader and assembly application test projects\n- add UART1 interrupt receive ring buffer\n- parse JDY-28M Mesh outer frames and source addresses\n- add CRC-16/MODBUS validation\n- implement relay control command 0x01 and response 0x81\n- support unicast and broadcast relay control frames\n- update host protocol, OTA documents, and serial tools
2026-11-05 16:12:51 +08:00

69 lines
2.2 KiB
Makefile
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# STM8S003F3P6TR 固件第一阶段构建文件。
# 本阶段只验证工程结构和模块接口,硬件寄存器驱动将在后续阶段逐步接入。
PROJECT := mesh_relay
BUILD_DIR := build
SRC_DIR := src
INC_DIR := include
CC := sdcc
OBJCOPY := packihx
MAKEBIN := makebin
CFLAGS := -mstm8 --std-c99 --opt-code-size -I$(INC_DIR)
# Bootloader占用0x8000~0x84FF,主程序必须从0x8500开始链接。
LDFLAGS := -mstm8 --out-fmt-ihx --code-loc 0x8500
SOURCES := $(shell find $(SRC_DIR) -name '*.c' -print)
# 当前验证固件暂时关闭 OTA:外部 SPI Flash 驱动和 OTA 状态机源码保留在仓库中,
# 但不参与本次主程序链接,避免 SDCC 将未使用的 OTA 代码整体放入固件。
SOURCES := $(filter-out $(SRC_DIR)/protocol/ota_manager.c \
$(SRC_DIR)/drivers/w25q64_app.c,$(SOURCES))
OBJECTS := $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%.rel,$(SOURCES))
IHX := $(BUILD_DIR)/$(PROJECT).ihx
HEX := $(BUILD_DIR)/$(PROJECT).hex
BIN := $(BUILD_DIR)/$(PROJECT).bin
.PHONY: all full clean size
all: $(HEX) $(BIN)
# 整片初次烧录目标:构建Bootloader和主程序后合并绝对地址HEX。
# OTA仍使用主程序单独生成的BIN,不使用这个完整镜像。
full: bootloader $(BUILD_DIR)/stm8_mesh_full.hex $(BUILD_DIR)/stm8_mesh_full.bin
bootloader:
$(MAKE) -C STM8_Bootloader
$(BUILD_DIR)/stm8_mesh_full.hex: STM8_Bootloader/build/stm8_bootloader.hex $(HEX) tools/merge_intel_hex.py
@mkdir -p $(dir $@)
python3 tools/merge_intel_hex.py $@ $< $(HEX)
$(BUILD_DIR)/stm8_mesh_full.bin: $(BUILD_DIR)/stm8_mesh_full.hex
$(MAKEBIN) -p -s 0x10000 -o 0x8000 $< $@
$(HEX): $(IHX)
@mkdir -p $(dir $@)
$(OBJCOPY) $< > $@
# 生成OTA使用的裸二进制:跳过0x0000~0x84FF,只保留0x8500之后的应用程序数据。
# -s 0x10000确保按STM8完整地址空间解析IHX;-o 0x8500去除Bootloader区域;
# -p再截断到应用程序最后一个实际占用地址,避免生成无意义的尾部空洞。
$(BIN): $(IHX)
@mkdir -p $(dir $@)
$(MAKEBIN) -p -s 0x10000 -o 0x8500 $< $@
$(IHX): $(OBJECTS)
@mkdir -p $(dir $@)
$(CC) $(LDFLAGS) -o $@ $(OBJECTS)
$(BUILD_DIR)/%.rel: $(SRC_DIR)/%.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c $< -o $@
size: $(IHX)
@ls -lh $(IHX) $(HEX) $(BIN)
clean:
rm -rf $(BUILD_DIR)