-
Notifications
You must be signed in to change notification settings - Fork 723
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[sw] Makefile refactor - added centrallized Makefile infra for maximizing reuse across SW test, lib and boot_rom targets - existing Make flows still remain (for the timebeing; will remove it once all approve of this) - all make commands are to be run from sw/ area - updated with chip_info generation - TODOs - add some documentation - need to fix support for external apps, eg coremark [dv,sw] coremark port now works - updates to get external app (coremark) compiling with the refactored flow - added ability to compile targets with external Makefiles with STANDALONE_SW var - added sw/benchmarks/srcs.mk to supply STANDALONE_CMD to build custom app [dv,sw] removed existing Makefiles (deprecated)
- Loading branch information
Showing
26 changed files
with
439 additions
and
250 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
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,34 @@ | ||
# Copyright lowRISC contributors. | ||
# Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
#################################################################################################### | ||
## Generate a baremetal application for the microcontroller ## | ||
## Mandatory variables that need to be set over the command line: ## | ||
## SW_DIR: this is the partial directory path to the SW test being built starting from sw/ ## | ||
## ex: if running hello_world.c, then SW_DIR=examples/hello_world ## | ||
## At this location, there needs to be a 'srcs.mk' file that contains the list of ## | ||
## SW_SRCS to be built for that SW test. ## | ||
## SW_NAME: This is the name of the SW test begin run. Optional if SW_DIR name (last dir) is ## | ||
## the same as the SW test name. ## | ||
## ## | ||
## Optional variables: ## | ||
## SW_BUILD_DIR: This is the output location for generating all sources ## | ||
## SW_FLAGS Global args to pass on to the compiler ## | ||
## SW_OPTS Global args to pass on to the sub-make commands ## | ||
#################################################################################################### | ||
|
||
|
||
# Generate a baremetal application for the microcontroller | ||
SW_ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) | ||
SW_DIR ?= examples/hello_world | ||
|
||
# sources | ||
STANDALONE_SW ?= 0 | ||
include ${SW_DIR}/srcs.mk | ||
include exts/common/srcs.mk | ||
include lib/srcs.mk | ||
|
||
# common options and rules | ||
include opts.mk | ||
include rules.mk |
This file was deleted.
Oops, something went wrong.
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,13 @@ | ||
# Copyright lowRISC contributors. | ||
# Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
COREMARK_DIR = $(SW_ROOT_DIR)/vendor/$(SW_NAME) | ||
COREMARK_PORT = $(SW_ROOT_DIR)/$(SW_DIR)/top_earlgrey | ||
STANDALONE_SW := 1 | ||
STANDALONE_CMD = $(MAKE) $(IMG_OUTPUTS) -C $(COREMARK_DIR) \ | ||
PORT_DIR=$(COREMARK_PORT) \ | ||
SW_DIR=$(SW_DIR) \ | ||
SW_ROOT_DIR=$(SW_ROOT_DIR) \ | ||
SW_BUILD_DIR=$(SW_BUILD_DIR) \ | ||
MAKEFLAGS=$(MAKEFLAGS) |
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 |
---|---|---|
@@ -1,82 +1,90 @@ | ||
#File : core_portme.mak | ||
|
||
NAME = coremark | ||
PORTME_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) | ||
PROGRAM_DIR := $(PORTME_DIR)/../ | ||
include ${SW_ROOT_DIR}/opts.mk | ||
|
||
include ${PROGRAM_DIR}/../../exts/common/options.mk | ||
PORT_CLEAN := $(OUTFILES) | ||
PORT_CLEAN := $(IMG_OUTPUTS) | ||
|
||
# FLAG : EXE, OEXT | ||
# Extensions of generated outputs | ||
OEXT = .o | ||
EXE = .elf | ||
|
||
# FLAG : OPATH | ||
# Path to the output folder. Default - current folder. | ||
OPATH = $(SW_BUILD_DIR)/ | ||
|
||
# Flag : OUTFLAG | ||
# Use this flag to define how to to get an executable (e.g -o) | ||
OUTFLAG= -T $(LINKER_SCRIPT) -L$(LIB_DIR) -l$(LIB_NAME) -Xlinker -Map=coremark.map -o | ||
# Flag : CC | ||
# Use this flag to define compiler to use | ||
CC = $(RV_TOOLS)/riscv32-unknown-elf-gcc | ||
# Flag : LD | ||
# Use this flag to define compiler to use | ||
LD = $(RV_TOOLS)/riscv32-unknown-elf-ld | ||
# Flag : AS | ||
# Use this flag to define compiler to use | ||
AS = $(RV_TOOLS)/riscv32-unknown-elf-as | ||
# Use this flag to define how to to get an executable (e.g -o) | ||
OUTFLAG = $(LINK_OPTS) -o | ||
|
||
# Flag : CFLAGS | ||
# Use this flag to define compiler options. Note, you can add compiler options from the command line using XCFLAGS="other flags" | ||
PORT_CFLAGS = -DTOTAL_DATA_SIZE=6000 -DMAIN_HAS_NOARGC=1 | ||
FLAGS_STR = "$(PORT_CFLAGS) $(XCFLAGS) $(XLFLAGS) $(LFLAGS_END)" | ||
CFLAGS += $(PORT_CFLAGS) $(XCFLAGS) -I$(PORT_DIR) -I. -I$(LIB_DIR) | ||
#Flag : LFLAGS_END | ||
# Define any libraries needed for linking or other flags that should come at the end of the link line (e.g. linker scripts). | ||
# Note : On certain platforms, the default clock_gettime implementation is supported but requires linking of librt. | ||
#SEPARATE_COMPILE=1 | ||
# Use this flag to define compiler options. Note, you can add compiler options | ||
# from the command line using XCFLAGS="other flags" | ||
PORT_CFLAGS = -DTOTAL_DATA_SIZE=6000 -DMAIN_HAS_NOARGC=1 | ||
FLAGS_STR = "$(PORT_CFLAGS) $(XCFLAGS) $(XLFLAGS) $(LFLAGS_END)" | ||
CFLAGS += $(PORT_CFLAGS) $(XCFLAGS) -I$(PORT_DIR) -I. $(INCS) | ||
|
||
# Flag : LFLAGS_END | ||
# Define any libraries needed for linking or other flags that should come | ||
# at the end of the link line (e.g. linker scripts). | ||
# Note : On certain platforms, the default clock_gettime implementation | ||
# is supported but requires linking of librt. | ||
LFLAGS_END = | ||
|
||
# Flag : SEPARATE_COMPILE | ||
# Do compile and link steps separately. Not needed at this point. | ||
|
||
# You must also define below how to create an object file, and how to link. | ||
OBJOUT = -o | ||
LFLAGS = | ||
OBJOUT = -o | ||
LFLAGS = | ||
ASFLAGS = | ||
OFLAG = -o | ||
COUT = -c | ||
OFLAG = -o | ||
COUT = -c | ||
|
||
LFLAGS_END = | ||
# Flag : PORT_SRCS | ||
# Port specific source files can be added here | ||
# You may also need cvt.c if the fcvt functions are not provided as intrinsics by your compiler! | ||
# Port specific source files can be added here | ||
# You may also need cvt.c if the fcvt functions are not provided as intrinsics by your compiler! | ||
PORT_SRCS = $(PORT_DIR)/core_portme.c $(PORT_DIR)/ee_printf.c $(EXT_SRCS) | ||
vpath %.c $(PORT_DIR) | ||
vpath %.s $(PORT_DIR) | ||
|
||
# Flag : LOAD | ||
# For a simple port, we assume self hosted compile and run, no load needed. | ||
# For a simple port, we assume self hosted compile and run, no load needed. | ||
|
||
# Flag : RUN | ||
# For a simple port, we assume self hosted compile and run, simple invocation of the executable | ||
# For a simple port, we assume self hosted compile and run, simple invocation of the executable | ||
|
||
# Flag : MKDIR | ||
MKDIR = mkdir -p | ||
|
||
LOAD = echo "Please set LOAD to the process of loading the executable to the flash" | ||
RUN = echo "Please set LOAD to the process of running the executable (e.g. via jtag, or board reset)" | ||
|
||
OEXT = .o | ||
EXE = .elf | ||
|
||
$(OPATH)$(PORT_DIR)/%$(OEXT) : %.c | ||
$(OPATH)%$(OEXT) : %.c | ||
$(CC) $(CFLAGS) $(XCFLAGS) $(COUT) $< $(OBJOUT) $@ | ||
|
||
$(OPATH)%$(OEXT) : %.c | ||
$(OPATH)%$(OEXT) : %.s | ||
$(AS) $(ASFLAGS) $< $(OBJOUT) $@ | ||
|
||
$(OPATH)%$(OEXT) : $(PORT_DIR)/%.c | ||
$(CC) $(CFLAGS) $(XCFLAGS) $(COUT) $< $(OBJOUT) $@ | ||
|
||
$(OPATH)$(PORT_DIR)/%$(OEXT) : %.s | ||
$(OPATH)%$(OEXT) : $(PORT_DIR)/%.s | ||
$(AS) $(ASFLAGS) $< $(OBJOUT) $@ | ||
|
||
# Target : port_pre% and port_post% | ||
# For the purpose of this simple port, no pre or post steps needed. | ||
%.vmem: %.bin | ||
srec_cat $^ -binary -offset 0x0 -byte-swap 4 -o $@ -vmem | ||
|
||
.PHONY : port_clean port_prebuild port_postbuild port_prerun port_postrun port_preload port_postload | ||
%.bin: %.elf | ||
$(OBJCOPY) -O binary $^ $@ | ||
|
||
port_postbuild: | ||
$(RV_TOOLS)/riscv32-unknown-elf-objcopy -O binary coremark.elf coremark.bin | ||
srec_cat coremark.bin -binary -offset 0x0 -byte-swap 4 -o coremark.vmem -vmem | ||
$(RV_TOOLS)/riscv32-unknown-elf-objdump -SD coremark.elf > coremark.dis | ||
%.dis: %.elf | ||
$(OBJDUMP) -SD $^ > $@ | ||
|
||
# FLAG : OPATH | ||
# Path to the output folder. Default - current folder. | ||
OPATH = ./ | ||
MKDIR = mkdir -p | ||
$(SW_BUILD_DIR)/$(IMG_NAME).elf: $(OUTFILE) | ||
$(MAKE) $(OUTFILE) | ||
mv $(OUTFILE) $@ | ||
|
||
# Target : port_pre% and port_post% | ||
|
||
.PHONY : port_clean port_prebuild port_postbuild port_prerun port_postrun port_preload port_postload |
Oops, something went wrong.