diff options
author | Andrey Zhizhikin <andrey.z@gmail.com> | 2021-03-03 16:33:33 +0000 |
---|---|---|
committer | Otavio Salvador <otavio@ossystems.com.br> | 2021-03-17 10:53:42 -0300 |
commit | 2bc347d473ec9545e761fa06205727a825b446d0 (patch) | |
tree | 9df92f007b142770da98b49ff6c7c250bf7d2190 | |
parent | badc0f6a1b278c1d7012556efa78aefcdd80ed68 (diff) | |
download | meta-freescale-2bc347d473ec9545e761fa06205727a825b446d0.tar.gz |
classes: imx-boot-container: add class to provide boot container
Add a class which extends the u-boot build mechanism with providing a
separate "flash.bin" binary that replaces the imx-boot in the WIC file.
This class is inherited in u-boot-fslc recipe and extends it only to
those machines that have a corresponding "imx-boot-container" machine
override set.
Signed-off-by: Andrey Zhizhikin <andrey.z@gmail.com>
-rw-r--r-- | classes/imx-boot-container.bbclass | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/classes/imx-boot-container.bbclass b/classes/imx-boot-container.bbclass new file mode 100644 index 00000000..003f997a --- /dev/null +++ b/classes/imx-boot-container.bbclass | |||
@@ -0,0 +1,107 @@ | |||
1 | # | ||
2 | # This class provides a support to build the boot container for | ||
3 | # i.MX8M derivatives | ||
4 | # | ||
5 | # imx8m machines require a separate build target to be executed | ||
6 | # due to the fact that final boot image is constructed using flash.bin | ||
7 | # taget. It produces a boot binary image, which is constructed from | ||
8 | # various binary components (u-boot with separate dtb, atf, DDR | ||
9 | # firmware and optional op-tee) into a single image using FIT format. | ||
10 | # This flash.bin file is then parsed and loaded either via | ||
11 | # SPL directly (imx8mm), or using bootrom code (imx8mn and imx8mp). | ||
12 | # | ||
13 | # In order to use flash.bin binary boot image, it is required that | ||
14 | # the U-Boot build is to be invoked for an additional build target. | ||
15 | # This class extendes the U-Boot build targets with the "flash.bin", | ||
16 | # which effectively serves as a boot container. It replaces the boot | ||
17 | # container `imx-boot` provided by NXP. | ||
18 | # | ||
19 | # Class inheritance is performed in u-boot-fslc recipe, and is controlled | ||
20 | # by variable UBOOT_PROVIDES_BOOT_CONTAINER, which is defined in the | ||
21 | # base machine include file (imx-base.inc), and is set to "1" when the | ||
22 | # 'imx-boot-container' is present in MACHINEOVERRIDES. | ||
23 | |||
24 | # Extend the UBOOT_MAKE_TARGET with additional target for U-Boot build | ||
25 | # system to produce the boot container | ||
26 | UBOOT_MAKE_TARGET += "flash.bin" | ||
27 | |||
28 | # Define ATF binary file to be deployed to the U-Boot build folder | ||
29 | ATF_MACHINE_NAME = "bl31-${ATF_PLATFORM}.bin" | ||
30 | ATF_MACHINE_NAME_append = "${@bb.utils.contains('MACHINE_FEATURES', 'optee', '-optee', '', d)}" | ||
31 | |||
32 | # This package aggregates output deployed by other packages, so set the | ||
33 | # appropriate dependencies for populate binaries task | ||
34 | do_resolve_and_populate_binaries[depends] += " \ | ||
35 | ${@' '.join('%s:do_deploy' % r for r in '${IMX_EXTRA_FIRMWARE}'.split() )} \ | ||
36 | imx-atf:do_deploy \ | ||
37 | ${@bb.utils.contains('MACHINE_FEATURES', 'optee', 'optee-os:do_deploy', '', d)} \ | ||
38 | " | ||
39 | |||
40 | # Append make flags to include ATF load address | ||
41 | EXTRA_OEMAKE += "ATF_LOAD_ADDR=${ATF_LOAD_ADDR}" | ||
42 | |||
43 | # Define an additional task that collects binary output from dependent packages | ||
44 | # and deploys them into the U-Boot build folder | ||
45 | do_resolve_and_populate_binaries() { | ||
46 | if [ ! -n "${ATF_LOAD_ADDR}" ]; then | ||
47 | bberror "ATF_LOAD_ADDR is undefined, result binary would be unusable!" | ||
48 | fi | ||
49 | |||
50 | if [ -n "${UBOOT_CONFIG}" ]; then | ||
51 | for config in ${UBOOT_MACHINE}; do | ||
52 | i=$(expr $i + 1); | ||
53 | for type in ${UBOOT_CONFIG}; do | ||
54 | j=$(expr $j + 1); | ||
55 | if [ $j -eq $i ]; then | ||
56 | for ddr_firmware in ${DDR_FIRMWARE_NAME}; do | ||
57 | # Sanitize the FW name as U-Boot expects it to be without version | ||
58 | if [ -n "${DDR_FIRMWARE_VERSION}" ]; then | ||
59 | ddr_firmware_name=$(echo $ddr_firmware | sed s/_${DDR_FIRMWARE_VERSION}//) | ||
60 | else | ||
61 | ddr_firmware_name="$ddr_firmware" | ||
62 | fi | ||
63 | bbnote "Copy ddr_firmware: ${ddr_firmware} from ${DEPLOY_DIR_IMAGE} -> ${B}/${config}/${ddr_firmware_name}" | ||
64 | cp ${DEPLOY_DIR_IMAGE}/${ddr_firmware} ${B}/${config}/${ddr_firmware_name} | ||
65 | done | ||
66 | if [ -n "${ATF_MACHINE_NAME}" ]; then | ||
67 | cp ${DEPLOY_DIR_IMAGE}/${BOOT_TOOLS}/${ATF_MACHINE_NAME} ${B}/${config}/bl31.bin | ||
68 | else | ||
69 | bberror "ATF binary is undefined, result binary would be unusable!" | ||
70 | fi | ||
71 | fi | ||
72 | done | ||
73 | unset j | ||
74 | done | ||
75 | unset i | ||
76 | fi | ||
77 | } | ||
78 | addtask do_resolve_and_populate_binaries before do_compile after do_configure | ||
79 | |||
80 | # Append the u-boot do_deploy task to deploy also the result flash.bin | ||
81 | # boot container as a replacement for the one provided by NXP BSP. | ||
82 | # | ||
83 | # Deploy task renames the target file from flash.bin to imx-boot to match | ||
84 | # the name WKS file requires. | ||
85 | # | ||
86 | # This effectively would allow the usage of the same WKS file for those | ||
87 | # derivatives that are using the boot container from U-Boot and those | ||
88 | # that are not yet have support for it enabled. | ||
89 | do_deploy_append() { | ||
90 | # Deploy the resulted flash.bin for WIC to pick it up | ||
91 | if [ -n "${UBOOT_CONFIG}" ]; then | ||
92 | for config in ${UBOOT_MACHINE}; do | ||
93 | i=$(expr $i + 1); | ||
94 | for type in ${UBOOT_CONFIG}; do | ||
95 | j=$(expr $j + 1); | ||
96 | if [ $j -eq $i ] | ||
97 | then | ||
98 | install -m 0644 ${B}/${config}/flash.bin ${DEPLOYDIR}/flash.bin-${MACHINE}-${UBOOT_CONFIG} | ||
99 | ln -sf flash.bin-${MACHINE}-${UBOOT_CONFIG} imx-boot | ||
100 | ln -sf flash.bin-${MACHINE}-${UBOOT_CONFIG} flash.bin | ||
101 | fi | ||
102 | done | ||
103 | unset j | ||
104 | done | ||
105 | unset i | ||
106 | fi | ||
107 | } | ||