chore: mv symbol file

This commit is contained in:
2024-12-05 07:44:57 +06:00
parent 2fc63b73e0
commit 88bffa691d
3 changed files with 1448 additions and 44 deletions

View File

@@ -1,4 +1,3 @@
# Toolchain
PREFIX = arm-none-eabi-
CC = $(PREFIX)gcc
AS = $(PREFIX)as
@@ -6,7 +5,6 @@ LD = $(PREFIX)ld
OBJCOPY = $(PREFIX)objcopy
SIZE = $(PREFIX)size
# Project configuration
PROJECT = firmware
MCU = cortex-m4
FLASH_START = 0x00000000
@@ -15,86 +13,79 @@ LD_FILE=linker.ld
RAM_START := 0x10002000
# Compiler flags
CFLAGS = -mcpu=$(MCU) -mthumb \
-Wall -Wextra -g3 \
-Os -ffunction-sections -fdata-sections \
-nostartfiles -Wl,-T,$(LD_FILE) -u main -Wl,--gc-sections \
-DLOAD_ADDRESS=$(LOAD_ADDRESS)
ASFLAGS = \
-mcpu=$(MCU) -mthumb \
-g
ASFLAGS = -mcpu=$(MCU) -mthumb -g
LDFLAGS = \
-T linker.ld -Map=$(BUILD_DIR)/$(PROJECT).map \
LDFLAGS = -T linker.ld -Map=$(BUILD_DIR)/$(PROJECT).map \
--gc-sections --no-warn-rwx-segments \
--defsym=_RAM_START_ADDR=$(RAM_START)
# Directories
SRC_DIR = src
BUILD_DIR = build
INCLUDE_DIR = include
# Source files
SRCS = $(wildcard $(SRC_DIR)/*.c)
ASM_SRCS = $(wildcard $(SRC_DIR)/*.s)
OBJS = $(SRCS:$(SRC_DIR)/%.c=$(BUILD_DIR)/%.o)
ASM_OBJS = $(ASM_SRCS:$(SRC_DIR)/%.s=$(BUILD_DIR)/%.o)
# Include paths
# todo
INCLUDES = -I$(INCLUDE_DIR)
# Output files
SRCS := $(wildcard $(SRC_DIR)/*.c) $(wildcard $(SRC_DIR)/*.s)
OBJS := $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%.o,$(filter %.c,$(SRCS))) \
$(patsubst $(SRC_DIR)/%.s,$(BUILD_DIR)/%.o,$(filter %.s,$(SRCS)))
ELF = $(BUILD_DIR)/$(PROJECT).elf
BIN = $(BUILD_DIR)/$(PROJECT).bin
HEX = $(BUILD_DIR)/$(PROJECT).hex
# flashing
# flash
INTERFACE = stlink
OPENOCD_BASE=openocd -f interface/$(INTERFACE).cfg -f rtl8710_openocd/script/rtl8710.ocd -c "init" -c "reset" -c "halt"
FLASH_BIN = $(BUILD_DIR)/$(PROJECT).bin
.PHONY: all clean flash size
.PHONY: all clean flash size test mac dump dump0 full_erase restore restore_nae verify reset
# Default target
all: $(BUILD_DIR) $(ELF) $(BIN) $(HEX) size
# Create build directory
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
# Compile C files
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c
@echo "CC $<"
@$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
# Compile assembly files
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.s
@echo "AS $<"
@$(AS) $(ASFLAGS) -c $< -o $@
# Link
$(ELF): $(OBJS) $(ASM_OBJS)
@echo "LD $@"
@$(LD) $(LDFLAGS) -o $@ $^
# Generate binary
$(BIN): $(ELF)
@echo "OBJCOPY $@"
@$(OBJCOPY) -O binary $< $@
# Generate Intel HEX file
$(HEX): $(ELF)
@echo "OBJCOPY $@"
@$(OBJCOPY) -O ihex $< $@
# Print size information
size: $(ELF)
@echo
@$(SIZE) $<
# flash commands
clean:
rm -rf $(BUILD_DIR)
# flash cmds
flash:
@$(OPENOCD_BASE) -c 'rtl8710_flash_auto_erase 1' \
-c 'rtl8710_flash_auto_verify 1' \
-c 'rtl8710_flash_write $(FLASH_BIN) 0' \
-c 'rtl8710_reboot' -c 'reset run' -c shutdown
test:
$(OPENOCD_BASE) -c "rtl8710_flash_read_id" -c "shutdown"
@@ -104,15 +95,6 @@ mac:
dump:
$(OPENOCD_BASE) -c "rtl8710_flash_read_id" -c "rtl8710_flash_read dump.bin 0 1048576" -c "shutdown"
dump0:
$(OPENOCD_BASE) -c "rtl8710_flash_read_id" -c "rtl8710_flash_read dump0.bin 0 4096" -c "shutdown"
flash:
@$(OPENOCD_BASE) -c 'rtl8710_flash_auto_erase 1' \
-c 'rtl8710_flash_auto_verify 1' \
-c 'rtl8710_flash_write $(FLASH_BIN) 0' \
-c 'rtl8710_reboot' -c 'reset run' -c shutdown
full_erase:
$(OPENOCD_BASE) -c "rtl8710_flash_mass_erase" -c shutdown
@@ -127,8 +109,3 @@ verify:
reset:
$(OPENOCD_BASE) -c "rtl8710_reboot" -c shutdown
# Clean build files
clean:
rm -rf $(BUILD_DIR)

1427
export-rom_symbol_v01.txt Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
/* from https://github.com/ambiot/amb1_sdk/blob/master/project/realtek_amebaz_va0_example/GCC-RELEASE/export-rom_symbol_v01.txt */
INCLUDE "./rtl8710_openocd/export-rom_symbol_v01.txt"
INCLUDE "export-rom_symbol_v01.txt"
MEMORY
{