This is used as a bootloader for RISC-V QEMU machines. Signed-off-by: Alistair Francis <alistair.fran...@wdc.com> --- ...Makefile-Don-t-specify-mabi-or-march.patch | 38 ++++++++++++++ ...-address-of-packed-member-warning-wi.patch | 52 +++++++++++++++++++ meta/recipes-bsp/opensbi/opensbi-payloads.inc | 37 +++++++++++++ meta/recipes-bsp/opensbi/opensbi_0.3.bb | 49 +++++++++++++++++ 4 files changed, 176 insertions(+) create mode 100644 meta/recipes-bsp/opensbi/files/0001-Makefile-Don-t-specify-mabi-or-march.patch create mode 100644 meta/recipes-bsp/opensbi/files/0001-sbi_ipi.c-Ignore-address-of-packed-member-warning-wi.patch create mode 100644 meta/recipes-bsp/opensbi/opensbi-payloads.inc create mode 100644 meta/recipes-bsp/opensbi/opensbi_0.3.bb
diff --git a/meta/recipes-bsp/opensbi/files/0001-Makefile-Don-t-specify-mabi-or-march.patch b/meta/recipes-bsp/opensbi/files/0001-Makefile-Don-t-specify-mabi-or-march.patch new file mode 100644 index 0000000000..9c2d0eb479 --- /dev/null +++ b/meta/recipes-bsp/opensbi/files/0001-Makefile-Don-t-specify-mabi-or-march.patch @@ -0,0 +1,38 @@ +From f5871e1f3650d6c8a032928cb5d8ca00c275c377 Mon Sep 17 00:00:00 2001 +From: Alistair Francis <alistair.fran...@wdc.com> +Date: Fri, 15 Feb 2019 14:57:41 -0800 +Subject: [PATCH] Makefile: Don't specify mabi or march + +To avoid + can't link double-float modules with soft-float modules +errors when building 32-bit openSBI don't specify mabi or march. + +Upstream-Status: Inappropriate [Fixes a 32-bit Yocto flow bug] +Signed-off-by: Alistair Francis <alistair.fran...@wdc.com> +--- + Makefile | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/Makefile b/Makefile +index ae68f55..10851fc 100644 +--- a/Makefile ++++ b/Makefile +@@ -145,7 +145,6 @@ GENFLAGS += $(firmware-genflags-y) + CFLAGS = -g -Wall -Werror -nostdlib -fno-strict-aliasing -O2 + CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls + CFLAGS += -mno-save-restore -mstrict-align +-CFLAGS += -mabi=$(PLATFORM_RISCV_ABI) -march=$(PLATFORM_RISCV_ISA) + CFLAGS += -mcmodel=$(PLATFORM_RISCV_CODE_MODEL) + CFLAGS += $(GENFLAGS) + CFLAGS += $(platform-cflags-y) +@@ -158,7 +157,6 @@ CPPFLAGS += $(firmware-cppflags-y) + ASFLAGS = -g -Wall -nostdlib -D__ASSEMBLY__ + ASFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls + ASFLAGS += -mno-save-restore -mstrict-align +-ASFLAGS += -mabi=$(PLATFORM_RISCV_ABI) -march=$(PLATFORM_RISCV_ISA) + ASFLAGS += -mcmodel=$(PLATFORM_RISCV_CODE_MODEL) + ASFLAGS += $(GENFLAGS) + ASFLAGS += $(platform-asflags-y) +-- +2.20.1 + diff --git a/meta/recipes-bsp/opensbi/files/0001-sbi_ipi.c-Ignore-address-of-packed-member-warning-wi.patch b/meta/recipes-bsp/opensbi/files/0001-sbi_ipi.c-Ignore-address-of-packed-member-warning-wi.patch new file mode 100644 index 0000000000..28577ddf00 --- /dev/null +++ b/meta/recipes-bsp/opensbi/files/0001-sbi_ipi.c-Ignore-address-of-packed-member-warning-wi.patch @@ -0,0 +1,52 @@ +From dbd2fdb9956417e1d49a14b9aea162b10598c6c0 Mon Sep 17 00:00:00 2001 +From: Khem Raj <raj.k...@gmail.com> +Date: Thu, 7 Mar 2019 20:48:04 -0800 +Subject: [PATCH] sbi_ipi.c: Ignore address-of-packed-member warning with gcc 9 + or newer + +This is a workaround until fixed correctly, for following error + +sbi_ipi.c:34:28: error: taking address of packed member of 'struct sbi_scratch' may result in an unaligned pointer value [-Werror=address-of-packed-member] +| 34 | atomic_raw_set_bit(event, &remote_scratch->ipi_type); +| | ^~~~~~~~~~~~~~~~~~~~~~~~~ + +Signed-off-by: Khem Raj <raj.k...@gmail.com> +--- + lib/sbi_ipi.c | 12 ++++++++++++ + 1 file changed, 12 insertions(+) + +diff --git a/lib/sbi_ipi.c b/lib/sbi_ipi.c +index 5f189c8..bc9df11 100644 +--- a/lib/sbi_ipi.c ++++ b/lib/sbi_ipi.c +@@ -31,7 +31,13 @@ static int sbi_ipi_send(struct sbi_scratch *scratch, u32 hartid, u32 event) + * trigger the interrupt + */ + remote_scratch = sbi_hart_id_to_scratch(scratch, hartid); ++#if __GNUC__ >= 9 ++#pragma GCC diagnostic ignored "-Waddress-of-packed-member" ++#endif + atomic_raw_set_bit(event, &remote_scratch->ipi_type); ++#if __GNUC__ >= 9 ++#pragma GCC diagnostic pop ++#endif + mb(); + sbi_platform_ipi_send(plat, hartid); + if (event != SBI_IPI_EVENT_SOFT) +@@ -97,7 +103,13 @@ void sbi_ipi_process(struct sbi_scratch *scratch) + sbi_hart_hang(); + break; + }; ++#if __GNUC__ >= 9 ++#pragma GCC diagnostic ignored "-Waddress-of-packed-member" ++#endif + ipi_type = atomic_raw_clear_bit(ipi_event, &scratch->ipi_type); ++#if __GNUC__ >= 9 ++#pragma GCC diagnostic pop ++#endif + } while(ipi_type > 0); + } + +-- +2.21.0 + diff --git a/meta/recipes-bsp/opensbi/opensbi-payloads.inc b/meta/recipes-bsp/opensbi/opensbi-payloads.inc new file mode 100644 index 0000000000..7df168325a --- /dev/null +++ b/meta/recipes-bsp/opensbi/opensbi-payloads.inc @@ -0,0 +1,37 @@ +def riscv_get_extra_oemake_image(d): + sbi_payload = d.getVar('RISCV_SBI_PAYLOAD') + deploy_dir = d.getVar('DEPLOY_DIR_IMAGE') + + if sbi_payload is None: + return "" + + if d.getVar('RISCV_SBI_PAYLOAD'): + return "FW_PAYLOAD_PATH=" + deploy_dir + "/" + sbi_payload + + return "" + +def riscv_get_extra_oemake_fdt(d): + sbi_fdt_payload = d.getVar('RISCV_SBI_FDT') + deploy_dir = d.getVar('DEPLOY_DIR_IMAGE') + + if sbi_fdt_payload is None: + return "" + + if d.getVar('RISCV_SBI_PAYLOAD'): + # This is internal to openSBI, not a full path + return "FW_PAYLOAD_FDT=" + sbi_fdt_payload + + return "" + +def riscv_get_do_compile_depends(d): + sbi_payload = d.getVar('RISCV_SBI_PAYLOAD') + + if sbi_payload is None: + return "" + + if 'linux' in sbi_payload or 'Image' in sbi_payload: + return "virtual/kernel:do_deploy" + if 'u-boot' in sbi_payload: + return "virtual/bootloader:do_deploy" + + return "" diff --git a/meta/recipes-bsp/opensbi/opensbi_0.3.bb b/meta/recipes-bsp/opensbi/opensbi_0.3.bb new file mode 100644 index 0000000000..fdfc5eca00 --- /dev/null +++ b/meta/recipes-bsp/opensbi/opensbi_0.3.bb @@ -0,0 +1,49 @@ +SUMMARY = "RISC-V Open Source Supervisor Binary Interface (OpenSBI)" +DESCRIPTION = "OpenSBI aims to provide an open-source and extensible implementation of the RISC-V SBI specification for a platform specific firmware (M-mode) and a general purpose OS, hypervisor or bootloader (S-mode or HS-mode). OpenSBI implementation can be easily extended by RISC-V platform or System-on-Chip vendors to fit a particular hadware configuration." +LICENSE = "BSD-2-Clause" +LIC_FILES_CHKSUM = "file://COPYING.BSD;md5=c36118b4f615f9da37635f2a7ac8ccaf" +DEPENDS += "dtc-native" + +require opensbi-payloads.inc + +inherit autotools-brokensep + +SRCREV = "ca20ac0cd4c099006d4eea4d9ac7bd7b58e2ae0f" +SRC_URI = "git://github.com/riscv/opensbi.git \ + file://0001-Makefile-Don-t-specify-mabi-or-march.patch \ + file://0001-sbi_ipi.c-Ignore-address-of-packed-member-warning-wi.patch \ + " + +S = "${WORKDIR}/git" + +SRC_URI[md5sum] = "621f38d8205ef5fb185e4055025e73df" +SRC_URI[sha256sum] = "07f18b73abf3b85aabe5bead19a923716c100d30eb58033459f39c3a224be300" + +EXTRA_OEMAKE += "PLATFORM=${RISCV_SBI_PLAT} I=${D}" +# If RISCV_SBI_PAYLOAD is set then include it as a payload +EXTRA_OEMAKE_append = " ${@riscv_get_extra_oemake_image(d)} ${@riscv_get_extra_oemake_fdt(d)}" + +# Required if specifying a custom payload +do_compile[depends] += "${@riscv_get_do_compile_depends(d)}" + +do_install_append() { + # In the future these might be required as a dependency for other packages. + # At the moment just delete them to avoid warnings + rm -r ${D}/include + rm -r ${D}/platform/${RISCV_SBI_PLAT}/lib + rm -r ${D}/platform/${RISCV_SBI_PLAT}/firmware/payloads +} + +do_deploy () { + install -d ${DEPLOY_DIR_IMAGE} + install -m 755 ${D}/platform/${RISCV_SBI_PLAT}/firmware/fw_payload.* ${DEPLOY_DIR_IMAGE}/ + install -m 755 ${D}/platform/${RISCV_SBI_PLAT}/firmware/fw_jump.* ${DEPLOY_DIR_IMAGE}/ +} + +addtask deploy after do_install + +FILES_${PN} += "/platform/${RISCV_SBI_PLAT}/firmware/fw_jump.*" +FILES_${PN} += "/platform/${RISCV_SBI_PLAT}/firmware/fw_payload.*" + +COMPATIBLE_HOST = "(riscv64|riscv32).*" +INHIBIT_PACKAGE_STRIP = "1" -- 2.22.0 -- _______________________________________________ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core