diff --git a/docs/datasheet/software.adoc b/docs/datasheet/software.adoc index db5fec289..a20c3d176 100644 --- a/docs/datasheet/software.adoc +++ b/docs/datasheet/software.adoc @@ -255,6 +255,10 @@ GDB_ARGS ?= -ex "target extended-remote localhost:3333" The following default compiler flags are used for compiling an application. These flags are defined via the `CC_OPTS` variable. +[TIP] +The makefile's `CC_OPTS` is exported as **define** to be available within a C program; for example +`neorv32_uart0_printf("%s\n", CC_OPTS);`. + [cols="<3,<9"] [grid="none"] |======================= @@ -268,7 +272,7 @@ The following default compiler flags are used for compiling an application. Thes | `-mno-fdiv` | Use built-in software functions for floating-point divisions and square roots (since the according instructions are not supported yet). | `-g` | Include debugging information/symbols in ELF. | `-mstrict-align` | Unaligned memory accesses cannot be resolved by the hardware and require emulation. -| `-mbranch-cost=...` | Branches cost a lot cycles on a multi-cycle architecture. +| `-mbranch-cost=10` | Branching costs a lot of cycles. |======================= :sectnums: @@ -341,7 +345,7 @@ __neorv32_ram_base = DEFINED(__neorv32_ram_base) ? __neorv32_ram_base : 0x800000 The region size and base address configuration can be edited by the user - either by explicitly changing the default values in the linker script or by overriding them when invoking `make`: - + .Overriding default `rom` size configuration (configuring 4096 bytes) [source, bash] ---- diff --git a/sw/common/common.mk b/sw/common/common.mk index f9621ea2b..03c0c2a1d 100644 --- a/sw/common/common.mk +++ b/sw/common/common.mk @@ -3,7 +3,8 @@ # ********************************************************************************************* # # BSD 3-Clause License # # # -# Copyright (c) 2023, Stephan Nolting. All rights reserved. # +# The NEORV32 RISC-V Processor, https://github.com/stnolting/neorv32 # +# Copyright (c) 2024, Stephan Nolting. All rights reserved. # # # # Redistribution and use in source and binary forms, with or without modification, are # # permitted provided that the following conditions are met: # @@ -28,8 +29,6 @@ # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING # # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED # # OF THE POSSIBILITY OF SUCH DAMAGE. # -# ********************************************************************************************* # -# The NEORV32 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting # ################################################################################################# @@ -125,8 +124,8 @@ OBJCOPY = $(RISCV_PREFIX)objcopy SIZE = $(RISCV_PREFIX)size GDB = $(RISCV_PREFIX)gdb -# Host native compiler -CC_X86 = gcc -Wall -O -g +# Host's native compiler +CC_HOST = gcc -Wall -O -g # NEORV32 executable image generator IMAGE_GEN = $(NEORV32_EXG_PATH)/image_gen @@ -138,6 +137,12 @@ CC_OPTS += $(USER_FLAGS) LD_LIBS = -lm -lc -lgcc LD_LIBS += $(USER_LIBS) +# Actual flags passed to the compiler +CC_FLAGS = $(CC_OPTS) + +# Export compiler flags as define string +CC_FLAGS += -DCC_OPTS="\"$(CC_OPTS)\"" + # ----------------------------------------------------------------------------- # Application output definitions @@ -169,7 +174,7 @@ target bl_image: CC_OPTS += -Wl,--defsym=make_bootloader=1 -Dmake_bootloader - # install/compile tools $(IMAGE_GEN): $(NEORV32_EXG_PATH)/image_gen.c @echo Compiling $(IMAGE_GEN) - @$(CC_X86) $< -o $(IMAGE_GEN) + @$(CC_HOST) $< -o $(IMAGE_GEN) # ----------------------------------------------------------------------------- @@ -177,23 +182,23 @@ $(IMAGE_GEN): $(NEORV32_EXG_PATH)/image_gen.c # ----------------------------------------------------------------------------- # Compile app *.s sources (assembly) %.s.o: %.s - @$(CC) -c $(CC_OPTS) -I $(NEORV32_INC_PATH) $(ASM_INC) $< -o $@ + @$(CC) -c $(CC_FLAGS) -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 $@ + @$(CC) -c $(CC_FLAGS) -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 $@ + @$(CC) -c $(CC_FLAGS) -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 $@ + @$(CC) -c $(CC_FLAGS) -I $(NEORV32_INC_PATH) $(APP_INC) $< -o $@ # Link object files and show memory utilization $(APP_ELF): $(OBJ) - @$(CC) $(CC_OPTS) -T $(LD_SCRIPT) $(OBJ) $(LD_LIBS) -o $@ + @$(CC) $(CC_FLAGS) -T $(LD_SCRIPT) $(OBJ) $(LD_LIBS) -o $@ @echo "Memory utilization:" @$(SIZE) $(APP_ELF) @@ -282,8 +287,8 @@ endif @$(SIZE) -V @echo "---------------- Check: NEORV32 image_gen ----------------" @$(IMAGE_GEN) -help - @echo "---------------- Check: Native GCC ----------------" - @$(CC_X86) -v + @echo "---------------- Check: Host's native GCC ----------------" + @$(CC_HOST) -v @echo @echo "Toolchain check OK" diff --git a/sw/example/coremark/core_portme.h b/sw/example/coremark/core_portme.h index 648efd95b..8dd342652 100644 --- a/sw/example/coremark/core_portme.h +++ b/sw/example/coremark/core_portme.h @@ -33,7 +33,7 @@ Original Author: Shay Gal-on /************************/ #define BAUD_RATE (19200) #define ITERATIONS (2000) -#define FLAGS_STR "see makefile" +#define FLAGS_STR CC_OPTS /************************/ /* Data types and settings */