Skip to content

Commit

Permalink
Build system: Fixes #2: Add multi-platform support
Browse files Browse the repository at this point in the history
Move all explicit platform or architecture specific references
into a new platform.mk file that is defined for each platform.

Change-Id: I9d6320d1ba957e0cc8d9b316b3578132331fa428
Signed-off-by: Ryan Harkin <ryan.harkin@linaro.org>
  • Loading branch information
Ryan Harkin authored and danh-arm committed Jan 20, 2014
1 parent 5443f2b commit 25cff83
Show file tree
Hide file tree
Showing 8 changed files with 206 additions and 84 deletions.
106 changes: 66 additions & 40 deletions Makefile
Expand Up @@ -51,50 +51,68 @@ else
endif

BL_COMMON_OBJS := misc_helpers.o cache_helpers.o tlb_helpers.o \
semihosting_call.o mmio.o pl011.o semihosting.o \
std.o bl_common.o platform_helpers.o sysreg_helpers.o

ARCH := aarch64
PLAT := fvp

BUILD_BASE:=./build
BUILD:=${BUILD_BASE}/${PLAT}/${BUILD_TYPE}
BUILD_BL1:=${BUILD}/bl1
BUILD_BL2:=${BUILD}/bl2
BUILD_BL31:=${BUILD}/bl31
BUILD_DIRS:=${BUILD_BL1} ${BUILD_BL2} ${BUILD_BL31}

all: bl1 bl2 bl31

$(info Including bl1.mk)
include bl1/bl1.mk
std.o bl_common.o platform_helpers.o
ARCH ?= aarch64

# By default, build all platforms available
PLAT ?= all

BUILD_BASE := ./build
BUILD_PLAT := ${BUILD_BASE}/${PLAT}/${BUILD_TYPE}
BUILD_BL1 := ${BUILD_PLAT}/bl1
BUILD_BL2 := ${BUILD_PLAT}/bl2
BUILD_BL31 := ${BUILD_PLAT}/bl31
BUILD_DIRS := ${BUILD_BL1} ${BUILD_BL2} ${BUILD_BL31}

PLATFORMS := $(shell ls -I common plat/)
ifeq (${PLAT},)
$(error "Error: Unknown platform. Please use PLAT=<platform name> to specify the platform.")
endif
ifeq ($(findstring ${PLAT},${PLATFORMS} all),)
$(error "Error: Invalid platform. The following platforms are available: ${PLATFORMS}")
endif

$(info Including bl2.mk)
include bl2/bl2.mk
ifeq (${PLAT},all)
all: ${PLATFORMS}
else
all: msg_start bl1 bl2 bl31
endif

$(info Including bl31.mk)
include bl31/bl31.mk
msg_start:
@echo "Building ${PLAT}"

${PLATFORMS}:
${MAKE} PLAT=$@ all

ifneq (${PLAT},all)
$(info Including ${PLAT}/platform.mk)
include plat/${PLAT}/platform.mk
$(info Including bl1.mk)
include bl1/bl1.mk
$(info Including bl2.mk)
include bl2/bl2.mk
$(info Including bl31.mk)
include bl31/bl31.mk
endif

.PHONY: dump clean realclean distclean bl1 bl2 bl31
.PHONY: all msg_start ${PLATFORMS} dump clean realclean distclean bl1 bl2 bl31
.SUFFIXES:


BL1_OBJS := $(addprefix ${BUILD_BL1}/,${BL1_OBJS} ${BL_COMMON_OBJS})
BL2_OBJS := $(addprefix ${BUILD_BL2}/,${BL2_OBJS} ${BL_COMMON_OBJS})
BL31_OBJS := $(addprefix ${BUILD_BL31}/,${BL31_OBJS} ${BL_COMMON_OBJS})
BL1_OBJS := $(addprefix ${BUILD_BL1}/,${BL1_OBJS} ${BL_COMMON_OBJS} ${PLAT_BL_COMMON_OBJS})
BL2_OBJS := $(addprefix ${BUILD_BL2}/,${BL2_OBJS} ${BL_COMMON_OBJS} ${PLAT_BL_COMMON_OBJS})
BL31_OBJS := $(addprefix ${BUILD_BL31}/,${BL31_OBJS} ${BL_COMMON_OBJS} ${PLAT_BL_COMMON_OBJS})
BL1_MAPFILE := $(addprefix ${BUILD_BL1}/,${BL1_MAPFILE})
BL2_MAPFILE := $(addprefix ${BUILD_BL2}/,${BL2_MAPFILE})
BL31_MAPFILE := $(addprefix ${BUILD_BL31}/,${BL31_MAPFILE})
BL1_LINKERFILE := $(addprefix ${BUILD_BL1}/,${BL1_LINKERFILE})
BL2_LINKERFILE := $(addprefix ${BUILD_BL2}/,${BL2_LINKERFILE})
BL31_LINKERFILE := $(addprefix ${BUILD_BL31}/,${BL31_LINKERFILE})

