aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Leach <Matthew.Leach@arm.com>2014-01-23 17:29:26 +0000
committerMark Rutland <mark.rutland@arm.com>2014-03-12 11:15:25 +0000
commitbae4ae6a834cd15bf50f0ddc9a7331d8b0ac7168 (patch)
treeede44c057db9d447028725f6a8e1ba08abe3ca60
parent20db29f89a11c023634ccaab152941a6afdf2d52 (diff)
downloadboot-wrapper-aarch64-bae4ae6a834cd15bf50f0ddc9a7331d8b0ac7168.tar.gz
Add autotools configuration.
This patch adds a basic auto-tools configuration environment for the bootwrapper consisting of the configure.ac file and the Makefile.am file. The configure.ac file includes several options and checks: - Ensure that an AArch64 compiler is used. - Add the mandatory --with-kernel-dir option that sets KERN_DIR. - Check that the correct base dtb file exists in KERN_DIR. - Add an option, --with-initrd, that allows a user to specify an initrd file to embed in the image. - Check for a working dtc and set DTC to the full-path to the executable. - Create the necessary symbolic links to the relevant kernel files. The Makefile.am file includes several changes: - Use a prebuilt dtb rather than a dts, which is decompiled to inject the chosen node. - Use the configured compiler tool names. - Use the configured SED program rather than assuming it is in PATH. Signed-off-by: Matthew Leach <matthew.leach@arm.com> [Mark: use dtb, add options, fix style issues, remove src/] Signed-off-by: Mark Rutland <mark.rutland@arm.com>
-rw-r--r--.gitignore15
-rw-r--r--Makefile.am (renamed from Makefile)45
-rw-r--r--README18
-rw-r--r--configure.ac75
4 files changed, 112 insertions, 41 deletions
diff --git a/.gitignore b/.gitignore
index f63ca94..4dfd7fc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,19 @@
*.dts
*.dtsi
*.o
-Image
+aclocal.m4
+autom4te.cache/
+config.guess
+config.log
+config.status
+config.sub
+configure
dtc
+fdt.dtb
+Image
+install-sh
+Makefile
+Makefile.in
+missing
model.lds
+patches/
diff --git a/Makefile b/Makefile.am
index b7fb61d..fd66c8c 100644
--- a/Makefile
+++ b/Makefile.am
@@ -1,5 +1,6 @@
#
-# Makefile - build a kernel+filesystem image for stand-alone Linux booting
+# Makefile.am - build a kernel+filesystem image for stand-alone Linux
+# booting
#
# Copyright (C) 2012 ARM Limited. All rights reserved.
#
@@ -15,76 +16,58 @@ GIC_CPU_BASE := 0x2c002000
CNTFRQ := 0x01800000 # 24Mhz
CPU_IDS ?= 0x0,0x1,0x2,0x3
-DEFINES += -DCNTFRQ=$(CNTFRQ)
+DEFINES = -DCNTFRQ=$(CNTFRQ)
DEFINES += -DCPU_IDS=$(CPU_IDS)
DEFINES += -DGIC_CPU_BASE=$(GIC_CPU_BASE)
DEFINES += -DGIC_DIST_BASE=$(GIC_DIST_BASE)
DEFINES += -DSYSREGS_BASE=$(SYSREGS_BASE)
DEFINES += -DUART_BASE=$(UART_BASE)
-#INITRD_FLAGS := -DUSE_INITRD
-CPPFLAGS += $(INITRD_FLAGS)
-
BOOTLOADER := boot.S
BOOTMETHOD := psci.o
MBOX_OFFSET := 0xfff8
-KERNEL := Image
KERNEL_OFFSET := 0x80000
LD_SCRIPT := model.lds.S
IMAGE := linux-system.axf
-FILESYSTEM := filesystem.cpio.gz
FS_OFFSET := 0x10000000
FILESYSTEM_START:= $(shell echo $$(($(PHYS_OFFSET) + $(FS_OFFSET))))
FILESYSTEM_SIZE := $(shell stat -Lc %s $(FILESYSTEM) 2>/dev/null || echo 0)
FILESYSTEM_END := $(shell echo $$(($(FILESYSTEM_START) + $(FILESYSTEM_SIZE))))
-FDT_SRC := rtsm_ve-aemv8a.dts
-FDT_INCL_REGEX := \(/include/[[:space:]]*"\)\([^"]\+\)\(".*\)
-FDT_DEPS := $(FDT_SRC) $(addprefix $(dir $(FDT_SRC)), $(shell sed -ne 'sq$(strip $(FDT_INCL_REGEX)q\2q p' < $(FDT_SRC))))
FDT_OFFSET := 0x08000000
-BOOTARGS_COMMON := "console=ttyAMA0 earlyprintk=pl011,0x1c090000 $(BOOTARGS_EXTRA)"
-
-ifneq (,$(findstring USE_INITRD,$(CPPFLAGS)))
-BOOTARGS := "$(BOOTARGS_COMMON)"
+if INITRD
+INITRD_FLAGS := -DUSE_INITRD
CHOSEN_NODE := chosen { \
- bootargs = \"$(BOOTARGS)\"; \
+ bootargs = \"$(CMDLINE)\"; \
linux,initrd-start = <$(FILESYSTEM_START)>; \
linux,initrd-end = <$(FILESYSTEM_END)>; \
};
else
-BOOTARGS := "root=/dev/nfs nfsroot=\<serverip\>:\<rootfs\>,tcp rw ip=dhcp $(BOOTARGS_COMMON)"
+INITRD_FLAGS :=
CHOSEN_NODE := chosen { \
- bootargs = \"$(BOOTARGS)\"; \
+ bootargs = \"$(CMDLINE)\"; \
};
endif
-CROSS_COMPILE ?= aarch64-none-linux-gnu-
-CC := $(CROSS_COMPILE)gcc
-LD := $(CROSS_COMPILE)ld
-DTC := $(if $(wildcard ./dtc), ./dtc, $(shell which dtc))
+CPPFLAGS += $(INITRD_FLAGS)
all: $(IMAGE)
-clean:
- rm -f $(IMAGE) boot.o cache.o gic.o mmu.o ns.o $(BOOTMETHOD) model.lds fdt.dtb
+CLEANFILES = $(IMAGE) boot.o cache.o gic.o mmu.o ns.o $(BOOTMETHOD) model.lds fdt.dtb
-$(IMAGE): boot.o cache.o gic.o mmu.o ns.o $(BOOTMETHOD) model.lds fdt.dtb $(KERNEL) $(FILESYSTEM)
+$(IMAGE): boot.o cache.o gic.o mmu.o ns.o $(BOOTMETHOD) model.lds fdt.dtb $(KERNEL_IMAGE) $(FILESYSTEM)
$(LD) -o $@ --script=model.lds
%.o: %.S Makefile
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c -o $@ $<
model.lds: $(LD_SCRIPT) Makefile
- $(CC) $(CPPFLAGS) -DPHYS_OFFSET=$(PHYS_OFFSET) -DMBOX_OFFSET=$(MBOX_OFFSET) -DKERNEL_OFFSET=$(KERNEL_OFFSET) -DFDT_OFFSET=$(FDT_OFFSET) -DFS_OFFSET=$(FS_OFFSET) -DKERNEL=$(KERNEL) -DFILESYSTEM=$(FILESYSTEM) -DBOOTMETHOD=$(BOOTMETHOD) -E -P -C -o $@ $<
-
-ifeq ($(DTC),)
- $(error No dtc found! You can git clone from git://git.jdl.com/software/dtc.git)
-endif
+ $(CPP) $(CPPFLAGS) -ansi -DPHYS_OFFSET=$(PHYS_OFFSET) -DMBOX_OFFSET=$(MBOX_OFFSET) -DKERNEL_OFFSET=$(KERNEL_OFFSET) -DFDT_OFFSET=$(FDT_OFFSET) -DFS_OFFSET=$(FS_OFFSET) -DKERNEL=$(KERNEL_IMAGE) -DFILESYSTEM=$(FILESYSTEM) -DBOOTMETHOD=$(BOOTMETHOD) -P -C -o $@ $<
-fdt.dtb: $(FDT_DEPS) Makefile
- ( echo "/include/ \"$(FDT_SRC)\"" ; echo "/ { $(CHOSEN_NODE) };" ) | $(DTC) -O dtb -o $@ -
+fdt.dtb: $(KERNEL_DTB) Makefile
+ ( $(DTC) -O dts -I dtb $(KERNEL_DTB) ; echo "/ { $(CHOSEN_NODE) };" ) | $(DTC) -O dtb -o $@ -
# The filesystem archive might not exist if INITRD is not being used
.PHONY: all clean $(FILESYSTEM)
diff --git a/README b/README
index 0c211b1..7013e25 100644
--- a/README
+++ b/README
@@ -1,14 +1,14 @@
Linux boot wrapper with FDT support
===================================
-The following files need to be linked into the boot wrapper directory:
+To get started:
-dtc - point to <linux-build-dir>/scripts/dtc/dtc
-rtsm_ve-aemv8a.dts - point to <linux-src-dir>/arch/arm64/boot/dts/rtsm_ve-aemv8a.dts
-rtsm_ve-motherboard.dtsi - point to <linux-src-dir>/arch/arm64/boot/dts/rtsm_ve-motherboard.dtsi
-skeleton.dtsi - point to <linux-src-dir>/arch/arm64/boot/dts/skeleton.dtsi
+$ autoreconf -i
+$ ./configure --host=<toolchain-triplet> --with-kernel-dir=<kernel-dir> <other-options>
+$ make
-Alternatively, you may specify the paths for dtc and the main dts file
-on the make command-line. For example:
-
-make DTC=<path-to-dtc> FDT_SRC=<linux-src-dir>/arch/arm64/boot/dts/vexpress-v2p-aarch64.dtsi
+Where:
+ - <toolchain-triplet>: this is something like aarch64-linux-gnu
+ - <kernel-dir>: the directory containing a pre-built aarch64 kernel
+ and its sources.
+ - <other-options>: see ./configure -h for a list of other options.
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..fdb5e17
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,75 @@
+# configure.ac - autoconf script for the AArch64 bootwrapper
+#
+# Copyright (c) 2014 ARM Limited. All rights reserved.
+#
+# Use of this source code is governed by a BSD-style license that can
+# be found in the LICENSE.txt file.
+
+AC_INIT([aarch64-boot-wrapper], [v0.1])
+
+# Ensure that we're using an AArch64 compiler
+AC_CANONICAL_SYSTEM
+
+if test "x$host_cpu" != "xaarch64"; then
+ AC_MSG_ERROR([The boot-wrapper can only be used with an AArch64 compiler.])
+fi
+
+AM_INIT_AUTOMAKE([foreign])
+
+# Allow a user to pass --with-kernel-dir
+AC_ARG_WITH([kernel-dir],
+ AS_HELP_STRING([--with-kernel-dir], [specify the root Linux kernel build directory (required)]),
+ AC_SUBST([KERN_DIR], [$withval]),
+ AC_MSG_ERROR([No kernel directory specified. Use --with-kernel-dir]))
+KERN_IMAGE=/arch/arm64/boot/Image
+KERN_DTB=/arch/arm64/boot/dts/rtsm_ve-aemv8a.dtb
+
+# Ensure that the user has provided us with a sane kernel dir.
+m4_define([CHECKFILES], [KERN_DIR,
+ KERN_DIR$KERN_DTB,
+ KERN_DIR$KERN_IMAGE])
+
+m4_foreach([checkfile], [CHECKFILES],
+ [AC_CHECK_FILE([$checkfile], [], AC_MSG_ERROR([No such file or directory: $checkfile]))])
+
+AC_SUBST([KERNEL_IMAGE], [$KERN_DIR$KERN_IMAGE])
+AC_SUBST([KERNEL_DTB], [$KERN_DIR$KERN_DTB])
+
+# Allow a user to pass --with-initrd
+AC_ARG_WITH([initrd],
+ AS_HELP_STRING([--with-initrd], [embed an initrd in the kernel image]),
+ USE_INITRD=$withval)
+AC_SUBST([FILESYSTEM], [$USE_INITRD])
+AM_CONDITIONAL([INITRD], [test "x$USE_INITRD" != "x"])
+
+C_CMDLINE="console=ttyAMA0 earlyprintk=pl011,0x1c090000"
+AC_ARG_WITH([cmdline],
+ AS_HELP_STRING([--with-cmdline], [set a command line for the kernel]),
+ [C_CMDLINE=$withval])
+AC_SUBST([CMDLINE], [$C_CMDLINE])
+
+# Ensure that we have all the needed programs
+AC_PROG_CC
+AC_PROG_CPP
+AM_PROG_AS
+AC_PROG_SED
+AC_PROG_LN_S
+AC_PATH_PROG([DTC], dtc, error)
+if test "x$DTC" = "xerror"; then
+ AC_MSG_ERROR([cannot find the device tree compiler (dtc)])
+fi
+AC_CHECK_TOOL(LD, ld)
+
+AC_CONFIG_FILES([Makefile])
+
+AC_OUTPUT
+
+# Print the final config to the user.
+echo ""
+echo " Boot wrapper configuration"
+echo " =========================="
+echo ""
+echo " Linux kernel build dir: ${KERN_DIR}"
+echo " Linux kernel command line: ${CMDLINE}"
+echo " Embedded initrd: ${FILESYSTEM:-NONE}"
+echo ""