diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-08-10 14:35:29 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-08-12 15:27:17 +0100 |
commit | fd1517e2b51a170f2427122c6b95396db251d827 (patch) | |
tree | dabfe3e631339c2fc99a9ee7febb0f9c128e325e /meta/classes-recipe/uboot-config.bbclass | |
parent | 10317912ee319ccf7f83605d438b5cbf9663f296 (diff) | |
download | poky-fd1517e2b51a170f2427122c6b95396db251d827.tar.gz |
classes: Update classes to match new bitbake class scope functionality
Move classes to classes-global or classes-recipe as appropriate to take
advantage of new bitbake functionality to check class scope/usage.
(From OE-Core rev: f5c128008365e141082c129417eb72d2751e8045)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes-recipe/uboot-config.bbclass')
-rw-r--r-- | meta/classes-recipe/uboot-config.bbclass | 133 |
1 files changed, 133 insertions, 0 deletions
diff --git a/meta/classes-recipe/uboot-config.bbclass b/meta/classes-recipe/uboot-config.bbclass new file mode 100644 index 0000000000..9889d026fa --- /dev/null +++ b/meta/classes-recipe/uboot-config.bbclass | |||
@@ -0,0 +1,133 @@ | |||
1 | # Handle U-Boot config for a machine | ||
2 | # | ||
3 | # The format to specify it, in the machine, is: | ||
4 | # | ||
5 | # UBOOT_CONFIG ??= <default> | ||
6 | # UBOOT_CONFIG[foo] = "config,images,binary" | ||
7 | # | ||
8 | # or | ||
9 | # | ||
10 | # UBOOT_MACHINE = "config" | ||
11 | # | ||
12 | # Copyright 2013, 2014 (C) O.S. Systems Software LTDA. | ||
13 | # | ||
14 | # SPDX-License-Identifier: MIT | ||
15 | |||
16 | |||
17 | def removesuffix(s, suffix): | ||
18 | if suffix and s.endswith(suffix): | ||
19 | return s[:-len(suffix)] | ||
20 | return s | ||
21 | |||
22 | # Some versions of u-boot use .bin and others use .img. By default use .bin | ||
23 | # but enable individual recipes to change this value. | ||
24 | UBOOT_SUFFIX ??= "bin" | ||
25 | UBOOT_BINARY ?= "u-boot.${UBOOT_SUFFIX}" | ||
26 | UBOOT_BINARYNAME ?= "${@os.path.splitext(d.getVar("UBOOT_BINARY"))[0]}" | ||
27 | UBOOT_IMAGE ?= "${UBOOT_BINARYNAME}-${MACHINE}-${PV}-${PR}.${UBOOT_SUFFIX}" | ||
28 | UBOOT_SYMLINK ?= "${UBOOT_BINARYNAME}-${MACHINE}.${UBOOT_SUFFIX}" | ||
29 | UBOOT_MAKE_TARGET ?= "all" | ||
30 | |||
31 | # Output the ELF generated. Some platforms can use the ELF file and directly | ||
32 | # load it (JTAG booting, QEMU) additionally the ELF can be used for debugging | ||
33 | # purposes. | ||
34 | UBOOT_ELF ?= "" | ||
35 | UBOOT_ELF_SUFFIX ?= "elf" | ||
36 | UBOOT_ELF_IMAGE ?= "u-boot-${MACHINE}-${PV}-${PR}.${UBOOT_ELF_SUFFIX}" | ||
37 | UBOOT_ELF_BINARY ?= "u-boot.${UBOOT_ELF_SUFFIX}" | ||
38 | UBOOT_ELF_SYMLINK ?= "u-boot-${MACHINE}.${UBOOT_ELF_SUFFIX}" | ||
39 | |||
40 | # Some versions of u-boot build an SPL (Second Program Loader) image that | ||
41 | # should be packaged along with the u-boot binary as well as placed in the | ||
42 | # deploy directory. For those versions they can set the following variables | ||
43 | # to allow packaging the SPL. | ||
44 | SPL_SUFFIX ?= "" | ||
45 | SPL_BINARY ?= "" | ||
46 | SPL_DELIMITER ?= "${@'.' if d.getVar("SPL_SUFFIX") else ''}" | ||
47 | SPL_BINARYFILE ?= "${@os.path.basename(d.getVar("SPL_BINARY"))}" | ||
48 | SPL_BINARYNAME ?= "${@removesuffix(d.getVar("SPL_BINARYFILE"), "." + d.getVar("SPL_SUFFIX"))}" | ||
49 | SPL_IMAGE ?= "${SPL_BINARYNAME}-${MACHINE}-${PV}-${PR}${SPL_DELIMITER}${SPL_SUFFIX}" | ||
50 | SPL_SYMLINK ?= "${SPL_BINARYNAME}-${MACHINE}${SPL_DELIMITER}${SPL_SUFFIX}" | ||
51 | |||
52 | # Additional environment variables or a script can be installed alongside | ||
53 | # u-boot to be used automatically on boot. This file, typically 'uEnv.txt' | ||
54 | # or 'boot.scr', should be packaged along with u-boot as well as placed in the | ||
55 | # deploy directory. Machine configurations needing one of these files should | ||
56 | # include it in the SRC_URI and set the UBOOT_ENV parameter. | ||
57 | UBOOT_ENV_SUFFIX ?= "txt" | ||
58 | UBOOT_ENV ?= "" | ||
59 | UBOOT_ENV_SRC_SUFFIX ?= "cmd" | ||
60 | UBOOT_ENV_SRC ?= "${UBOOT_ENV}.${UBOOT_ENV_SRC_SUFFIX}" | ||
61 | UBOOT_ENV_BINARY ?= "${UBOOT_ENV}.${UBOOT_ENV_SUFFIX}" | ||
62 | UBOOT_ENV_IMAGE ?= "${UBOOT_ENV}-${MACHINE}-${PV}-${PR}.${UBOOT_ENV_SUFFIX}" | ||
63 | UBOOT_ENV_SYMLINK ?= "${UBOOT_ENV}-${MACHINE}.${UBOOT_ENV_SUFFIX}" | ||
64 | |||
65 | # Default name of u-boot initial env, but enable individual recipes to change | ||
66 | # this value. | ||
67 | UBOOT_INITIAL_ENV ?= "${PN}-initial-env" | ||
68 | |||
69 | # U-Boot EXTLINUX variables. U-Boot searches for /boot/extlinux/extlinux.conf | ||
70 | # to find EXTLINUX conf file. | ||
71 | UBOOT_EXTLINUX_INSTALL_DIR ?= "/boot/extlinux" | ||
72 | UBOOT_EXTLINUX_CONF_NAME ?= "extlinux.conf" | ||
73 | UBOOT_EXTLINUX_SYMLINK ?= "${UBOOT_EXTLINUX_CONF_NAME}-${MACHINE}-${PR}" | ||
74 | |||
75 | # Options for the device tree compiler passed to mkimage '-D' feature: | ||
76 | UBOOT_MKIMAGE_DTCOPTS ??= "" | ||
77 | SPL_MKIMAGE_DTCOPTS ??= "" | ||
78 | |||
79 | # mkimage command | ||
80 | UBOOT_MKIMAGE ?= "uboot-mkimage" | ||
81 | UBOOT_MKIMAGE_SIGN ?= "${UBOOT_MKIMAGE}" | ||
82 | |||
83 | # Arguments passed to mkimage for signing | ||
84 | UBOOT_MKIMAGE_SIGN_ARGS ?= "" | ||
85 | SPL_MKIMAGE_SIGN_ARGS ?= "" | ||
86 | |||
87 | # Options to deploy the u-boot device tree | ||
88 | UBOOT_DTB ?= "" | ||
89 | UBOOT_DTB_BINARY ??= "" | ||
90 | |||
91 | python () { | ||
92 | ubootmachine = d.getVar("UBOOT_MACHINE") | ||
93 | ubootconfigflags = d.getVarFlags('UBOOT_CONFIG') | ||
94 | ubootbinary = d.getVar('UBOOT_BINARY') | ||
95 | ubootbinaries = d.getVar('UBOOT_BINARIES') | ||
96 | # The "doc" varflag is special, we don't want to see it here | ||
97 | ubootconfigflags.pop('doc', None) | ||
98 | ubootconfig = (d.getVar('UBOOT_CONFIG') or "").split() | ||
99 | |||
100 | if not ubootmachine and not ubootconfig: | ||
101 | PN = d.getVar("PN") | ||
102 | FILE = os.path.basename(d.getVar("FILE")) | ||
103 | bb.debug(1, "To build %s, see %s for instructions on \ | ||
104 | setting up your machine config" % (PN, FILE)) | ||
105 | raise bb.parse.SkipRecipe("Either UBOOT_MACHINE or UBOOT_CONFIG must be set in the %s machine configuration." % d.getVar("MACHINE")) | ||
106 | |||
107 | if ubootmachine and ubootconfig: | ||
108 | raise bb.parse.SkipRecipe("You cannot use UBOOT_MACHINE and UBOOT_CONFIG at the same time.") | ||
109 | |||
110 | if ubootconfigflags and ubootbinaries: | ||
111 | raise bb.parse.SkipRecipe("You cannot use UBOOT_BINARIES as it is internal to uboot_config.bbclass.") | ||
112 | |||
113 | if len(ubootconfig) > 0: | ||
114 | for config in ubootconfig: | ||
115 | for f, v in ubootconfigflags.items(): | ||
116 | if config == f: | ||
117 | items = v.split(',') | ||
118 | if items[0] and len(items) > 3: | ||
119 | raise bb.parse.SkipRecipe('Only config,images,binary can be specified!') | ||
120 | d.appendVar('UBOOT_MACHINE', ' ' + items[0]) | ||
121 | # IMAGE_FSTYPES appending | ||
122 | if len(items) > 1 and items[1]: | ||
123 | bb.debug(1, "Appending '%s' to IMAGE_FSTYPES." % items[1]) | ||
124 | d.appendVar('IMAGE_FSTYPES', ' ' + items[1]) | ||
125 | if len(items) > 2 and items[2]: | ||
126 | bb.debug(1, "Appending '%s' to UBOOT_BINARIES." % items[2]) | ||
127 | d.appendVar('UBOOT_BINARIES', ' ' + items[2]) | ||
128 | else: | ||
129 | bb.debug(1, "Appending '%s' to UBOOT_BINARIES." % ubootbinary) | ||
130 | d.appendVar('UBOOT_BINARIES', ' ' + ubootbinary) | ||
131 | return | ||
132 | raise bb.parse.SkipRecipe("The selected UBOOT_CONFIG key %s has no match in %s." % (ubootconfig, ubootconfigflags.keys())) | ||
133 | } | ||