diff --git a/Makefile b/Makefile index c1ba4b2d..cb885bc6 100644 --- a/Makefile +++ b/Makefile @@ -28,11 +28,12 @@ include common.mk soctarget ?= atombones # Directories -sim_dir := sim -scar_dir := test/scar -elfdump_dir := tools/elfdump -lib_dir := sw/lib -doxy_dir := sim/docs +sim_dir := sim +scar_dir := test/scar +elfdump_dir := tools/elfdump +bootloader_dir := sw/bootloader +lib_dir := sw/lib +doxy_dir := sim/docs # Flags to the makefiles MKFLAGS := -s @@ -46,12 +47,13 @@ endif # Recepies #====================================================================== -default: sim lib ## Build sim, elfdump, and libs +default: sim lib boot ## Build sim, elfdump, and libs @printf "\n$(CLR_GR)==============================\n" @printf " Build Succesful!\n" @printf "==============================$(CLR_NC)\n" @printf " - atomsim [$(soctarget)]\n" @printf " - software libraries\n" + @printf " - bootloader [$(soctarget)]\n" all : doxy-pdf default ## Build default with docs @printf " - doxygen-docs in latex, html & pdf\n" @@ -93,6 +95,20 @@ clean-sim: ## Clean atomsim build files test: ## Test the build using banner example cd sw/examples && make ex=banner sim=true clean compile run + +# ======== Bootloader ======== +.PHONY : boot +boot: ## Build bootloader for given target [default: atombones] + @printf "$(CLR_GR)>> Building bootloader [soctarget:$(soctarget)] $(CLR_NC)\n" + make $(MKFLAGS) -C $(bootloader_dir) soctarget=$(soctarget) + + +.PHONY: clean-boot +clean-boot: ## Clean bootloader build files + @printf "$(CLR_GR)>> Cleaning bootloader build files $(CLR_NC)\n" + make $(MKFLAGS) -C $(bootloader_dir) soctarget=$(soctarget) clean + + # ======== SCAR ======== .PHONY: scar scar: $(bin_dir)/$(sim_executable) ## Verify target using scar @@ -156,4 +172,4 @@ clean: clean-sim clean-lib ## Alias for clean-sim, clean-lib .PHONY: clean-all -clean-all: clean-sim clean-scar clean-elfdump clean-lib clean-doxy ## Clean all build files \ No newline at end of file +clean-all: clean-sim clean-boot clean-scar clean-elfdump clean-lib clean-doxy ## Clean all build files \ No newline at end of file diff --git a/sw/examples/Makefile b/sw/examples/Makefile index 71898f72..940fc871 100644 --- a/sw/examples/Makefile +++ b/sw/examples/Makefile @@ -82,7 +82,7 @@ endif RVPREFIX := riscv64-unknown-elf CFLAGS := -Wall -CFLAGS += -mabi=ilp32 -march=rv32i -nostartfiles -ffreestanding -Os +CFLAGS += -mabi=ilp32 -march=rv32i -nostartfiles -ffreestanding -Os -g CFLAGS += -I $(RVATOM_LIB)/include -L $(RVATOM_LIB) LINKERSCRIPT := None @@ -104,7 +104,7 @@ ifeq ($(__check_soctarget),true) # check for validity of soctarget & select compile script ifeq ($(soctarget),atombones) CFLAGS += -DTARGET_ATOMBONES - LINKERSCRIPT:= $(RVATOM_LIB)/link/link.ld + LINKERSCRIPT:= $(RVATOM_LIB)/link/link_atombones.ld else ifeq ($(soctarget),hydrogensoc) CFLAGS += -DTARGET_HYDROGENSOC @@ -204,7 +204,7 @@ $(ex)/$(executable): $(SRC_FILES) cd $(ex) && $(RVPREFIX)-gcc $(CFLAGS) $(src_files) -o $(executable) $(LFLAGS) ifeq ($(objdump), true) - $(RVPREFIX)-objdump -htd $@ > $@.objdump + $(RVPREFIX)-objdump -Shtd $@ > $@.objdump endif ifeq ($(bin), true) diff --git a/sw/lib/Makefile b/sw/lib/Makefile index 471d90eb..a09dab03 100644 --- a/sw/lib/Makefile +++ b/sw/lib/Makefile @@ -1,9 +1,6 @@ ################################################## # ******** Makefile for Building libcatom ******** - - - include ../../common.mk ################################################## soctarget?=None @@ -15,6 +12,8 @@ soctarget?=None # user application to enable gcc garbage collection OPT = true +DEBUG ?= 1 + ################################################## # targets for which we don't need soctarget to be defined __check_soctarget := true @@ -58,6 +57,10 @@ ifeq ($(OPT), true) # For optimized code CFLAGS+= -fdata-sections -ffunction-sections endif +ifeq ($(DEBUG), 1) +CFLAGS += -g -O0 +endif + # Common sources C_SRCS := $(wildcard $(SRC_DIR)/*.c) S_SRCS := $(wildcard $(SRC_DIR)/*.S)