*.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/
+++ /dev/null
-#
-# 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)
--- /dev/null
+#
+# 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)
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.
--- /dev/null
+# 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 ""