baremetal-helloworld_git.bb 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. SUMMARY = "Baremetal examples to work with the several QEMU architectures supported on OpenEmbedded"
  2. HOMEPAGE = "https://github.com/aehs29/baremetal-helloqemu"
  3. DESCRIPTION = "These are introductory examples to showcase the use of QEMU to run baremetal applications."
  4. LICENSE = "MIT"
  5. LIC_FILES_CHKSUM = "file://LICENSE;md5=39346640a23c701e4f459e05f56f4449"
  6. SRCREV = "db2bf750eaef7fc0832e13ada8291343bbcc3afe"
  7. PV = "0.1+git"
  8. SRC_URI = "git://github.com/ahcbb6/baremetal-helloqemu.git;protocol=https;branch=master"
  9. UPSTREAM_CHECK_COMMITS = "1"
  10. # The following variables should be set to accomodate each application
  11. BAREMETAL_BINNAME ?= "hello_baremetal_${MACHINE}"
  12. IMAGE_LINK_NAME ?= "baremetal-helloworld-image-${MACHINE}"
  13. IMAGE_NAME_SUFFIX ?= ""
  14. # Baremetal-Image creates the proper wiring, assumes the output is provided in
  15. # binary and ELF format, installed on ${base_libdir}/firmware/ , we want a
  16. # package to be created since we might have some way of updating the baremetal
  17. # firmware from Linux
  18. inherit baremetal-image
  19. # startup code for x86 uses NASM syntax
  20. DEPENDS:qemux86:append = " nasm-native"
  21. # These parameters are app specific for this example
  22. # This will be translated automatically to the architecture and
  23. # machine that QEMU uses on OE, e.g. -machine virt -cpu cortex-a57
  24. # but the examples can also be run on other architectures/machines
  25. # such as vexpress-a15 by overriding the setting on the machine.conf
  26. COMPATIBLE_MACHINE = "qemuarmv5|qemuarm|qemuarm64|qemuriscv64|qemuriscv32|qemux86|qemux86-64"
  27. BAREMETAL_QEMUARCH ?= ""
  28. BAREMETAL_QEMUARCH:qemuarmv5 = "versatile"
  29. BAREMETAL_QEMUARCH:qemuarm = "arm"
  30. BAREMETAL_QEMUARCH:qemuarm64 = "aarch64"
  31. BAREMETAL_QEMUARCH:qemuriscv64 = "riscv64"
  32. BAREMETAL_QEMUARCH:qemuriscv32 = "riscv32"
  33. BAREMETAL_QEMUARCH:qemux86 = "x86"
  34. BAREMETAL_QEMUARCH:qemux86-64 = "x86-64"
  35. EXTRA_OEMAKE:append = " QEMUARCH=${BAREMETAL_QEMUARCH} V=1"
  36. # qemux86-64 uses a different Makefile
  37. do_compile:prepend:qemux86-64(){
  38. cd x86-64
  39. }
  40. # Install binaries on the proper location for baremetal-image to fetch and deploy
  41. do_install(){
  42. install -d ${D}/${base_libdir}/firmware
  43. install -m 755 ${B}/build/hello_baremetal_${BAREMETAL_QEMUARCH}.bin ${D}/${base_libdir}/firmware/${BAREMETAL_BINNAME}.bin
  44. install -m 755 ${B}/build/hello_baremetal_${BAREMETAL_QEMUARCH}.elf ${D}/${base_libdir}/firmware/${BAREMETAL_BINNAME}.elf
  45. }
  46. FILES:${PN} += " \
  47. ${base_libdir}/firmware/${BAREMETAL_BINNAME}.bin \
  48. ${base_libdir}/firmware/${BAREMETAL_BINNAME}.elf \
  49. "
  50. # qemux86-64 boots from iso rather than -kernel, create image to boot from
  51. do_image:append:qemux86-64(){
  52. dd if=/dev/zero of=${B}/build/img.iso bs=1M count=10 status=none
  53. dd if=${B}/build/stage1.bin of=${B}/build/img.iso bs=512 count=1 conv=notrunc
  54. dd if=${B}/build/stage2.bin of=${B}/build/img.iso bs=512 seek=1 count=64 conv=notrunc
  55. dd if=${B}/build/hello_baremetal_x86-64.bin of=${B}/build/img.iso bs=512 seek=65 conv=notrunc
  56. install ${B}/build/img.iso ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.iso
  57. }