blob: 19de5d2c612e7ab0f8e57a0e83be0823d3cbfd21 [file] [log] [blame]
Andrew Geissleree5626e2020-04-29 10:53:34 -05001SUMMARY = "Universal Boot Loader for embedded devices"
2PROVIDES = "virtual/bootloader"
3
4B = "${WORKDIR}/build"
5
6PACKAGE_ARCH = "${MACHINE_ARCH}"
7
8DEPENDS += "kern-tools-native"
9
Andrew Geissler6dc303a2020-04-29 11:11:19 -050010inherit uboot-config uboot-extlinux-config uboot-sign deploy cml1 python3native
Andrew Geissleree5626e2020-04-29 10:53:34 -050011
Andrew Geissler6dc303a2020-04-29 11:11:19 -050012DEPENDS += "swig-native"
Andrew Geissleree5626e2020-04-29 10:53:34 -050013
14EXTRA_OEMAKE = 'CROSS_COMPILE=${TARGET_PREFIX} CC="${TARGET_PREFIX}gcc ${TOOLCHAIN_OPTIONS}" V=1'
15EXTRA_OEMAKE += 'HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}"'
Andrew Geissler6dc303a2020-04-29 11:11:19 -050016EXTRA_OEMAKE += 'STAGING_INCDIR=${STAGING_INCDIR_NATIVE} STAGING_LIBDIR=${STAGING_LIBDIR_NATIVE}'
Andrew Geissleree5626e2020-04-29 10:53:34 -050017
18PACKAGECONFIG ??= "openssl"
19# u-boot will compile its own tools during the build, with specific
20# configurations (aka when CONFIG_FIT_SIGNATURE is enabled) openssl is needed as
21# a host build dependency.
22PACKAGECONFIG[openssl] = ",,openssl-native"
23
24# Allow setting an additional version string that will be picked up by the
25# u-boot build system and appended to the u-boot version. If the .scmversion
26# file already exists it will not be overwritten.
27UBOOT_LOCALVERSION ?= ""
28
Andrew Geissleree5626e2020-04-29 10:53:34 -050029# returns all the elements from the src uri that are .cfg files
30def find_cfgs(d):
31 sources=src_patches(d, True)
32 sources_list=[]
33 for s in sources:
34 if s.endswith('.cfg'):
35 sources_list.append(s)
36
37 return sources_list
38
39do_configure () {
40 if [ -z "${UBOOT_CONFIG}" ]; then
41 if [ -n "${UBOOT_MACHINE}" ]; then
42 oe_runmake -C ${S} O=${B} ${UBOOT_MACHINE}
43 else
44 oe_runmake -C ${S} O=${B} oldconfig
45 fi
46 merge_config.sh -m .config ${@" ".join(find_cfgs(d))}
47 cml1_do_configure
48 fi
49}
50
51do_compile () {
52 if [ "${@bb.utils.filter('DISTRO_FEATURES', 'ld-is-gold', d)}" ]; then
53 sed -i 's/$(CROSS_COMPILE)ld$/$(CROSS_COMPILE)ld.bfd/g' ${S}/config.mk
54 fi
55
56 unset LDFLAGS
57 unset CFLAGS
58 unset CPPFLAGS
59
60 if [ ! -e ${B}/.scmversion -a ! -e ${S}/.scmversion ]
61 then
62 echo ${UBOOT_LOCALVERSION} > ${B}/.scmversion
63 echo ${UBOOT_LOCALVERSION} > ${S}/.scmversion
64 fi
65
66 if [ -n "${UBOOT_CONFIG}" ]
67 then
68 unset i j k
69 for config in ${UBOOT_MACHINE}; do
70 i=$(expr $i + 1);
71 for type in ${UBOOT_CONFIG}; do
72 j=$(expr $j + 1);
73 if [ $j -eq $i ]
74 then
75 oe_runmake -C ${S} O=${B}/${config} ${config}
76 oe_runmake -C ${S} O=${B}/${config} ${UBOOT_MAKE_TARGET}
77 for binary in ${UBOOT_BINARIES}; do
78 k=$(expr $k + 1);
79 if [ $k -eq $i ]; then
80 cp ${B}/${config}/${binary} ${B}/${config}/u-boot-${type}.${UBOOT_SUFFIX}
81 fi
82 done
83 unset k
84 fi
85 done
86 unset j
87 done
88 unset i
89 else
90 oe_runmake -C ${S} O=${B} ${UBOOT_MAKE_TARGET}
91 fi
92
93}
94
95do_install () {
96 if [ -n "${UBOOT_CONFIG}" ]
97 then
98 for config in ${UBOOT_MACHINE}; do
99 i=$(expr $i + 1);
100 for type in ${UBOOT_CONFIG}; do
101 j=$(expr $j + 1);
102 if [ $j -eq $i ]
103 then
104 install -d ${D}/boot
105 install -m 644 ${B}/${config}/u-boot-${type}.${UBOOT_SUFFIX} ${D}/boot/u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX}
106 ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${D}/boot/${UBOOT_BINARY}-${type}
107 ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${D}/boot/${UBOOT_BINARY}
108 fi
109 done
110 unset j
111 done
112 unset i
113 else
114 install -d ${D}/boot
115 install -m 644 ${B}/${UBOOT_BINARY} ${D}/boot/${UBOOT_IMAGE}
116 ln -sf ${UBOOT_IMAGE} ${D}/boot/${UBOOT_BINARY}
117 fi
118
119 if [ -n "${UBOOT_ELF}" ]
120 then
121 if [ -n "${UBOOT_CONFIG}" ]
122 then
123 for config in ${UBOOT_MACHINE}; do
124 i=$(expr $i + 1);
125 for type in ${UBOOT_CONFIG}; do
126 j=$(expr $j + 1);
127 if [ $j -eq $i ]
128 then
129 install -m 644 ${B}/${config}/${UBOOT_ELF} ${D}/boot/u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX}
130 ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} ${D}/boot/${UBOOT_BINARY}-${type}
131 ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} ${D}/boot/${UBOOT_BINARY}
132 fi
133 done
134 unset j
135 done
136 unset i
137 else
138 install -m 644 ${B}/${UBOOT_ELF} ${D}/boot/${UBOOT_ELF_IMAGE}
139 ln -sf ${UBOOT_ELF_IMAGE} ${D}/boot/${UBOOT_ELF_BINARY}
140 fi
141 fi
142
143 if [ -e ${WORKDIR}/fw_env.config ] ; then
144 install -d ${D}${sysconfdir}
145 install -m 644 ${WORKDIR}/fw_env.config ${D}${sysconfdir}/fw_env.config
146 fi
147
148 if [ -n "${SPL_BINARY}" ]
149 then
150 if [ -n "${UBOOT_CONFIG}" ]
151 then
152 for config in ${UBOOT_MACHINE}; do
153 i=$(expr $i + 1);
154 for type in ${UBOOT_CONFIG}; do
155 j=$(expr $j + 1);
156 if [ $j -eq $i ]
157 then
158 install -m 644 ${B}/${config}/${SPL_BINARY} ${D}/boot/${SPL_IMAGE}-${type}-${PV}-${PR}
159 ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${D}/boot/${SPL_BINARYNAME}-${type}
160 ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${D}/boot/${SPL_BINARYNAME}
161 fi
162 done
163 unset j
164 done
165 unset i
166 else
167 install -m 644 ${B}/${SPL_BINARY} ${D}/boot/${SPL_IMAGE}
168 ln -sf ${SPL_IMAGE} ${D}/boot/${SPL_BINARYNAME}
169 fi
170 fi
171
172 if [ -n "${UBOOT_ENV}" ]
173 then
174 install -m 644 ${WORKDIR}/${UBOOT_ENV_BINARY} ${D}/boot/${UBOOT_ENV_IMAGE}
175 ln -sf ${UBOOT_ENV_IMAGE} ${D}/boot/${UBOOT_ENV_BINARY}
176 fi
177
178 if [ "${UBOOT_EXTLINUX}" = "1" ]
179 then
180 install -Dm 0644 ${UBOOT_EXTLINUX_CONFIG} ${D}/${UBOOT_EXTLINUX_INSTALL_DIR}/${UBOOT_EXTLINUX_CONF_NAME}
181 fi
182
183}
184
Patrick Williamsb9799be2021-08-06 09:13:33 -0500185FILES:${PN} = "/boot ${sysconfdir} ${datadir}"
Andrew Geissleree5626e2020-04-29 10:53:34 -0500186
187do_deploy () {
188 if [ -n "${UBOOT_CONFIG}" ]
189 then
190 for config in ${UBOOT_MACHINE}; do
191 i=$(expr $i + 1);
192 for type in ${UBOOT_CONFIG}; do
193 j=$(expr $j + 1);
194 if [ $j -eq $i ]
195 then
196 install -d ${DEPLOYDIR}
197 install -m 644 ${B}/${config}/u-boot-${type}.${UBOOT_SUFFIX} ${DEPLOYDIR}/u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX}
198 cd ${DEPLOYDIR}
199 ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${UBOOT_SYMLINK}-${type}
200 ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${UBOOT_SYMLINK}
201 ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${UBOOT_BINARY}-${type}
202 ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${UBOOT_BINARY}
203 fi
204 done
205 unset j
206 done
207 unset i
208 else
209 install -d ${DEPLOYDIR}
210 install -m 644 ${B}/${UBOOT_BINARY} ${DEPLOYDIR}/${UBOOT_IMAGE}
211 cd ${DEPLOYDIR}
212 rm -f ${UBOOT_BINARY} ${UBOOT_SYMLINK}
213 ln -sf ${UBOOT_IMAGE} ${UBOOT_SYMLINK}
214 ln -sf ${UBOOT_IMAGE} ${UBOOT_BINARY}
215 fi
216
217 if [ -n "${UBOOT_ELF}" ]
218 then
219 if [ -n "${UBOOT_CONFIG}" ]
220 then
221 for config in ${UBOOT_MACHINE}; do
222 i=$(expr $i + 1);
223 for type in ${UBOOT_CONFIG}; do
224 j=$(expr $j + 1);
225 if [ $j -eq $i ]
226 then
227 install -m 644 ${B}/${config}/${UBOOT_ELF} ${DEPLOYDIR}/u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX}
228 ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} ${DEPLOYDIR}/${UBOOT_ELF_BINARY}-${type}
229 ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} ${DEPLOYDIR}/${UBOOT_ELF_BINARY}
230 ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} ${DEPLOYDIR}/${UBOOT_ELF_SYMLINK}-${type}
231 ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} ${DEPLOYDIR}/${UBOOT_ELF_SYMLINK}
232 fi
233 done
234 unset j
235 done
236 unset i
237 else
238 install -m 644 ${B}/${UBOOT_ELF} ${DEPLOYDIR}/${UBOOT_ELF_IMAGE}
239 ln -sf ${UBOOT_ELF_IMAGE} ${DEPLOYDIR}/${UBOOT_ELF_BINARY}
240 ln -sf ${UBOOT_ELF_IMAGE} ${DEPLOYDIR}/${UBOOT_ELF_SYMLINK}
241 fi
242 fi
243
244
245 if [ -n "${SPL_BINARY}" ]
246 then
247 if [ -n "${UBOOT_CONFIG}" ]
248 then
249 for config in ${UBOOT_MACHINE}; do
250 i=$(expr $i + 1);
251 for type in ${UBOOT_CONFIG}; do
252 j=$(expr $j + 1);
253 if [ $j -eq $i ]
254 then
255 install -m 644 ${B}/${config}/${SPL_BINARY} ${DEPLOYDIR}/${SPL_IMAGE}-${type}-${PV}-${PR}
256 rm -f ${DEPLOYDIR}/${SPL_BINARYNAME} ${DEPLOYDIR}/${SPL_SYMLINK}-${type}
257 ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${DEPLOYDIR}/${SPL_BINARYNAME}-${type}
258 ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${DEPLOYDIR}/${SPL_BINARYNAME}
259 ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${DEPLOYDIR}/${SPL_SYMLINK}-${type}
260 ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${DEPLOYDIR}/${SPL_SYMLINK}
261 fi
262 done
263 unset j
264 done
265 unset i
266 else
267 install -m 644 ${B}/${SPL_BINARY} ${DEPLOYDIR}/${SPL_IMAGE}
268 rm -f ${DEPLOYDIR}/${SPL_BINARYNAME} ${DEPLOYDIR}/${SPL_SYMLINK}
269 ln -sf ${SPL_IMAGE} ${DEPLOYDIR}/${SPL_BINARYNAME}
270 ln -sf ${SPL_IMAGE} ${DEPLOYDIR}/${SPL_SYMLINK}
271 fi
272 fi
273
274
275 if [ -n "${UBOOT_ENV}" ]
276 then
277 install -m 644 ${WORKDIR}/${UBOOT_ENV_BINARY} ${DEPLOYDIR}/${UBOOT_ENV_IMAGE}
278 rm -f ${DEPLOYDIR}/${UBOOT_ENV_BINARY} ${DEPLOYDIR}/${UBOOT_ENV_SYMLINK}
279 ln -sf ${UBOOT_ENV_IMAGE} ${DEPLOYDIR}/${UBOOT_ENV_BINARY}
280 ln -sf ${UBOOT_ENV_IMAGE} ${DEPLOYDIR}/${UBOOT_ENV_SYMLINK}
281 fi
282
283 if [ "${UBOOT_EXTLINUX}" = "1" ]
284 then
285 install -m 644 ${UBOOT_EXTLINUX_CONFIG} ${DEPLOYDIR}/${UBOOT_EXTLINUX_SYMLINK}
286 ln -sf ${UBOOT_EXTLINUX_SYMLINK} ${DEPLOYDIR}/${UBOOT_EXTLINUX_CONF_NAME}-${MACHINE}
287 ln -sf ${UBOOT_EXTLINUX_SYMLINK} ${DEPLOYDIR}/${UBOOT_EXTLINUX_CONF_NAME}
288 fi
289}
290
291addtask deploy before do_build after do_compile