From ab6bf790f96181585b4e2e6a2d4bf35396f7fa66 Mon Sep 17 00:00:00 2001 From: Brad Campbell Date: Fri, 2 Sep 2022 12:17:49 -0400 Subject: [PATCH 1/3] make: add base cortex-m toolchain variable --- Configuration.mk | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Configuration.mk b/Configuration.mk index 8d6a09f57..b0dc0e264 100644 --- a/Configuration.mk +++ b/Configuration.mk @@ -314,10 +314,11 @@ override LEGACY_LIBS_rv32imac += \ # Setup the correct toolchain for each architecture. ARM has a standard # toolchain we can use for every variant. -TOOLCHAIN_cortex-m0 := arm-none-eabi -TOOLCHAIN_cortex-m3 := arm-none-eabi -TOOLCHAIN_cortex-m4 := arm-none-eabi -TOOLCHAIN_cortex-m7 := arm-none-eabi +TOOLCHAIN_cortex-m := arm-none-eabi +TOOLCHAIN_cortex-m0 := $(TOOLCHAIN_cortex-m) +TOOLCHAIN_cortex-m3 := $(TOOLCHAIN_cortex-m) +TOOLCHAIN_cortex-m4 := $(TOOLCHAIN_cortex-m) +TOOLCHAIN_cortex-m7 := $(TOOLCHAIN_cortex-m) # Setup the correct compiler. For cortex-m we only support GCC as it is the only # toolchain with the PIC support we need for Tock userspace apps. From 556b0033c12e0e9e11a9cebb57701f5b2e8fb424 Mon Sep 17 00:00:00 2001 From: Brad Campbell Date: Fri, 2 Sep 2022 12:19:20 -0400 Subject: [PATCH 2/3] change size to family size --- AppMakefile.mk | 29 ++++++++++++++++++++++++++++- Configuration.mk | 2 ++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/AppMakefile.mk b/AppMakefile.mk index 993e2e153..0a40a6ea0 100644 --- a/AppMakefile.mk +++ b/AppMakefile.mk @@ -266,6 +266,31 @@ $$(BUILDDIR)/$(1)/$(2).userland_debug.lst: $$(BUILDDIR)/$(1)/$(2).userland_debug ############################################################################################ endef + +# Rules that apply to an entire architecture family (e.g. cortex-m). +# +# - Argument $(1) is the architecture family (e.g. cortex-m). +# - Argument $(2) is the list of architectures in that family. +# - Argument $(3) is the list of output names for the .elf of each arch. +# +# Note: all variables, other than $(1), used within this block must be double +# dollar-signed so that their values will be evaluated when run, not when +# generated. +define ARCH_FAMILY_RULES + +$(1)_DIRECTORY_NAMES := $$(addsuffix /,$(2)) +$(1)_DIRECTORY_FILES := $$(join $$($(1)_DIRECTORY_NAMES),$(3)) +$(1)_DIRECTORY_FILES_EXT := $$(addsuffix .elf,$$($(1)_DIRECTORY_FILES)) +$(1)_ELF_FILES := $$(addprefix $$(BUILDDIR)/,$$($(1)_DIRECTORY_FILES_EXT)) + +# Rule to print the size of the built binaries from an architecture family. +.PHONY: size-$(1) +size-$(1): $$($(1)_ELF_FILES) + @echo Application size report for arch family $(1): + $$(Q)$$(TOOLCHAIN_$(1))$$(SIZE) -t $$^ + +endef + # Functions to parse the `TOCK_TARGETS` array. Entries 3 and 4 default to the # PIC addresses if they are not specified. ARCH_FN = $(firstword $(subst |, ,$1)) @@ -279,6 +304,7 @@ RAM_ADDRESS_FN = $(if $(word 4,$(subst |, ,$1)),$(word 4,$(subst |, ,$1)),0x0000 # Actually generate the rules for each architecture $(foreach platform, $(TOCK_ARCHS), $(eval $(call BUILD_RULES_PER_ARCH,$(platform)))) $(foreach platform, $(TOCK_TARGETS), $(eval $(call BUILD_RULES,$(call ARCH_FN,$(platform)),$(call OUTPUT_NAME_FN,$(platform)),$(call FLASH_ADDRESS_FN,$(platform)),$(call RAM_ADDRESS_FN,$(platform))))) +$(foreach family, $(TOCK_ARCH_FAMILIES), $(eval $(call ARCH_FAMILY_RULES,$(family),$(foreach target, $(filter $(family)%,$(TOCK_TARGETS)), $(call ARCH_FN, $(target))),$(foreach target, $(filter $(family)%,$(TOCK_TARGETS)), $(call OUTPUT_NAME_FN, $(target)))))) @@ -290,8 +316,9 @@ $(BUILDDIR)/$(PACKAGE_NAME).tab: $(foreach platform, $(TOCK_TARGETS), $(BUILDDIR # Rules for building apps +SIZE_RULES = $(addprefix size-,$(TOCK_ARCH_FAMILIES)) .PHONY: all -all: $(BUILDDIR)/$(PACKAGE_NAME).tab size +all: $(BUILDDIR)/$(PACKAGE_NAME).tab $(SIZE_RULES) # The size target accumulates dependencies in the platform build rule creation .PHONY: size diff --git a/Configuration.mk b/Configuration.mk index b0dc0e264..bd54420e5 100644 --- a/Configuration.mk +++ b/Configuration.mk @@ -66,6 +66,7 @@ PACKAGE_NAME ?= $(shell basename "$(shell pwd)") # targets build by default as well. ifeq ($(RISCV),) TOCK_TARGETS ?= cortex-m0 cortex-m3 cortex-m4 cortex-m7 +TOCK_ARCH_FAMILIES ?= cortex-m else # Specific addresses useful for the OpenTitan hardware memory map. OPENTITAN_TOCK_TARGETS := rv32imc|rv32imc.0x20030080.0x10005000|0x20030080|0x10005000\ @@ -92,6 +93,7 @@ TOCK_TARGETS ?= cortex-m0\ rv32imc|rv32imc.0x00080060.0x40008000|0x00080060|0x40008000\ $(OPENTITAN_TOCK_TARGETS) \ $(ARTY_E21_TOCK_TARGETS) +TOCK_ARCH_FAMILIES ?= cortex-m rv32i endif # Generate `TOCK_ARCHS`, the set of architectures listed in `TOCK_TARGETS`. From 37d9445080536a1ac4b60d0ceee388136c2a46f9 Mon Sep 17 00:00:00 2001 From: Brad Campbell Date: Fri, 2 Sep 2022 14:49:43 -0400 Subject: [PATCH 3/3] lua only builds for cortex-m --- examples/lua-hello/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/lua-hello/Makefile b/examples/lua-hello/Makefile index f2dafae3c..278514e1d 100644 --- a/examples/lua-hello/Makefile +++ b/examples/lua-hello/Makefile @@ -6,6 +6,7 @@ TOCK_USERLAND_BASE_DIR = ../.. # We only compile this for Cortex-M platforms because of compiler # errors when building lua on risc-v. TOCK_TARGETS := cortex-m0 cortex-m3 cortex-m4 cortex-m7 +TOCK_ARCH_FAMILIES := cortex-m # Which files to compile. C_SRCS := $(wildcard *.c)