The correct compiler and the linker options is now in the make file.
The make file is still in its basic trial and error form.
# Compiler and Linker options
CC = riscv64-unknown-elf-gcc
OBJCOPY = riscv64-unknown-elf-objcopy
ASFLAGS = -march=rv32g -mabi=ilp32 -static -mcmodel=medany -fvisibility=hidden -nostdlib -nostartfiles
LDFLAGS = -T sparkfun-red-v.ld
#LDFLAGS = -T red-v.ld
# Source files
SRC_DIR = src
BOOT_DIR = $(SRC_DIR)/boot
INCLUDE_DIR = $(SRC_DIR)/include
DATA_DIR = $(SRC_DIR)/data
UNIT_TESTS_DIR = $(SRC_DIR)/unit-tests
STRINGS_TEST_UNIT_TESTS_DIR = $(UNIT_TESTS_DIR)/strings-module
MODULES_DIR= $(SRC_DIR)/modules
DEBUG_MODULE_DIR = $(MODULES_DIR)/debug-module
STRINGS_MODULE_DIR= $(MODULES_DIR)/strings-module
SRC = $(SRC_DIR)/main.s \
$(STRINGS_TEST_UNIT_TESTS_DIR)/strings-tests.s \
$(DEBUG_MODULE_DIR)/debug.s \
$(STRINGS_MODULE_DIR)/strings.s \
$(BOOT_DIR)/boot.s
INCLUDES = $(INCLUDE_DIR)/constants.s \
$(INCLUDE_DIR)/macros.s \
$(INCLUDE_DIR)/string-macros.s
DATA = $(DATA_DIR)/data.s \
$(DATA_DIR)/rodata.s \
$(DATA_DIR)/bss.s
# Output files
ELF = ./build/main.elf
HEX = ./build/main.hex
all: $(HEX)
$(HEX): $(ELF)
$(OBJCOPY) -O ihex $< $@
$(ELF): $(SRC) $(INCLUDES) $(DATA)
$(CC) $(ASFLAGS) $(LDFLAGS) $(SRC) -o $@
clean:
rm -f $(ELF) $(HEX)
.PHONY: all clean
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.