baremetal-helloworld: Create recipe for baremetal examples on QEMU
PATCH 1/2 baremetal-helloworld: Create recipe for baremetal examples on QEMU
Create HelloWorld examples that run on several of the QEMU architectures supported by the build system.
This recipe can be used by anyone to understand how baremetal applications can be built using OpenEmbedded and how the wiring to set them up could be.
This should also facilitate creating/extending the OE testing infrastructure to allow baremetal applications or RTOSs to be tested in the same way that Linux currently is.
This can easily be extended to work on other MACHINES in the future.
To run this example:
# Source the oe environment as usual
$ source oe-init-buildenv
# Set TCLIBC to either newlib or baremetal
$ echo "TCLIBC = \"newlib\"" >> ./conf/local.conf
# Use one of the supported architectures (qemuarm64, qemuarm or qemuarmv5)
$ echo "MACHINE = \"qemuarm64\"" >> ./conf/local.conf
# Build
$ bitbake baremetal-helloworld
# Launch QEMU
$ runqemu
runqemu - INFO - Running bitbake -e ...
runqemu - INFO - Continuing with the following parameters:
KERNEL: [tmp/deploy/images/qemuarm64/baremetal-helloworld-qemuarm64.bin]
MACHINE: [qemuarm64]
FSTYPE: [bin]
ROOTFS: [tmp/deploy/images/qemuarm64/baremetal-helloworld-qemuarm64.bin]
CONFFILE: [tmp/deploy/images/qemuarm64/baremetal-helloworld-qemuarm64.qemuboot.conf]
Hello OpenEmbedded!
--- .../baremetal-examples/baremetal-helloworld_git.bb | 114 +++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 meta/recipes-extended/baremetal-examples/baremetal-helloworld_git.bb
meta/recipes-extended/baremetal-examples/baremetal-helloworld_git.bb new file +114 -0
@@ -0,0 +1,114 @@ +SUMMARY = "Baremetal examples to work with the several QEMU architectures supported on OpenEmbedded" +HOMEPAGE = "https://github.com/aehs29/baremetal-helloqemu" +LICENSE = "CC-BY-SA-4.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=4084714af41157e38872e798eb3fe1b1" + +SRCREV = "fe81742f1159725408dd7305e40e7bd4dfd1e264" + +SRC_URI = "git://github.com/aehs29/baremetal-helloqemu.git;protocol=https " + +S = "${WORKDIR}/git" +B = "${WORKDIR}/build" + +# These examples are not meant to be built when using either musl or glibc +COMPATIBLE_HOST_libc-musl_class-target = "null" +COMPATIBLE_HOST_libc-glibc_class-target = "null" + +# This will be translated automatically to the architecture and +# machine that QEMU uses on OE, e.g. -machine virt -cpu cortex-a57 +# but the examples can also be run on other architectures/machines +# such as vexpress-a15 by overriding the setting on the machine.conf +COMPATIBLE_MACHINE = "qemuarmv5|qemuarm|qemuarm64" + +BAREMETAL_QEMUARCH ?= "" +BAREMETAL_QEMUARCH_qemuarmv5 = "versatile" +BAREMETAL_QEMUARCH_qemuarm = "arm" +BAREMETAL_QEMUARCH_qemuarm64 = "aarch64" + + +EXTRA_OEMAKE_append = " QEMUARCH=${BAREMETAL_QEMUARCH}" + +do_configure(){ + # Avoid building on the source directory + cp ${S}/* ${B} +} + +do_install(){ + install -d ${D}/${datadir} + install -m 755 ${B}/hello_baremetal_${BAREMETAL_QEMUARCH}.bin ${D}/${datadir}/hello_baremetal_${MACHINE}.bin + install -m 755 ${B}/hello_baremetal_${BAREMETAL_QEMUARCH}.elf ${D}/${datadir}/hello_baremetal_${MACHINE}.elf +} + +# Make sure there are no race conditions when +# assembling compiling and linking steps +PARALLEL_MAKE = "" + +# Borrowed from meta-freertos +inherit rootfs-postcommands +inherit deploy +do_deploy[dirs] = "${DEPLOYDIR} ${DEPLOY_DIR_IMAGE}" +do_rootfs[dirs] = "${DEPLOYDIR} ${DEPLOY_DIR_IMAGE}" +DEPLOYDIR = "${IMGDEPLOYDIR}" +IMAGE_LINK_NAME ?= "baremetal-helloworld-image-${MACHINE}" +IMAGE_NAME_SUFFIX ?= "" + +do_deploy(){ + install ${D}/${datadir}/hello_baremetal_${MACHINE}.bin ${DEPLOYDIR}/${IMAGE_LINK_NAME}.bin + install ${D}/${datadir}/hello_baremetal_${MACHINE}.elf ${DEPLOYDIR}/${IMAGE_LINK_NAME}.elf +} + +do_image(){ + : +} + +FILES_${PN} += " \ + ${datadir}/hello_baremetal_${MACHINE}.bin \ + ${datadir}/hello_baremetal_${MACHINE}.elf \ +" + +python do_rootfs(){ + from oe.utils import execute_pre_post_process + from pathlib import Path + + # Write empty manifest testdate file + deploy_dir = d.getVar('DEPLOYDIR') + link_name = d.getVar('IMAGE_LINK_NAME') + manifest_name = d.getVar('IMAGE_MANIFEST') + + Path(manifest_name).touch() + if os.path.exists(manifest_name) and link_name: + manifest_link = deploy_dir + "/" + link_name + ".manifest" + if os.path.lexists(manifest_link): + os.remove(manifest_link) + os.symlink(os.path.basename(manifest_name), manifest_link) + execute_pre_post_process(d, d.getVar('ROOTFS_POSTPROCESS_COMMAND')) +} + +# QEMU generic FreeRTOS parameters +QB_DEFAULT_KERNEL = "${IMAGE_LINK_NAME}.bin" +QB_MEM = "-m 256" +QB_OPT_APPEND = "-nographic" +QB_DEFAULT_FSTYPE = "bin" +QB_DTB = "" + +# This next part is necessary to trick the build system into thinking +# its building an image recipe so it generates the qemuboot.conf +addtask do_deploy after do_write_qemuboot_conf before do_build +addtask do_rootfs before do_deploy after do_install +addtask do_image after do_rootfs before do_build +inherit qemuboot + +# Based on image.bbclass to make sure we build qemu +python(){ + # do_addto_recipe_sysroot doesnt exist for all recipes, but we need it to have + # /usr/bin on recipe-sysroot (qemu) populated + def extraimage_getdepends(task): + deps = "" + for dep in (d.getVar('EXTRA_IMAGEDEPENDS') or "").split(): + # Make sure we only add it for qemu + if 'qemu' in dep: + deps += " %s:%s" % (dep, task) + return deps + d.appendVarFlag('do_image', 'depends', extraimage_getdepends('do_addto_recipe_sysroot')) + d.appendVarFlag('do_image', 'depends', extraimage_getdepends('do_populate_sysroot')) +}
Signature · 1 line
2.7.4
Quoted 52 lines · Alejandro Enedino Hernandez Samaniego
Create HelloWorld examples that run on several of the QEMU architectures supported by the build system.
This recipe can be used by anyone to understand how baremetal applications can be built using OpenEmbedded and how the wiring to set them up could be.
This should also facilitate creating/extending the OE testing infrastructure to allow baremetal applications or RTOSs to be tested in the same way that Linux currently is.
This can easily be extended to work on other MACHINES in the future.
To run this example:
# Source the oe environment as usual
$ source oe-init-buildenv# Set TCLIBC to either newlib or baremetal
$ echo "TCLIBC = \"newlib\"" >> ./conf/local.conf# Use one of the supported architectures (qemuarm64, qemuarm or qemuarmv5)
$ echo "MACHINE = \"qemuarm64\"" >> ./conf/local.conf# Build
$ bitbake baremetal-helloworld# Launch QEMU
$ runqemurunqemu - INFO - Running bitbake -e ...
runqemu - INFO - Continuing with the following parameters:
KERNEL: [tmp/deploy/images/qemuarm64/baremetal-helloworld-qemuarm64.bin]
MACHINE: [qemuarm64]
FSTYPE: [bin]
ROOTFS: [tmp/deploy/images/qemuarm64/baremetal-helloworld-qemuarm64.bin]
CONFFILE: [tmp/deploy/images/qemuarm64/baremetal-helloworld-qemuarm64.qemuboot.conf]Hello OpenEmbedded!
--- .../baremetal-examples/baremetal-helloworld_git.bb | 114 +++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 meta/recipes-extended/baremetal-examples/baremetal-helloworld_git.bbmeta/recipes-extended/baremetal-examples/baremetal-helloworld_git.bb new file +0
-0
meta/recipes-extended/baremetal-examples/baremetal-helloworld_git.bb line 3
Quoted 3 lines
meta/recipes-extended/baremetal-examples/baremetal-helloworld_git.bb new file +3
-0@@ -0,0 +1,114 @@ +SUMMARY = "Baremetal examples to work with the several QEMU architectures supported on OpenEmbedded" +HOMEPAGE = "https://github.com/aehs29/baremetal-helloqemu" +LICENSE = "CC-BY-SA-4.0"
I've raised https://github.com/aehs29/baremetal-helloqemu/issues/1 as CC licenses aren't recommended for software.
Quoted 33 lines
meta/recipes-extended/baremetal-examples/baremetal-helloworld_git.bb new file +33
-0+LIC_FILES_CHKSUM = "file://LICENSE;md5=4084714af41157e38872e798eb3fe1b1" + +SRCREV = "fe81742f1159725408dd7305e40e7bd4dfd1e264" + +SRC_URI = "git://github.com/aehs29/baremetal-helloqemu.git;protocol=https " + +S = "${WORKDIR}/git" +B = "${WORKDIR}/build" + +# These examples are not meant to be built when using either musl or glibc +COMPATIBLE_HOST_libc-musl_class-target = "null" +COMPATIBLE_HOST_libc-glibc_class-target = "null" + +# This will be translated automatically to the architecture and +# machine that QEMU uses on OE, e.g. -machine virt -cpu cortex-a57 +# but the examples can also be run on other architectures/machines +# such as vexpress-a15 by overriding the setting on the machine.conf +COMPATIBLE_MACHINE = "qemuarmv5|qemuarm|qemuarm64" + +BAREMETAL_QEMUARCH ?= "" +BAREMETAL_QEMUARCH_qemuarmv5 = "versatile" +BAREMETAL_QEMUARCH_qemuarm = "arm" +BAREMETAL_QEMUARCH_qemuarm64 = "aarch64" + + +EXTRA_OEMAKE_append = " QEMUARCH=${BAREMETAL_QEMUARCH}" + +do_configure(){ + # Avoid building on the source directory + cp ${S}/* ${B} +} + +do_install(){
meta/recipes-extended/baremetal-examples/baremetal-helloworld_git.bb line 46
Quoted 10 lines
meta/recipes-extended/baremetal-examples/baremetal-helloworld_git.bb new file +10
-0+ install -d ${D}/${datadir} + install -m 755 ${B}/hello_baremetal_${BAREMETAL_QEMUARCH}.bin ${D}/${datadir}/hello_baremetal_${MACHINE}.bin + install -m 755 ${B}/hello_baremetal_${BAREMETAL_QEMUARCH}.elf ${D}/${datadir}/hello_baremetal_${MACHINE}.elf +} + +# Make sure there are no race conditions when +# assembling compiling and linking steps +PARALLEL_MAKE = "" + +# Borrowed from meta-freertos
Can these borrowed sections go into a bbclass to make the example simpler? meta-freertos might then be able to use the bbclass from openembedded-core.
Quoted 69 lines
meta/recipes-extended/baremetal-examples/baremetal-helloworld_git.bb new file +68
-1+inherit rootfs-postcommands +inherit deploy +do_deploy[dirs] = "${DEPLOYDIR} ${DEPLOY_DIR_IMAGE}" +do_rootfs[dirs] = "${DEPLOYDIR} ${DEPLOY_DIR_IMAGE}" +DEPLOYDIR = "${IMGDEPLOYDIR}" +IMAGE_LINK_NAME ?= "baremetal-helloworld-image-${MACHINE}" +IMAGE_NAME_SUFFIX ?= "" + +do_deploy(){ + install ${D}/${datadir}/hello_baremetal_${MACHINE}.bin ${DEPLOYDIR}/${IMAGE_LINK_NAME}.bin + install ${D}/${datadir}/hello_baremetal_${MACHINE}.elf ${DEPLOYDIR}/${IMAGE_LINK_NAME}.elf +} + +do_image(){ + : +} + +FILES_${PN} += " \ + ${datadir}/hello_baremetal_${MACHINE}.bin \ + ${datadir}/hello_baremetal_${MACHINE}.elf \ +" + +python do_rootfs(){ + from oe.utils import execute_pre_post_process + from pathlib import Path + + # Write empty manifest testdate file + deploy_dir = d.getVar('DEPLOYDIR') + link_name = d.getVar('IMAGE_LINK_NAME') + manifest_name = d.getVar('IMAGE_MANIFEST') + + Path(manifest_name).touch() + if os.path.exists(manifest_name) and link_name: + manifest_link = deploy_dir + "/" + link_name + ".manifest" + if os.path.lexists(manifest_link): + os.remove(manifest_link) + os.symlink(os.path.basename(manifest_name), manifest_link) + execute_pre_post_process(d, d.getVar('ROOTFS_POSTPROCESS_COMMAND')) +} + +# QEMU generic FreeRTOS parameters +QB_DEFAULT_KERNEL = "${IMAGE_LINK_NAME}.bin" +QB_MEM = "-m 256" +QB_OPT_APPEND = "-nographic" +QB_DEFAULT_FSTYPE = "bin" +QB_DTB = "" + +# This next part is necessary to trick the build system into thinking +# its building an image recipe so it generates the qemuboot.conf +addtask do_deploy after do_write_qemuboot_conf before do_build +addtask do_rootfs before do_deploy after do_install +addtask do_image after do_rootfs before do_build +inherit qemuboot + +# Based on image.bbclass to make sure we build qemu +python(){ + # do_addto_recipe_sysroot doesnt exist for all recipes, but we need it to have + # /usr/bin on recipe-sysroot (qemu) populated + def extraimage_getdepends(task): + deps = "" + for dep in (d.getVar('EXTRA_IMAGEDEPENDS') or "").split(): + # Make sure we only add it for qemu + if 'qemu' in dep: + deps += " %s:%s" % (dep, task) + return deps + d.appendVarFlag('do_image', 'depends', extraimage_getdepends('do_addto_recipe_sysroot')) + d.appendVarFlag('do_image', 'depends', extraimage_getdepends('do_populate_sysroot')) +} --
Quoted 1 line
2.7.4
Thanks,
Paul
Hey Paul,
Quoted 65 lines · Paul Barker
Quoted 5 lines · Alejandro Enedino Hernandez Samaniego
Create HelloWorld examples that run on several of the QEMU architectures supported by the build system.
This recipe can be used by anyone to understand how baremetal
applications
Quoted 1 line
can be built using OpenEmbedded and how the wiring to set them up could
be.
Quoted 2 lines
This should also facilitate creating/extending the OE testing
infrastructure
Quoted 1 line
to allow baremetal applications or RTOSs to be tested in the same way
that
Quoted 6 lines
Linux currently is.
This can easily be extended to work on other MACHINES in the future.
To run this example:
Quoted 7 lines
# Source the oe environment as usual
$ source oe-init-buildenv# Set TCLIBC to either newlib or baremetal
$ echo "TCLIBC = \"newlib\"" >> ./conf/local.conf# Use one of the supported architectures (qemuarm64, qemuarm or
qemuarmv5)
Quoted 8 lines
$ echo "MACHINE = \"qemuarm64\"" >> ./conf/local.conf# Build
$ bitbake baremetal-helloworld# Launch QEMU
$ runqemuQuoted 7 lines
runqemu - INFO - Running bitbake -e ...
runqemu - INFO - Continuing with the following parameters:
KERNEL: [tmp/deploy/images/qemuarm64/baremetal-helloworld-qemuarm64.bin]
MACHINE: [qemuarm64]
FSTYPE: [bin]
ROOTFS: [tmp/deploy/images/qemuarm64/baremetal-helloworld-qemuarm64.bin] CONFFILE:[
tmp/deploy/images/qemuarm64/baremetal-helloworld-qemuarm64.qemuboot.conf]Quoted 4 lines
Hello OpenEmbedded!
Signed-off-by Alejandro Enedino Hernandez Samaniego <Quoted 2 lines
--- .../baremetal-examples/baremetal-helloworld_git.bb | 114+++++++++++++++++++++
Quoted 2 lines
1 file changed, 114 insertions(+) create mode 100644 meta/recipes-extended/baremetal-examples/baremetal-helloworld_git.bb
Review
Quoted 2 lines
(quoted diff) +0
-0baremetal-helloworld_git.bb b/meta/recipes-extended/baremetal-examples/ baremetal-helloworld_git.bb
meta/recipes-extended/baremetal-examples/
Quoted 4 lines
new file mode 100644
index 0000000..aab48b1meta/recipes-extended/baremetal-examples/ new file +0
-0baremetal-helloworld_git.bb
Quoted 11 lines
meta/recipes-extended/baremetal-examples/ line 1
Quoted 2 lines
meta/recipes-extended/baremetal-examples/ new file +1
-0@@ -0,0 +1,114 @@ +SUMMARY = "Baremetal examples to work with the several QEMUarchitectures supported on OpenEmbedded"
meta/recipes-extended/baremetal-examples/ line 3
Quoted 2 lines
meta/recipes-extended/baremetal-examples/ new file +2
-0+HOMEPAGE = "https://github.com/aehs29/baremetal-helloqemu" +LICENSE = "CC-BY-SA-4.0"I've raised https://github.com/aehs29/baremetal-helloqemu/issues/1 as CC licenses aren't recommended for software.
I do agree, I originally had it as MIT, although I did base this on the original work of someone who made it work for the versatile architecture and they licensed that with CC-BY-SA and as I was reading I have to use the same license as them.
I thought about it and for the Hello OpenEmbedded examples it would be ok since they should serve mostly as basis for the wiring that users can use to build, run and test their baremetal apps on OE, so the license wouldn't affect them, but I'm open to suggestions here.
Quoted 40 lines
meta/recipes-extended/baremetal-examples/ line 8
Quoted 5 lines
meta/recipes-extended/baremetal-examples/ new file +5
-0+LIC_FILES_CHKSUM = "file://LICENSE;md5=4084714af41157e38872e798eb3fe1b1" + +SRCREV = "fe81742f1159725408dd7305e40e7bd4dfd1e264" + +SRC_URI = "git://github.com/aehs29/baremetal-helloqemu.git;protocol=https "
meta/recipes-extended/baremetal-examples/ line 13
Quoted 5 lines
meta/recipes-extended/baremetal-examples/ new file +5
-0+ +S = "${WORKDIR}/git" +B = "${WORKDIR}/build" + +# These examples are not meant to be built when using either musl orglibc
Quoted 15 lines
meta/recipes-extended/baremetal-examples/ new file +15
-0+COMPATIBLE_HOST_libc-musl_class-target = "null" +COMPATIBLE_HOST_libc-glibc_class-target = "null" + +# This will be translated automatically to the architecture and +# machine that QEMU uses on OE, e.g. -machine virt -cpu cortex-a57 +# but the examples can also be run on other architectures/machines +# such as vexpress-a15 by overriding the setting on the machine.conf +COMPATIBLE_MACHINE = "qemuarmv5|qemuarm|qemuarm64" + +BAREMETAL_QEMUARCH ?= "" +BAREMETAL_QEMUARCH_qemuarmv5 = "versatile" +BAREMETAL_QEMUARCH_qemuarm = "arm" +BAREMETAL_QEMUARCH_qemuarm64 = "aarch64" + +meta/recipes-extended/baremetal-examples/ line 38
Quoted 10 lines
meta/recipes-extended/baremetal-examples/ new file +10
-0+EXTRA_OEMAKE_append = " QEMUARCH=${BAREMETAL_QEMUARCH}" + +do_configure(){ + # Avoid building on the source directory + cp ${S}/* ${B} +} + +do_install(){ + install -d ${D}/${datadir} + install -m 755 ${B}/hello_baremetal_${BAREMETAL_QEMUARCH}.bin${D}/${datadir}/hello_baremetal_${MACHINE}.bin
meta/recipes-extended/baremetal-examples/ line 39
Quoted 1 line
meta/recipes-extended/baremetal-examples/ new file +1
-0+ install -m 755 ${B}/hello_baremetal_${BAREMETAL_QEMUARCH}.elf${D}/${datadir}/hello_baremetal_${MACHINE}.elf
Quoted 12 lines
meta/recipes-extended/baremetal-examples/ line 46
Quoted 7 lines
meta/recipes-extended/baremetal-examples/ new file +7
-0+} + +# Make sure there are no race conditions when +# assembling compiling and linking steps +PARALLEL_MAKE = "" + +# Borrowed from meta-freertosCan these borrowed sections go into a bbclass to make the example simpler? meta-freertos might then be able to use the bbclass from openembedded-core.
Yup, I am in the process pf upstreaming to core part of the FreeRTOS work, this will go on a class eventually, but as part of the work I am writing some oeqa tests and I wanted to have this merged for now, will move this to a class later.
Cheers,
Alejandro
Quoted 79 lines
meta/recipes-extended/baremetal-examples/ line 56
Quoted 10 lines
meta/recipes-extended/baremetal-examples/ new file +10
-0+inherit rootfs-postcommands +inherit deploy +do_deploy[dirs] = "${DEPLOYDIR} ${DEPLOY_DIR_IMAGE}" +do_rootfs[dirs] = "${DEPLOYDIR} ${DEPLOY_DIR_IMAGE}" +DEPLOYDIR = "${IMGDEPLOYDIR}" +IMAGE_LINK_NAME ?= "baremetal-helloworld-image-${MACHINE}" +IMAGE_NAME_SUFFIX ?= "" + +do_deploy(){ + install ${D}/${datadir}/hello_baremetal_${MACHINE}.bin${DEPLOYDIR}/${IMAGE_LINK_NAME}.bin
meta/recipes-extended/baremetal-examples/ line 57
Quoted 1 line
meta/recipes-extended/baremetal-examples/ new file +1
-0+ install ${D}/${datadir}/hello_baremetal_${MACHINE}.elf${DEPLOYDIR}/${IMAGE_LINK_NAME}.elf
Quoted 36 lines
meta/recipes-extended/baremetal-examples/ new file +36
-0+} + +do_image(){ + : +} + +FILES_${PN} += " \ + ${datadir}/hello_baremetal_${MACHINE}.bin \ + ${datadir}/hello_baremetal_${MACHINE}.elf \ +" + +python do_rootfs(){ + from oe.utils import execute_pre_post_process + from pathlib import Path + + # Write empty manifest testdate file + deploy_dir = d.getVar('DEPLOYDIR') + link_name = d.getVar('IMAGE_LINK_NAME') + manifest_name = d.getVar('IMAGE_MANIFEST') + + Path(manifest_name).touch() + if os.path.exists(manifest_name) and link_name: + manifest_link = deploy_dir + "/" + link_name + ".manifest" + if os.path.lexists(manifest_link): + os.remove(manifest_link) + os.symlink(os.path.basename(manifest_name), manifest_link) + execute_pre_post_process(d, d.getVar('ROOTFS_POSTPROCESS_COMMAND')) +} + +# QEMU generic FreeRTOS parameters +QB_DEFAULT_KERNEL = "${IMAGE_LINK_NAME}.bin" +QB_MEM = "-m 256" +QB_OPT_APPEND = "-nographic" +QB_DEFAULT_FSTYPE = "bin" +QB_DTB = "" +meta/recipes-extended/baremetal-examples/ line 103
Quoted 10 lines
meta/recipes-extended/baremetal-examples/ new file +10
-0+# This next part is necessary to trick the build system into thinking +# its building an image recipe so it generates the qemuboot.conf +addtask do_deploy after do_write_qemuboot_conf before do_build +addtask do_rootfs before do_deploy after do_install +addtask do_image after do_rootfs before do_build +inherit qemuboot + +# Based on image.bbclass to make sure we build qemu +python(){ + # do_addto_recipe_sysroot doesnt exist for all recipes, but we needit to have
meta/recipes-extended/baremetal-examples/ line 112
Quoted 9 lines
meta/recipes-extended/baremetal-examples/ new file +9
-0+ # /usr/bin on recipe-sysroot (qemu) populated + def extraimage_getdepends(task): + deps = "" + for dep in (d.getVar('EXTRA_IMAGEDEPENDS') or "").split(): + # Make sure we only add it for qemu + if 'qemu' in dep: + deps += " %s:%s" % (dep, task) + return deps + d.appendVarFlag('do_image', 'depends',
extraimage_getdepends('do_addto_recipe_sysroot'))meta/recipes-extended/baremetal-examples/ line 113
Quoted 1 line
meta/recipes-extended/baremetal-examples/ new file +1
-0+ d.appendVarFlag('do_image', 'depends',
extraimage_getdepends('do_populate_sysroot'))Quoted 3 lines
meta/recipes-extended/baremetal-examples/ new file +1
-1+} --2.7.4
Thanks,
Paul
Quoted 70 lines · Alejandro Enedino Hernandez Samaniego
Hey Paul,
Quoted 49 lines · Paul Barker
Quoted 46 lines · Alejandro Enedino Hernandez Samaniego
Create HelloWorld examples that run on several of the QEMU architectures supported by the build system.
This recipe can be used by anyone to understand how baremetal applications can be built using OpenEmbedded and how the wiring to set them up could be.
This should also facilitate creating/extending the OE testing infrastructure to allow baremetal applications or RTOSs to be tested in the same way that Linux currently is.
This can easily be extended to work on other MACHINES in the future.
To run this example:
# Source the oe environment as usual
$ source oe-init-buildenv# Set TCLIBC to either newlib or baremetal
$ echo "TCLIBC = \"newlib\"" >> ./conf/local.conf# Use one of the supported architectures (qemuarm64, qemuarm or qemuarmv5)
$ echo "MACHINE = \"qemuarm64\"" >> ./conf/local.conf# Build
$ bitbake baremetal-helloworld# Launch QEMU
$ runqemurunqemu - INFO - Running bitbake -e ...
runqemu - INFO - Continuing with the following parameters:
KERNEL: [tmp/deploy/images/qemuarm64/baremetal-helloworld-qemuarm64.bin]
MACHINE: [qemuarm64]
FSTYPE: [bin]
ROOTFS: [tmp/deploy/images/qemuarm64/baremetal-helloworld-qemuarm64.bin]
CONFFILE: [tmp/deploy/images/qemuarm64/baremetal-helloworld-qemuarm64.qemuboot.conf]Hello OpenEmbedded!
--- .../baremetal-examples/baremetal-helloworld_git.bb | 114 +++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 meta/recipes-extended/baremetal-examples/baremetal-helloworld_git.bbQuoted 14 lines
meta/recipes-extended/baremetal-examples/baremetal-helloworld_git.bb line 3
Quoted 9 lines
meta/recipes-extended/baremetal-examples/baremetal-helloworld_git.bb new file +3
-0@@ -0,0 +1,114 @@ +SUMMARY = "Baremetal examples to work with the several QEMU architectures supported on OpenEmbedded" +HOMEPAGE = "https://github.com/aehs29/baremetal-helloqemu" +LICENSE = "CC-BY-SA-4.0"I've raised https://github.com/aehs29/baremetal-helloqemu/issues/1 as CC licenses aren't recommended for software.
Quoted 3 lines
I do agree, I originally had it as MIT, although I did base this on the original work of someone who made it work for the versatile architecture and they licensed that with CC-BY-SA and as I was reading I have to use the same license as them.
I thought about it and for the Hello OpenEmbedded examples it would be ok since they should serve mostly as basis for the wiring that users can use to build, run and test their baremetal apps on OE, so the license wouldn't affect them, but I'm open to suggestions here.
A bad license choice in a sample recipe is just going to encourage others to use it though. I'd recommend reviewing
https://wiki.creativecommons.org/wiki/ShareAlike_compatibility:_GPLv3
to see if you can use GPLv3 instead if you've got CC-BY-SA inputs. You could also contact the original author and ask about licensing the code more cleanly.
Thanks,
Paul
Hey guys,
Quoted 98 lines · Paul Barker
Quoted 11 lines · Alejandro Enedino Hernandez Samaniego
Hey Paul,
Quoted 5 lines · Paul Barker
Quoted 2 lines · Alejandro Enedino Hernandez Samaniego
Create HelloWorld examples that run on several of the QEMU
architectures
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
supported by the build system.
This recipe can be used by anyone to understand how baremetal
applications
Quoted 1 line
Quoted 1 line
Quoted 1 line
can be built using OpenEmbedded and how the wiring to set them up
could be.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
This should also facilitate creating/extending the OE testing
infrastructure
Quoted 1 line
Quoted 1 line
Quoted 1 line
to allow baremetal applications or RTOSs to be tested in the same way
that
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Linux currently is.
This can easily be extended to work on other MACHINES in the future.
To run this example:
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
# Source the oe environment as usual
$ source oe-init-buildenv# Set TCLIBC to either newlib or baremetal
$ echo "TCLIBC = \"newlib\"" >> ./conf/local.conf# Use one of the supported architectures (qemuarm64, qemuarm or
qemuarmv5)
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
$ echo "MACHINE = \"qemuarm64\"" >> ./conf/local.conf# Build
$ bitbake baremetal-helloworld# Launch QEMU
$ runqemurunqemu - INFO - Running bitbake -e ...
runqemu - INFO - Continuing with the following parameters:
KERNEL:[tmp/deploy/images/qemuarm64/baremetal-helloworld-qemuarm64.bin]
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
MACHINE: [qemuarm64]
FSTYPE: [bin]
ROOTFS:[tmp/deploy/images/qemuarm64/baremetal-helloworld-qemuarm64.bin]
Quoted 1 line
Quoted 1 line
Quoted 1 line
CONFFILE:
[
tmp/deploy/images/qemuarm64/baremetal-helloworld-qemuarm64.qemuboot.conf]Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Hello OpenEmbedded!
Signed-off-by Alejandro Enedino Hernandez Samaniego <Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
--- .../baremetal-examples/baremetal-helloworld_git.bb | 114+++++++++++++++++++++
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
1 file changed, 114 insertions(+) create mode 100644 meta/recipes-extended/baremetal-examples/baremetal-helloworld_git.bb
Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +0
-0baremetal-helloworld_git.bb b/meta/recipes-extended/baremetal-examples/ baremetal-helloworld_git.bb
Quoted 4 lines
Quoted 4 lines
meta/recipes-extended/baremetal-examples/
Quoted 4 lines
new file mode 100644
index 0000000..aab48b1meta/recipes-extended/baremetal-examples/ new file +0
-0baremetal-helloworld_git.bb
Quoted 2 lines
Quoted 2 lines
meta/recipes-extended/baremetal-examples/ line 1
Quoted 2 lines
meta/recipes-extended/baremetal-examples/ new file +1
-0@@ -0,0 +1,114 @@ +SUMMARY = "Baremetal examples to work with the several QEMUarchitectures supported on OpenEmbedded"
Quoted 9 lines
Quoted 7 lines
meta/recipes-extended/baremetal-examples/ line 3
Quoted 2 lines
meta/recipes-extended/baremetal-examples/ new file +2
-0+HOMEPAGE = "https://github.com/aehs29/baremetal-helloqemu" +LICENSE = "CC-BY-SA-4.0"I've raised https://github.com/aehs29/baremetal-helloqemu/issues/1 as CC licenses aren't recommended for software.
I do agree, I originally had it as MIT, although I did base this on the
original work of someone who made it work for the versatile architecture and they licensed that with CC-BY-SA and as I was reading I have to use the same license as them.
Quoted 2 lines
I thought about it and for the Hello OpenEmbedded examples it would be
ok since they should serve mostly as basis for the wiring that users can use to build, run and test their baremetal apps on OE, so the license wouldn't affect them, but I'm open to suggestions here.
Quoted 7 lines
A bad license choice in a sample recipe is just going to encourage others to use it though. I'd recommend reviewing
https://wiki.creativecommons.org/wiki/ShareAlike_compatibility:_GPLv3
to see if you can use GPLv3 instead if you've got CC-BY-SA inputs. You could also contact the original author and ask about licensing the code more cleanly.
Agreed, I took a look at that already and it looks like the compatibility starts with CC-BY-SA 4 which didn't exist when the original code was written, but that's why I chose v4 because it was compatible with the older ones and people that use this can use GPLv3 if they want to since this is CC-BY-SA v4, again this wasn't my first choice either.
I tried contacting the author already but it's been a while and he hasn't replied yet.
Alejandro
Quoted 4 lines
Thanks,
Paul
Quoted 37 lines · Alejandro Enedino Hernandez Samaniego
Create HelloWorld examples that run on several of the QEMU architectures supported by the build system.
This recipe can be used by anyone to understand how baremetal applications can be built using OpenEmbedded and how the wiring to set them up could be.
This should also facilitate creating/extending the OE testing infrastructure to allow baremetal applications or RTOSs to be tested in the same way that Linux currently is.
This can easily be extended to work on other MACHINES in the future.
To run this example:
# Source the oe environment as usual
$ source oe-init-buildenv# Set TCLIBC to either newlib or baremetal
$ echo "TCLIBC = \"newlib\"" >> ./conf/local.conf# Use one of the supported architectures (qemuarm64, qemuarm or qemuarmv5)
$ echo "MACHINE = \"qemuarm64\"" >> ./conf/local.conf# Build
$ bitbake baremetal-helloworld# Launch QEMU
$ runqemurunqemu - INFO - Running bitbake -e ...
runqemu - INFO - Continuing with the following parameters:
KERNEL: [tmp/deploy/images/qemuarm64/baremetal-helloworld-qemuarm64.bin]
MACHINE: [qemuarm64]
FSTYPE: [bin]
ROOTFS: [tmp/deploy/images/qemuarm64/baremetal-helloworld-qemuarm64.bin]
CONFFILE: [tmp/deploy/images/qemuarm64/baremetal-helloworld-qemuarm64.qemuboot.conf]
Quoted 1 line
Hello OpenEmbedded!
Looks good.
Should this be in meta-skeleton? That sublayer generally has our configuration example tests in as far as I can tell...
Do you plan to add an oe-selftest for this?
Cheers,
Richard
Quoted 49 lines · Richard Purdie
Quoted 4 lines · Alejandro Enedino Hernandez Samaniego
Create HelloWorld examples that run on several of the QEMU architectures supported by the build system.
This recipe can be used by anyone to understand how baremetal
applications
Quoted 1 line
can be built using OpenEmbedded and how the wiring to set them up could
be.
Quoted 2 lines
This should also facilitate creating/extending the OE testing
infrastructure
Quoted 1 line
to allow baremetal applications or RTOSs to be tested in the same way
that
Quoted 6 lines
Linux currently is.
This can easily be extended to work on other MACHINES in the future.
To run this example:
Quoted 7 lines
# Source the oe environment as usual
$ source oe-init-buildenv# Set TCLIBC to either newlib or baremetal
$ echo "TCLIBC = \"newlib\"" >> ./conf/local.conf# Use one of the supported architectures (qemuarm64, qemuarm or
qemuarmv5)
Quoted 8 lines
$ echo "MACHINE = \"qemuarm64\"" >> ./conf/local.conf# Build
$ bitbake baremetal-helloworld# Launch QEMU
$ runqemuQuoted 7 lines
runqemu - INFO - Running bitbake -e ...
runqemu - INFO - Continuing with the following parameters:
KERNEL: [tmp/deploy/images/qemuarm64/baremetal-helloworld-qemuarm64.bin]
MACHINE: [qemuarm64]
FSTYPE: [bin]
ROOTFS: [tmp/deploy/images/qemuarm64/baremetal-helloworld-qemuarm64.bin] CONFFILE:[
tmp/deploy/images/qemuarm64/baremetal-helloworld-qemuarm64.qemuboot.conf]Quoted 2 lines
Hello OpenEmbedded!
Looks good.
Quoted 9 lines
Should this be in meta-skeleton? That sublayer generally has our configuration example tests in as far as I can tell...
Do you plan to add an oe-selftest for this?
Cheers,
Richard
Hey Richard,
I do, that's exactly the plan, I'm working on both oe-selftest and runtime testing cases for this, I'm just doing it in chunks.
Cheers,
Alejandro
Quoted 1 line
Quoted 52 lines · Alejandro Enedino Hernandez Samaniego
Create HelloWorld examples that run on several of the QEMU architectures supported by the build system.
This recipe can be used by anyone to understand how baremetal applications can be built using OpenEmbedded and how the wiring to set them up could be.
This should also facilitate creating/extending the OE testing infrastructure to allow baremetal applications or RTOSs to be tested in the same way that Linux currently is.
This can easily be extended to work on other MACHINES in the future.
To run this example:
# Source the oe environment as usual
$ source oe-init-buildenv# Set TCLIBC to either newlib or baremetal
$ echo "TCLIBC = \"newlib\"" >> ./conf/local.conf# Use one of the supported architectures (qemuarm64, qemuarm or qemuarmv5)
$ echo "MACHINE = \"qemuarm64\"" >> ./conf/local.conf# Build
$ bitbake baremetal-helloworld# Launch QEMU
$ runqemurunqemu - INFO - Running bitbake -e ...
runqemu - INFO - Continuing with the following parameters:
KERNEL: [tmp/deploy/images/qemuarm64/baremetal-helloworld-qemuarm64.bin]
MACHINE: [qemuarm64]
FSTYPE: [bin]
ROOTFS: [tmp/deploy/images/qemuarm64/baremetal-helloworld-qemuarm64.bin]
CONFFILE: [tmp/deploy/images/qemuarm64/baremetal-helloworld-qemuarm64.qemuboot.conf]Hello OpenEmbedded!
--- .../baremetal-examples/baremetal-helloworld_git.bb | 114 +++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 meta/recipes-extended/baremetal-examples/baremetal-helloworld_git.bbmeta/recipes-extended/baremetal-examples/baremetal-helloworld_git.bb new file +0
-0
meta/recipes-extended/baremetal-examples/baremetal-helloworld_git.bb line 3
Quoted 3 lines
meta/recipes-extended/baremetal-examples/baremetal-helloworld_git.bb new file +3
-0@@ -0,0 +1,114 @@ +SUMMARY = "Baremetal examples to work with the several QEMU architectures supported on OpenEmbedded" +HOMEPAGE = "https://github.com/aehs29/baremetal-helloqemu" +LICENSE = "CC-BY-SA-4.0"
I think MIT or Apache-2.0 would be much nicer.
meta/recipes-extended/baremetal-examples/baremetal-helloworld_git.bb line 15
Quoted 12 lines
meta/recipes-extended/baremetal-examples/baremetal-helloworld_git.bb new file +12
-0+LIC_FILES_CHKSUM = "file://LICENSE;md5=4084714af41157e38872e798eb3fe1b1" + +SRCREV = "fe81742f1159725408dd7305e40e7bd4dfd1e264" + +SRC_URI = "git://github.com/aehs29/baremetal-helloqemu.git;protocol=https " + +S = "${WORKDIR}/git" +B = "${WORKDIR}/build" + +# These examples are not meant to be built when using either musl or glibc +COMPATIBLE_HOST_libc-musl_class-target = "null" +COMPATIBLE_HOST_libc-glibc_class-target = "null"
Perhaps check for TARGET_OS instead of LIBC
meta/recipes-extended/baremetal-examples/baremetal-helloworld_git.bb line 27
Quoted 11 lines
meta/recipes-extended/baremetal-examples/baremetal-helloworld_git.bb new file +11
-0+# This will be translated automatically to the architecture and +# machine that QEMU uses on OE, e.g. -machine virt -cpu cortex-a57 +# but the examples can also be run on other architectures/machines +# such as vexpress-a15 by overriding the setting on the machine.conf +COMPATIBLE_MACHINE = "qemuarmv5|qemuarm|qemuarm64" + +BAREMETAL_QEMUARCH ?= "" +BAREMETAL_QEMUARCH_qemuarmv5 = "versatile" +BAREMETAL_QEMUARCH_qemuarm = "arm" +BAREMETAL_QEMUARCH_qemuarm64 = "aarch64" +
this setting should be abstracted into something like baremetal.bbclass
meta/recipes-extended/baremetal-examples/baremetal-helloworld_git.bb line 34
Quoted 7 lines
meta/recipes-extended/baremetal-examples/baremetal-helloworld_git.bb new file +7
-0+ +EXTRA_OEMAKE_append = " QEMUARCH=${BAREMETAL_QEMUARCH}" + +do_configure(){ + # Avoid building on the source directory + cp ${S}/* ${B} +}
copying sources to B why is that needed ?
meta/recipes-extended/baremetal-examples/baremetal-helloworld_git.bb line 45
Quoted 11 lines
meta/recipes-extended/baremetal-examples/baremetal-helloworld_git.bb new file +11
-0+ +do_install(){ + install -d ${D}/${datadir} + install -m 755 ${B}/hello_baremetal_${BAREMETAL_QEMUARCH}.bin ${D}/${datadir}/hello_baremetal_${MACHINE}.bin + install -m 755 ${B}/hello_baremetal_${BAREMETAL_QEMUARCH}.elf ${D}/${datadir}/hello_baremetal_${MACHINE}.elf +} + +# Make sure there are no race conditions when +# assembling compiling and linking steps +PARALLEL_MAKE = "" +
hmmm bad example to start of.
Quoted 31 lines
meta/recipes-extended/baremetal-examples/baremetal-helloworld_git.bb new file +31
-0+# Borrowed from meta-freertos +inherit rootfs-postcommands +inherit deploy +do_deploy[dirs] = "${DEPLOYDIR} ${DEPLOY_DIR_IMAGE}" +do_rootfs[dirs] = "${DEPLOYDIR} ${DEPLOY_DIR_IMAGE}" +DEPLOYDIR = "${IMGDEPLOYDIR}" +IMAGE_LINK_NAME ?= "baremetal-helloworld-image-${MACHINE}" +IMAGE_NAME_SUFFIX ?= "" + +do_deploy(){ + install ${D}/${datadir}/hello_baremetal_${MACHINE}.bin ${DEPLOYDIR}/${IMAGE_LINK_NAME}.bin + install ${D}/${datadir}/hello_baremetal_${MACHINE}.elf ${DEPLOYDIR}/${IMAGE_LINK_NAME}.elf +} + +do_image(){ + : +} + +FILES_${PN} += " \ + ${datadir}/hello_baremetal_${MACHINE}.bin \ + ${datadir}/hello_baremetal_${MACHINE}.elf \ +" + +python do_rootfs(){ + from oe.utils import execute_pre_post_process + from pathlib import Path + + # Write empty manifest testdate file + deploy_dir = d.getVar('DEPLOYDIR') + link_name = d.getVar('IMAGE_LINK_NAME') + manifest_name = d.getVar('IMAGE_MANIFEST')
meta/recipes-extended/baremetal-examples/baremetal-helloworld_git.bb line 86
Quoted 10 lines
meta/recipes-extended/baremetal-examples/baremetal-helloworld_git.bb new file +10
-0+ + Path(manifest_name).touch() + if os.path.exists(manifest_name) and link_name: + manifest_link = deploy_dir + "/" + link_name + ".manifest" + if os.path.lexists(manifest_link): + os.remove(manifest_link) + os.symlink(os.path.basename(manifest_name), manifest_link) + execute_pre_post_process(d, d.getVar('ROOTFS_POSTPROCESS_COMMAND')) +} +
these all should be abstracted
meta/recipes-extended/baremetal-examples/baremetal-helloworld_git.bb line 93
Quoted 7 lines
meta/recipes-extended/baremetal-examples/baremetal-helloworld_git.bb new file +7
-0+# QEMU generic FreeRTOS parameters +QB_DEFAULT_KERNEL = "${IMAGE_LINK_NAME}.bin" +QB_MEM = "-m 256" +QB_OPT_APPEND = "-nographic" +QB_DEFAULT_FSTYPE = "bin" +QB_DTB = "" +
this setting perhaps should be in machine conf ?
Quoted 29 lines
meta/recipes-extended/baremetal-examples/baremetal-helloworld_git.bb new file +21
-1+# This next part is necessary to trick the build system into thinking +# its building an image recipe so it generates the qemuboot.conf +addtask do_deploy after do_write_qemuboot_conf before do_build +addtask do_rootfs before do_deploy after do_install +addtask do_image after do_rootfs before do_build +inherit qemuboot + +# Based on image.bbclass to make sure we build qemu +python(){ + # do_addto_recipe_sysroot doesnt exist for all recipes, but we need it to have + # /usr/bin on recipe-sysroot (qemu) populated + def extraimage_getdepends(task): + deps = "" + for dep in (d.getVar('EXTRA_IMAGEDEPENDS') or "").split(): + # Make sure we only add it for qemu + if 'qemu' in dep: + deps += " %s:%s" % (dep, task) + return deps + d.appendVarFlag('do_image', 'depends', extraimage_getdepends('do_addto_recipe_sysroot')) + d.appendVarFlag('do_image', 'depends', extraimage_getdepends('do_populate_sysroot')) +} --2.7.4
--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core
Hey Khem,
Quoted 65 lines · Khem Raj
Quoted 5 lines · Alejandro Enedino Hernandez Samaniego
Create HelloWorld examples that run on several of the QEMU architectures supported by the build system.
This recipe can be used by anyone to understand how baremetal
applications
Quoted 1 line
can be built using OpenEmbedded and how the wiring to set them up could
be.
Quoted 2 lines
This should also facilitate creating/extending the OE testing
infrastructure
Quoted 1 line
to allow baremetal applications or RTOSs to be tested in the same way
that
Quoted 6 lines
Linux currently is.
This can easily be extended to work on other MACHINES in the future.
To run this example:
Quoted 7 lines
# Source the oe environment as usual
$ source oe-init-buildenv# Set TCLIBC to either newlib or baremetal
$ echo "TCLIBC = \"newlib\"" >> ./conf/local.conf# Use one of the supported architectures (qemuarm64, qemuarm or
qemuarmv5)
Quoted 8 lines
$ echo "MACHINE = \"qemuarm64\"" >> ./conf/local.conf# Build
$ bitbake baremetal-helloworld# Launch QEMU
$ runqemuQuoted 7 lines
runqemu - INFO - Running bitbake -e ...
runqemu - INFO - Continuing with the following parameters:
KERNEL: [tmp/deploy/images/qemuarm64/baremetal-helloworld-qemuarm64.bin]
MACHINE: [qemuarm64]
FSTYPE: [bin]
ROOTFS: [tmp/deploy/images/qemuarm64/baremetal-helloworld-qemuarm64.bin] CONFFILE:[
tmp/deploy/images/qemuarm64/baremetal-helloworld-qemuarm64.qemuboot.conf]Quoted 4 lines
Hello OpenEmbedded!
Signed-off-by Alejandro Enedino Hernandez Samaniego <Quoted 2 lines
--- .../baremetal-examples/baremetal-helloworld_git.bb | 114+++++++++++++++++++++
Quoted 2 lines
1 file changed, 114 insertions(+) create mode 100644 meta/recipes-extended/baremetal-examples/baremetal-helloworld_git.bb
Review
Quoted 2 lines
(quoted diff) +0
-0baremetal-helloworld_git.bb b/meta/recipes-extended/baremetal-examples/ baremetal-helloworld_git.bb
meta/recipes-extended/baremetal-examples/
Quoted 4 lines
new file mode 100644
index 0000000..aab48b1meta/recipes-extended/baremetal-examples/ new file +0
-0baremetal-helloworld_git.bb
Quoted 8 lines
meta/recipes-extended/baremetal-examples/ line 1
Quoted 2 lines
meta/recipes-extended/baremetal-examples/ new file +1
-0@@ -0,0 +1,114 @@ +SUMMARY = "Baremetal examples to work with the several QEMUarchitectures supported on OpenEmbedded"
meta/recipes-extended/baremetal-examples/ line 3
Quoted 2 lines
meta/recipes-extended/baremetal-examples/ new file +2
-0+HOMEPAGE = "https://github.com/aehs29/baremetal-helloqemu" +LICENSE = "CC-BY-SA-4.0"I think MIT or Apache-2.0 would be much nicer.
I agree but this wasn't by choice, the original code written for the versatile architecture was licensed on CC-BY-SA, which AFAIC wouldn't be compatible with those, this is the best I could come up with since this way, something that uses this could use GPLv3 if there's a better way let me know
Quoted 12 lines
meta/recipes-extended/baremetal-examples/ line 8
Quoted 5 lines
meta/recipes-extended/baremetal-examples/ new file +5
-0+LIC_FILES_CHKSUM = "file://LICENSE;md5=4084714af41157e38872e798eb3fe1b1" + +SRCREV = "fe81742f1159725408dd7305e40e7bd4dfd1e264" + +SRC_URI = "git://github.com/aehs29/baremetal-helloqemu.git;protocol=https "
meta/recipes-extended/baremetal-examples/ line 13
Quoted 5 lines
meta/recipes-extended/baremetal-examples/ new file +5
-0+ +S = "${WORKDIR}/git" +B = "${WORKDIR}/build" + +# These examples are not meant to be built when using either musl orglibc
Quoted 5 lines
meta/recipes-extended/baremetal-examples/ line 15
Quoted 2 lines
meta/recipes-extended/baremetal-examples/ new file +2
-0+COMPATIBLE_HOST_libc-musl_class-target = "null" +COMPATIBLE_HOST_libc-glibc_class-target = "null"Perhaps check for
TARGET_OSinstead of LIBC
We had decided this to avoid bitbake world errors, if you think TARGET_OS is better I'm okay with that.
Quoted 80 lines
meta/recipes-extended/baremetal-examples/ line 26
Quoted 11 lines
meta/recipes-extended/baremetal-examples/ new file +11
-0+# This will be translated automatically to the architecture and +# machine that QEMU uses on OE, e.g. -machine virt -cpu cortex-a57 +# but the examples can also be run on other architectures/machines +# such as vexpress-a15 by overriding the setting on the machine.conf +COMPATIBLE_MACHINE = "qemuarmv5|qemuarm|qemuarm64" + +BAREMETAL_QEMUARCH ?= "" +BAREMETAL_QEMUARCH_qemuarmv5 = "versatile" +BAREMETAL_QEMUARCH_qemuarm = "arm" +BAREMETAL_QEMUARCH_qemuarm64 = "aarch64" +this setting should be abstracted into something like baremetal.bbclass
meta/recipes-extended/baremetal-examples/ line 33
Quoted 7 lines
meta/recipes-extended/baremetal-examples/ new file +7
-0+ +EXTRA_OEMAKE_append = " QEMUARCH=${BAREMETAL_QEMUARCH}" + +do_configure(){ + # Avoid building on the source directory + cp ${S}/* ${B} +}copying sources to B why is that needed ?
meta/recipes-extended/baremetal-examples/ line 37
Quoted 4 lines
meta/recipes-extended/baremetal-examples/ new file +4
-0+ +do_install(){ + install -d ${D}/${datadir} + install -m 755 ${B}/hello_baremetal_${BAREMETAL_QEMUARCH}.bin${D}/${datadir}/hello_baremetal_${MACHINE}.bin
meta/recipes-extended/baremetal-examples/ line 38
Quoted 1 line
meta/recipes-extended/baremetal-examples/ new file +1
-0+ install -m 755 ${B}/hello_baremetal_${BAREMETAL_QEMUARCH}.elf${D}/${datadir}/hello_baremetal_${MACHINE}.elf
meta/recipes-extended/baremetal-examples/ line 44
Quoted 6 lines
meta/recipes-extended/baremetal-examples/ new file +6
-0+} + +# Make sure there are no race conditions when +# assembling compiling and linking steps +PARALLEL_MAKE = "" +hmmm bad example to start of.
meta/recipes-extended/baremetal-examples/ line 55
Quoted 11 lines
meta/recipes-extended/baremetal-examples/ new file +11
-0+# Borrowed from meta-freertos +inherit rootfs-postcommands +inherit deploy +do_deploy[dirs] = "${DEPLOYDIR} ${DEPLOY_DIR_IMAGE}" +do_rootfs[dirs] = "${DEPLOYDIR} ${DEPLOY_DIR_IMAGE}" +DEPLOYDIR = "${IMGDEPLOYDIR}" +IMAGE_LINK_NAME ?= "baremetal-helloworld-image-${MACHINE}" +IMAGE_NAME_SUFFIX ?= "" + +do_deploy(){ + install ${D}/${datadir}/hello_baremetal_${MACHINE}.bin${DEPLOYDIR}/${IMAGE_LINK_NAME}.bin
meta/recipes-extended/baremetal-examples/ line 56
Quoted 1 line
meta/recipes-extended/baremetal-examples/ new file +1
-0+ install ${D}/${datadir}/hello_baremetal_${MACHINE}.elf${DEPLOYDIR}/${IMAGE_LINK_NAME}.elf
Quoted 24 lines
meta/recipes-extended/baremetal-examples/ new file +24
-0+} + +do_image(){ + : +} + +FILES_${PN} += " \ + ${datadir}/hello_baremetal_${MACHINE}.bin \ + ${datadir}/hello_baremetal_${MACHINE}.elf \ +" + +python do_rootfs(){ + from oe.utils import execute_pre_post_process + from pathlib import Path + + # Write empty manifest testdate file + deploy_dir = d.getVar('DEPLOYDIR') + link_name = d.getVar('IMAGE_LINK_NAME') + manifest_name = d.getVar('IMAGE_MANIFEST') + + Path(manifest_name).touch() + if os.path.exists(manifest_name) and link_name: + manifest_link = deploy_dir + "/" + link_name + ".manifest" + if os.path.lexists(manifest_link):
Quoted 9 lines
meta/recipes-extended/baremetal-examples/ line 85
Quoted 5 lines
meta/recipes-extended/baremetal-examples/ new file +5
-0+ os.remove(manifest_link) + os.symlink(os.path.basename(manifest_name), manifest_link) + execute_pre_post_process(d, d.getVar('ROOTFS_POSTPROCESS_COMMAND')) +} +these all should be abstracted
Ok, of all the above, my intention is to create a class that abstracts this, it actually already is a class on meta-freertos, even the code below, but I have WIP on testimage, oe-selftest, FreeRTOS and for the next couple of days I'll have a lot on my plate and I'm trying to split the work in chunks, so it doesn't break other WIP and at the same time I get things done, I agree its not ideal, but its less confusing for me to have a single class for now (the meta-freertos one), along with these recipes already being built for the test cases and once I can upstream the work, all this will be abstracted in a class in oe-core, I can file a bug in bugzilla and take it to keep track of this if that helps.
v2 fixes:
Copying sources
Paralell make
Quoted 10 lines
meta/recipes-extended/baremetal-examples/ line 92
Quoted 7 lines
meta/recipes-extended/baremetal-examples/ new file +7
-0+# QEMU generic FreeRTOS parameters +QB_DEFAULT_KERNEL = "${IMAGE_LINK_NAME}.bin" +QB_MEM = "-m 256" +QB_OPT_APPEND = "-nographic" +QB_DEFAULT_FSTYPE = "bin" +QB_DTB = "" +this setting perhaps should be in machine conf ?
Those are already on the machine.conf, these are overriding the Linux configurations so QEMU loads the baremetal application correctly , e.g. FSTYPE=bin
Quoted 33 lines
meta/recipes-extended/baremetal-examples/ line 102
Quoted 10 lines
meta/recipes-extended/baremetal-examples/ new file +10
-0+# This next part is necessary to trick the build system into thinking +# its building an image recipe so it generates the qemuboot.conf +addtask do_deploy after do_write_qemuboot_conf before do_build +addtask do_rootfs before do_deploy after do_install +addtask do_image after do_rootfs before do_build +inherit qemuboot + +# Based on image.bbclass to make sure we build qemu +python(){ + # do_addto_recipe_sysroot doesnt exist for all recipes, but we needit to have
meta/recipes-extended/baremetal-examples/ line 111
Quoted 9 lines
meta/recipes-extended/baremetal-examples/ new file +9
-0+ # /usr/bin on recipe-sysroot (qemu) populated + def extraimage_getdepends(task): + deps = "" + for dep in (d.getVar('EXTRA_IMAGEDEPENDS') or "").split(): + # Make sure we only add it for qemu + if 'qemu' in dep: + deps += " %s:%s" % (dep, task) + return deps + d.appendVarFlag('do_image', 'depends',
extraimage_getdepends('do_addto_recipe_sysroot'))meta/recipes-extended/baremetal-examples/ line 112
Quoted 1 line
meta/recipes-extended/baremetal-examples/ new file +1
-0+ d.appendVarFlag('do_image', 'depends',
extraimage_getdepends('do_populate_sysroot'))Quoted 9 lines
meta/recipes-extended/baremetal-examples/ new file +1
-1+} --2.7.4
--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core