Browse Source

Build system: Fixes #2: Add multi-platform support

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>
pull/14/head
Ryan Harkin 11 years ago
committed by Dan Handley
parent
commit
25cff83ee4
  1. 106
      Makefile
  2. 2
      acknowledgements.md
  3. 24
      bl1/bl1.mk
  4. 21
      bl2/bl2.mk
  5. 43
      bl31/bl31.mk
  6. 5
      docs/change-log.md
  7. 8
      docs/user-guide.md
  8. 81
      plat/fvp/platform.mk

106
Makefile

@ -51,37 +51,57 @@ else
endif endif
BL_COMMON_OBJS := misc_helpers.o cache_helpers.o tlb_helpers.o \ 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
std.o bl_common.o platform_helpers.o sysreg_helpers.o ARCH ?= aarch64
ARCH := aarch64 # By default, build all platforms available
PLAT := fvp PLAT ?= all
BUILD_BASE:=./build BUILD_BASE := ./build
BUILD:=${BUILD_BASE}/${PLAT}/${BUILD_TYPE} BUILD_PLAT := ${BUILD_BASE}/${PLAT}/${BUILD_TYPE}
BUILD_BL1:=${BUILD}/bl1 BUILD_BL1 := ${BUILD_PLAT}/bl1
BUILD_BL2:=${BUILD}/bl2 BUILD_BL2 := ${BUILD_PLAT}/bl2
BUILD_BL31:=${BUILD}/bl31 BUILD_BL31 := ${BUILD_PLAT}/bl31
BUILD_DIRS:=${BUILD_BL1} ${BUILD_BL2} ${BUILD_BL31} BUILD_DIRS := ${BUILD_BL1} ${BUILD_BL2} ${BUILD_BL31}
all: bl1 bl2 bl31 PLATFORMS := $(shell ls -I common plat/)
ifeq (${PLAT},)
$(info Including bl1.mk) $(error "Error: Unknown platform. Please use PLAT=<platform name> to specify the platform.")
include bl1/bl1.mk endif
ifeq ($(findstring ${PLAT},${PLATFORMS} all),)
$(error "Error: Invalid platform. The following platforms are available: ${PLATFORMS}")
endif
$(info Including bl2.mk) ifeq (${PLAT},all)
include bl2/bl2.mk all: ${PLATFORMS}
else
all: msg_start bl1 bl2 bl31
endif
$(info Including bl31.mk) msg_start:
include bl31/bl31.mk @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: .SUFFIXES:
BL1_OBJS := $(addprefix ${BUILD_BL1}/,${BL1_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}) BL2_OBJS := $(addprefix ${BUILD_BL2}/,${BL2_OBJS} ${BL_COMMON_OBJS} ${PLAT_BL_COMMON_OBJS})
BL31_OBJS := $(addprefix ${BUILD_BL31}/,${BL31_OBJS} ${BL_COMMON_OBJS}) BL31_OBJS := $(addprefix ${BUILD_BL31}/,${BL31_OBJS} ${BL_COMMON_OBJS} ${PLAT_BL_COMMON_OBJS})
BL1_MAPFILE := $(addprefix ${BUILD_BL1}/,${BL1_MAPFILE}) BL1_MAPFILE := $(addprefix ${BUILD_BL1}/,${BL1_MAPFILE})
BL2_MAPFILE := $(addprefix ${BUILD_BL2}/,${BL2_MAPFILE}) BL2_MAPFILE := $(addprefix ${BUILD_BL2}/,${BL2_MAPFILE})
BL31_MAPFILE := $(addprefix ${BUILD_BL31}/,${BL31_MAPFILE}) BL31_MAPFILE := $(addprefix ${BUILD_BL31}/,${BL31_MAPFILE})
@ -89,12 +109,10 @@ BL1_LINKERFILE := $(addprefix ${BUILD_BL1}/,${BL1_LINKERFILE})
BL2_LINKERFILE := $(addprefix ${BUILD_BL2}/,${BL2_LINKERFILE}) BL2_LINKERFILE := $(addprefix ${BUILD_BL2}/,${BL2_LINKERFILE})
BL31_LINKERFILE := $(addprefix ${BUILD_BL31}/,${BL31_LINKERFILE}) BL31_LINKERFILE := $(addprefix ${BUILD_BL31}/,${BL31_LINKERFILE})
INCLUDES += -Ilib/include/ -Iinclude/aarch64/ -Iinclude/ \ INCLUDES += -Ilib/include/ -Iinclude/${ARCH}/ -Iinclude/ \
-Idrivers/arm/interconnect/cci-400/ \
-Idrivers/arm/peripherals/pl011/ \
-Iplat/fvp -Idrivers/power \
-Iarch/system/gic -Icommon/psci \ -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 \ ASFLAGS += -nostdinc -ffreestanding -Wa,--fatal-warnings \
-mgeneral-regs-only -D__ASSEMBLY__ ${INCLUDES} -mgeneral-regs-only -D__ASSEMBLY__ ${INCLUDES}
@ -133,13 +151,18 @@ NM := ${CROSS_COMPILE}nm
PP := ${CROSS_COMPILE}gcc -E ${CFLAGS} PP := ${CROSS_COMPILE}gcc -E ${CFLAGS}
bl1: ${BUILD_BL1} ${BUILD}/bl1.bin bl1: ${BUILD_BL1} ${BUILD_PLAT}/bl1.bin
bl2: ${BUILD_BL2} ${BUILD}/bl2.bin bl2: ${BUILD_BL2} ${BUILD_PLAT}/bl2.bin
bl31: ${BUILD_BL31} ${BUILD}/bl31.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: clean:
@echo " CLEAN" @echo " CLEAN"
${Q}rm -rf ${BUILD} ${Q}rm -rf ${BUILD_PLAT}
realclean distclean: realclean distclean:
@echo " REALCLEAN" @echo " REALCLEAN"
@ -180,15 +203,15 @@ ${BUILD_BL31}/%.o: %.c
${Q}${CC} ${CFLAGS} -c $< -o $@ ${Q}${CC} ${CFLAGS} -c $< -o $@
${BUILD_BL1}/%.ld: %.ld.S ${BUILD_BL1}/%.ld: %.ld.S
@echo " LDS $<" @echo " PP $<"
${Q}${AS} ${ASFLAGS} -P -E $< -o $@ ${Q}${AS} ${ASFLAGS} -P -E $< -o $@
${BUILD_BL2}/%.ld: %.ld.S ${BUILD_BL2}/%.ld: %.ld.S
@echo " LDS $<" @echo " PP $<"
${Q}${AS} ${ASFLAGS} -P -E $< -o $@ ${Q}${AS} ${ASFLAGS} -P -E $< -o $@
${BUILD_BL31}/%.ld: %.ld.S ${BUILD_BL31}/%.ld: %.ld.S
@echo " LDS $<" @echo " PP $<"
${Q}${AS} ${ASFLAGS} -P -E $< -o $@ ${Q}${AS} ${ASFLAGS} -P -E $< -o $@
@ -204,19 +227,22 @@ ${BUILD_BL31}/bl31.elf: ${BL31_OBJS} ${BL31_LINKERFILE}
@echo " LD $@" @echo " LD $@"
${Q}${LD} -o $@ ${LDFLAGS} ${BL31_LDFLAGS} ${BL31_OBJS} ${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 $< $@ ${Q}${OC} -O binary $< $@
@echo @echo
@echo "Built $@ successfully" @echo "Built $@ successfully"
@echo @echo
${BUILD}/bl2.bin: ${BUILD_BL2}/bl2.elf ${BUILD_PLAT}/bl2.bin: ${BUILD_BL2}/bl2.elf
@echo " BIN $@"
${Q}${OC} -O binary $< $@ ${Q}${OC} -O binary $< $@
@echo @echo
@echo "Built $@ successfully" @echo "Built $@ successfully"
@echo @echo
${BUILD}/bl31.bin: ${BUILD_BL31}/bl31.elf ${BUILD_PLAT}/bl31.bin: ${BUILD_BL31}/bl31.elf
@echo " BIN $@"
${Q}${OC} -O binary $< $@ ${Q}${OC} -O binary $< $@
@echo @echo
@echo "Built $@ successfully" @echo "Built $@ successfully"

2
acknowledgements.md

@ -3,7 +3,7 @@ Contributor Acknowledgements
Companies Companies
--------- ---------
Linaro Limited
Individuals Individuals
----------- -----------

24
bl1/bl1.mk

@ -28,19 +28,21 @@
# POSSIBILITY OF SUCH DAMAGE. # POSSIBILITY OF SUCH DAMAGE.
# #
vpath %.c drivers/arm/interconnect/cci-400/ plat/fvp \ vpath %.c plat/${PLAT} plat/${PLAT}/${ARCH} \
plat/fvp/${ARCH} drivers/arm/peripherals/pl011 common/ lib/ \ common/ lib/ arch/${ARCH} \
lib/semihosting arch/aarch64/ lib/stdlib ${PLAT_BL1_C_VPATH}
vpath %.S arch/${ARCH}/cpu plat/common/aarch64 \ vpath %.S arch/${ARCH}/cpu plat/common/${ARCH} \
plat/fvp/${ARCH} lib/semihosting/aarch64 \ plat/${PLAT}/${ARCH} \
include/ lib/arch/aarch64 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_ENTRY_POINT := reset_handler
BL1_MAPFILE := bl1.map BL1_MAPFILE := bl1.map
BL1_LINKERFILE := bl1.ld BL1_LINKERFILE := bl1.ld
BL1_OBJS := $(BL1_C_OBJS) $(BL1_ASM_OBJS)

21
bl2/bl2.mk

@ -28,21 +28,22 @@
# POSSIBILITY OF SUCH DAMAGE. # POSSIBILITY OF SUCH DAMAGE.
# #
vpath %.c common/ drivers/arm/interconnect/cci-400/ \ vpath %.c common/ lib/ \
drivers/arm/peripherals/pl011 common/ lib/ \ plat/${PLAT} plat/${PLAT}/${ARCH} arch/${ARCH} \
plat/fvp plat/fvp/${ARCH} lib/semihosting arch/aarch64/ \ ${PLAT_BL2_C_VPATH}
lib/stdlib
vpath %.S lib/arch/aarch64 \ vpath %.S lib/arch/${ARCH} \
lib/semihosting/aarch64 \ include lib/sync/locks/exclusive \
include lib/sync/locks/exclusive ${PLAT_BL2_S_VPATH}
BL2_ASM_OBJS := bl2_entrypoint.o spinlock.o BL2_OBJS += bl2_entrypoint.o \
BL2_C_OBJS := bl2_main.o bl2_plat_setup.o bl2_arch_setup.o fvp_common.o \ bl2_arch_setup.o \
bl2_main.o \
spinlock.o \
early_exceptions.o early_exceptions.o
BL2_ENTRY_POINT := bl2_entrypoint BL2_ENTRY_POINT := bl2_entrypoint
BL2_MAPFILE := bl2.map BL2_MAPFILE := bl2.map
BL2_LINKERFILE := bl2.ld BL2_LINKERFILE := bl2.ld
BL2_OBJS := $(BL2_C_OBJS) $(BL2_ASM_OBJS)
CFLAGS += $(DEFINES) CFLAGS += $(DEFINES)

43
bl31/bl31.mk

@ -28,27 +28,34 @@
# POSSIBILITY OF SUCH DAMAGE. # POSSIBILITY OF SUCH DAMAGE.
# #
vpath %.c drivers/arm/interconnect/cci-400/ common/ lib/ \ vpath %.c common/ lib/ arch/system/gic \
drivers/arm/peripherals/pl011 plat/fvp common/psci \ plat/${PLAT} arch/${ARCH} common/psci \
lib/semihosting arch/aarch64/ lib/stdlib lib/sync/locks/bakery/ \ lib/sync/locks/bakery/ \
drivers/power/ arch/system/gic/ plat/fvp/aarch64/ plat/${PLAT}/${ARCH} ${PLAT_BL31_C_VPATH}
vpath %.S lib/arch/aarch64 common/psci \ vpath %.S lib/arch/${ARCH} common/psci \
lib/semihosting/aarch64 include/ plat/fvp/${ARCH} \ include/ plat/${PLAT}/${ARCH} \
lib/sync/locks/exclusive plat/common/aarch64/ \ lib/sync/locks/exclusive plat/common/${ARCH} \
arch/system/gic/${ARCH} arch/system/gic/${ARCH} \
${PLAT_BL31_S_VPATH}
BL31_ASM_OBJS := bl31_entrypoint.o runtime_exceptions.o psci_entry.o \ BL31_OBJS += bl31_arch_setup.o \
spinlock.o gic_v3_sysregs.o fvp_helpers.o bl31_entrypoint.o \
BL31_C_OBJS := bl31_main.o bl31_plat_setup.o bl31_arch_setup.o \ exception_handlers.o \
exception_handlers.o bakery_lock.o cci400.o \ runtime_exceptions.o \
fvp_common.o fvp_pm.o fvp_pwrc.o fvp_topology.o \ bl31_main.o \
runtime_svc.o fvp_gic.o gic_v2.o gic_v3.o psci_setup.o \ psci_entry.o \
psci_common.o psci_afflvl_on.o psci_main.o \ psci_setup.o \
psci_afflvl_off.o psci_afflvl_suspend.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_ENTRY_POINT := bl31_entrypoint
BL31_MAPFILE := bl31.map BL31_MAPFILE := bl31.map
BL31_LINKERFILE := bl31.ld BL31_LINKERFILE := bl31.ld
BL31_OBJS := $(BL31_C_OBJS) $(BL31_ASM_OBJS)

5
docs/change-log.md

@ -98,6 +98,11 @@ Detailed changes since last release
system. The GICv3 re-distributors are probed to work out which system. The GICv3 re-distributors are probed to work out which
re-distributor should be used with which CPU. 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 ARM Trusted Firmware - version 0.2
================================== ==================================

8
docs/user-guide.md

@ -82,7 +82,7 @@ To build the software for the FVPs, follow these steps:
3. Set the compiler path and build: 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 By default this produces a release version of the build. To produce a debug
version instead, refer to the "Debugging options" section below. version instead, refer to the "Debugging options" section below.
@ -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: 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. ... where `<D>` is `0` or `1`, as specified when building.
@ -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 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 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 example DS-5) might not support this and may need an older version of DWARF
@ -135,7 +135,7 @@ Extra debug options can be passed to the build system by setting `CFLAGS`:
CFLAGS='-O0 -gdwarf-2' \ CFLAGS='-O0 -gdwarf-2' \
CROSS_COMPILE=<path-to-aarch64-gcc>/bin/aarch64-none-elf- \ 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. NOTE: The Foundation FVP does not provide a debugger interface.

