diff options
21 files changed, 546 insertions, 0 deletions
diff --git a/classes/zephyrtest.bbclass b/classes/zephyrtest.bbclass new file mode 100644 index 0000000..4887be5 --- /dev/null +++ b/classes/zephyrtest.bbclass @@ -0,0 +1,27 @@ + +python zephyrtest_virtclass_handler () { + cls = e.data.getVar("BBEXTENDCURR", True) + variant = e.data.getVar("BBEXTENDVARIANT", True) + + # ipk doesn't like underscores in pacakges names. So just use dashes + # for PN and the image name. + variant_dashes = variant.replace('_', '-') + pn = e.data.getVar("PN", True) + "-" + variant_dashes + pn_underscores = e.data.getVar("PN", True) + "-" + variant + + # kerneltype should be micro or nano + kerneltype = pn.replace(variant_dashes, '').rsplit('-', 2)[1] + e.data.setVar("PN", pn) + e.data.setVar("ZEPHYR_IMAGENAME", "test_" + variant_dashes + '-' + kerneltype + ".elf") + e.data.setVar("ZEPHYR_IMAGE_SRCDIR", "samples/" + kerneltype + "kernel/test/test_" + variant) + if kerneltype == "micro": + e.data.setVar("ZEPHYR_MAKE_OUTPUT", "microkernel.elf") + else: + e.data.setVar("ZEPHYR_MAKE_OUTPUT", "nanokernel.elf") + + # Allow to build using both foo-some_test form as well ass foo-some-test + e.data.setVar("PROVIDES", e.data.getVar("PROVIDES", True) + pn_underscores) +} + +addhandler zephyrtest_virtclass_handler +zephyrtest_virtclass_handler[eventmask] = "bb.event.RecipePreFinalise" diff --git a/conf/distro/zephyr.conf b/conf/distro/zephyr.conf new file mode 100644 index 0000000..81bf867 --- /dev/null +++ b/conf/distro/zephyr.conf @@ -0,0 +1,9 @@ +require conf/distro/poky.conf + +DISTRO = "zephyr" +DISTRO_NAME = "Zephyr" + +TCLIBC = "baremetal" + +TEST_TARGET = "QemuTargetZephyr" +TEST_SUITES = "zephyr" diff --git a/conf/layer.conf b/conf/layer.conf new file mode 100644 index 0000000..ea4bac6 --- /dev/null +++ b/conf/layer.conf @@ -0,0 +1,10 @@ +# We have a conf and classes directory, add to BBPATH +BBPATH .= ":${LAYERDIR}" + +# We have recipes-* directories, add to BBFILES +BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \ + ${LAYERDIR}/recipes-*/*/*.bbappend" + +BBFILE_COLLECTIONS += "zephyr" +BBFILE_PATTERN_zephyr = "^${LAYERDIR}/" +BBFILE_PRIORITY_zephyr = "6" diff --git a/lib/oeqa/__init__.py b/lib/oeqa/__init__.py new file mode 100644 index 0000000..8eda927 --- /dev/null +++ b/lib/oeqa/__init__.py @@ -0,0 +1,3 @@ +# Enable other layers to have modules in the same named directory +from pkgutil import extend_path +__path__ = extend_path(__path__, __name__) diff --git a/lib/oeqa/controllers/__init__.py b/lib/oeqa/controllers/__init__.py new file mode 100644 index 0000000..8eda927 --- /dev/null +++ b/lib/oeqa/controllers/__init__.py @@ -0,0 +1,3 @@ +# Enable other layers to have modules in the same named directory +from pkgutil import extend_path +__path__ = extend_path(__path__, __name__) diff --git a/lib/oeqa/controllers/zephyrtargetconrol.py b/lib/oeqa/controllers/zephyrtargetconrol.py new file mode 100644 index 0000000..136cca3 --- /dev/null +++ b/lib/oeqa/controllers/zephyrtargetconrol.py @@ -0,0 +1,67 @@ +# Copyright (C) 2013 Intel Corporation +# +# Released under the MIT license (see COPYING.MIT) + +# This module is used by testimage.bbclass for setting up and controlling a target machine. + +import os +import shutil +import bb +import logging +from oeqa.targetcontrol import QemuTarget +from oeqa.utils.dump import TargetDumper +from oeqa.utils.qemuzephyrrunner import QemuZephyrRunner + +class QemuTargetZephyr(QemuTarget): + + def __init__(self, d): + + super(QemuTarget, self).__init__(d) + + self.qemulog = os.path.join(self.testdir, "qemu_boot_log.%s" % self.datetime) + dump_target_cmds = d.getVar("testimage_dump_target", True) + dump_host_cmds = d.getVar("testimage_dump_host", True) + dump_dir = d.getVar("TESTIMAGE_DUMP_DIR", True) + + self.kernel = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True), d.getVar("ZEPHYR_IMAGENAME", True)) + self.rootfs = "" + + # Log QemuRunner log output to a file + import oe.path + bb.utils.mkdirhier(self.testdir) + self.qemurunnerlog = os.path.join(self.testdir, 'qemurunner_log.%s' % self.datetime) + logger = logging.getLogger('BitBake.QemuRunner') + loggerhandler = logging.FileHandler(self.qemurunnerlog) + loggerhandler.setFormatter(logging.Formatter("%(levelname)s: %(message)s")) + logger.addHandler(loggerhandler) + oe.path.symlink(os.path.basename(self.qemurunnerlog), os.path.join(self.testdir, 'qemurunner_log'), force=True) + + self.runner = QemuZephyrRunner(machine=d.getVar("MACHINE", True), + rootfs=self.rootfs, + tmpdir = d.getVar("TMPDIR", True), + deploy_dir_image = d.getVar("DEPLOY_DIR_IMAGE", True), + display = d.getVar("BB_ORIGENV", False).getVar("DISPLAY", True), + logfile = self.qemulog, + kernel = self.kernel, + boottime = int(d.getVar("TEST_QEMUBOOT_TIMEOUT", True))) + + self.target_dumper = TargetDumper(dump_target_cmds, dump_dir, self.runner) + + def deploy(self): + try: + bb.utils.mkdirhier(self.testdir) + if self.rootfs: + shutil.copyfile(self.origrootfs, self.rootfs) + except Exception as e: + bb.fatal("Error copying rootfs: %s" % e) + + qemuloglink = os.path.join(self.testdir, "qemu_boot_log") + if os.path.islink(qemuloglink): + os.unlink(qemuloglink) + os.symlink(self.qemulog, qemuloglink) + + bb.note("Qemu log file: %s" % self.qemulog) + super(QemuTarget, self).deploy() + + def wait_for_serial(self, func_timeout, data_timeout): + return self.runner.wait_for_serial(func_timeout, data_timeout) diff --git a/lib/oeqa/runtime/__init__.py b/lib/oeqa/runtime/__init__.py new file mode 100644 index 0000000..8eda927 --- /dev/null +++ b/lib/oeqa/runtime/__init__.py @@ -0,0 +1,3 @@ +# Enable other layers to have modules in the same named directory +from pkgutil import extend_path +__path__ = extend_path(__path__, __name__) diff --git a/lib/oeqa/runtime/zephyr.py b/lib/oeqa/runtime/zephyr.py new file mode 100644 index 0000000..c46340e --- /dev/null +++ b/lib/oeqa/runtime/zephyr.py @@ -0,0 +1,16 @@ +import unittest +from oeqa.oetest import oeRuntimeTest + +class ZephyrTest(oeRuntimeTest): + + def test_boot_tiny(self): + success = False + logfile = self.target.wait_for_serial(300, 30) + + with open(logfile) as f: + for line in f: + if "PROJECT EXECUTION SUCCESSFUL" in line: + success = True + break + + self.assertTrue(success, msg='"PROJECT EXECUTION SUCCESSFUL" not in %s' % logfile) diff --git a/lib/oeqa/utils/__init__.py b/lib/oeqa/utils/__init__.py new file mode 100644 index 0000000..8eda927 --- /dev/null +++ b/lib/oeqa/utils/__init__.py @@ -0,0 +1,3 @@ +# Enable other layers to have modules in the same named directory +from pkgutil import extend_path +__path__ = extend_path(__path__, __name__) diff --git a/lib/oeqa/utils/qemuzephyrrunner.py b/lib/oeqa/utils/qemuzephyrrunner.py new file mode 100644 index 0000000..8021a22 --- /dev/null +++ b/lib/oeqa/utils/qemuzephyrrunner.py @@ -0,0 +1,131 @@ +# Copyright (C) 2015 Intel Corporation +# +# Released under the MIT license (see COPYING.MIT) + +# This module provides a class for starting qemu images of poky tiny. +# It's used by testimage.bbclass. + +import subprocess +import os +import time +import signal +import socket +import select +import bb +import tempfile +from qemurunner import QemuRunner + +class QemuZephyrRunner(QemuRunner): + + def __init__(self, machine, rootfs, display, tmpdir, deploy_dir_image, logfile, kernel, boottime): + QemuRunner.__init__(self, machine, rootfs, display, tmpdir, + deploy_dir_image, logfile, boottime, None, + None) + + # Popen object for runqemu + self.socketfile = tempfile.NamedTemporaryFile() + self.socketname = self.socketfile.name + self.server_socket = None + self.kernel = kernel + + def create_socket(self): + tries = 3 + while tries > 0: + try: + self.server_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + self.server_socket.connect(self.socketname) + bb.note("Created listening socket for qemu serial console.") + tries = 0 + except socket.error, msg: + self.server_socket.close() + bb.error("Failed to create listening socket %s: %s" % (self.socketname, msg)) + tries -= 1 + + def start(self, qemuparams = None): + + if not os.path.exists(self.tmpdir): + bb.error("Invalid TMPDIR path %s" % self.tmpdir) + return False + else: + os.environ["OE_TMPDIR"] = self.tmpdir + if not os.path.exists(self.deploy_dir_image): + bb.error("Invalid DEPLOY_DIR_IMAGE path %s" % self.deploy_dir_image) + return False + else: + os.environ["DEPLOY_DIR_IMAGE"] = self.deploy_dir_image + + if not os.path.exists(self.kernel): + bb.error("Invalid kernel path: %s" % self.deploy_dir_image) + return False + + self.qemuparams = '-nographic -serial unix:%s,server' % (self.socketname) + qemu_binary = "" + if 'arm' in self.machine: + qemu_binary = 'qemu-system-arm' + qemu_machine_args = '-machine lm3s6965evb' + elif 'x86' in self.machine: + qemu_binary = 'qemu-system-i386' + qemu_machine_args = '-machine type=pc-0.14' + + self.origchldhandler = signal.getsignal(signal.SIGCHLD) + signal.signal(signal.SIGCHLD, self.handleSIGCHLD) + + launch_cmd = '%s -kernel %s %s %s' % (qemu_binary, self.kernel, self.qemuparams, qemu_machine_args) + bb.note(launch_cmd) + self.runqemu = subprocess.Popen(launch_cmd,shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT,preexec_fn=os.setpgrp) + + # + # We need the preexec_fn above so that all runqemu processes can easily be killed + # (by killing their process group). This presents a problem if this controlling + # process itself is killed however since those processes don't notice the death + # of the parent and merrily continue on. + # + # Rather than hack runqemu to deal with this, we add something here instead. + # Basically we fork off another process which holds an open pipe to the parent + # and also is setpgrp. If/when the pipe sees EOF from the parent dieing, it kills + # the process group. This is like pctrl's PDEATHSIG but for a process group + # rather than a single process. + # + r, w = os.pipe() + self.monitorpid = os.fork() + if self.monitorpid: + os.close(r) + self.monitorpipe = os.fdopen(w, "w") + else: + # child process + os.setpgrp() + os.close(w) + r = os.fdopen(r) + x = r.read() + os.killpg(os.getpgid(self.runqemu.pid), signal.SIGTERM) + sys.exit(0) + + bb.note("qemu started, pid is %s" % self.runqemu.pid) + #Hack to wait for socket to show up because I'm tired + time.sleep(5) + self.create_socket() + + return True + + def is_alive(self): + if not self.runqemu: + return False + return True + + def wait_for_serial(self, func_timeout, data_timeout): + stopread = False + check_endtime = False + self.server_socket.setblocking(0) + endtime = time.time() + func_timeout + + while time.time() < endtime: + sread, _, _ = select.select([self.server_socket],[],[],data_timeout) + if not sread: + break + answer = self.server_socket.recv(1024) + if answer: + self.log(answer) + else: + break + + return self.logfile diff --git a/recipes-kernel/zephyr-kernel/files/0001-Makefile.toolchain.yocto-Don-t-error-out-if-CROSS_CO.patch b/recipes-kernel/zephyr-kernel/files/0001-Makefile.toolchain.yocto-Don-t-error-out-if-CROSS_CO.patch new file mode 100644 index 0000000..d139f8b --- /dev/null +++ b/recipes-kernel/zephyr-kernel/files/0001-Makefile.toolchain.yocto-Don-t-error-out-if-CROSS_CO.patch @@ -0,0 +1,32 @@ +From 6f6f75cae61750e104d9601d4060e4cd782bd217 Mon Sep 17 00:00:00 2001 +From: Randy Witt <randy.e.witt@linux.intel.com> +Date: Thu, 10 Sep 2015 11:08:14 -0700 +Subject: [PATCH 1/3] Makefile.toolchain.yocto: Don't error out if + CROSS_COMPILE is set + +If CROSS_COMPILE is set, that means the user is trying to specify the +compiler manually. So don't error out when YOCTO_SDK_INSTALL_DIR isn't +set but CROSS_COMPILE is set. + +Signed-off-by: Randy Witt <randy.e.witt@linux.intel.com> +--- + scripts/Makefile.toolchain.yocto | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/scripts/Makefile.toolchain.yocto b/scripts/Makefile.toolchain.yocto +index cf6918e..77b1a12 100644 +--- a/scripts/Makefile.toolchain.yocto ++++ b/scripts/Makefile.toolchain.yocto +@@ -1,6 +1,8 @@ + ++ifndef CROSS_COMPILE + ifndef YOCTO_SDK_INSTALL_DIR +-$(error YOCTO_SDK_INSTALL_DIR is not set) ++ $(error YOCTO_SDK_INSTALL_DIR is not set) ++endif + endif + + # arm +-- +2.4.3 + diff --git a/recipes-kernel/zephyr-kernel/files/0002-zephyr-env.sh-Work-with-zsh.patch b/recipes-kernel/zephyr-kernel/files/0002-zephyr-env.sh-Work-with-zsh.patch new file mode 100644 index 0000000..a8513e8 --- /dev/null +++ b/recipes-kernel/zephyr-kernel/files/0002-zephyr-env.sh-Work-with-zsh.patch @@ -0,0 +1,36 @@ +From 9c5edc055897c4acc365e8cf874ab2664a68d7ea Mon Sep 17 00:00:00 2001 +From: Randy Witt <randy.e.witt@linux.intel.com> +Date: Thu, 10 Sep 2015 11:10:18 -0700 +Subject: [PATCH 2/3] zephyr-env.sh: Work with zsh + +Without this change ZEPHYR_BASE won't be set up properly when using zsh. +This makes it so the path of the zephyr-env.sh is found sucessfully when +using zsh. + +Signed-off-by: Randy Witt <randy.e.witt@linux.intel.com> +--- + zephyr-env.sh | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +diff --git a/zephyr-env.sh b/zephyr-env.sh +index e62d8e2..971be8d 100644 +--- a/zephyr-env.sh ++++ b/zephyr-env.sh +@@ -9,7 +9,13 @@ fi + # run (if it exists) by this script. + + # identify OS source tree root directory +-export ZEPHYR_BASE=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) ++if [ -n "$BASH_SOURCE" ]; then ++ export ZEPHYR_BASE="`dirname $BASH_SOURCE`" ++elif [ -n "$ZSH_NAME" ]; then ++ export ZEPHYR_BASE="`dirname $0`" ++else ++ export ZEPHYR_BASE="`pwd`" ++fi + + scripts_path=${ZEPHYR_BASE}/scripts + echo "${PATH}" | grep -q "${scripts_path}" +-- +2.4.3 + diff --git a/recipes-kernel/zephyr-kernel/files/0003-zephyr-env.sh-Don-t-wait-to-test-for-error-condition.patch b/recipes-kernel/zephyr-kernel/files/0003-zephyr-env.sh-Don-t-wait-to-test-for-error-condition.patch new file mode 100644 index 0000000..18f0ba3 --- /dev/null +++ b/recipes-kernel/zephyr-kernel/files/0003-zephyr-env.sh-Don-t-wait-to-test-for-error-condition.patch @@ -0,0 +1,36 @@ +From b7e1267f98a7ee7e571afa919a0489b4e2cc92f7 Mon Sep 17 00:00:00 2001 +From: Randy Witt <randy.e.witt@linux.intel.com> +Date: Thu, 10 Sep 2015 11:12:29 -0700 +Subject: [PATCH 3/3] zephyr-env.sh: Don't wait to test for error condition + +Previously if a user had done "set -e" in their shell and ran this script +it was possible that "echo "${PATH}" | grep -q "${scripts_path}" could +cause the script to error out completely. + +Instead of runnning the command then doing a test on $?, just run the +test on the command itself. + +Signed-off-by: Randy Witt <randy.e.witt@linux.intel.com> +--- + zephyr-env.sh | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/zephyr-env.sh b/zephyr-env.sh +index 971be8d..a17a681 100644 +--- a/zephyr-env.sh ++++ b/zephyr-env.sh +@@ -18,8 +18,9 @@ else + fi + + scripts_path=${ZEPHYR_BASE}/scripts +-echo "${PATH}" | grep -q "${scripts_path}" +-[ $? != 0 ] && export PATH=${scripts_path}:${PATH} ++if ! echo "${PATH}" | grep -q "${scripts_path}"; then ++ export PATH=${scripts_path}:${PATH} ++fi + unset scripts_path + + # enable custom environment settings +-- +2.4.3 + diff --git a/recipes-kernel/zephyr-kernel/zephyr-image.inc b/recipes-kernel/zephyr-kernel/zephyr-image.inc new file mode 100644 index 0000000..18f80a7 --- /dev/null +++ b/recipes-kernel/zephyr-kernel/zephyr-image.inc @@ -0,0 +1,51 @@ +require zephyr-kernel.inc + +inherit testimage +inherit deploy + +INHIBIT_DEFAULT_DEPS = "1" +DEPENDS += "gcc-cross-${TARGET_ARCH} libgcc" + +export ZEPHYR_GCC_VARIANT="yocto" + +LIB_INCLUDE_DIR = "-L`dirname \`$CC -print-libgcc-file-name\``" +CROSS_COMPILE = "${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}" +QEMU_BIN_PATH = "${STAGING_BINDIR_NATIVE}" + +PLATFORM_CONFIG_arm = "basic_cortex_m3" +ARCH_arm = "${TRANSLATED_TARGET_ARCH}" + +OE_TERMINAL_EXPORTS += "CROSS_COMPILE" +OE_TERMINAL_EXPORTS += "PLATFORM_CONFIG" +OE_TERMINAL_EXPORTS += "ARCH" + +# oe_runmake isn't used because of the make -e causing issues with some +# make variables. +MAKE_COMMAND = "make -j V=1 ARCH=${ARCH} PLATFORM_CONFIG=${PLATFORM_CONFIG} CROSS_COMPILE=${CROSS_COMPILE} LIB_INCLUDE_DIR=${LIB_INCLUDE_DIR}" + +do_configure[noexec] = "1" + +# The makefiles are explicit about the flags they want, so don't unset +# them so zephyr flags actually get used. Should we set EXTRA_CFLAGS so our +# additional flags get picked up? +# This is done here rather than in the task so that things still work +# in devshell. +python () { + d.delVar('CFLAGS') + d.delVar('CXXFLAGS') + d.delVar('LDFLAGS') +} + +# oe_runmake isn't used because of the make -e causing issues with some +# make variables. +do_compile () { + source ${S}/zephyr-env.sh + + ${MAKE_COMMAND} -C ${ZEPHYR_IMAGE_SRCDIR} pristine + ${MAKE_COMMAND} -C ${ZEPHYR_IMAGE_SRCDIR} +} + +do_deploy () { + install -D ${ZEPHYR_IMAGE_SRCDIR}/outdir/${ZEPHYR_MAKE_OUTPUT} ${DEPLOYDIR}/${ZEPHYR_IMAGENAME} +} +addtask deploy after do_compile diff --git a/recipes-kernel/zephyr-kernel/zephyr-kernel-test-all.bb b/recipes-kernel/zephyr-kernel/zephyr-kernel-test-all.bb new file mode 100644 index 0000000..41d9f3b --- /dev/null +++ b/recipes-kernel/zephyr-kernel/zephyr-kernel-test-all.bb @@ -0,0 +1,20 @@ +LICENSE = "CLOSED" +INHIBIT_DEFAULT_DEPS = "1" + +require zephyr-kernel-test-micro.inc +require zephyr-kernel-test-nano.inc + +addtask testimage +deltask configure +deltask compile +deltask install + +do_testimage () { + : +} + +do_testimage[depends] = '${@" ".join(["zephyr-kernel-test-micro-" + x + ":do_testimage" for x in d.getVar("ZEPHYRMICROTESTS", True).split()])}' +do_testimage[depends] += '${@" ".join(["zephyr-kernel-test-nano-" + x + ":do_testimage" for x in d.getVar("ZEPHYRNANOTESTS", True).split()])}' + +do_build[depends] = '${@" ".join(["zephyr-kernel-test-micro-" + x + ":do_build" for x in d.getVar("ZEPHYRMICROTESTS", True).split()])}' +do_build[depends] += '${@" ".join(["zephyr-kernel-test-nano-" + x + ":do_build" for x in d.getVar("ZEPHYRNANOTESTS", True).split()])}' diff --git a/recipes-kernel/zephyr-kernel/zephyr-kernel-test-micro.bb b/recipes-kernel/zephyr-kernel/zephyr-kernel-test-micro.bb new file mode 100644 index 0000000..aba897e --- /dev/null +++ b/recipes-kernel/zephyr-kernel/zephyr-kernel-test-micro.bb @@ -0,0 +1,8 @@ +require zephyr-image.inc +require zephyr-kernel-test-micro.inc + +BBCLASSEXTEND = '${@" ".join(["zephyrtest:" + x for x in d.getVar("ZEPHYRMICROTESTS", True).split()])}' + + + + diff --git a/recipes-kernel/zephyr-kernel/zephyr-kernel-test-micro.inc b/recipes-kernel/zephyr-kernel/zephyr-kernel-test-micro.inc new file mode 100644 index 0000000..028226f --- /dev/null +++ b/recipes-kernel/zephyr-kernel/zephyr-kernel-test-micro.inc @@ -0,0 +1,6 @@ +# libs +ZEPHYRMICROTESTS_remove_arm = "tickless fp_sharing static_idt" + +ZEPHYRMICROTESTS_arc = "" + +ZEPHYRMICROTESTS = "critical fifo map pipe sprintf static_idt task_irq timer events fp_sharing mail mutex pool sema stackprot task tickless xip" diff --git a/recipes-kernel/zephyr-kernel/zephyr-kernel-test-nano.bb b/recipes-kernel/zephyr-kernel/zephyr-kernel-test-nano.bb new file mode 100644 index 0000000..5bd9e9a --- /dev/null +++ b/recipes-kernel/zephyr-kernel/zephyr-kernel-test-nano.bb @@ -0,0 +1,4 @@ +require zephyr-image.inc +require zephyr-kernel-test-nano.inc + +BBCLASSEXTEND = '${@" ".join(["zephyrtest:" + x for x in d.getVar("ZEPHYRNANOTESTS", True).split()])}' diff --git a/recipes-kernel/zephyr-kernel/zephyr-kernel-test-nano.inc b/recipes-kernel/zephyr-kernel/zephyr-kernel-test-nano.inc new file mode 100644 index 0000000..03bf4aa --- /dev/null +++ b/recipes-kernel/zephyr-kernel/zephyr-kernel-test-nano.inc @@ -0,0 +1,5 @@ + +ZEPHYRNANOTESTS_arm += "arm_m3_irq_vector_table" +ZEPHYRNANOTESTS_arc = "" + +ZEPHYRNANOTESTS += "fp_sharing stack timer context lifo stackprot xip fifo sema static_idt" diff --git a/recipes-kernel/zephyr-kernel/zephyr-kernel.bb b/recipes-kernel/zephyr-kernel/zephyr-kernel.bb new file mode 100644 index 0000000..f69cffb --- /dev/null +++ b/recipes-kernel/zephyr-kernel/zephyr-kernel.bb @@ -0,0 +1,62 @@ +require zephyr-kernel.inc + +inherit deploy + +INHIBIT_DEFAULT_DEPS = "1" +DEPENDS += "gcc-cross-${TARGET_ARCH} libgcc" + +#SRC_URI += "file://0001-defs.host-Allow-HOS_Bin-to-be-overridden.patch" + +export ZEPHYR_GCC_VARIANT="yocto" + +# The makefiles are explicit about the flags they want, so don't unset +# them so zephyr flags actually get used. Should we set EXTRA_CFLAGS so our +# additional flags get picked up? +# This is done here rather than in the task so that things still work +# in devshell. +python () { + d.delVar('CFLAGS') + d.delVar('CXXFLAGS') + d.delVar('LDFLAGS') +} + +do_configure[noexec] = "1" + +MACRO_SUPPORT = "1" +MACRO_SUPPORT_arc = "0" + +LIB_INCLUDE_DIR="-L`dirname \`$CC -print-libgcc-file-name\``" +CROSS_COMPILE="${STAGING_BINDIR_TOOLCHAIN}/${TARGET_PREFIX}" + +# oe_runmake isn't used because of the make -e causing issues with some +# make variables. +MAKE_COMMAND = "make -j V=1 CROSS_COMPILE=${CROSS_COMPILE} LIB_INCLUDE_DIR=${LIB_INCLUDE_DIR}" + +do_compile () { + . ${S}/zephyr-env.sh + + if [ "${MACRO_SUPPORT}" -eq "1" ]; then + ${MAKE_COMMAND} -C samples/microkernel/apps/hello_world pristine + ${MAKE_COMMAND} -C samples/microkernel/apps/hello_world + + ${MAKE_COMMAND} -C samples/microkernel/apps/philosophers pristine + ${MAKE_COMMAND} -C samples/microkernel/apps/philosophers + fi + + ${MAKE_COMMAND} -C samples/nanokernel/apps/hello_world pristine + ${MAKE_COMMAND} -C samples/nanokernel/apps/hello_world + + ${MAKE_COMMAND} -C samples/nanokernel/apps/philosophers pristine + ${MAKE_COMMAND} -C samples/nanokernel/apps/philosophers +} + +do_deploy () { + if [ "${MACRO_SUPPORT}" -eq "1" ]; then + install -D samples/microkernel/apps/hello_world/outdir/microkernel.elf ${DEPLOYDIR}/hello_world_micro.elf + install -D samples/microkernel/apps/philosophers/outdir/microkernel.elf ${DEPLOYDIR}/philosophers_micro.elf + fi + + install -D samples/nanokernel/apps/hello_world/outdir/nanokernel.elf ${DEPLOYDIR}/hello_world_nano.elf + install -D samples/nanokernel/apps/philosophers/outdir/nanokernel.elf ${DEPLOYDIR}/philosophers_nano.elf +} +addtask deploy after do_compile diff --git a/recipes-kernel/zephyr-kernel/zephyr-kernel.inc b/recipes-kernel/zephyr-kernel/zephyr-kernel.inc new file mode 100644 index 0000000..6d62868 --- /dev/null +++ b/recipes-kernel/zephyr-kernel/zephyr-kernel.inc @@ -0,0 +1,14 @@ +LICENSE = "CLOSED" + +SRC_URI += "file://0001-Makefile.toolchain.yocto-Don-t-error-out-if-CROSS_CO.patch" +SRC_URI += "file://0002-zephyr-env.sh-Work-with-zsh.patch" +SRC_URI += "file://0003-zephyr-env.sh-Don-t-wait-to-test-for-error-condition.patch" + +# Modify these as desired +PV = "1.0+git${SRCPV}" + +S = "${WORKDIR}/git" + +# There shouldn't be a manifest for zephyr kernels since there is no root +# filesystem. +IMAGE_NO_MANIFEST = "1" |