INCLUDES += -Ilib/include/ -Iinclude/aarch64/ -Iinclude/ \
-Idrivers/arm/interconnect/cci-400/ \
-Idrivers/arm/peripherals/pl011/ \
-Iplat/fvp -Idrivers/power \
INCLUDES += -Ilib/include/ -Iinclude/${ARCH}/ -Iinclude/ \
-Iarch/system/gic -Icommon/psci \
-Iinclude/stdlib -Iinclude/stdlib/sys
-Iinclude/stdlib -Iinclude/stdlib/sys \
-Iplat/${PLAT} ${PLAT_INCLUDES}

ASFLAGS += -nostdinc -ffreestanding -Wa,--fatal-warnings \
-mgeneral-regs-only -D__ASSEMBLY__ ${INCLUDES}
Expand Down Expand Up @@ -133,13 +151,18 @@ NM := ${CROSS_COMPILE}nm
PP := ${CROSS_COMPILE}gcc -E ${CFLAGS}


bl1: ${BUILD_BL1} ${BUILD}/bl1.bin
bl2: ${BUILD_BL2} ${BUILD}/bl2.bin
bl31: ${BUILD_BL31} ${BUILD}/bl31.bin
bl1: ${BUILD_BL1} ${BUILD_PLAT}/bl1.bin
bl2: ${BUILD_BL2} ${BUILD_PLAT}/bl2.bin
bl31: ${BUILD_BL31} ${BUILD_PLAT}/bl31.bin

ifeq (${PLAT},all)
ifeq (${MAKECMDGOALS},clean)
$(error "Please select a platform with PLAT=<platform>. You can use 'make distclean' to clean up all platform builds")
endif
endif
clean:
@echo " CLEAN"
${Q}rm -rf ${BUILD}
${Q}rm -rf ${BUILD_PLAT}

realclean distclean:
@echo " REALCLEAN"
Expand Down Expand Up @@ -180,15 +203,15 @@ ${BUILD_BL31}/%.o: %.c
${Q}${CC} ${CFLAGS} -c $< -o $@

${BUILD_BL1}/%.ld: %.ld.S
@echo " LDS $<"
@echo " PP $<"
${Q}${AS} ${ASFLAGS} -P -E $< -o $@

${BUILD_BL2}/%.ld: %.ld.S
@echo " LDS $<"
@echo " PP $<"
${Q}${AS} ${ASFLAGS} -P -E $< -o $@

${BUILD_BL31}/%.ld: %.ld.S
@echo " LDS $<"
@echo " PP $<"
${Q}${AS} ${ASFLAGS} -P -E $< -o $@


Expand All @@ -204,19 +227,22 @@ ${BUILD_BL31}/bl31.elf: ${BL31_OBJS} ${BL31_LINKERFILE}
@echo " LD $@"
${Q}${LD} -o $@ ${LDFLAGS} ${BL31_LDFLAGS} ${BL31_OBJS}

${BUILD}/bl1.bin: ${BUILD_BL1}/bl1.elf
${BUILD_PLAT}/bl1.bin: ${BUILD_BL1}/bl1.elf
@echo " BIN $@"
${Q}${OC} -O binary $< $@
@echo
@echo "Built $@ successfully"
@echo

${BUILD}/bl2.bin: ${BUILD_BL2}/bl2.elf
${BUILD_PLAT}/bl2.bin: ${BUILD_BL2}/bl2.elf
@echo " BIN $@"
${Q}${OC} -O binary $< $@
@echo
@echo "Built $@ successfully"
@echo

