From: Matthew Leach Date: Thu, 23 Jan 2014 17:29:26 +0000 (+0000) Subject: Add autotools configuration. X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=bae4ae6a834cd15bf50f0ddc9a7331d8b0ac7168;p=people%2Fjulieng%2Fboot-wrapper-aarch64.git 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 [Mark: use dtb, add options, fix style issues, remove src/] Signed-off-by: Mark Rutland --- 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 deleted file mode 100644 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=\:\,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 index 0000000..fd66c8c --- /dev/null +++ b/Makefile.am @@ -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 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 /scripts/dtc/dtc -rtsm_ve-aemv8a.dts - point to /arch/arm64/boot/dts/rtsm_ve-aemv8a.dts -rtsm_ve-motherboard.dtsi - point to /arch/arm64/boot/dts/rtsm_ve-motherboard.dtsi -skeleton.dtsi - point to /arch/arm64/boot/dts/skeleton.dtsi +$ autoreconf -i +$ ./configure --host= --with-kernel-dir= +$ make -Alternatively, you may specify the paths for dtc and the main dts file -on the make command-line. For example: - -make DTC= FDT_SRC=/arch/arm64/boot/dts/vexpress-v2p-aarch64.dtsi +Where: + - : this is something like aarch64-linux-gnu + - : the directory containing a pre-built aarch64 kernel + and its sources. + - : 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 ""