diff --git a/Makefile b/Makefile index e9cb767..6e8c387 100644 --- a/Makefile +++ b/Makefile @@ -21,8 +21,7 @@ SRC_INC_DIR = $(SRC_DIR)/inc # Source files SRCS := $(wildcard $(SRC_DIR)/*.c) $(wildcard $(BSP_DIR)/*.c) ASRCS := $(wildcard $(SRC_DIR)/*.s) $(wildcard $(BSP_DIR)/*.s) -OPT_SRCS := $(SCRIPTS_DIR)/bootloader.opt -#OPT_SRCS := $(SCRIPTS_DIR)/factory.opt +OPT_SRCS := $(wildcard $(SCRIPTS_DIR)/*.opt) # Compiler tools CC = $(TOOLCHAIN)/sdcc @@ -38,6 +37,7 @@ CFLAGS += --stack-auto --noinduction --use-non-free ## Disable lospre (workaround for bug 2673) #CFLAGS += --nolospre LDFLAGS = -m$(ARCH) -l$(ARCH) --out-fmt-ihx +OPTFLAGS = -Wl-bOPTION=0x4800 -Wl-bOPTION_BOOT=0x481C # Object files OBJS = $(patsubst %.c,$(BUILD_DIR)/%.rel,$(notdir $(SRCS))) \ @@ -79,7 +79,7 @@ $(BUILD_DIR)/$(TARGET).bin: $(BUILD_DIR)/$(TARGET).hex # Link option bytes separately at address 0x4800 $(BUILD_DIR)/option.hex: $(OPT_OBJS) - $(CC) $(LDFLAGS) -Wl-bOPTION=0x4800 $(OPT_OBJS) -o $@ || true + $(CC) $(LDFLAGS) $(OPTFLAGS) $(OPT_OBJS) -o $@ || true $(BUILD_DIR)/option.bin: $(BUILD_DIR)/option.hex $(OBJCOPY) -I ihex --output-target=binary $< $@ diff --git a/scripts/bootloader.opt b/scripts/bootloader.opt index e68a4f6..82cf1b2 100644 --- a/scripts/bootloader.opt +++ b/scripts/bootloader.opt @@ -12,21 +12,7 @@ UART1_BRR1 = 0x5232 ; 波特率寄存器1 UART1_CR2 = 0x5235 ; 控制寄存器2 ;; 引导程序主体(位于OPT保留区域0x481C-0x483F) - .area OPTION - -_bootO_start_opt: - .db 0x00 ; ROP - .db 0x00,0xFF ; UCB - .db 0x00,0xFF ; AFR - .db 0x00,0xFF ; Misc - .db 0x00,0xFF ; Clock - .db 0x00,0xFF ; HSECNT - -_bootO_resv_data: - .db 0x00,0x00,0x00,0x00,0x00 - .db 0x00,0x00,0x00,0x00 - .db 0x00,0x00,0x00,0x00 - .db 0x00,0x00,0x00,0x00 + .area OPTION_BOOT _bootO_start_data: ;; 终止标志(复制过程遇到0停止) diff --git a/scripts/config.opt b/scripts/config.opt new file mode 100644 index 0000000..ed5e3c6 --- /dev/null +++ b/scripts/config.opt @@ -0,0 +1,10 @@ +;; option bytes(0x4800~0x480A) + .area OPTION + +_bootO_start_opt: + .db 0x00 ; ROP + .db 0x00,0xFF ; UCB + .db 0x00,0xFF ; AFR + .db 0x00,0xFF ; Misc + .db 0x00,0xFF ; Clock + .db 0x00,0xFF ; HSECNT diff --git a/scripts/factory.opt b/scripts/factory.opt deleted file mode 100644 index 636a3c4..0000000 --- a/scripts/factory.opt +++ /dev/null @@ -1,22 +0,0 @@ -;; option O0 O1 N1 O2 N2 O3 N3 O4 N4 O5 N5 -;; 4800 00 00 FF 00 FF 00 FF 00 FF 00 FF - -;; 引导程序主体(位于OPT保留区域0x481C-0x483F) - .area OPTION - -_bootO_start_opt: - .db 0x00 ; ROP - .db 0x00,0xFF ; UCB - .db 0x00,0xFF ; AFR - .db 0x00,0xFF ; Misc - .db 0x00,0xFF ; Clock - .db 0x00,0xFF ; HSECNT - -_bootO_resv_data: - .db 0x00,0x00,0x00,0x00,0x00 - .db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 - .db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 - .db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 - .db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 - .db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 - .db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00