summaryrefslogtreecommitdiffstats
path: root/bsp/meta-arm/meta-arm-bsp/recipes-bsp/boot-wrapper-aaarch64/boot-wrapper-aarch64.inc
blob: 3cd3917757dfac2c34924a2f2617798b40466b91 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
SUMMARY = "Linux aarch64 boot wrapper with FDT support"
LICENSE = "BSD"

inherit autotools deploy

PROVIDES = "virtual/gem5-bootloader boot-wrapper-aarch64"

PACKAGE_ARCH = "${MACHINE_ARCH}"

COMPATIBLE_MACHINE ?= ""

# Device tree to put in the image
# by default use the standard kernel devicetree
# This should be overwritten if the devicetree is not generated
# by the kernel.
# This should point to a file in the deploy image directory
BOOT_WRAPPER_AARCH64_DEVICETREE ??= "${KERNEL_DEVICETREE}"

# Kernel image to put in the image
# This should point to a file in the deploy image directory
BOOT_WRAPPER_AARCH64_KERNEL ??= "Image"

# Kernel command line for the image
BOOT_WRAPPER_AARCH64_CMDLINE ??= "rw"

# Image generated by boot wrapper
BOOT_WRAPPER_AARCH64_IMAGE ??= "linux-system.axf"

DEPENDS += "virtual/kernel dtc-native"

EXTRA_OECONF += "--with-kernel-dir=${WORKDIR}/kernel"
EXTRA_OECONF += "--with-dtb=${WORKDIR}/kernel/dummy.dtb"
EXTRA_OECONF += "--with-cmdline=\"\""
EXTRA_OECONF += "--enable-psci --enable-gicv3"

# unset LDFLAGS solves this error when compiling kernel modules:
# aarch64-poky-linux-ld: unrecognized option '-Wl,-O1'
EXTRA_OEMAKE += "'LDFLAGS= --gc-sections '"

# Strip prefix if any
REAL_DTB = "${@os.path.basename(d.getVar('BOOT_WRAPPER_AARCH64_DEVICETREE'))}"

EXTRA_OEMAKE += "'KERNEL_DTB=${DEPLOY_DIR_IMAGE}/${REAL_DTB}'"
EXTRA_OEMAKE += "'KERNEL_IMAGE=${DEPLOY_DIR_IMAGE}/${BOOT_WRAPPER_AARCH64_KERNEL}'"
EXTRA_OEMAKE += "'CMDLINE=${BOOT_WRAPPER_AARCH64_CMDLINE}'"


do_configure_prepend() {
    # Create dummy files to make configure happy.
    # We will pass the generated ones directly to make.
    mkdir -p ${WORKDIR}/kernel/arch/arm64/boot
    echo "dummy" > ${WORKDIR}/kernel/arch/arm64/boot/Image
    echo "dummy" > ${WORKDIR}/kernel/dummy.dtb

    # Generate configure
    (cd ${S} && autoreconf -i || exit 1)
}

do_compile[noexec] = "1"
do_install[noexec] = "1"

# We need the kernel to create an image
do_deploy[depends] += "virtual/kernel:do_deploy"

do_deploy() {
    if [ ! -f ${DEPLOY_DIR_IMAGE}/${REAL_DTB} ]; then
        echo "ERROR: cannot find ${REAL_DTB} in ${DEPLOY_DIR_IMAGE}" >&2
        echo "Please check your BOOT_WRAPPER_AARCH64_DEVICETREE settings" >&2
        exit 1
    fi

    if [ ! -f ${DEPLOY_DIR_IMAGE}/${BOOT_WRAPPER_AARCH64_KERNEL} ]; then
        echo "ERROR: cannot find ${BOOT_WRAPPER_AARCH64_KERNEL}" \
            " in ${DEPLOY_DIR_IMAGE}" >&2
        echo "Please check your BOOT_WRAPPER_AARCH64_KERNEL settings" >&2
        exit 1
    fi

    oe_runmake clean
    oe_runmake all

    install -D -p -m 644 ${BOOT_WRAPPER_AARCH64_IMAGE} \
        ${DEPLOYDIR}/linux-system.axf
}
addtask deploy before do_build after do_compile