blob: e84a90f28c75cbab0a68318067f6625c2587dc6d [file] [log] [blame]
Andrew Geissler82c905d2020-04-13 13:39:40 -05001SUMMARY = "Baremetal examples to work with the several QEMU architectures supported on OpenEmbedded"
2HOMEPAGE = "https://github.com/aehs29/baremetal-helloqemu"
3LICENSE = "MIT"
4LIC_FILES_CHKSUM = "file://LICENSE;md5=39346640a23c701e4f459e05f56f4449"
5
6SRCREV = "99f4fa4a3b266b42b52af302610b0f4f429ba5e3"
7PV = "0.1+git${SRCPV}"
8
9SRC_URI = "git://github.com/aehs29/baremetal-helloqemu.git;protocol=https;branch=master"
10
11S = "${WORKDIR}/git/"
12
13# These examples are not meant to be built when using either musl or glibc
14COMPATIBLE_HOST_libc-musl_class-target = "null"
15COMPATIBLE_HOST_libc-glibc_class-target = "null"
16
17# This will be translated automatically to the architecture and
18# 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
20# such as vexpress-a15 by overriding the setting on the machine.conf
21COMPATIBLE_MACHINE = "qemuarmv5|qemuarm|qemuarm64"
22
23BAREMETAL_QEMUARCH ?= ""
24BAREMETAL_QEMUARCH_qemuarmv5 = "versatile"
25BAREMETAL_QEMUARCH_qemuarm = "arm"
26BAREMETAL_QEMUARCH_qemuarm64 = "aarch64"
27
28
29EXTRA_OEMAKE_append = " QEMUARCH=${BAREMETAL_QEMUARCH} V=1"
30
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
37# Borrowed from meta-freertos
38inherit rootfs-postcommands
39inherit deploy
40IMGDEPLOYDIR ?= "${WORKDIR}/deploy-${PN}-image-complete"
41do_deploy[dirs] = "${DEPLOYDIR} ${DEPLOY_DIR_IMAGE}"
42do_rootfs[dirs] = "${DEPLOYDIR} ${DEPLOY_DIR_IMAGE}"
43DEPLOYDIR = "${IMGDEPLOYDIR}"
44IMAGE_LINK_NAME ?= "baremetal-helloworld-image-${MACHINE}"
45IMAGE_NAME_SUFFIX ?= ""
46
47do_deploy(){
48 install ${D}/${datadir}/hello_baremetal_${MACHINE}.bin ${DEPLOYDIR}/${IMAGE_LINK_NAME}.bin
49 install ${D}/${datadir}/hello_baremetal_${MACHINE}.elf ${DEPLOYDIR}/${IMAGE_LINK_NAME}.elf
50}
51
52do_image(){
53 :
54}
55
56FILES_${PN} += " \
57 ${datadir}/hello_baremetal_${MACHINE}.bin \
58 ${datadir}/hello_baremetal_${MACHINE}.elf \
59"
60
61python do_rootfs(){
62 from oe.utils import execute_pre_post_process
63 from pathlib import Path
64
65 # Write empty manifest testdate file
66 deploy_dir = d.getVar('DEPLOYDIR')
67 link_name = d.getVar('IMAGE_LINK_NAME')
68 manifest_name = d.getVar('IMAGE_MANIFEST')
69
70 Path(manifest_name).touch()
71 if os.path.exists(manifest_name) and link_name:
72 manifest_link = deploy_dir + "/" + link_name + ".manifest"
73 if os.path.lexists(manifest_link):
74 os.remove(manifest_link)
75 os.symlink(os.path.basename(manifest_name), manifest_link)
76 execute_pre_post_process(d, d.getVar('ROOTFS_POSTPROCESS_COMMAND'))
77}
78
79# QEMU generic FreeRTOS parameters
80QB_DEFAULT_KERNEL = "${IMAGE_LINK_NAME}.bin"
81QB_MEM = "-m 256"
82QB_OPT_APPEND = "-nographic"
83QB_DEFAULT_FSTYPE = "bin"
84QB_DTB = ""
85
86# This next part is necessary to trick the build system into thinking
87# its building an image recipe so it generates the qemuboot.conf
88addtask do_deploy after do_write_qemuboot_conf before do_build
89addtask do_rootfs before do_deploy after do_install
90addtask do_image after do_rootfs before do_build
91inherit qemuboot
92
93# Based on image.bbclass to make sure we build qemu
94python(){
95 # do_addto_recipe_sysroot doesnt exist for all recipes, but we need it to have
96 # /usr/bin on recipe-sysroot (qemu) populated
97 def extraimage_getdepends(task):
98 deps = ""
99 for dep in (d.getVar('EXTRA_IMAGEDEPENDS') or "").split():
100 # Make sure we only add it for qemu
101 if 'qemu' in dep:
102 deps += " %s:%s" % (dep, task)
103 return deps
104 d.appendVarFlag('do_image', 'depends', extraimage_getdepends('do_addto_recipe_sysroot'))
105 d.appendVarFlag('do_image', 'depends', extraimage_getdepends('do_populate_sysroot'))
106}