summaryrefslogtreecommitdiff
path: root/distribution/yocto-advanced/meta-schulung-extended/recipes-bsp/boot/qemu-boot-files.bb
blob: e885d2573530dd58830d631b5bc13b9d8c3a9820 (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
# specify build dependencies
DEPENDS += "linux-basic"
DEPENDS += "u-boot"
DEPENDS += "u-boot-mkimage-native"
DEPENDS += "keys-native"

# fit image configuration file
SRC_URI = "file://signed-config.its"

# license information
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

# create signed fit image for kernel/devicetree and uimage for qemu booting
do_compile () {
	# extract TEXT_BASE from u-boot configuration
	TEXT_BASE=`grep CONFIG_SYS_TEXT_BASE \
		${PKG_CONFIG_SYSROOT_DIR}${datadir}/u-boot/u-boot.cfg | \
		awk '{print $3}'`

	cp ${DEPLOY_DIR_IMAGE}/devicetree-${DTB} dtb
	cp ${DEPLOY_DIR_IMAGE}/zImage .
	cp ${WORKDIR}/signed-config.its .

	# create fit image with signed configuration
	# and update the dtb to contain the public key
	uboot-mkimage -f signed-config.its \
		-k ${STAGING_DIR_NATIVE}${datadir_native}/keys \
		-K dtb -r image.fit

	# create the final u-boot image by appending the new dtb
	cat ${DEPLOY_DIR_IMAGE}/u-boot-nodtb.bin dtb > u-boot-dtb.bin

	# pack u-boot into a uimage file so we can
	# trick qemu into booting u-boot
	uboot-mkimage -A ${HOST_ARCH} -C none -T kernel -O linux \
		-d u-boot-dtb.bin -a $TEXT_BASE -e $TEXT_BASE u-boot.uimg
}

# specify task dependencies for compiling
# - bitbake only knows about dependencies that are specified
#   otherwise it assumes it can do things in parallel
# - the build dependencies ${DEPEND} only create a task dependency
#   on do_install (do_deploy comes after do_install)
# - for linux-basic and u-boot-sample we need to wait for do_deploy
#   to complete because our do_compile uses their deployed files
do_compile[depends] += "linux-basic:do_deploy"
do_compile[depends] += "u-boot:do_deploy"

# use the deploy class (poky/meta/deploy.bbclass)
# - this officially creates a deploy task
# - this creates and sets ${DEPLOYDIR}
inherit deploy

# deploy fit image (kernel/devicetree) and uimage (u-boot)
do_deploy () {
	install -D -m 0644 image.fit ${DEPLOYDIR}/image.fit
	install -D -m 0644 u-boot.uimg ${DEPLOYDIR}/u-boot.uimg
}

# set do_deploy to occur after do_install
addtask do_deploy after do_install