[meta-xilinx] [contrib][RFC] linux-boot-simple: introduce ultra trivial kernel Image launcher

Jean-Francois Dagenais jeff.dagenais at gmail.com
Tue Jul 9 12:09:58 PDT 2019


This very crude linux loader assumes the kernel image, the dtb and itself have
been copied to RAM at the addresses given at compile time (see variables in
recipe).

The kernel will use the "/chosen/bootargs" from the dtb.

It is meant to "replace" u-boot for very simple cases. One can load all these
binaries from boot.bin using the bif file "load=" syntax. FSBL then blindly
copies those to the specfied HW addresses.

Follow the thread around this message:
https://lists.yoctoproject.org/pipermail/meta-xilinx/2019-June/004433.html

Signed-off-by: Jean-Francois Dagenais <jeff.dagenais at gmail.com>
---
 .../linux-boot-simple/files/linux-boot-simple.s    | 45 ++++++++++++++++++++++
 .../linux-boot-simple/linux-boot-simple.bb         | 29 ++++++++++++++
 2 files changed, 74 insertions(+)
 create mode 100644 meta-xilinx-contrib/recipes-bsp/linux-boot-simple/files/linux-boot-simple.s
 create mode 100644 meta-xilinx-contrib/recipes-bsp/linux-boot-simple/linux-boot-simple.bb

diff --git a/meta-xilinx-contrib/recipes-bsp/linux-boot-simple/files/linux-boot-simple.s b/meta-xilinx-contrib/recipes-bsp/linux-boot-simple/files/linux-boot-simple.s
new file mode 100644
index 0000000..4aa9a0d
--- /dev/null
+++ b/meta-xilinx-contrib/recipes-bsp/linux-boot-simple/files/linux-boot-simple.s
@@ -0,0 +1,45 @@
+/*
+* (C) Copyright 2015 - 2019, Xilinx, Inc
+*
+* Originally written by Edgar E. Iglesias and Jason Wu.
+* Modified for yocto by Jean-Francois Dagenais
+*
+* Set yocto variables BOOT_LOAD_KERNEL_ADDRESS and BOOT_LOAD_DTB_ADDRESS and
+* BOOT_LOAD_LINUX_BOOT_SIMPLE at the global scope (e.g. local.conf,
+* machine.conf or distro.conf) to tell this code where in RAM the kernel and
+* device-tree blob are.
+*
+* See linux-boot-simple.bb
+*
+* Example use in machine.conf with xilinx-bootbin's BIF_PARTITION_... variables:
+* (mymachine.conf)
+* BOOT_LOAD_DTB_ADDRESS = "0x60000"
+* BOOT_LOAD_KERNEL_ADDRESS = "0x80000"
+* BOOT_LOAD_LINUX_BOOT_SIMPLE = "0x5F000"
+* BIF_PARTITION_ATTR[linux-trampoline] = "destination_cpu=a53-0,exception_level=el-2"
+* BIF_PARTITION_IMAGE[linux-trampoline] = "${DEPLOY_DIR_IMAGE}/linux-boot-simple.elf"
+* BIF_PARTITION_DEPENDS[linux-trampoline] = "linux-boot-simple:do_deploy"
+* BIF_PARTITION_ATTR[dtb] := "load=${BOOT_LOAD_DTB_ADDRESS}"
+* BIF_PARTITION_IMAGE[dtb] = "${DEPLOY_DIR_IMAGE}/${MACHINE}.dtb"
+* BIF_PARTITION_DEPENDS[dtb] = "virtual/kernel:do_deploy"
+* BIF_PARTITION_ATTR[kernel] := "load=${BOOT_LOAD_KERNEL_ADDRESS}"
+* BIF_PARTITION_IMAGE[kernel] = "${DEPLOY_DIR_IMAGE}/Image-${MACHINE}.bin"
+* BIF_PARTITION_DEPENDS[kernel] = "virtual/kernel:do_deploy"
+*
+* Then replace "u-boot" with "linux-trampoline" in the list of bif partitions:
+* BIF_PARTITION_ATTR_mymachine = "fsbl bitstream pmu atf linux-trampoline dtb kernel"
+*/
+       .section        .text
+       .global         _start
+_start:
+       ldr      x17, kernel_start
+       ldr      x0, kernel_dts
+       mov      x1, xzr
+       mov      x2, xzr
+       mov      x3, xzr
+       blr      x17
+       .balign 8
+kernel_start:
+       .dword   __BOOT_LOAD_KERNEL_ADDRESS__
+kernel_dts:
+       .dword   __BOOT_LOAD_DTB_ADDRESS__
diff --git a/meta-xilinx-contrib/recipes-bsp/linux-boot-simple/linux-boot-simple.bb b/meta-xilinx-contrib/recipes-bsp/linux-boot-simple/linux-boot-simple.bb
new file mode 100644
index 0000000..7f0d57b
--- /dev/null
+++ b/meta-xilinx-contrib/recipes-bsp/linux-boot-simple/linux-boot-simple.bb
@@ -0,0 +1,29 @@
+SUMMARY = "Simple Boot Loader for embedded devices"
+LICENSE = "GPLv2"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6"
+
+SRC_URI += "file://linux-boot-simple.s"
+
+B = "${WORKDIR}/build"
+
+PACKAGE_ARCH = "${MACHINE_ARCH}"
+
+inherit xsct-tc
+
+do_configure() {
+        sed "s/__BOOT_LOAD_KERNEL_ADDRESS__/${BOOT_LOAD_KERNEL_ADDRESS}/" ${WORKDIR}/${PN}.s > ${B}/${PN}.s
+        sed -i "s/__BOOT_LOAD_DTB_ADDRESS__/${BOOT_LOAD_DTB_ADDRESS}/" ${B}/${PN}.s
+}
+
+do_compile() {
+        aarch64-none-elf-gcc -nostartfiles -nodefaultlibs -Wl,--build-id=none,-Ttext=${BOOT_LOAD_LINUX_BOOT_SIMPLE} ${PN}.s -o ${PN}.elf
+}
+
+do_install[noexec] = "1"
+
+inherit deploy
+
+do_deploy() {
+        cp ${B}/linux-boot-simple.elf ${DEPLOYDIR}
+}
+addtask deploy before do_build after do_compile
-- 
2.11.0



More information about the meta-xilinx mailing list