2021-05-21 06:19:50 +00:00
|
|
|
RISCV_TOOLS_PATH := /opt/riscv32/bin
|
2021-04-25 11:34:21 +00:00
|
|
|
RISCV_TOOLS_PREFIX := riscv32-unknown-elf-
|
|
|
|
|
|
|
|
RISCV_GCC := $(abspath $(RISCV_TOOLS_PATH)/$(RISCV_TOOLS_PREFIX)gcc)
|
|
|
|
RISCV_AS := $(abspath $(RISCV_TOOLS_PATH)/$(RISCV_TOOLS_PREFIX)as)
|
|
|
|
RISCV_GXX := $(abspath $(RISCV_TOOLS_PATH)/$(RISCV_TOOLS_PREFIX)g++)
|
|
|
|
RISCV_OBJDUMP := $(abspath $(RISCV_TOOLS_PATH)/$(RISCV_TOOLS_PREFIX)objdump)
|
|
|
|
RISCV_GDB := $(abspath $(RISCV_TOOLS_PATH)/$(RISCV_TOOLS_PREFIX)gdb)
|
|
|
|
RISCV_AR := $(abspath $(RISCV_TOOLS_PATH)/$(RISCV_TOOLS_PREFIX)ar)
|
|
|
|
RISCV_OBJCOPY := $(abspath $(RISCV_TOOLS_PATH)/$(RISCV_TOOLS_PREFIX)objcopy)
|
|
|
|
RISCV_READELF := $(abspath $(RISCV_TOOLS_PATH)/$(RISCV_TOOLS_PREFIX)readelf)
|
|
|
|
|
|
|
|
BIN_TO_MEM := $(BSP_DIR)/../../tools/BinToMem.py
|
|
|
|
|
|
|
|
.PHONY: all
|
|
|
|
all: $(TARGET)
|
|
|
|
|
|
|
|
ASM_SRCS += $(BSP_DIR)/crt0.S
|
2021-07-26 01:54:38 +00:00
|
|
|
ASM_SRCS += $(BSP_DIR)/trap_entry.S
|
2021-04-25 11:34:21 +00:00
|
|
|
|
|
|
|
C_SRCS += $(BSP_DIR)/lib/utils.c
|
|
|
|
C_SRCS += $(BSP_DIR)/lib/xprintf.c
|
|
|
|
C_SRCS += $(BSP_DIR)/lib/uart.c
|
2021-05-14 06:37:47 +00:00
|
|
|
C_SRCS += $(BSP_DIR)/lib/sim_ctrl.c
|
2021-08-10 01:54:20 +00:00
|
|
|
C_SRCS += $(BSP_DIR)/lib/timer.c
|
2021-05-15 06:52:30 +00:00
|
|
|
C_SRCS += $(BSP_DIR)/lib/gpio.c
|
2021-07-22 01:40:26 +00:00
|
|
|
C_SRCS += $(BSP_DIR)/lib/rvic.c
|
2021-08-19 01:45:40 +00:00
|
|
|
C_SRCS += $(BSP_DIR)/lib/i2c.c
|
2021-09-10 01:56:21 +00:00
|
|
|
C_SRCS += $(BSP_DIR)/lib/spi.c
|
|
|
|
C_SRCS += $(BSP_DIR)/lib/pinmux.c
|
2021-04-25 11:34:21 +00:00
|
|
|
|
|
|
|
LINKER_SCRIPT := $(BSP_DIR)/link.lds
|
|
|
|
|
|
|
|
INCLUDES += -I$(BSP_DIR)
|
|
|
|
|
|
|
|
LDFLAGS += -T $(LINKER_SCRIPT) -nostartfiles -Wl,--gc-sections -Wl,--check-sections
|
|
|
|
|
|
|
|
ASM_OBJS := $(ASM_SRCS:.S=.o)
|
|
|
|
C_OBJS := $(C_SRCS:.c=.o)
|
|
|
|
|
|
|
|
LINK_OBJS += $(ASM_OBJS) $(C_OBJS)
|
|
|
|
LINK_DEPS += $(LINKER_SCRIPT)
|
|
|
|
|
|
|
|
CLEAN_OBJS += $(TARGET) $(LINK_OBJS) $(TARGET).dump $(TARGET).bin $(TARGET).hex $(TARGET).mem
|
|
|
|
|
|
|
|
CFLAGS += -march=$(RISCV_ARCH)
|
|
|
|
CFLAGS += -mabi=$(RISCV_ABI)
|
|
|
|
CFLAGS += -mcmodel=$(RISCV_MCMODEL) -ffunction-sections -fdata-sections -fno-builtin-printf -fno-builtin-malloc
|
|
|
|
|
|
|
|
$(TARGET): $(LINK_OBJS) $(LINK_DEPS) Makefile
|
|
|
|
$(RISCV_GCC) $(CFLAGS) $(INCLUDES) $(LINK_OBJS) -o $@ $(LDFLAGS)
|
|
|
|
$(RISCV_OBJCOPY) -O binary $@ $@.bin
|
|
|
|
$(RISCV_OBJDUMP) --disassemble-all $@ > $@.dump
|
|
|
|
$(BIN_TO_MEM) $@.bin $@.mem
|
|
|
|
|
|
|
|
$(ASM_OBJS): %.o: %.S
|
|
|
|
$(RISCV_GCC) $(CFLAGS) $(INCLUDES) -c -o $@ $<
|
|
|
|
|
|
|
|
$(C_OBJS): %.o: %.c
|
|
|
|
$(RISCV_GCC) $(CFLAGS) $(INCLUDES) -c -o $@ $<
|
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
|
|
|
rm -f $(CLEAN_OBJS)
|