summaryrefslogtreecommitdiffstats
path: root/meta-skeleton
diff options
context:
space:
mode:
authorAlejandro Hernandez <alejandro@enedino.org>2020-07-05 23:50:37 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-07-08 10:37:12 +0100
commit843e4844c796c0460e48440bab2dc73718970a88 (patch)
tree198e875e75d3aa2e442ec440b9b745ac01497f2a /meta-skeleton
parent9ab3e05ad0ee120d2bb37bf01ca5f02d44f86d33 (diff)
downloadpoky-843e4844c796c0460e48440bab2dc73718970a88.tar.gz
baremetal-helloworld: Use baremetal-image class to deploy the application
(From OE-Core rev: dd5a64feb5426ec870cf5d53ef056b24eb450487) Signed-off-by: Alejandro Hernandez Samaniego <alejandro@enedino.org> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta-skeleton')
-rw-r--r--meta-skeleton/recipes-baremetal/baremetal-examples/baremetal-helloworld_git.bb109
1 files changed, 19 insertions, 90 deletions
diff --git a/meta-skeleton/recipes-baremetal/baremetal-examples/baremetal-helloworld_git.bb b/meta-skeleton/recipes-baremetal/baremetal-examples/baremetal-helloworld_git.bb
index a5789e27d3..3acc523a88 100644
--- a/meta-skeleton/recipes-baremetal/baremetal-examples/baremetal-helloworld_git.bb
+++ b/meta-skeleton/recipes-baremetal/baremetal-examples/baremetal-helloworld_git.bb
@@ -10,10 +10,19 @@ SRC_URI = "git://github.com/aehs29/baremetal-helloqemu.git;protocol=https;branch
10 10
11S = "${WORKDIR}/git/" 11S = "${WORKDIR}/git/"
12 12
13# These examples are not meant to be built when using either musl or glibc 13# The following variables should be set to accomodate each application
14COMPATIBLE_HOST_libc-musl_class-target = "null" 14BAREMETAL_BINNAME ?= "hello_baremetal_${MACHINE}"
15COMPATIBLE_HOST_libc-glibc_class-target = "null" 15IMAGE_LINK_NAME ?= "baremetal-helloworld-image-${MACHINE}"
16IMAGE_NAME_SUFFIX ?= ""
17
18# Baremetal-Image creates the proper wiring, assumes the output is provided in
19# binary and ELF format, installed on ${base_libdir}/firmware/ , we want a
20# package to be created since we might have some way of updating the baremetal
21# firmware from Linux
22inherit baremetal-image
23
16 24
25# These parameters are app specific for this example
17# This will be translated automatically to the architecture and 26# This will be translated automatically to the architecture and
18# machine that QEMU uses on OE, e.g. -machine virt -cpu cortex-a57 27# machine that QEMU uses on OE, e.g. -machine virt -cpu cortex-a57
19# but the examples can also be run on other architectures/machines 28# but the examples can also be run on other architectures/machines
@@ -25,97 +34,17 @@ BAREMETAL_QEMUARCH_qemuarmv5 = "versatile"
25BAREMETAL_QEMUARCH_qemuarm = "arm" 34BAREMETAL_QEMUARCH_qemuarm = "arm"
26BAREMETAL_QEMUARCH_qemuarm64 = "aarch64" 35BAREMETAL_QEMUARCH_qemuarm64 = "aarch64"
27 36
28
29EXTRA_OEMAKE_append = " QEMUARCH=${BAREMETAL_QEMUARCH} V=1" 37EXTRA_OEMAKE_append = " QEMUARCH=${BAREMETAL_QEMUARCH} V=1"
30 38
31do_install(){
32 install -d ${D}/${datadir}
33 install -m 755 ${B}build/hello_baremetal_${BAREMETAL_QEMUARCH}.bin ${D}/${datadir}/hello_baremetal_${MACHINE}.bin
34 install -m 755 ${B}build/hello_baremetal_${BAREMETAL_QEMUARCH}.elf ${D}/${datadir}/hello_baremetal_${MACHINE}.elf
35}
36 39
37# Borrowed from meta-freertos 40# Install binaries on the proper location for baremetal-image to fetch and deploy
38inherit rootfs-postcommands 41do_install(){
39IMGDEPLOYDIR ?= "${WORKDIR}/deploy-${PN}-image-complete" 42 install -d ${D}/${base_libdir}/firmware
40do_rootfs[dirs] = "${DEPLOYDIR} ${DEPLOY_DIR_IMAGE}" 43 install -m 755 ${B}build/hello_baremetal_${BAREMETAL_QEMUARCH}.bin ${D}/${base_libdir}/firmware/${BAREMETAL_BINNAME}.bin
41DEPLOYDIR = "${IMGDEPLOYDIR}" 44 install -m 755 ${B}build/hello_baremetal_${BAREMETAL_QEMUARCH}.elf ${D}/${base_libdir}/firmware/${BAREMETAL_BINNAME}.elf
42IMAGE_LINK_NAME ?= "baremetal-helloworld-image-${MACHINE}"
43IMAGE_NAME_SUFFIX ?= ""
44
45do_image_complete(){
46 :
47}
48
49do_image(){
50 install ${D}/${datadir}/hello_baremetal_${MACHINE}.bin ${DEPLOYDIR}/${IMAGE_LINK_NAME}.bin
51 install ${D}/${datadir}/hello_baremetal_${MACHINE}.elf ${DEPLOYDIR}/${IMAGE_LINK_NAME}.elf
52} 45}
53 46
54FILES_${PN} += " \ 47FILES_${PN} += " \
55 ${datadir}/hello_baremetal_${MACHINE}.bin \ 48 ${base_libdir}/firmware/${BAREMETAL_BINNAME}.bin \
56 ${datadir}/hello_baremetal_${MACHINE}.elf \ 49 ${base_libdir}/firmware/${BAREMETAL_BINNAME}.elf \
57" 50"
58
59python do_rootfs(){
60 from oe.utils import execute_pre_post_process
61 from pathlib import Path
62
63 # Write empty manifest testdate file
64 deploy_dir = d.getVar('DEPLOYDIR')
65 link_name = d.getVar('IMAGE_LINK_NAME')
66 manifest_name = d.getVar('IMAGE_MANIFEST')
67
68 Path(manifest_name).touch()
69 if os.path.exists(manifest_name) and link_name:
70 manifest_link = deploy_dir + "/" + link_name + ".manifest"
71 if os.path.lexists(manifest_link):
72 os.remove(manifest_link)
73 os.symlink(os.path.basename(manifest_name), manifest_link)
74 execute_pre_post_process(d, d.getVar('ROOTFS_POSTPROCESS_COMMAND'))
75}
76
77# QEMU generic FreeRTOS parameters
78QB_DEFAULT_KERNEL = "${IMAGE_LINK_NAME}.bin"
79QB_MEM = "-m 256"
80QB_OPT_APPEND = "-nographic"
81QB_DEFAULT_FSTYPE = "bin"
82QB_DTB = ""
83
84
85# Assure binaries, manifest and qemubootconf are populated on DEPLOY_DIR_IMAGE
86do_image_complete[dirs] = "${TOPDIR}"
87do_image_complete[umask] = "022"
88SSTATETASKS += "do_image_complete"
89SSTATE_SKIP_CREATION_task-image-complete = '1'
90do_image_complete[sstate-inputdirs] = "${IMGDEPLOYDIR}"
91do_image_complete[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}"
92do_image_complete[stamp-extra-info] = "${MACHINE_ARCH}"
93addtask do_image_complete after do_image before do_build
94
95python do_image_complete_setscene () {
96 sstate_setscene(d)
97}
98addtask do_image_complete_setscene
99
100# This next part is necessary to trick the build system into thinking
101# its building an image recipe so it generates the qemuboot.conf
102# addtask do_deploy after do_write_qemuboot_conf before do_build
103addtask do_rootfs before do_image after do_install
104addtask do_image after do_rootfs before do_build
105addtask do_image_complete after do_image before do_build
106inherit qemuboot
107
108# Based on image.bbclass to make sure we build qemu
109python(){
110 # do_addto_recipe_sysroot doesnt exist for all recipes, but we need it to have
111 # /usr/bin on recipe-sysroot (qemu) populated
112 def extraimage_getdepends(task):
113 deps = ""
114 for dep in (d.getVar('EXTRA_IMAGEDEPENDS') or "").split():
115 # Make sure we only add it for qemu
116 if 'qemu' in dep:
117 deps += " %s:%s" % (dep, task)
118 return deps
119 d.appendVarFlag('do_image', 'depends', extraimage_getdepends('do_addto_recipe_sysroot'))
120 d.appendVarFlag('do_image', 'depends', extraimage_getdepends('do_populate_sysroot'))
121}