81
plat/fvp/platform.mk

@ -0,0 +1,81 @@
#
# Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# Neither the name of ARM nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific
# prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED 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.
#
PLAT_INCLUDES := -Idrivers/arm/interconnect/cci-400/ \
-Idrivers/arm/peripherals/pl011/ \
-Idrivers/power
PLAT_BL1_C_VPATH := drivers/arm/interconnect/cci-400/ \
drivers/arm/peripherals/pl011 \
lib/semihosting \
lib/stdlib
PLAT_BL1_S_VPATH := lib/semihosting/${ARCH}
PLAT_BL2_C_VPATH := drivers/arm/interconnect/cci-400 \
drivers/arm/peripherals/pl011 \
lib/stdlib \
lib/semihosting
PLAT_BL2_S_VPATH := lib/semihosting/${ARCH}
PLAT_BL31_C_VPATH := drivers/arm/interconnect/cci-400 \
drivers/arm/peripherals/pl011 \
lib/semihosting \
lib/stdlib \
drivers/power
PLAT_BL31_S_VPATH := lib/semihosting/${ARCH}
PLAT_BL_COMMON_OBJS := semihosting_call.o \
mmio.o \
pl011.o \
semihosting.o \
sysreg_helpers.o
BL1_OBJS += bl1_plat_setup.o \
bl1_plat_helpers.o \
fvp_helpers.o \
fvp_common.o \
cci400.o
BL2_OBJS += bl2_plat_setup.o \
fvp_common.o
BL31_OBJS += bl31_plat_setup.o \
fvp_helpers.o \
fvp_common.o \
fvp_pm.o \
fvp_pwrc.o \
fvp_topology.o \
fvp_gic.o \
cci400.o \
gic_v2.o \
gic_v3.o
Loading…
Cancel
Save