From 8839eb4ac41153cfda64fa9988ea369e484d0e93 Mon Sep 17 00:00:00 2001 From: adrizcorp Date: Tue, 27 Feb 2024 15:43:22 -0800 Subject: [PATCH] modifying Makefiles to make them compatible with windows file directory --- sw/bootloader/makefile | 3 +- sw/common/common.mk | 9 +- sw/example/atomic_test/makefile | 9 + sw/example/bus_explorer/makefile | 9 + sw/example/coremark/makefile | 9 + sw/example/demo_blink_led/makefile | 11 +- sw/example/demo_cfs/makefile | 9 + sw/example/demo_cfu/makefile | 9 + sw/example/demo_crc/makefile | 9 + sw/example/demo_dma/makefile | 9 + sw/example/demo_emulate_unaligned/makefile | 9 + sw/example/demo_gptmr/makefile | 9 + sw/example/demo_hpm/makefile | 9 + sw/example/demo_mtime/makefile | 9 + sw/example/demo_neopixel/makefile | 9 + sw/example/demo_newlib/makefile | 12 +- sw/example/demo_onewire/makefile | 9 + sw/example/demo_pwm/makefile | 9 + sw/example/demo_sdi/makefile | 9 + sw/example/demo_slink/makefile | 9 + sw/example/demo_spi/makefile | 9 + sw/example/demo_spi_irq/makefile | 13 +- sw/example/demo_trng/makefile | 9 + sw/example/demo_twi/makefile | 9 + sw/example/demo_wdt/makefile | 9 + sw/example/demo_xip/makefile | 9 + sw/example/demo_xirq/makefile | 9 + sw/example/float_corner_test/makefile | 9 + sw/example/floating_point_test/makefile | 9 + sw/example/game_of_life/makefile | 9 + sw/example/hello_cpp/makefile | 9 + sw/example/hello_world/makefile | 16 +- sw/example/makefile | 50 ++++ sw/example/processor_check/makefile | 20 +- sw/ocd-firmware/makefile | 266 +++++++++++++++++++++ 35 files changed, 619 insertions(+), 15 deletions(-) diff --git a/sw/bootloader/makefile b/sw/bootloader/makefile index 6b29dbe..d1957fa 100644 --- a/sw/bootloader/makefile +++ b/sw/bootloader/makefile @@ -1,10 +1,11 @@ -# Modify this variable to fit your NEORV32 setup (neorv32 home folder) +# Modify this variable to fit your NEORV32 setup (neorv32 home folder) OSFLAG := ifeq ($(OS),Windows_NT) NEORV32_HOME ?= ..\.. + include $(NEORV32_HOME)\sw\common\common.mk else diff --git a/sw/common/common.mk b/sw/common/common.mk index 0669c50..dd2dfff 100644 --- a/sw/common/common.mk +++ b/sw/common/common.mk @@ -115,8 +115,8 @@ SRC = $(APP_SRC) SRC += $(CORE_SRC) # Define all object files -OBJ = $(SRC:%=%.o) - +OBJ = $(SRC:%=%.o) +OBJ += $(NEORV32_SRC_PATH)\neorv32_gpio.c.o $(NEORV32_SRC_PATH)\neorv32_cfs.c.o $(NEORV32_SRC_PATH)\neorv32_cpu.c.o $(NEORV32_SRC_PATH)\neorv32_cpu_amo.c.o $(NEORV32_SRC_PATH)\neorv32_cpu_cfu.c.o $(NEORV32_SRC_PATH)\neorv32_crc.c.o $(NEORV32_SRC_PATH)\neorv32_dma.c.o $(NEORV32_SRC_PATH)\neorv32_gptmr.c.o $(NEORV32_SRC_PATH)\neorv32_mtime.c.o $(NEORV32_SRC_PATH)\neorv32_neoled.c.o $(NEORV32_SRC_PATH)\neorv32_onewire.c.o $(NEORV32_SRC_PATH)\neorv32_pwm.c.o $(NEORV32_SRC_PATH)\neorv32_rte.c.o $(NEORV32_SRC_PATH)\neorv32_sdi.c.o $(NEORV32_SRC_PATH)\neorv32_slink.c.o $(NEORV32_SRC_PATH)\neorv32_spi.c.o $(NEORV32_SRC_PATH)\neorv32_trng.c.o $(NEORV32_SRC_PATH)\neorv32_twi.c.o $(NEORV32_SRC_PATH)\neorv32_uart.c.o $(NEORV32_SRC_PATH)\neorv32_wdt.c.o $(NEORV32_SRC_PATH)\neorv32_xip.c.o $(NEORV32_SRC_PATH)\syscalls.c.o $(NEORV32_SRC_PATH)\neorv32_xirq.c.o # ----------------------------------------------------------------------------- # Tools and flags @@ -207,6 +207,7 @@ $(IMAGE_GEN): $(NEORV32_EXG_PATH)\image_gen.c # Link object files and show memory utilization $(APP_ELF): $(OBJ) + echo "culo" @$(CC) $(CC_FLAGS) -T $(LD_SCRIPT) $(OBJ) $(LD_LIBS) -o $@ @echo "Memory utilization:" @$(SIZE) $(APP_ELF) @@ -327,10 +328,10 @@ gdb: # Clean up # ----------------------------------------------------------------------------- clean: - @$(RM_WIN) -f *.elf *.o *.bin *.out *.asm *.vhd *.hex .gdb_history + @$(RM_WIN) *.elf *.o *.bin *.out *.asm *.vhd *.hex .gdb_history clean_all: clean - @$(RM_WIN) -f $(OBJ) $(IMAGE_GEN) + @$(RM_WIN) $(IMAGE_GEN) # ----------------------------------------------------------------------------- diff --git a/sw/example/atomic_test/makefile b/sw/example/atomic_test/makefile index 8f9e2fd..fa59946 100644 --- a/sw/example/atomic_test/makefile +++ b/sw/example/atomic_test/makefile @@ -1,4 +1,13 @@ # Modify this variable to fit your NEORV32 setup (neorv32 home folder) +OSFLAG := + +ifeq ($(OS),Windows_NT) +NEORV32_HOME ?= ..\..\.. + +include $(NEORV32_HOME)\sw\common\common.mk +else + NEORV32_HOME ?= ../../.. include $(NEORV32_HOME)/sw/common/common.mk +endif \ No newline at end of file diff --git a/sw/example/bus_explorer/makefile b/sw/example/bus_explorer/makefile index 8f9e2fd..fa59946 100644 --- a/sw/example/bus_explorer/makefile +++ b/sw/example/bus_explorer/makefile @@ -1,4 +1,13 @@ # Modify this variable to fit your NEORV32 setup (neorv32 home folder) +OSFLAG := + +ifeq ($(OS),Windows_NT) +NEORV32_HOME ?= ..\..\.. + +include $(NEORV32_HOME)\sw\common\common.mk +else + NEORV32_HOME ?= ../../.. include $(NEORV32_HOME)/sw/common/common.mk +endif \ No newline at end of file diff --git a/sw/example/coremark/makefile b/sw/example/coremark/makefile index 8f9e2fd..fa59946 100644 --- a/sw/example/coremark/makefile +++ b/sw/example/coremark/makefile @@ -1,4 +1,13 @@ # Modify this variable to fit your NEORV32 setup (neorv32 home folder) +OSFLAG := + +ifeq ($(OS),Windows_NT) +NEORV32_HOME ?= ..\..\.. + +include $(NEORV32_HOME)\sw\common\common.mk +else + NEORV32_HOME ?= ../../.. include $(NEORV32_HOME)/sw/common/common.mk +endif \ No newline at end of file diff --git a/sw/example/demo_blink_led/makefile b/sw/example/demo_blink_led/makefile index 94c806e..fa59946 100644 --- a/sw/example/demo_blink_led/makefile +++ b/sw/example/demo_blink_led/makefile @@ -1,4 +1,13 @@ # Modify this variable to fit your NEORV32 setup (neorv32 home folder) -NEORV32_HOME ?= ../../.. +OSFLAG := + +ifeq ($(OS),Windows_NT) +NEORV32_HOME ?= ..\..\.. include $(NEORV32_HOME)\sw\common\common.mk +else + +NEORV32_HOME ?= ../../.. + +include $(NEORV32_HOME)/sw/common/common.mk +endif \ No newline at end of file diff --git a/sw/example/demo_cfs/makefile b/sw/example/demo_cfs/makefile index 8f9e2fd..fa59946 100644 --- a/sw/example/demo_cfs/makefile +++ b/sw/example/demo_cfs/makefile @@ -1,4 +1,13 @@ # Modify this variable to fit your NEORV32 setup (neorv32 home folder) +OSFLAG := + +ifeq ($(OS),Windows_NT) +NEORV32_HOME ?= ..\..\.. + +include $(NEORV32_HOME)\sw\common\common.mk +else + NEORV32_HOME ?= ../../.. include $(NEORV32_HOME)/sw/common/common.mk +endif \ No newline at end of file diff --git a/sw/example/demo_cfu/makefile b/sw/example/demo_cfu/makefile index 8f9e2fd..fa59946 100644 --- a/sw/example/demo_cfu/makefile +++ b/sw/example/demo_cfu/makefile @@ -1,4 +1,13 @@ # Modify this variable to fit your NEORV32 setup (neorv32 home folder) +OSFLAG := + +ifeq ($(OS),Windows_NT) +NEORV32_HOME ?= ..\..\.. + +include $(NEORV32_HOME)\sw\common\common.mk +else + NEORV32_HOME ?= ../../.. include $(NEORV32_HOME)/sw/common/common.mk +endif \ No newline at end of file diff --git a/sw/example/demo_crc/makefile b/sw/example/demo_crc/makefile index 8f9e2fd..fa59946 100644 --- a/sw/example/demo_crc/makefile +++ b/sw/example/demo_crc/makefile @@ -1,4 +1,13 @@ # Modify this variable to fit your NEORV32 setup (neorv32 home folder) +OSFLAG := + +ifeq ($(OS),Windows_NT) +NEORV32_HOME ?= ..\..\.. + +include $(NEORV32_HOME)\sw\common\common.mk +else + NEORV32_HOME ?= ../../.. include $(NEORV32_HOME)/sw/common/common.mk +endif \ No newline at end of file diff --git a/sw/example/demo_dma/makefile b/sw/example/demo_dma/makefile index 8f9e2fd..fa59946 100644 --- a/sw/example/demo_dma/makefile +++ b/sw/example/demo_dma/makefile @@ -1,4 +1,13 @@ # Modify this variable to fit your NEORV32 setup (neorv32 home folder) +OSFLAG := + +ifeq ($(OS),Windows_NT) +NEORV32_HOME ?= ..\..\.. + +include $(NEORV32_HOME)\sw\common\common.mk +else + NEORV32_HOME ?= ../../.. include $(NEORV32_HOME)/sw/common/common.mk +endif \ No newline at end of file diff --git a/sw/example/demo_emulate_unaligned/makefile b/sw/example/demo_emulate_unaligned/makefile index 8f9e2fd..fa59946 100644 --- a/sw/example/demo_emulate_unaligned/makefile +++ b/sw/example/demo_emulate_unaligned/makefile @@ -1,4 +1,13 @@ # Modify this variable to fit your NEORV32 setup (neorv32 home folder) +OSFLAG := + +ifeq ($(OS),Windows_NT) +NEORV32_HOME ?= ..\..\.. + +include $(NEORV32_HOME)\sw\common\common.mk +else + NEORV32_HOME ?= ../../.. include $(NEORV32_HOME)/sw/common/common.mk +endif \ No newline at end of file diff --git a/sw/example/demo_gptmr/makefile b/sw/example/demo_gptmr/makefile index 8f9e2fd..fa59946 100644 --- a/sw/example/demo_gptmr/makefile +++ b/sw/example/demo_gptmr/makefile @@ -1,4 +1,13 @@ # Modify this variable to fit your NEORV32 setup (neorv32 home folder) +OSFLAG := + +ifeq ($(OS),Windows_NT) +NEORV32_HOME ?= ..\..\.. + +include $(NEORV32_HOME)\sw\common\common.mk +else + NEORV32_HOME ?= ../../.. include $(NEORV32_HOME)/sw/common/common.mk +endif \ No newline at end of file diff --git a/sw/example/demo_hpm/makefile b/sw/example/demo_hpm/makefile index 8f9e2fd..fa59946 100644 --- a/sw/example/demo_hpm/makefile +++ b/sw/example/demo_hpm/makefile @@ -1,4 +1,13 @@ # Modify this variable to fit your NEORV32 setup (neorv32 home folder) +OSFLAG := + +ifeq ($(OS),Windows_NT) +NEORV32_HOME ?= ..\..\.. + +include $(NEORV32_HOME)\sw\common\common.mk +else + NEORV32_HOME ?= ../../.. include $(NEORV32_HOME)/sw/common/common.mk +endif \ No newline at end of file diff --git a/sw/example/demo_mtime/makefile b/sw/example/demo_mtime/makefile index 8f9e2fd..fa59946 100644 --- a/sw/example/demo_mtime/makefile +++ b/sw/example/demo_mtime/makefile @@ -1,4 +1,13 @@ # Modify this variable to fit your NEORV32 setup (neorv32 home folder) +OSFLAG := + +ifeq ($(OS),Windows_NT) +NEORV32_HOME ?= ..\..\.. + +include $(NEORV32_HOME)\sw\common\common.mk +else + NEORV32_HOME ?= ../../.. include $(NEORV32_HOME)/sw/common/common.mk +endif \ No newline at end of file diff --git a/sw/example/demo_neopixel/makefile b/sw/example/demo_neopixel/makefile index 8f9e2fd..fa59946 100644 --- a/sw/example/demo_neopixel/makefile +++ b/sw/example/demo_neopixel/makefile @@ -1,4 +1,13 @@ # Modify this variable to fit your NEORV32 setup (neorv32 home folder) +OSFLAG := + +ifeq ($(OS),Windows_NT) +NEORV32_HOME ?= ..\..\.. + +include $(NEORV32_HOME)\sw\common\common.mk +else + NEORV32_HOME ?= ../../.. include $(NEORV32_HOME)/sw/common/common.mk +endif \ No newline at end of file diff --git a/sw/example/demo_newlib/makefile b/sw/example/demo_newlib/makefile index 2f51fef..fa59946 100644 --- a/sw/example/demo_newlib/makefile +++ b/sw/example/demo_newlib/makefile @@ -1,5 +1,13 @@ -# Configure max HEAP size -override USER_FLAGS += "-Wl,--defsym,__neorv32_heap_size=1024" +# Modify this variable to fit your NEORV32 setup (neorv32 home folder) +OSFLAG := + +ifeq ($(OS),Windows_NT) +NEORV32_HOME ?= ..\..\.. + +include $(NEORV32_HOME)\sw\common\common.mk +else NEORV32_HOME ?= ../../.. + include $(NEORV32_HOME)/sw/common/common.mk +endif \ No newline at end of file diff --git a/sw/example/demo_onewire/makefile b/sw/example/demo_onewire/makefile index 8f9e2fd..fa59946 100644 --- a/sw/example/demo_onewire/makefile +++ b/sw/example/demo_onewire/makefile @@ -1,4 +1,13 @@ # Modify this variable to fit your NEORV32 setup (neorv32 home folder) +OSFLAG := + +ifeq ($(OS),Windows_NT) +NEORV32_HOME ?= ..\..\.. + +include $(NEORV32_HOME)\sw\common\common.mk +else + NEORV32_HOME ?= ../../.. include $(NEORV32_HOME)/sw/common/common.mk +endif \ No newline at end of file diff --git a/sw/example/demo_pwm/makefile b/sw/example/demo_pwm/makefile index 8f9e2fd..fa59946 100644 --- a/sw/example/demo_pwm/makefile +++ b/sw/example/demo_pwm/makefile @@ -1,4 +1,13 @@ # Modify this variable to fit your NEORV32 setup (neorv32 home folder) +OSFLAG := + +ifeq ($(OS),Windows_NT) +NEORV32_HOME ?= ..\..\.. + +include $(NEORV32_HOME)\sw\common\common.mk +else + NEORV32_HOME ?= ../../.. include $(NEORV32_HOME)/sw/common/common.mk +endif \ No newline at end of file diff --git a/sw/example/demo_sdi/makefile b/sw/example/demo_sdi/makefile index 8f9e2fd..fa59946 100644 --- a/sw/example/demo_sdi/makefile +++ b/sw/example/demo_sdi/makefile @@ -1,4 +1,13 @@ # Modify this variable to fit your NEORV32 setup (neorv32 home folder) +OSFLAG := + +ifeq ($(OS),Windows_NT) +NEORV32_HOME ?= ..\..\.. + +include $(NEORV32_HOME)\sw\common\common.mk +else + NEORV32_HOME ?= ../../.. include $(NEORV32_HOME)/sw/common/common.mk +endif \ No newline at end of file diff --git a/sw/example/demo_slink/makefile b/sw/example/demo_slink/makefile index 8f9e2fd..fa59946 100644 --- a/sw/example/demo_slink/makefile +++ b/sw/example/demo_slink/makefile @@ -1,4 +1,13 @@ # Modify this variable to fit your NEORV32 setup (neorv32 home folder) +OSFLAG := + +ifeq ($(OS),Windows_NT) +NEORV32_HOME ?= ..\..\.. + +include $(NEORV32_HOME)\sw\common\common.mk +else + NEORV32_HOME ?= ../../.. include $(NEORV32_HOME)/sw/common/common.mk +endif \ No newline at end of file diff --git a/sw/example/demo_spi/makefile b/sw/example/demo_spi/makefile index 8f9e2fd..fa59946 100644 --- a/sw/example/demo_spi/makefile +++ b/sw/example/demo_spi/makefile @@ -1,4 +1,13 @@ # Modify this variable to fit your NEORV32 setup (neorv32 home folder) +OSFLAG := + +ifeq ($(OS),Windows_NT) +NEORV32_HOME ?= ..\..\.. + +include $(NEORV32_HOME)\sw\common\common.mk +else + NEORV32_HOME ?= ../../.. include $(NEORV32_HOME)/sw/common/common.mk +endif \ No newline at end of file diff --git a/sw/example/demo_spi_irq/makefile b/sw/example/demo_spi_irq/makefile index dbb60f0..a63fd85 100644 --- a/sw/example/demo_spi_irq/makefile +++ b/sw/example/demo_spi_irq/makefile @@ -1,7 +1,16 @@ # Modify this variable to fit your NEORV32 setup (neorv32 home folder) -NEORV32_HOME ?= ../../.. +OSFLAG := + +ifeq ($(OS),Windows_NT) +NEORV32_HOME ?= ..\..\.. APP_SRC ?= $(wildcard ./*.c) $(wildcard ./*.s) $(wildcard ./*.cpp) $(wildcard ./*.S) $(wildcard ./drv/*.c) -APP_INC ?= -I . -I ./drv +APP_INC ?= -I . -I .\drv +include $(NEORV32_HOME)\sw\common\common.mk +else +NEORV32_HOME ?= ../../.. +APP_SRC ?= $(wildcard ./*.c) $(wildcard ./*.s) $(wildcard ./*.cpp) $(wildcard ./*.S) $(wildcard ./drv/*.c) +APP_INC ?= -I . -I ./drv include $(NEORV32_HOME)/sw/common/common.mk +endif \ No newline at end of file diff --git a/sw/example/demo_trng/makefile b/sw/example/demo_trng/makefile index 8f9e2fd..fa59946 100644 --- a/sw/example/demo_trng/makefile +++ b/sw/example/demo_trng/makefile @@ -1,4 +1,13 @@ # Modify this variable to fit your NEORV32 setup (neorv32 home folder) +OSFLAG := + +ifeq ($(OS),Windows_NT) +NEORV32_HOME ?= ..\..\.. + +include $(NEORV32_HOME)\sw\common\common.mk +else + NEORV32_HOME ?= ../../.. include $(NEORV32_HOME)/sw/common/common.mk +endif \ No newline at end of file diff --git a/sw/example/demo_twi/makefile b/sw/example/demo_twi/makefile index 8f9e2fd..fa59946 100644 --- a/sw/example/demo_twi/makefile +++ b/sw/example/demo_twi/makefile @@ -1,4 +1,13 @@ # Modify this variable to fit your NEORV32 setup (neorv32 home folder) +OSFLAG := + +ifeq ($(OS),Windows_NT) +NEORV32_HOME ?= ..\..\.. + +include $(NEORV32_HOME)\sw\common\common.mk +else + NEORV32_HOME ?= ../../.. include $(NEORV32_HOME)/sw/common/common.mk +endif \ No newline at end of file diff --git a/sw/example/demo_wdt/makefile b/sw/example/demo_wdt/makefile index 8f9e2fd..fa59946 100644 --- a/sw/example/demo_wdt/makefile +++ b/sw/example/demo_wdt/makefile @@ -1,4 +1,13 @@ # Modify this variable to fit your NEORV32 setup (neorv32 home folder) +OSFLAG := + +ifeq ($(OS),Windows_NT) +NEORV32_HOME ?= ..\..\.. + +include $(NEORV32_HOME)\sw\common\common.mk +else + NEORV32_HOME ?= ../../.. include $(NEORV32_HOME)/sw/common/common.mk +endif \ No newline at end of file diff --git a/sw/example/demo_xip/makefile b/sw/example/demo_xip/makefile index 8f9e2fd..fa59946 100644 --- a/sw/example/demo_xip/makefile +++ b/sw/example/demo_xip/makefile @@ -1,4 +1,13 @@ # Modify this variable to fit your NEORV32 setup (neorv32 home folder) +OSFLAG := + +ifeq ($(OS),Windows_NT) +NEORV32_HOME ?= ..\..\.. + +include $(NEORV32_HOME)\sw\common\common.mk +else + NEORV32_HOME ?= ../../.. include $(NEORV32_HOME)/sw/common/common.mk +endif \ No newline at end of file diff --git a/sw/example/demo_xirq/makefile b/sw/example/demo_xirq/makefile index 8f9e2fd..fa59946 100644 --- a/sw/example/demo_xirq/makefile +++ b/sw/example/demo_xirq/makefile @@ -1,4 +1,13 @@ # Modify this variable to fit your NEORV32 setup (neorv32 home folder) +OSFLAG := + +ifeq ($(OS),Windows_NT) +NEORV32_HOME ?= ..\..\.. + +include $(NEORV32_HOME)\sw\common\common.mk +else + NEORV32_HOME ?= ../../.. include $(NEORV32_HOME)/sw/common/common.mk +endif \ No newline at end of file diff --git a/sw/example/float_corner_test/makefile b/sw/example/float_corner_test/makefile index 8f9e2fd..fa59946 100644 --- a/sw/example/float_corner_test/makefile +++ b/sw/example/float_corner_test/makefile @@ -1,4 +1,13 @@ # Modify this variable to fit your NEORV32 setup (neorv32 home folder) +OSFLAG := + +ifeq ($(OS),Windows_NT) +NEORV32_HOME ?= ..\..\.. + +include $(NEORV32_HOME)\sw\common\common.mk +else + NEORV32_HOME ?= ../../.. include $(NEORV32_HOME)/sw/common/common.mk +endif \ No newline at end of file diff --git a/sw/example/floating_point_test/makefile b/sw/example/floating_point_test/makefile index 8f9e2fd..fa59946 100644 --- a/sw/example/floating_point_test/makefile +++ b/sw/example/floating_point_test/makefile @@ -1,4 +1,13 @@ # Modify this variable to fit your NEORV32 setup (neorv32 home folder) +OSFLAG := + +ifeq ($(OS),Windows_NT) +NEORV32_HOME ?= ..\..\.. + +include $(NEORV32_HOME)\sw\common\common.mk +else + NEORV32_HOME ?= ../../.. include $(NEORV32_HOME)/sw/common/common.mk +endif \ No newline at end of file diff --git a/sw/example/game_of_life/makefile b/sw/example/game_of_life/makefile index 8f9e2fd..fa59946 100644 --- a/sw/example/game_of_life/makefile +++ b/sw/example/game_of_life/makefile @@ -1,4 +1,13 @@ # Modify this variable to fit your NEORV32 setup (neorv32 home folder) +OSFLAG := + +ifeq ($(OS),Windows_NT) +NEORV32_HOME ?= ..\..\.. + +include $(NEORV32_HOME)\sw\common\common.mk +else + NEORV32_HOME ?= ../../.. include $(NEORV32_HOME)/sw/common/common.mk +endif \ No newline at end of file diff --git a/sw/example/hello_cpp/makefile b/sw/example/hello_cpp/makefile index 8f9e2fd..fa59946 100644 --- a/sw/example/hello_cpp/makefile +++ b/sw/example/hello_cpp/makefile @@ -1,4 +1,13 @@ # Modify this variable to fit your NEORV32 setup (neorv32 home folder) +OSFLAG := + +ifeq ($(OS),Windows_NT) +NEORV32_HOME ?= ..\..\.. + +include $(NEORV32_HOME)\sw\common\common.mk +else + NEORV32_HOME ?= ../../.. include $(NEORV32_HOME)/sw/common/common.mk +endif \ No newline at end of file diff --git a/sw/example/hello_world/makefile b/sw/example/hello_world/makefile index 0ba3e70..22604d3 100644 --- a/sw/example/hello_world/makefile +++ b/sw/example/hello_world/makefile @@ -1,7 +1,19 @@ # Modify this variable to fit your NEORV32 setup (neorv32 home folder) -NEORV32_HOME ?= ../../.. +OSFLAG := -include $(NEORV32_HOME)/sw/common/common.mk +ifeq ($(OS),Windows_NT) +NEORV32_HOME ?= ..\..\.. +sim-check: sim + cat $(NEORV32_HOME)\sim\simple\neorv32.uart0.sim_mode.text.out | grep "Hello world! :)" + +include $(NEORV32_HOME)\sw\common\common.mk +else + +NEORV32_HOME ?= ../../.. sim-check: sim cat $(NEORV32_HOME)/sim/simple/neorv32.uart0.sim_mode.text.out | grep "Hello world! :)" + +include $(NEORV32_HOME)/sw/common/common.mk +endif + diff --git a/sw/example/makefile b/sw/example/makefile index 906aa2b..d7215a3 100644 --- a/sw/example/makefile +++ b/sw/example/makefile @@ -1,6 +1,49 @@ #------------------------------------------------------------------------------- # Make defaults and targets #------------------------------------------------------------------------------- + +# Modify this variable to fit your NEORV32 setup (neorv32 home folder) +OSFLAG := + +ifeq ($(OS),Windows_NT) + +.SUFFIXES: +.DEFAULT_GOAL := help + +TOPTARGETS := exe clean_all check info all + +SUBDIRS := $(wildcard */.) +# ignore dummy folders (starting with '~') +DUMMYDIRS := $(wildcard ~*/.) +SUBDIRS := $(filter-out $(DUMMYDIRS), $(SUBDIRS)) + +$(TOPTARGETS): $(SUBDIRS) +$(SUBDIRS): + @$(MAKE) -C $@ $(MAKECMDGOALS) + +.PHONY: $(TOPTARGETS) $(SUBDIRS) + + +#------------------------------------------------------------------------------- +# Help +#------------------------------------------------------------------------------- +help: + @echo "Build / clean up all projects" + @echo "Targets:" + @echo " help - show this text" + @echo " check - check toolchain" + @echo " info - show makefile configuration" + @echo " exe - create executables from all projects" + @echo " all - create executables and boot images from all projects" + @echo " clean_all - clean up everything" + + + + +else + + + .SUFFIXES: .DEFAULT_GOAL := help @@ -31,3 +74,10 @@ help: @echo " exe - create executables from all projects" @echo " all - create executables and boot images from all projects" @echo " clean_all - clean up everything" + + + +endif + + + diff --git a/sw/example/processor_check/makefile b/sw/example/processor_check/makefile index a9234b6..b5dbd9b 100644 --- a/sw/example/processor_check/makefile +++ b/sw/example/processor_check/makefile @@ -1,7 +1,21 @@ -# Modify this variable to fit your NEORV32 setup (neorv32 home folder) -NEORV32_HOME ?= ../../.. -include $(NEORV32_HOME)/sw/common/common.mk +# Modify this variable to fit your NEORV32 setup (neorv32 home folder) +OSFLAG := + +ifeq ($(OS),Windows_NT) +NEORV32_HOME ?= ..\..\.. +sim-check: sim + cat $(NEORV32_HOME)\sim\simple\neorv32.uart0.sim_mode.text.out | grep "PROCESSOR TEST COMPLETED SUCCESSFULLY!" + + +include $(NEORV32_HOME)\sw\common\common.mk +else + +NEORV32_HOME ?= ../../.. sim-check: sim cat $(NEORV32_HOME)/sim/simple/neorv32.uart0.sim_mode.text.out | grep "PROCESSOR TEST COMPLETED SUCCESSFULLY!" + + +include $(NEORV32_HOME)/sw/common/common.mk +endif \ No newline at end of file diff --git a/sw/ocd-firmware/makefile b/sw/ocd-firmware/makefile index bfc65bb..6967882 100644 --- a/sw/ocd-firmware/makefile +++ b/sw/ocd-firmware/makefile @@ -37,6 +37,269 @@ ################################################################################################# + + +# Modify this variable to fit your NEORV32 setup (neorv32 home folder) +OSFLAG := + +ifeq ($(OS),Windows_NT) + + RM_WIN=del + +# Compiler toolchain + RISCV_PREFIX = C:\riscv_precompiled\bin\riscv-none-elf- +# ***************************************************************************** +# USER CONFIGURATION +# ***************************************************************************** +# User's application sources (*.c, *.cpp, *.s, *.S); add additional files here +APP_SRC ?= $(wildcard ./*.S) + +# User's application include folders (don't forget the '-I' before each entry) +APP_INC ?= -I . +# User's application include folders - for assembly files only (don't forget the '-I' before each entry) +ASM_INC ?= -I . + +# Optimization +EFFORT ?= -Os + + + +# CPU architecture and ABI +MARCH = rv32i_zicsr_zifencei +MABI = ilp32 + +# User flags for additional configuration (will be added to compiler flags) +USER_FLAGS ?= + +# Relative or absolute path to the NEORV32 home folder +NEORV32_HOME ?= ..\.. +# ***************************************************************************** + + + +# ----------------------------------------------------------------------------- +# NEORV32 framework +# ----------------------------------------------------------------------------- +# Path to NEORV32 linker script and startup file +NEORV32_COM_PATH = $(NEORV32_HOME)\sw\common +# Path to main NEORV32 library include files +NEORV32_INC_PATH = $(NEORV32_HOME)\sw\lib\include +# Path to main NEORV32 library source files +NEORV32_SRC_PATH = $(NEORV32_HOME)\sw\lib\source +# Path to NEORV32 executable generator +NEORV32_EXG_PATH = $(NEORV32_HOME)\sw\image_gen +# Path to NEORV32 core rtl folder +NEORV32_RTL_PATH = $(NEORV32_HOME)\rtl\core +# Marker file to check for NEORV32 home folder +NEORV32_HOME_MARKER = $(NEORV32_INC_PATH)\neorv32.h + +# Linker script +LD_SCRIPT = .\debug_rom.ld + +# Main output files +APP_ASM = main.asm +APP_IMG = neorv32_debug_mem.code.vhd + + +# ----------------------------------------------------------------------------- +# Sources and objects +# ----------------------------------------------------------------------------- +# Define all sources +SRC = $(APP_SRC) + +# Define all object files +OBJ = $(SRC:%=%.o) + + +# ----------------------------------------------------------------------------- +# Tools and flags +# ----------------------------------------------------------------------------- +# Compiler tools +CC = $(RISCV_PREFIX)gcc +OBJDUMP = $(RISCV_PREFIX)objdump +OBJCOPY = $(RISCV_PREFIX)objcopy +SIZE = $(RISCV_PREFIX)size + +# Host native compiler +CC_X86 = gcc -Wall -O -g + +# NEORV32 executable image generator +IMAGE_GEN = $(NEORV32_EXG_PATH)\image_gen + +# Compiler & linker flags +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 += $(USER_FLAGS) + + +# ----------------------------------------------------------------------------- +# Application output definitions +# ----------------------------------------------------------------------------- +.PHONY: check info help elf_info clean clean_all bootloader +.DEFAULT_GOAL := help + +# 'compile' is still here for compatibility +compile: $(APP_ASM) +install: $(APP_ASM) $(APP_IMG) +all: $(APP_ASM) $(APP_IMG) + +# Check if making bootloader +# Use different base address and legth for instruction memory/"rom" (BOOTMEM instead of IMEM) +# Also define "make_bootloader" for crt0.S +target bootloader: CC_OPTS += -Wl,--defsym=make_bootloader=1 -Dmake_bootloader + + +# ----------------------------------------------------------------------------- +# Image generator targets +# ----------------------------------------------------------------------------- +# install/compile tools +$(IMAGE_GEN): $(NEORV32_EXG_PATH)/image_gen.c + @echo Compiling $(IMAGE_GEN) + @$(CC_X86) $< -o $(IMAGE_GEN) + + +# ----------------------------------------------------------------------------- +# General targets: Assemble, compile, link, dump +# ----------------------------------------------------------------------------- +# Compile app *.s sources (assembly) +%.s.o: %.s + @$(CC) -c $(CC_OPTS) -I $(NEORV32_INC_PATH) $(ASM_INC) $< -o $@ + +# Compile app *.S sources (assembly + C pre-processor) +%.S.o: %.S + @$(CC) -c $(CC_OPTS) -I $(NEORV32_INC_PATH) $(ASM_INC) $< -o $@ + +# Compile app *.c sources +%.c.o: %.c + @$(CC) -c $(CC_OPTS) -I $(NEORV32_INC_PATH) $(APP_INC) $< -o $@ + +# Compile app *.cpp sources +%.cpp.o: %.cpp + @$(CC) -c $(CC_OPTS) -I $(NEORV32_INC_PATH) $(APP_INC) $< -o $@ + +# Link object files and show memory utilization +main.elf: $(OBJ) + @$(CC) $(CC_OPTS) -T $(LD_SCRIPT) $(OBJ) -o $@ -lm + @echo "Memory utilization:" + @$(SIZE) main.elf + +# Assembly listing file (for debugging) +$(APP_ASM): main.elf + @$(OBJDUMP) -d -S -z $< > $@ + +# Generate final executable from .text only +main.bin: main.elf $(APP_ASM) + @$(OBJCOPY) -I elf32-little $< -j .text -O binary text.bin + @cat text.bin > $@ + @rm -f text.bin + + +# ----------------------------------------------------------------------------- +# Application targets: install (as VHDL file) +# ----------------------------------------------------------------------------- + +# Generate NEORV32 executable VHDL boot image +$(APP_IMG): main.bin $(IMAGE_GEN) + @$(IMAGE_GEN) -app_img $< $@ $(shell basename $(CURDIR)) + + +# ----------------------------------------------------------------------------- +# Check toolchain +# ----------------------------------------------------------------------------- +check: $(IMAGE_GEN) + @echo "---------------- Check: NEORV32_HOME folder ----------------" + @echo "NEORV32_HOME: $(NEORV32_HOME)" + @echo "---------------- Check: $(CC) ----------------" + @$(CC) -v + @echo "---------------- Check: $(OBJDUMP) ----------------" + @$(OBJDUMP) -V + @echo "---------------- Check: $(OBJCOPY) ----------------" + @$(OBJCOPY) -V + @echo "---------------- Check: $(SIZE) ----------------" + @$(SIZE) -V + @echo "---------------- Check: NEORV32 image_gen ----------------" + @$(IMAGE_GEN) -help + @echo "---------------- Check: Native GCC ----------------" + @$(CC_X86) -v + @echo + @echo "Toolchain check OK" + + +# ----------------------------------------------------------------------------- +# Show configuration +# ----------------------------------------------------------------------------- +info: + @echo "---------------- Info: Project ----------------" + @echo "Project folder: $(shell basename $(CURDIR))" + @echo "Source files: $(APP_SRC)" + @echo "Include folder(s): $(APP_INC)" + @echo "ASM include folder(s): $(ASM_INC)" + @echo "---------------- Info: NEORV32 ----------------" + @echo "NEORV32 home folder (NEORV32_HOME): $(NEORV32_HOME)" + @echo "IMAGE_GEN: $(IMAGE_GEN)" + @echo "Core source files:" + @echo "$(CORE_SRC)" + @echo "Core include folder:" + @echo "$(NEORV32_INC_PATH)" + @echo "---------------- Info: Objects ----------------" + @echo "Project object files:" + @echo "$(OBJ)" + @echo "---------------- Info: RISC-V CPU ----------------" + @echo "MARCH: $(MARCH)" + @echo "MABI: $(MABI)" + @echo "---------------- Info: Toolchain ----------------" + @echo "Toolchain: $(RISCV_TOLLCHAIN)" + @echo "CC: $(CC)" + @echo "OBJDUMP: $(OBJDUMP)" + @echo "OBJCOPY: $(OBJCOPY)" + @echo "SIZE: $(SIZE)" + @echo "---------------- Info: Compiler Libraries ----------------" + @echo "LIBGCC:" + @$(CC) -print-libgcc-file-name + @echo "SEARCH-DIRS:" + @$(CC) -print-search-dirs + @echo "---------------- Info: Flags ----------------" + @echo "USER_FLAGS: $(USER_FLAGS)" + @echo "CC_OPTS: $(CC_OPTS)" + @echo "---------------- Info: Host Native GCC Flags ----------------" + @echo "CC_X86: $(CC_X86)" + + +# ----------------------------------------------------------------------------- +# Show final ELF details (just for debugging) +# ----------------------------------------------------------------------------- +elf_info: main.elf + @$(OBJDUMP) -x main.elf + + +# ----------------------------------------------------------------------------- +# Help +# ----------------------------------------------------------------------------- +help: + @echo "<<< NEORV32 Application Makefile >>>" + @echo "Make sure to add the bin folder of RISC-V GCC to your PATH variable." + @echo "Targets:" + @echo " help - show this text" + @echo " check - check toolchain" + @echo " info - show makefile/toolchain configuration" + @echo " exe - compile and generate executable for upload via bootloader" + @echo " all - compile and generate executable for upload via bootloader and generate and install VHDL IMEM boot image (for application)" + @echo " clean - clean up project" + @echo " clean_all - clean up project, core libraries and image generator" + + +# ----------------------------------------------------------------------------- +# Clean up +# ----------------------------------------------------------------------------- +clean: + @$(RM_WIN) *.elf *.o *.bin *.out *.asm *.vhd *.hex .gdb_history + +clean_all: clean + @$(RM_WIN) $(IMAGE_GEN) + + +else + # ***************************************************************************** # USER CONFIGURATION # ***************************************************************************** @@ -290,3 +553,6 @@ clean: clean_all: clean @rm -f $(OBJ) $(IMAGE_GEN) + +endif +