diff options
| -rw-r--r-- | meta-skeleton/recipes-baremetal/baremetal-examples/baremetal-helloworld_git.bb | 109 |
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 | ||
| 11 | S = "${WORKDIR}/git/" | 11 | S = "${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 |
| 14 | COMPATIBLE_HOST_libc-musl_class-target = "null" | 14 | BAREMETAL_BINNAME ?= "hello_baremetal_${MACHINE}" |
| 15 | COMPATIBLE_HOST_libc-glibc_class-target = "null" | 15 | IMAGE_LINK_NAME ?= "baremetal-helloworld-image-${MACHINE}" |
| 16 | IMAGE_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 | ||
| 22 | inherit 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" | |||
| 25 | BAREMETAL_QEMUARCH_qemuarm = "arm" | 34 | BAREMETAL_QEMUARCH_qemuarm = "arm" |
| 26 | BAREMETAL_QEMUARCH_qemuarm64 = "aarch64" | 35 | BAREMETAL_QEMUARCH_qemuarm64 = "aarch64" |
| 27 | 36 | ||
| 28 | |||
| 29 | EXTRA_OEMAKE_append = " QEMUARCH=${BAREMETAL_QEMUARCH} V=1" | 37 | EXTRA_OEMAKE_append = " QEMUARCH=${BAREMETAL_QEMUARCH} V=1" |
| 30 | 38 | ||
| 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 | 39 | ||
| 37 | # Borrowed from meta-freertos | 40 | # Install binaries on the proper location for baremetal-image to fetch and deploy |
| 38 | inherit rootfs-postcommands | 41 | do_install(){ |
| 39 | IMGDEPLOYDIR ?= "${WORKDIR}/deploy-${PN}-image-complete" | 42 | install -d ${D}/${base_libdir}/firmware |
| 40 | do_rootfs[dirs] = "${DEPLOYDIR} ${DEPLOY_DIR_IMAGE}" | 43 | install -m 755 ${B}build/hello_baremetal_${BAREMETAL_QEMUARCH}.bin ${D}/${base_libdir}/firmware/${BAREMETAL_BINNAME}.bin |
| 41 | DEPLOYDIR = "${IMGDEPLOYDIR}" | 44 | install -m 755 ${B}build/hello_baremetal_${BAREMETAL_QEMUARCH}.elf ${D}/${base_libdir}/firmware/${BAREMETAL_BINNAME}.elf |
| 42 | IMAGE_LINK_NAME ?= "baremetal-helloworld-image-${MACHINE}" | ||
| 43 | IMAGE_NAME_SUFFIX ?= "" | ||
| 44 | |||
| 45 | do_image_complete(){ | ||
| 46 | : | ||
| 47 | } | ||
| 48 | |||
| 49 | do_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 | ||
| 54 | FILES_${PN} += " \ | 47 | FILES_${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 | |||
| 59 | python 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 | ||
| 78 | QB_DEFAULT_KERNEL = "${IMAGE_LINK_NAME}.bin" | ||
| 79 | QB_MEM = "-m 256" | ||
| 80 | QB_OPT_APPEND = "-nographic" | ||
| 81 | QB_DEFAULT_FSTYPE = "bin" | ||
| 82 | QB_DTB = "" | ||
| 83 | |||
| 84 | |||
| 85 | # Assure binaries, manifest and qemubootconf are populated on DEPLOY_DIR_IMAGE | ||
| 86 | do_image_complete[dirs] = "${TOPDIR}" | ||
| 87 | do_image_complete[umask] = "022" | ||
| 88 | SSTATETASKS += "do_image_complete" | ||
| 89 | SSTATE_SKIP_CREATION_task-image-complete = '1' | ||
| 90 | do_image_complete[sstate-inputdirs] = "${IMGDEPLOYDIR}" | ||
| 91 | do_image_complete[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}" | ||
| 92 | do_image_complete[stamp-extra-info] = "${MACHINE_ARCH}" | ||
| 93 | addtask do_image_complete after do_image before do_build | ||
| 94 | |||
| 95 | python do_image_complete_setscene () { | ||
| 96 | sstate_setscene(d) | ||
| 97 | } | ||
| 98 | addtask 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 | ||
| 103 | addtask do_rootfs before do_image after do_install | ||
| 104 | addtask do_image after do_rootfs before do_build | ||
| 105 | addtask do_image_complete after do_image before do_build | ||
| 106 | inherit qemuboot | ||
| 107 | |||
| 108 | # Based on image.bbclass to make sure we build qemu | ||
| 109 | python(){ | ||
| 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 | } | ||
