Line 14... |
Line 14... |
|
|
# Compiler toolchain
|
# Compiler toolchain
|
RISCV_PREFIX ?= riscv32-unknown-elf-
|
RISCV_PREFIX ?= riscv32-unknown-elf-
|
|
|
# CPU architecture and ABI
|
# CPU architecture and ABI
|
MARCH ?= -march=rv32i
|
MARCH ?= rv32i
|
MABI ?= -mabi=ilp32
|
MABI ?= ilp32
|
|
|
# User flags for additional configuration (will be added to compiler flags)
|
# User flags for additional configuration (will be added to compiler flags)
|
USER_FLAGS ?=
|
USER_FLAGS ?=
|
|
|
# Relative or absolute path to the NEORV32 home folder
|
# Relative or absolute path to the NEORV32 home folder
|
Line 85... |
Line 85... |
|
|
# NEORV32 executable image generator
|
# NEORV32 executable image generator
|
IMAGE_GEN = $(NEORV32_EXG_PATH)/image_gen
|
IMAGE_GEN = $(NEORV32_EXG_PATH)/image_gen
|
|
|
# Compiler & linker flags
|
# Compiler & linker flags
|
CC_OPTS = $(MARCH) $(MABI) $(EFFORT) -Wall -ffunction-sections -fdata-sections -nostartfiles -mno-fdiv
|
CC_OPTS = -march=$(MARCH) -mabi=$(MABI) $(EFFORT) -Wall -ffunction-sections -fdata-sections -nostartfiles -mno-fdiv
|
CC_OPTS += -Wl,--gc-sections -lm -lc -lgcc -lc
|
CC_OPTS += -Wl,--gc-sections -lm -lc -lgcc -lc
|
# This accelerates instruction fetch after branches when C extension is enabled (irrelevant when C extension is disabled)
|
# This accelerates instruction fetch after branches when C extension is enabled (irrelevant when C extension is disabled)
|
CC_OPTS += -falign-functions=4 -falign-labels=4 -falign-loops=4 -falign-jumps=4
|
CC_OPTS += -falign-functions=4 -falign-labels=4 -falign-loops=4 -falign-jumps=4
|
CC_OPTS += $(USER_FLAGS)
|
CC_OPTS += $(USER_FLAGS)
|
|
|
Line 102... |
Line 102... |
|
|
# 'compile' is still here for compatibility
|
# 'compile' is still here for compatibility
|
exe: $(APP_ASM) $(APP_EXE)
|
exe: $(APP_ASM) $(APP_EXE)
|
hex: $(APP_ASM) $(APP_HEX)
|
hex: $(APP_ASM) $(APP_HEX)
|
compile: $(APP_ASM) $(APP_EXE)
|
compile: $(APP_ASM) $(APP_EXE)
|
install: $(APP_ASM) $(APP_IMG)
|
image: $(APP_ASM) $(APP_IMG)
|
all: $(APP_ASM) $(APP_EXE) $(APP_IMG) $(APP_HEX)
|
install: image install-$(APP_IMG)
|
|
all: $(APP_ASM) $(APP_EXE) $(APP_IMG) $(APP_HEX) install
|
|
|
# Check if making bootloader
|
# Check if making bootloader
|
# Use different base address and legth for instruction memory/"rom" (BOOTMEM instead of IMEM)
|
# Use different base address and length for instruction memory/"rom" (BOOTROM instead of IMEM)
|
# Also define "make_bootloader" for crt0.S
|
# Also define "make_bootloader" symbol for crt0.S
|
target bootloader: CC_OPTS += -Wl,--defsym=make_bootloader=1 -Dmake_bootloader
|
target bootloader: CC_OPTS += -Wl,--defsym=make_bootloader=1 -Dmake_bootloader
|
|
target bl_image: CC_OPTS += -Wl,--defsym=make_bootloader=1 -Dmake_bootloader
|
|
|
|
|
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
# Image generator targets
|
# Image generator targets
|
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
Line 172... |
Line 174... |
|
|
# Generate NEORV32 executable VHDL boot image
|
# Generate NEORV32 executable VHDL boot image
|
$(APP_IMG): main.bin $(IMAGE_GEN)
|
$(APP_IMG): main.bin $(IMAGE_GEN)
|
@set -e
|
@set -e
|
@$(IMAGE_GEN) -app_img $< $@ $(shell basename $(CURDIR))
|
@$(IMAGE_GEN) -app_img $< $@ $(shell basename $(CURDIR))
|
|
|
|
install-$(APP_IMG): $(APP_IMG)
|
|
@set -e
|
@echo "Installing application image to $(NEORV32_RTL_PATH)/$(APP_IMG)"
|
@echo "Installing application image to $(NEORV32_RTL_PATH)/$(APP_IMG)"
|
@cp $(APP_IMG) $(NEORV32_RTL_PATH)/.
|
@cp $(APP_IMG) $(NEORV32_RTL_PATH)/.
|
|
|
# Generate NEORV32 executable image in plain hex format
|
# Generate NEORV32 executable image in plain hex format
|
$(APP_HEX): main.bin $(IMAGE_GEN)
|
$(APP_HEX): main.bin $(IMAGE_GEN)
|
Line 188... |
Line 193... |
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
# Create and install bootloader VHDL init image
|
# Create and install bootloader VHDL init image
|
$(BOOT_IMG): main.bin $(IMAGE_GEN)
|
$(BOOT_IMG): main.bin $(IMAGE_GEN)
|
@set -e
|
@set -e
|
@$(IMAGE_GEN) -bld_img $< $(BOOT_IMG) $(shell basename $(CURDIR))
|
@$(IMAGE_GEN) -bld_img $< $(BOOT_IMG) $(shell basename $(CURDIR))
|
|
|
|
install-$(BOOT_IMG): $(BOOT_IMG)
|
|
@set -e
|
@echo "Installing bootloader image to $(NEORV32_RTL_PATH)/$(BOOT_IMG)"
|
@echo "Installing bootloader image to $(NEORV32_RTL_PATH)/$(BOOT_IMG)"
|
@cp $(BOOT_IMG) $(NEORV32_RTL_PATH)/.
|
@cp $(BOOT_IMG) $(NEORV32_RTL_PATH)/.
|
|
|
# Just an alias that
|
# Just an alias
|
bootloader: $(BOOT_IMG)
|
bl_image: $(BOOT_IMG)
|
|
bootloader: bl_image install-$(BOOT_IMG)
|
|
|
|
|
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
# Check toolchain
|
# Check toolchain
|
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
Line 265... |
Line 274... |
|
|
|
|
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
# In-console simulation using default/simple testbench and GHDL
|
# In-console simulation using default/simple testbench and GHDL
|
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
sim: $(APP_IMG)
|
sim: $(APP_IMG) install
|
@echo "Simulating $(APP_IMG)..."
|
@echo "Simulating $(APP_IMG)..."
|
@sh $(NEORV32_SIM_PATH)/simple/ghdl.sh
|
@sh $(NEORV32_SIM_PATH)/simple/ghdl.sh
|
|
|
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
# Show final ELF details (just for debugging)
|
# Show final ELF details (just for debugging)
|
Line 288... |
Line 297... |
@echo " help - show this text"
|
@echo " help - show this text"
|
@echo " check - check toolchain"
|
@echo " check - check toolchain"
|
@echo " info - show makefile/toolchain configuration"
|
@echo " info - show makefile/toolchain configuration"
|
@echo " exe - compile and generate executable for upload via bootloader"
|
@echo " exe - compile and generate executable for upload via bootloader"
|
@echo " hex - compile and generate executable raw file"
|
@echo " hex - compile and generate executable raw file"
|
|
@echo " image - compile and generate VHDL IMEM boot image (for application) in local folder"
|
@echo " install - compile, generate and install VHDL IMEM boot image (for application)"
|
@echo " install - compile, generate and install VHDL IMEM boot image (for application)"
|
@echo " sim - in-console simulation using default/simple testbench and GHDL"
|
@echo " sim - in-console simulation using default/simple testbench and GHDL"
|
@echo " all - exe + hex + install"
|
@echo " all - exe + hex + install"
|
@echo " elf_info - show ELF layout info"
|
@echo " elf_info - show ELF layout info"
|
@echo " clean - clean up project"
|
@echo " clean - clean up project"
|
@echo " clean_all - clean up project, core libraries and image generator"
|
@echo " clean_all - clean up project, core libraries and image generator"
|
|
@echo " bl_image - compile and generate VHDL BOOTROM boot image (for bootloader only!) in local folder"
|
@echo " bootloader - compile, generate and install VHDL BOOTROM boot image (for bootloader only!)"
|
@echo " bootloader - compile, generate and install VHDL BOOTROM boot image (for bootloader only!)"
|
|
|
|
|
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
# Clean up
|
# Clean up
|