diff options
| author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-11-07 13:31:53 +0000 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-11-07 13:31:53 +0000 |
| commit | 8c22ff0d8b70d9b12f0487ef696a7e915b9e3173 (patch) | |
| tree | efdc32587159d0050a69009bdf2330a531727d95 /meta/classes-recipe/baremetal-image.bbclass | |
| parent | d412d2747595c1cc4a5e3ca975e3adc31b2f7891 (diff) | |
| download | poky-8c22ff0d8b70d9b12f0487ef696a7e915b9e3173.tar.gz | |
The poky repository master branch is no longer being updated.
You can either:
a) switch to individual clones of bitbake, openembedded-core, meta-yocto and yocto-docs
b) use the new bitbake-setup
You can find information about either approach in our documentation:
https://docs.yoctoproject.org/
Note that "poky" the distro setting is still available in meta-yocto as
before and we continue to use and maintain that.
Long live Poky!
Some further information on the background of this change can be found
in: https://lists.openembedded.org/g/openembedded-architecture/message/2179
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes-recipe/baremetal-image.bbclass')
| -rw-r--r-- | meta/classes-recipe/baremetal-image.bbclass | 170 |
1 files changed, 0 insertions, 170 deletions
diff --git a/meta/classes-recipe/baremetal-image.bbclass b/meta/classes-recipe/baremetal-image.bbclass deleted file mode 100644 index 4afc171314..0000000000 --- a/meta/classes-recipe/baremetal-image.bbclass +++ /dev/null | |||
| @@ -1,170 +0,0 @@ | |||
| 1 | # | ||
| 2 | # Copyright OpenEmbedded Contributors | ||
| 3 | # | ||
| 4 | # SPDX-License-Identifier: MIT | ||
| 5 | # | ||
| 6 | |||
| 7 | # Baremetal image class | ||
| 8 | # | ||
| 9 | # This class is meant to be inherited by recipes for baremetal/RTOS applications | ||
| 10 | # It contains code that would be used by all of them, every recipe just needs to | ||
| 11 | # override certain variables. | ||
| 12 | # | ||
| 13 | # For scalability purposes, code within this class focuses on the "image" wiring | ||
| 14 | # to satisfy the OpenEmbedded image creation and testing infrastructure. | ||
| 15 | # | ||
| 16 | # See meta-skeleton for a working example. | ||
| 17 | |||
| 18 | |||
| 19 | # Toolchain should be baremetal or newlib/picolibc based. | ||
| 20 | # TCLIBC="baremetal" or TCLIBC="newlib" or TCLIBC="picolibc" | ||
| 21 | COMPATIBLE_HOST:libc-musl:class-target = "null" | ||
| 22 | COMPATIBLE_HOST:libc-glibc:class-target = "null" | ||
| 23 | |||
| 24 | |||
| 25 | inherit rootfs-postcommands | ||
| 26 | |||
| 27 | # Set some defaults, but these should be overriden by each recipe if required | ||
| 28 | IMGDEPLOYDIR ?= "${WORKDIR}/deploy-${PN}-image-complete" | ||
| 29 | BAREMETAL_BINNAME ?= "hello_baremetal_${MACHINE}" | ||
| 30 | IMAGE_LINK_NAME ?= "baremetal-helloworld-image-${MACHINE}" | ||
| 31 | IMAGE_NAME_SUFFIX ?= "" | ||
| 32 | |||
| 33 | IMAGE_OUTPUT_MANIFEST_DIR = "${WORKDIR}/deploy-image-output-manifest" | ||
| 34 | IMAGE_OUTPUT_MANIFEST = "${IMAGE_OUTPUT_MANIFEST_DIR}/manifest.json" | ||
| 35 | |||
| 36 | do_rootfs[dirs] = "${IMGDEPLOYDIR} ${DEPLOY_DIR_IMAGE}" | ||
| 37 | |||
| 38 | do_image(){ | ||
| 39 | install ${D}/${base_libdir}/firmware/${BAREMETAL_BINNAME}.bin ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.bin | ||
| 40 | install ${D}/${base_libdir}/firmware/${BAREMETAL_BINNAME}.elf ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.elf | ||
| 41 | } | ||
| 42 | |||
| 43 | python do_image_complete(){ | ||
| 44 | from pathlib import Path | ||
| 45 | import json | ||
| 46 | |||
| 47 | data = { | ||
| 48 | "taskname": "do_image", | ||
| 49 | "imagetype": "baremetal-image", | ||
| 50 | "images": [] | ||
| 51 | } | ||
| 52 | |||
| 53 | img_deploy_dir = Path(d.getVar("IMGDEPLOYDIR")) | ||
| 54 | |||
| 55 | for child in img_deploy_dir.iterdir(): | ||
| 56 | if not child.is_file() or child.is_symlink(): | ||
| 57 | continue | ||
| 58 | |||
| 59 | data["images"].append({ | ||
| 60 | "filename": child.name, | ||
| 61 | }) | ||
| 62 | |||
| 63 | with open(d.getVar("IMAGE_OUTPUT_MANIFEST"), "w") as f: | ||
| 64 | json.dump([data], f) | ||
| 65 | } | ||
| 66 | |||
| 67 | python do_rootfs(){ | ||
| 68 | from oe.utils import execute_pre_post_process | ||
| 69 | from pathlib import Path | ||
| 70 | |||
| 71 | # Write empty manifest file to satisfy test infrastructure | ||
| 72 | deploy_dir = d.getVar('IMGDEPLOYDIR') | ||
| 73 | link_name = d.getVar('IMAGE_LINK_NAME') | ||
| 74 | manifest_name = d.getVar('IMAGE_MANIFEST') | ||
| 75 | |||
| 76 | Path(manifest_name).touch() | ||
| 77 | if os.path.exists(manifest_name) and link_name: | ||
| 78 | manifest_link = deploy_dir + "/" + link_name + ".manifest" | ||
| 79 | if manifest_link != manifest_name: | ||
| 80 | if os.path.lexists(manifest_link): | ||
| 81 | os.remove(manifest_link) | ||
| 82 | os.symlink(os.path.basename(manifest_name), manifest_link) | ||
| 83 | # A lot of postprocess commands assume the existence of rootfs/etc | ||
| 84 | sysconfdir = d.getVar("IMAGE_ROOTFS") + d.getVar('sysconfdir') | ||
| 85 | bb.utils.mkdirhier(sysconfdir) | ||
| 86 | |||
| 87 | execute_pre_post_process(d, d.getVar('ROOTFS_POSTPROCESS_COMMAND')) | ||
| 88 | execute_pre_post_process(d, d.getVar("ROOTFS_POSTUNINSTALL_COMMAND")) | ||
| 89 | } | ||
| 90 | |||
| 91 | |||
| 92 | # Assure binaries, manifest and qemubootconf are populated on DEPLOY_DIR_IMAGE | ||
| 93 | do_image_complete[dirs] = "${TOPDIR}" | ||
| 94 | SSTATETASKS += "do_image_complete" | ||
| 95 | SSTATE_SKIP_CREATION:task-image-complete = '1' | ||
| 96 | do_image_complete[sstate-inputdirs] = "${IMGDEPLOYDIR}" | ||
| 97 | do_image_complete[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}" | ||
| 98 | do_image_complete[stamp-extra-info] = "${MACHINE_ARCH}" | ||
| 99 | do_image_complete[sstate-plaindirs] += "${IMAGE_OUTPUT_MANIFEST_DIR}" | ||
| 100 | do_image_complete[dirs] += "${IMAGE_OUTPUT_MANIFEST_DIR}" | ||
| 101 | addtask do_image_complete after do_image before do_build | ||
| 102 | |||
| 103 | python do_image_complete_setscene () { | ||
| 104 | sstate_setscene(d) | ||
| 105 | } | ||
| 106 | addtask do_image_complete_setscene | ||
| 107 | |||
| 108 | # QEMU generic Baremetal/RTOS parameters | ||
| 109 | QB_DEFAULT_KERNEL ?= "${IMAGE_LINK_NAME}.bin" | ||
| 110 | QB_MEM ?= "-m 256" | ||
| 111 | QB_DEFAULT_FSTYPE ?= "bin" | ||
| 112 | QB_DTB ?= "" | ||
| 113 | QB_OPT_APPEND:append = " -nographic" | ||
| 114 | |||
| 115 | # QEMU x86 requires an .elf kernel to boot rather than a .bin | ||
| 116 | QB_DEFAULT_KERNEL:qemux86 ?= "${IMAGE_LINK_NAME}.elf" | ||
| 117 | # QEMU x86-64 refuses to boot from -kernel, needs a multiboot compatible image | ||
| 118 | QB_DEFAULT_FSTYPE:qemux86-64 ?= "iso" | ||
| 119 | |||
| 120 | # RISC-V tunes set the BIOS, unset, and instruct QEMU to | ||
| 121 | # ignore the BIOS and boot from -kernel | ||
| 122 | QB_DEFAULT_BIOS:qemuriscv64 = "" | ||
| 123 | QB_DEFAULT_BIOS:qemuriscv32 = "" | ||
| 124 | QB_OPT_APPEND:append:qemuriscv64 = " -bios none" | ||
| 125 | QB_OPT_APPEND:append:qemuriscv32 = " -bios none" | ||
| 126 | |||
| 127 | |||
| 128 | # Use the medium-any code model for the RISC-V 64 bit implementation, | ||
| 129 | # since medlow can only access addresses below 0x80000000 and RAM | ||
| 130 | # starts at 0x80000000 on RISC-V 64 | ||
| 131 | # Keep RISC-V 32 using -mcmodel=medlow (symbols lie between -2GB:2GB) | ||
| 132 | TARGET_CFLAGS:append:qemuriscv64 = " -mcmodel=medany" | ||
| 133 | |||
| 134 | |||
| 135 | ## Emulate image.bbclass | ||
| 136 | # Handle inherits of any of the image classes we need | ||
| 137 | IMAGE_CLASSES ??= "" | ||
| 138 | IMGCLASSES = " ${IMAGE_CLASSES}" | ||
| 139 | inherit_defer ${IMGCLASSES} | ||
| 140 | # Set defaults to satisfy IMAGE_FEATURES check | ||
| 141 | IMAGE_FEATURES ?= "" | ||
| 142 | IMAGE_FEATURES[type] = "list" | ||
| 143 | IMAGE_FEATURES[validitems] += "" | ||
| 144 | |||
| 145 | |||
| 146 | # This next part is necessary to trick the build system into thinking | ||
| 147 | # its building an image recipe so it generates the qemuboot.conf | ||
| 148 | addtask do_rootfs before do_image after do_install | ||
| 149 | addtask do_image after do_rootfs before do_image_complete | ||
| 150 | addtask do_image_complete after do_image before do_build | ||
| 151 | inherit qemuboot | ||
| 152 | |||
| 153 | # Based on image.bbclass to make sure we build qemu | ||
| 154 | python(){ | ||
| 155 | # do_addto_recipe_sysroot doesnt exist for all recipes, but we need it to have | ||
| 156 | # /usr/bin on recipe-sysroot (qemu) populated | ||
| 157 | # The do_addto_recipe_sysroot dependency is coming from EXTRA_IMAGDEPENDS now, | ||
| 158 | # we just need to add the logic to add its dependency to do_image. | ||
| 159 | def extraimage_getdepends(task): | ||
| 160 | deps = "" | ||
| 161 | for dep in (d.getVar('EXTRA_IMAGEDEPENDS') or "").split(): | ||
| 162 | # Make sure we only add it for qemu | ||
| 163 | if 'qemu' in dep: | ||
| 164 | if ":" in dep: | ||
| 165 | deps += " %s " % (dep) | ||
| 166 | else: | ||
| 167 | deps += " %s:%s" % (dep, task) | ||
| 168 | return deps | ||
| 169 | d.appendVarFlag('do_image', 'depends', extraimage_getdepends('do_populate_sysroot')) | ||
| 170 | } | ||
