summaryrefslogtreecommitdiffstats
path: root/meta-xilinx-core/recipes-bsp/embeddedsw/fsbl.bb
blob: 68cfeb22b58d843d100060d31707504433f5d54d (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
DESCRIPTION = "Xilinx First Stage Boot Loader"

LICENSE = "CLOSED"

PROVIDES = "virtual/fsbl"

INHERIT_DEFAULT_DEPENDS = "1"

COMPATIBLE_MACHINE = "^$"
COMPATIBLE_MACHINE:zynq = "zynq"
COMPATIBLE_MACHINE:zynqmp = "zynqmp"

# Since we're just copying, we can run any config
COMPATIBLE_HOST = ".*"

PACKAGE_ARCH = "${MACHINE_ARCH}"

# Default expects the user to provide the fsbl in the deploy
# directory, named "fsbl.elf"
# A machine, multiconfig, or local.conf should override this
FSBL_DEPENDS ??= ""
FSBL_MCDEPENDS ??= ""
FSBL_DEPLOY_DIR ??= "${DEPLOY_DIR_IMAGE}"
FSBL_DEPLOY_DIR[vardepsexclude] += "TOPDIR"
FSBL_IMAGE_NAME ??= "fsbl-${MACHINE}"

# Default is for the multilib case (without the extension .elf)
FSBL_FILE ??= "${FSBL_DEPLOY_DIR}/${FSBL_IMAGE_NAME}"
FSBL_FILE[vardepsexclude] = "FSBL_DEPLOY_DIR"

do_fetch[depends] += "${FSBL_DEPENDS}"
do_fetch[mcdepends] += "${FSBL_MCDEPENDS}"

inherit deploy

do_install() {
    if [ ! -e ${FSBL_FILE}.elf ]; then
        echo "Unable to find FSBL_FILE (${FSBL_FILE}.elf)"
        exit 1
    fi

    install -Dm 0644 ${FSBL_FILE}.elf ${D}/boot/${PN}.elf
}

# If the item is already in OUR deploy_image_dir, nothing to deploy!
SHOULD_DEPLOY = "${@'false' if (d.getVar('FSBL_FILE')).startswith(d.getVar('DEPLOY_DIR_IMAGE')) else 'true'}"
do_deploy() {
    # If the item is already in OUR deploy_image_dir, nothing to deploy!
    if ${SHOULD_DEPLOY}; then
        install -Dm 0644 ${FSBL_FILE}.elf ${DEPLOYDIR}/${FSBL_IMAGE_NAME}.elf
    fi
}

addtask deploy before do_build after do_install

INSANE_SKIP:${PN} = "arch"
INSANE_SKIP:${PN}-dbg = "arch"

SYSROOT_DIRS += "/boot"
FILES:${PN} = "/boot/${PN}.elf"

def check_fsbl_variables(d):
    # If both are blank, the user MUST pass in the path to the firmware!
    if not d.getVar('FSBL_DEPENDS') and not d.getVar('FSBL_MCDEPENDS'):
        # Don't cache this, as the items on disk can change!
        d.setVar('BB_DONT_CACHE', '1')

        if not os.path.exists(d.getVar('FSBL_FILE') + ".elf"):
            if not d.getVar('WITHIN_EXT_SDK'):
                raise bb.parse.SkipRecipe("The expect file %s.elf is not available.\nSet FSBL_FILE to the path with a precompiled FSBL binary. See the meta-xilinx-core README for more information." % d.getVar('FSBL_FILE'))
        else:
            # We found the file, so be sure to track it
            d.setVar('SRC_URI', 'file://${FSBL_FILE}.elf')
            d.setVarFlag('do_install', 'file-checksums', '${FSBL_FILE}.elf:True')
            d.setVarFlag('do_deploy', 'file-checksums', '${FSBL_FILE}.elf:True')

python() {
    # Need to allow bbappends to change the check
    check_fsbl_variables(d)
}