]> xenbits.xensource.com Git - people/julieng/boot-wrapper-aarch64.git/commitdiff
Add autotools configuration.
authorMatthew Leach <Matthew.Leach@arm.com>
Thu, 23 Jan 2014 17:29:26 +0000 (17:29 +0000)
committerMark Rutland <mark.rutland@arm.com>
Wed, 12 Mar 2014 11:15:25 +0000 (11:15 +0000)
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>
.gitignore
Makefile [deleted file]
Makefile.am [new file with mode: 0644]
README
configure.ac [new file with mode: 0644]

index f63ca94897da1e0b07912d836db7363d4fafc289..4dfd7fc23936d1beef7e92a221a100929e54fc6a 100644 (file)
@@ -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
deleted file mode 100644 (file)
index b7fb61d..0000000
--- a/Makefile
+++ /dev/null
@@ -1,90 +0,0 @@
-#
-# Makefile - build a kernel+filesystem image for stand-alone Linux booting
-#
-# Copyright (C) 2012 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.
-
-# VE
-PHYS_OFFSET    := 0x80000000
-UART_BASE      := 0x1c090000
-SYSREGS_BASE   := 0x1c010000
-GIC_DIST_BASE  := 0x2c001000
-GIC_CPU_BASE   := 0x2c002000
-CNTFRQ         := 0x01800000   # 24Mhz
-CPU_IDS                ?= 0x0,0x1,0x2,0x3
-
-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)"
-CHOSEN_NODE    := chosen {                                             \
-                       bootargs = \"$(BOOTARGS)\";                     \
-                       linux,initrd-start = <$(FILESYSTEM_START)>;     \
-                       linux,initrd-end = <$(FILESYSTEM_END)>;         \
-                  };
-else
-BOOTARGS       := "root=/dev/nfs nfsroot=\<serverip\>:\<rootfs\>,tcp rw ip=dhcp $(BOOTARGS_COMMON)"
-CHOSEN_NODE    := chosen {                                             \
-                       bootargs = \"$(BOOTARGS)\";                     \
-                  };
-endif
-
-CROSS_COMPILE  ?= aarch64-none-linux-gnu-
-CC             := $(CROSS_COMPILE)gcc
-LD             := $(CROSS_COMPILE)ld
-DTC            := $(if $(wildcard ./dtc), ./dtc, $(shell which dtc))
-
-all: $(IMAGE)
-
-clean:
-       rm -f $(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)
-       $(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
-
-fdt.dtb: $(FDT_DEPS) Makefile
-       ( echo "/include/ \"$(FDT_SRC)\"" ; 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/Makefile.am b/Makefile.am
new file mode 100644 (file)
index 0000000..fd66c8c
--- /dev/null
@@ -0,0 +1,73 @@
+#
+# Makefile.am - build a kernel+filesystem image for stand-alone Linux
+# booting
+#
+# Copyright (C) 2012 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.
+
+# VE
+PHYS_OFFSET    := 0x80000000
+UART_BASE      := 0x1c090000
+SYSREGS_BASE   := 0x1c010000
+GIC_DIST_BASE  := 0x2c001000
+GIC_CPU_BASE   := 0x2c002000
+CNTFRQ         := 0x01800000   # 24Mhz
+CPU_IDS                ?= 0x0,0x1,0x2,0x3
+
+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)
+
+BOOTLOADER     := boot.S
+BOOTMETHOD     := psci.o
+MBOX_OFFSET    := 0xfff8
+KERNEL_OFFSET  := 0x80000
+LD_SCRIPT      := model.lds.S
+IMAGE          := linux-system.axf
+
+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_OFFSET     := 0x08000000
+
+if INITRD
+INITRD_FLAGS   := -DUSE_INITRD
+CHOSEN_NODE    := chosen {                                             \
+                       bootargs = \"$(CMDLINE)\";                      \
+                       linux,initrd-start = <$(FILESYSTEM_START)>;     \
+                       linux,initrd-end = <$(FILESYSTEM_END)>;         \
+                  };
+else
+INITRD_FLAGS   :=
+CHOSEN_NODE    := chosen {                                             \
+                       bootargs = \"$(CMDLINE)\";                      \
+                  };
+endif
+
+CPPFLAGS       += $(INITRD_FLAGS)
+
+all: $(IMAGE)
+
+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_IMAGE) $(FILESYSTEM)
+       $(LD) -o $@ --script=model.lds
+
+%.o: %.S Makefile
+       $(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c -o $@ $<
+
+model.lds: $(LD_SCRIPT) Makefile
+       $(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: $(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 0c211b122a7002da34e4b0564f0d91c3b6a65264..7013e255903bcaceae5d01c867de4c088cc5df18 100644 (file)
--- 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 (file)
index 0000000..fdb5e17
--- /dev/null
@@ -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 ""