${BUILD}/bl31.bin: ${BUILD_BL31}/bl31.elf
${BUILD_PLAT}/bl31.bin: ${BUILD_BL31}/bl31.elf
@echo " BIN $@"
${Q}${OC} -O binary $< $@
@echo
@echo "Built $@ successfully"
Expand Down
2 changes: 1 addition & 1 deletion acknowledgements.md
Expand Up @@ -3,7 +3,7 @@ Contributor Acknowledgements

Companies
---------

Linaro Limited

Individuals
-----------
24 changes: 13 additions & 11 deletions bl1/bl1.mk
Expand Up @@ -28,19 +28,21 @@
# POSSIBILITY OF SUCH DAMAGE.
#

vpath %.c drivers/arm/interconnect/cci-400/ plat/fvp \
plat/fvp/${ARCH} drivers/arm/peripherals/pl011 common/ lib/ \
lib/semihosting arch/aarch64/ lib/stdlib
vpath %.c plat/${PLAT} plat/${PLAT}/${ARCH} \
common/ lib/ arch/${ARCH} \
${PLAT_BL1_C_VPATH}

vpath %.S arch/${ARCH}/cpu plat/common/aarch64 \
plat/fvp/${ARCH} lib/semihosting/aarch64 \
include/ lib/arch/aarch64
vpath %.S arch/${ARCH}/cpu plat/common/${ARCH} \
plat/${PLAT}/${ARCH} \
include/ lib/arch/${ARCH} \
${PLAT_BL1_S_VPATH}

BL1_OBJS += bl1_arch_setup.o \
bl1_entrypoint.o \
early_exceptions.o \
bl1_main.o \
cpu_helpers.o

BL1_ASM_OBJS := bl1_entrypoint.o bl1_plat_helpers.o cpu_helpers.o
BL1_C_OBJS := bl1_main.o cci400.o bl1_plat_setup.o bl1_arch_setup.o \
fvp_common.o fvp_helpers.o early_exceptions.o
BL1_ENTRY_POINT := reset_handler
BL1_MAPFILE := bl1.map
BL1_LINKERFILE := bl1.ld

BL1_OBJS := $(BL1_C_OBJS) $(BL1_ASM_OBJS)
21 changes: 11 additions & 10 deletions bl2/bl2.mk
Expand Up @@ -28,21 +28,22 @@
# POSSIBILITY OF SUCH DAMAGE.
#

vpath %.c common/ drivers/arm/interconnect/cci-400/ \
drivers/arm/peripherals/pl011 common/ lib/ \
plat/fvp plat/fvp/${ARCH} lib/semihosting arch/aarch64/ \
lib/stdlib
vpath %.c common/ lib/ \
plat/${PLAT} plat/${PLAT}/${ARCH} arch/${ARCH} \
${PLAT_BL2_C_VPATH}

vpath %.S lib/arch/aarch64 \
lib/semihosting/aarch64 \
include lib/sync/locks/exclusive
vpath %.S lib/arch/${ARCH} \
include lib/sync/locks/exclusive \
${PLAT_BL2_S_VPATH}

BL2_ASM_OBJS := bl2_entrypoint.o spinlock.o
BL2_C_OBJS := bl2_main.o bl2_plat_setup.o bl2_arch_setup.o fvp_common.o \
BL2_OBJS += bl2_entrypoint.o \
bl2_arch_setup.o \
bl2_main.o \
spinlock.o \
early_exceptions.o

BL2_ENTRY_POINT := bl2_entrypoint
BL2_MAPFILE := bl2.map
BL2_LINKERFILE := bl2.ld

BL2_OBJS := $(BL2_C_OBJS) $(BL2_ASM_OBJS)
CFLAGS += $(DEFINES)
43 changes: 25 additions & 18 deletions bl31/bl31.mk
Expand Up @@ -28,27 +28,34 @@
# POSSIBILITY OF SUCH DAMAGE.
#

vpath %.c drivers/arm/interconnect/cci-400/ common/ lib/ \
drivers/arm/peripherals/pl011 plat/fvp common/psci \
lib/semihosting arch/aarch64/ lib/stdlib lib/sync/locks/bakery/ \
drivers/power/ arch/system/gic/ plat/fvp/aarch64/
vpath %.c common/ lib/ arch/system/gic \
plat/${PLAT} arch/${ARCH} common/psci \
lib/sync/locks/bakery/ \
plat/${PLAT}/${ARCH} ${PLAT_BL31_C_VPATH}

