From 836567924595cd810009a226124b16ea1f0f4f48 Mon Sep 17 00:00:00 2001 From: Daniel Leung Date: Wed, 23 Oct 2019 01:35:42 -0700 Subject: [PATCH] meta-zephyr-sdk: build custom SeaBIOS for QEMU This adds a receipe to build SeaBIOS for use with QEMU, which includes a patch to avoid clearing screen and disabling line wrapping in serial console. This helps with looking at emulator outputs (from both running locally and sanitycheck) as clearing screen and disabling line wrapping affect developer terminal, requiring running 'reset' to make it useful again. The config files comes from QEMU. Signed-off-by: Daniel Leung --- .../recipes-devtools/qemu/zephyr-qemu_git.bb | 14 +++- ...ar-screen-and-don-t-disable-line-wra.patch | 35 ++++++++++ .../seabios/files/config.seabios-128k | 17 +++++ .../seabios/files/config.seabios-256k | 4 ++ .../seabios/files/hostcc.patch | 21 ++++++ .../seabios/zephyr-seabios_1.12.1.bb | 67 +++++++++++++++++++ 6 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 meta-zephyr-sdk/recipes-devtools/seabios/files/0001-sercon-don-t-clear-screen-and-don-t-disable-line-wra.patch create mode 100644 meta-zephyr-sdk/recipes-devtools/seabios/files/config.seabios-128k create mode 100644 meta-zephyr-sdk/recipes-devtools/seabios/files/config.seabios-256k create mode 100644 meta-zephyr-sdk/recipes-devtools/seabios/files/hostcc.patch create mode 100644 meta-zephyr-sdk/recipes-devtools/seabios/zephyr-seabios_1.12.1.bb diff --git a/meta-zephyr-sdk/recipes-devtools/qemu/zephyr-qemu_git.bb b/meta-zephyr-sdk/recipes-devtools/qemu/zephyr-qemu_git.bb index 11916d24..e3faf2c1 100644 --- a/meta-zephyr-sdk/recipes-devtools/qemu/zephyr-qemu_git.bb +++ b/meta-zephyr-sdk/recipes-devtools/qemu/zephyr-qemu_git.bb @@ -1,5 +1,6 @@ -DEPENDS = "glib-2.0 zlib pixman gnutls dtc" +DEPENDS = "glib-2.0 zlib pixman gnutls dtc zephyr-seabios" +DEPENDS_append_class-nativesdk = " nativesdk-zephyr-seabios" LICENSE = "GPLv2" FILESEXTRAPATHS_prepend := "${THISDIR}/files:" LIC_FILES_CHKSUM = "file://COPYING;md5=441c28d2cf86e15a37fa47e15a72fbac \ @@ -201,6 +202,17 @@ QEMU_FLAGS = "--disable-docs --disable-sdl --disable-debug-info --disable-cap- --disable-virtfs --disable-xen --disable-curl --disable-attr --disable-curses --disable-iconv \ " +copy_seabios() { + cp ${STAGING_DIR}/usr/share/firmware/bios.bin ${S}/pc-bios/bios.bin + cp ${STAGING_DIR}/usr/share/firmware/bios-256k.bin ${S}/pc-bios/bios-256k.bin +} + +do_unpack_append() { + bb.build.exec_func('copy_seabios', d) +} + +do_unpack[depends] = "zephyr-seabios:do_populate_sysroot" + do_configure() { ${S}/configure ${QEMU_FLAGS} --target-list="${QEMUS_BUILT}" --prefix=${prefix} \ --sysconfdir=${sysconfdir} --libexecdir=${libexecdir} --localstatedir=${localstatedir} diff --git a/meta-zephyr-sdk/recipes-devtools/seabios/files/0001-sercon-don-t-clear-screen-and-don-t-disable-line-wra.patch b/meta-zephyr-sdk/recipes-devtools/seabios/files/0001-sercon-don-t-clear-screen-and-don-t-disable-line-wra.patch new file mode 100644 index 00000000..0ca9477c --- /dev/null +++ b/meta-zephyr-sdk/recipes-devtools/seabios/files/0001-sercon-don-t-clear-screen-and-don-t-disable-line-wra.patch @@ -0,0 +1,35 @@ +From a6030cbfc6f7e98c7ed0e217332cba27daa1a686 Mon Sep 17 00:00:00 2001 +From: Daniel Leung +Date: Sat, 12 Oct 2019 14:57:08 -0700 +Subject: [PATCH 1/1] sercon: don't clear screen and don't disable line + wrapping + +This helps with looking at emulator outputs (from both running +locally and sanitycheck) as clearing screen and disabling line +wrapping affect developer terminal. + +Signed-off-by: Daniel Leung +--- + src/sercon.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/src/sercon.c b/src/sercon.c +index a5dadb7..80bd4b1 100644 +--- a/src/sercon.c ++++ b/src/sercon.c +@@ -346,10 +346,12 @@ static void sercon_1000(struct bregs *regs) + SET_LOW(sercon_row_last, 0); + SET_LOW(sercon_attr_last, 0); + ++#if 0 + sercon_term_reset(); + sercon_term_no_linewrap(); + if (clearscreen) + sercon_term_clear_screen(); ++#endif + } + + /* Set text-mode cursor shape */ +-- +2.23.0 + diff --git a/meta-zephyr-sdk/recipes-devtools/seabios/files/config.seabios-128k b/meta-zephyr-sdk/recipes-devtools/seabios/files/config.seabios-128k new file mode 100644 index 00000000..a17502ca --- /dev/null +++ b/meta-zephyr-sdk/recipes-devtools/seabios/files/config.seabios-128k @@ -0,0 +1,17 @@ +# for qemu machine types 1.7 + older +# need to turn off features (xhci,uas) to make it fit into 128k +CONFIG_QEMU=y +CONFIG_ROM_SIZE=128 +CONFIG_ATA_DMA=n +CONFIG_BOOTSPLASH=n +CONFIG_XEN=n +CONFIG_USB_OHCI=n +CONFIG_USB_XHCI=n +CONFIG_USB_UAS=n +CONFIG_SDCARD=n +CONFIG_TCGBIOS=n +CONFIG_MPT_SCSI=n +CONFIG_PVSCSI=n +CONFIG_NVME=n +CONFIG_USE_SMM=n +CONFIG_VGAHOOKS=n diff --git a/meta-zephyr-sdk/recipes-devtools/seabios/files/config.seabios-256k b/meta-zephyr-sdk/recipes-devtools/seabios/files/config.seabios-256k new file mode 100644 index 00000000..d1bcc945 --- /dev/null +++ b/meta-zephyr-sdk/recipes-devtools/seabios/files/config.seabios-256k @@ -0,0 +1,4 @@ +# for qemu machine types 2.0 + newer +CONFIG_QEMU=y +CONFIG_ROM_SIZE=256 +CONFIG_ATA_DMA=n diff --git a/meta-zephyr-sdk/recipes-devtools/seabios/files/hostcc.patch b/meta-zephyr-sdk/recipes-devtools/seabios/files/hostcc.patch new file mode 100644 index 00000000..f665e1a3 --- /dev/null +++ b/meta-zephyr-sdk/recipes-devtools/seabios/files/hostcc.patch @@ -0,0 +1,21 @@ +diff -ur a/Makefile b/Makefile +--- a/Makefile 2015-02-02 22:02:58.651041951 -0500 ++++ b/Makefile 2015-02-02 23:08:13.884514003 -0500 +@@ -8,7 +8,7 @@ + OUT=out/ + + # Common command definitions +-export HOSTCC := $(CC) ++export HOSTCC ?= $(CC) + export CONFIG_SHELL := sh + export KCONFIG_AUTOHEADER := autoconf.h + export KCONFIG_CONFIG := $(CURDIR)/.config +@@ -22,7 +22,7 @@ + OBJDUMP=$(CROSS_PREFIX)objdump + STRIP=$(CROSS_PREFIX)strip + PYTHON=python +-CPP=cpp ++CPP=$(CROSS_PREFIX)cpp + IASL:=iasl + LD32BIT_FLAG:=-melf_i386 + diff --git a/meta-zephyr-sdk/recipes-devtools/seabios/zephyr-seabios_1.12.1.bb b/meta-zephyr-sdk/recipes-devtools/seabios/zephyr-seabios_1.12.1.bb new file mode 100644 index 00000000..de3f61e4 --- /dev/null +++ b/meta-zephyr-sdk/recipes-devtools/seabios/zephyr-seabios_1.12.1.bb @@ -0,0 +1,67 @@ +# Origin: +# http://git.yoctoproject.org/cgit/cgit.cgi/meta-virtualization/plain/recipes-extended/seabios/seabios_1.11.2.bb--2019-10-22 + +DESCRIPTION = "SeaBIOS" +HOMEPAGE = "http://www.coreboot.org/SeaBIOS" +LICENSE = "LGPLv3" +SECTION = "firmware" + +FILESEXTRAPATHS_prepend := "${THISDIR}/files:" + +INHIBIT_PACKAGE_DEBUG_SPLIT = "1" +INHIBIT_PACKAGE_STRIP = "1" +INHIBIT_SYSROOT_STRIP = "1" + +BBCLASSEXTEND = "native nativesdk" + +SRCREV = "a5cab58e9a3fb6e168aba919c5669bea406573b4" +SRC_URI = " \ + git://git.seabios.org/seabios.git;protocol=https;branch=1.12-stable \ + file://hostcc.patch \ + file://0001-sercon-don-t-clear-screen-and-don-t-disable-line-wra.patch \ + file://config.seabios-128k \ + file://config.seabios-256k \ + " + +S = "${WORKDIR}/git" + +LIC_FILES_CHKSUM = "file://COPYING;md5=d32239bcb673463ab874e80d47fae504 \ + file://COPYING.LESSER;md5=6a6a8e020838b23406c81b19c1d46df6 \ + " + +SRC_URI[md5sum] = "6cb6cba431fd725126ddb5ec529ab85c" +SRC_URI[sha256sum] = "89ba3f3e3436008992e2304ca1afa1a9527e77c309d896d1b0332e97339f6127" + +DEPENDS = "util-linux-native file-native bison-native flex-native gettext-native python-native" + +TUNE_CCARGS = "" +EXTRA_OEMAKE += "HOSTCC='${BUILD_CC}'" +EXTRA_OEMAKE += "CROSS_PREFIX=${TARGET_PREFIX}" +EXTRA_OEMAKE += "EXTRAVERSION='-zephyr'" + +do_configure() { + mkdir -p ${B}/128k + cp ${WORKDIR}/config.seabios-128k ${B}/128k/.config + oe_runmake KCONFIG_CONFIG=${B}/128k/.config OUT=${B}/128k/ oldnoconfig + + mkdir -p ${B}/256k + cp ${WORKDIR}/config.seabios-256k ${B}/256k/.config + oe_runmake KCONFIG_CONFIG=${B}/256k/.config OUT=${B}/256k/ oldnoconfig +} + +do_compile() { + unset CPP + unset CPPFLAGS + + oe_runmake KCONFIG_CONFIG=${B}/128k/.config OUT=${B}/128k/ + oe_runmake KCONFIG_CONFIG=${B}/256k/.config OUT=${B}/256k/ +} + +do_install() { + # install into staging are so these can be picked up by zephyr-qemu. + install -d ${STAGING_DIR}/usr/share/firmware + install -m 0644 ${B}/128k/bios.bin ${STAGING_DIR}/usr/share/firmware/bios.bin + install -m 0644 ${B}/256k/bios.bin ${STAGING_DIR}/usr/share/firmware/bios-256k.bin +} + +INSANE_SKIP_${PN} = "already-stripped"