-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cross build GCC/LLVM working but no boot
- Loading branch information
1 parent
a4e6e1e
commit e671f0c
Showing
17 changed files
with
1,199 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,232 @@ | ||
##############################################################################80 | ||
# | ||
# Copyright Christopher Kormanyos 2023 - 2024. | ||
# Distributed under The Unlicense. | ||
# | ||
##############################################################################80 | ||
|
||
##############################################################################80 | ||
# | ||
# Makefile | ||
# | ||
# Build system for RED-V_SiFive_RISC-V_FE310_SoC based on standard GNU tools | ||
# | ||
# Using GNU Make 4.2.1 (see version information in build log) | ||
# | ||
# 23-June-2024 | ||
# | ||
# See also a definitive list of GCC command line options | ||
# (for numerous target systems) here: | ||
# https://man7.org/linux/man-pages/man1/gcc.1.html | ||
# | ||
##############################################################################80 | ||
|
||
############################################################################################ | ||
# Defines | ||
############################################################################################ | ||
|
||
HW_TARGET = RedV_FE310 | ||
PRJ_NAME = Blinky_$(HW_TARGET) | ||
OUTPUT_DIR = $(CURDIR)/../bin | ||
OBJ_DIR = $(CURDIR)/../tmp/obj | ||
SRC_DIR = $(CURDIR)/../Code | ||
LD_SCRIPT = $(SRC_DIR)/Memory_Map.ld | ||
|
||
##############################################################################80 | ||
# tools | ||
##############################################################################80 | ||
|
||
ifeq ($(TYP_CC),LLVM) | ||
PATH_TOOLS_CC := $(CURDIR)/tools/Util/msys64/usr/local/llvm-17.0.2-riscv32/bin | ||
endif | ||
|
||
ifeq ($(TYP_CC),GCC) | ||
PATH_TOOLS_CC := $(CURDIR)/tools/Util/msys64/usr/local/gcc-13.2.0-riscv32-unknown-elf/bin | ||
endif | ||
|
||
TOOL_PREFIX := $(CURDIR)/tools/UnxUtils/usr/local/wbin | ||
TOOL_PREFIX := $(TOOL_PREFIX)/ | ||
|
||
GNUMAKE := $(CURDIR)/make$(EXEEXT) | ||
|
||
EXEEXT := .exe | ||
|
||
ifeq ($(TYP_CC),LLVM) | ||
AS := $(PATH_TOOLS_CC)/clang++$(EXEEXT) | ||
CC := $(PATH_TOOLS_CC)/clang++$(EXEEXT) | ||
CP := $(PATH_TOOLS_CC)/clang++$(EXEEXT) | ||
LD := $(PATH_TOOLS_CC)/clang++$(EXEEXT) | ||
OBJDUMP := $(PATH_TOOLS_CC)/llvm-objdump$(EXEEXT) | ||
OBJCOPY := $(PATH_TOOLS_CC)/llvm-objcopy$(EXEEXT) | ||
READELF := $(PATH_TOOLS_CC)/llvm-readelf$(EXEEXT) | ||
endif | ||
ifeq ($(TYP_CC),GCC) | ||
AS := $(PATH_TOOLS_CC)/riscv32-unknown-elf-g++$(EXEEXT) | ||
CC := $(PATH_TOOLS_CC)/riscv32-unknown-elf-g++$(EXEEXT) | ||
CP := $(PATH_TOOLS_CC)/riscv32-unknown-elf-g++$(EXEEXT) | ||
LD := $(PATH_TOOLS_CC)/riscv32-unknown-elf-g++$(EXEEXT) | ||
OBJDUMP := $(PATH_TOOLS_CC)/riscv32-unknown-elf-objdump$(EXEEXT) | ||
OBJCOPY := $(PATH_TOOLS_CC)/riscv32-unknown-elf-objcopy$(EXEEXT) | ||
READELF := $(PATH_TOOLS_CC)/riscv32-unknown-elf-readelf$(EXEEXT) | ||
endif | ||
ECHO := $(TOOL_PREFIX)echo$(EXEEXT) | ||
MKDIR := $(TOOL_PREFIX)mkdir$(EXEEXT) | ||
MV := $(TOOL_PREFIX)mv$(EXEEXT) | ||
RM := $(TOOL_PREFIX)rm$(EXEEXT) | ||
|
||
|
||
AS := $(subst /,\,$(AS)) | ||
CC := $(subst /,\,$(CC)) | ||
CP := $(subst /,\,$(CP)) | ||
LD := $(subst /,\,$(LD)) | ||
OBJDUMP := $(subst /,\,$(OBJDUMP)) | ||
OBJCOPY := $(subst /,\,$(OBJCOPY)) | ||
READELF := $(subst /,\,$(READELF)) | ||
ECHO := $(subst /,\,$(ECHO)) | ||
MKDIR := $(subst /,\,$(MKDIR)) | ||
MV := $(subst /,\,$(MV)) | ||
RM := $(subst /,\,$(RM)) | ||
|
||
##############################################################################80 | ||
# OS-independent abstratcion of the null-device | ||
##############################################################################80 | ||
|
||
NULL_DEVICE := NUL | ||
$(NULL_DEVICE) := NUL | ||
|
||
##############################################################################80 | ||
# flags | ||
##############################################################################80 | ||
|
||
OPT := -O2 \ | ||
-fno-reorder-blocks-and-partition \ | ||
-fno-reorder-functions | ||
|
||
OPT := -O0 | ||
|
||
ARCH := -mcpu=sifive-e31 \ | ||
-mabi=ilp32 \ | ||
-march=rv32imac \ | ||
|
||
ifeq ($(TYP_CC),GCC) | ||
ARCH += -msmall-data-limit=0 | ||
ARCH += -falign-functions=4 | ||
endif | ||
|
||
ASOPS := $(OPT) \ | ||
$(ARCH) \ | ||
|
||
|
||
ifeq ($(TYP_CC),GCC) | ||
ASOPS += -Wa,-adhln=$(OBJ_DIR)/$(basename $(@F)).lst | ||
endif | ||
|
||
|
||
COPS := $(OPT) \ | ||
$(ARCH) \ | ||
-ffast-math \ | ||
-falign-functions=4 \ | ||
-g3 \ | ||
-Wconversion \ | ||
-Wsign-conversion \ | ||
-Wunused-parameter \ | ||
-Wuninitialized \ | ||
-Wmissing-declarations \ | ||
-Wshadow \ | ||
-Wunreachable-code \ | ||
-Wmissing-include-dirs \ | ||
-std=c11 \ | ||
-Wall \ | ||
-Wextra \ | ||
-fomit-frame-pointer \ | ||
-gdwarf-2 \ | ||
-fno-exceptions | ||
|
||
|
||
LOPS := -e Startup_Init \ | ||
$(ARCH) \ | ||
-ffast-math \ | ||
-falign-functions=4 \ | ||
-Wl,--print-memory-usage \ | ||
-Wl,--print-map \ | ||
-Wl,-T$(LD_SCRIPT) \ | ||
-Wl,-Map=$(OUTPUT_DIR)/$(PRJ_NAME).map | ||
|
||
ifeq ($(TYP_CC),GCC) | ||
LOPS += -nostdlib | ||
LOPS += -nostartfiles | ||
endif | ||
|
||
############################################################################################ | ||
# Source Files | ||
############################################################################################ | ||
|
||
SRC_FILES := $(SRC_DIR)/Mcal/mtimer.c \ | ||
$(SRC_DIR)/Mcal/Clock.c \ | ||
$(SRC_DIR)/Mcal/Mcu.c \ | ||
$(SRC_DIR)/Startup/boot.s \ | ||
$(SRC_DIR)/Startup/intvect.c \ | ||
$(SRC_DIR)/Startup/Startup.c \ | ||
$(SRC_DIR)/main.c | ||
|
||
############################################################################################ | ||
# Include Paths | ||
############################################################################################ | ||
|
||
INC_FILES := $(SRC_DIR) \ | ||
$(SRC_DIR)/Mcal | ||
|
||
############################################################################################ | ||
# Rules | ||
############################################################################################ | ||
|
||
VPATH := $(subst \,/,$(sort $(dir $(SRC_FILES)) $(OBJ_DIR))) | ||
|
||
FILES_O := $(addprefix $(OBJ_DIR)/, $(notdir $(addsuffix .o, $(basename $(SRC_FILES))))) | ||
|
||
|
||
ifeq ($(MAKECMDGOALS),build) | ||
-include $(subst .o,.d,$(FILES_O)) | ||
endif | ||
|
||
|
||
all : clean version $(OUTPUT_DIR)/$(PRJ_NAME).elf | ||
|
||
|
||
.PHONY : version | ||
version : | ||
@-$(ECHO) print compiler version | ||
@-$(ECHO) | ||
@-$(CC) -v | ||
|
||
|
||
.PHONY : clean | ||
clean : | ||
@-$(ECHO) clean and create directories | ||
@-$(ECHO) | ||
@-$(RM) -rf $(OBJ_DIR) *.o 2>$(NULL_DEVICE) | ||
@-$(RM) -rf $(OBJ_DIR) *.d 2>$(NULL_DEVICE) | ||
@-$(RM) -rf $(OUTPUT_DIR) *.hex 2>$(NULL_DEVICE) | ||
@-$(RM) -rf $(OUTPUT_DIR) *.elf 2>$(NULL_DEVICE) | ||
@-$(RM) -rf $(OUTPUT_DIR) *.list 2>$(NULL_DEVICE) | ||
@-$(RM) -rf $(OUTPUT_DIR) *.map 2>$(NULL_DEVICE) | ||
@-$(RM) -rf $(OUTPUT_DIR) *.txt 2>$(NULL_DEVICE) | ||
@-$(MKDIR) -p $(subst \,/,$(OBJ_DIR)) | ||
@-$(MKDIR) -p $(subst \,/,$(OUTPUT_DIR)) | ||
|
||
|
||
$(OBJ_DIR)/%.o : %.c | ||
@-echo +++ compile: $(subst \,/,$<) to $(subst \,/,$@) | ||
@-$(CC) -x c $(COPS) $(addprefix -I, $(INC_FILES)) -c $< -o $(OBJ_DIR)/$(basename $(@F)).o | ||
|
||
|
||
$(OBJ_DIR)/%.o : %.s | ||
@-echo +++ compile: $(subst \,/,$<) to $(subst \,/,$@) | ||
@-$(CC) -x assembler $(ASOPS) $(addprefix -I, $(INC_FILES)) -c $< -o $(OBJ_DIR)/$(basename $(@F)).o | ||
|
||
|
||
$(OUTPUT_DIR)/$(PRJ_NAME).elf : $(FILES_O) $(LD_SCRIPT) | ||
@$(LD) -x none $(LOPS) $(FILES_O) -o $(OUTPUT_DIR)/$(PRJ_NAME).elf | ||
@$(OBJDUMP) -D --wide $(OUTPUT_DIR)/$(PRJ_NAME).elf > $(OUTPUT_DIR)/$(PRJ_NAME).list.all | ||
@$(OBJCOPY) $(OUTPUT_DIR)/$(PRJ_NAME).elf -O ihex $(OUTPUT_DIR)/$(PRJ_NAME).hex | ||
@$(READELF) --wide -S -s $(OUTPUT_DIR)/$(PRJ_NAME).elf > $(OUTPUT_DIR)/$(PRJ_NAME).readelf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.10.35004.147 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RED-V_SiFive_RISC-V_FE310_SoC", "RED-V_SiFive_RISC-V_FE310_SoC.vcxproj", "{097CF2E1-2689-43E4-A112-A4FE44B8679A}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Blinky_RedV_FE310 GCC|x64 = Blinky_RedV_FE310 GCC|x64 | ||
Blinky_RedV_FE310 LLVM|x64 = Blinky_RedV_FE310 LLVM|x64 | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{097CF2E1-2689-43E4-A112-A4FE44B8679A}.Blinky_RedV_FE310 GCC|x64.ActiveCfg = Blinky_RedV_FE310 GCC|x64 | ||
{097CF2E1-2689-43E4-A112-A4FE44B8679A}.Blinky_RedV_FE310 GCC|x64.Build.0 = Blinky_RedV_FE310 GCC|x64 | ||
{097CF2E1-2689-43E4-A112-A4FE44B8679A}.Blinky_RedV_FE310 LLVM|x64.ActiveCfg = Blinky_RedV_FE310 LLVM|x64 | ||
{097CF2E1-2689-43E4-A112-A4FE44B8679A}.Blinky_RedV_FE310 LLVM|x64.Build.0 = Blinky_RedV_FE310 LLVM|x64 | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {09FE8ABC-CC3E-46F9-BEA1-0F9AD302894E} | ||
EndGlobalSection | ||
EndGlobal |
Oops, something went wrong.