vpath %.S lib/arch/aarch64 common/psci \
lib/semihosting/aarch64 include/ plat/fvp/${ARCH} \
lib/sync/locks/exclusive plat/common/aarch64/ \
arch/system/gic/${ARCH}
vpath %.S lib/arch/${ARCH} common/psci \
include/ plat/${PLAT}/${ARCH} \
lib/sync/locks/exclusive plat/common/${ARCH} \
arch/system/gic/${ARCH} \
${PLAT_BL31_S_VPATH}

BL31_ASM_OBJS := bl31_entrypoint.o runtime_exceptions.o psci_entry.o \
spinlock.o gic_v3_sysregs.o fvp_helpers.o
BL31_C_OBJS := bl31_main.o bl31_plat_setup.o bl31_arch_setup.o \
exception_handlers.o bakery_lock.o cci400.o \
fvp_common.o fvp_pm.o fvp_pwrc.o fvp_topology.o \
runtime_svc.o fvp_gic.o gic_v2.o gic_v3.o psci_setup.o \
psci_common.o psci_afflvl_on.o psci_main.o \
psci_afflvl_off.o psci_afflvl_suspend.o
BL31_OBJS += bl31_arch_setup.o \
bl31_entrypoint.o \
exception_handlers.o \
runtime_exceptions.o \
bl31_main.o \
psci_entry.o \
psci_setup.o \
psci_common.o \
psci_afflvl_on.o \
psci_main.o \
psci_afflvl_off.o \
psci_afflvl_suspend.o \
spinlock.o \
gic_v3_sysregs.o \
bakery_lock.o \
runtime_svc.o

BL31_ENTRY_POINT := bl31_entrypoint
BL31_MAPFILE := bl31.map
BL31_LINKERFILE := bl31.ld

BL31_OBJS := $(BL31_C_OBJS) $(BL31_ASM_OBJS)
5 changes: 5 additions & 0 deletions docs/change-log.md
Expand Up @@ -98,6 +98,11 @@ Detailed changes since last release
system. The GICv3 re-distributors are probed to work out which
re-distributor should be used with which CPU.

* Add multi-platform support to the build system. The user may now specify
which platform to build using PLAT=<platform> as part of the make command
line. Default behaviour is to make all platforms. New platforms are
automatically detected by the make file when they are added to the plat
directory.

ARM Trusted Firmware - version 0.2
==================================
Expand Down
8 changes: 4 additions & 4 deletions docs/user-guide.md
Expand Up @@ -82,7 +82,7 @@ To build the software for the FVPs, follow these steps:

3. Set the compiler path and build:

CROSS_COMPILE=<path-to-aarch64-gcc>/bin/aarch64-none-elf- make
CROSS_COMPILE=<path-to-aarch64-gcc>/bin/aarch64-none-elf- make PLAT=fvp

By default this produces a release version of the build. To produce a debug
version instead, refer to the "Debugging options" section below.
Expand All @@ -104,7 +104,7 @@ To build the software for the FVPs, follow these steps:

5. (Optional) Build products for a specific build variant can be removed using:

make DEBUG=<D> clean
make DEBUG=<D> PLAT=fvp clean

... where `<D>` is `0` or `1`, as specified when building.

Expand All @@ -117,7 +117,7 @@ To build the software for the FVPs, follow these steps:

To compile a debug version and make the build more verbose use

CROSS_COMPILE=<path-to-aarch64-gcc>/bin/aarch64-none-elf- make DEBUG=1 V=1
CROSS_COMPILE=<path-to-aarch64-gcc>/bin/aarch64-none-elf- make PLAT=fvp DEBUG=1 V=1

AArch64 GCC uses DWARF version 4 debugging symbols by default. Some tools (for
example DS-5) might not support this and may need an older version of DWARF
Expand All @@ -135,7 +135,7 @@ Extra debug options can be passed to the build system by setting `CFLAGS`:

CFLAGS='-O0 -gdwarf-2' \
CROSS_COMPILE=<path-to-aarch64-gcc>/bin/aarch64-none-elf- \
make DEBUG=1 V=1
make PLAT=fvp DEBUG=1 V=1


NOTE: The Foundation FVP does not provide a debugger interface.
Expand Down

0 comments on commit 25cff83

Please sign in to comment.