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