diff mbox series

[meta-ti,master/scarthgap] meta-ti-bsp: Add Zephyr RTOS example firmware

Message ID 20240322213214.78886-1-afd@ti.com
State Accepted
Delegated to: Ryan Eatmon
Headers show
Series [meta-ti,master/scarthgap] meta-ti-bsp: Add Zephyr RTOS example firmware | expand

Commit Message

Andrew Davis March 22, 2024, 9:32 p.m. UTC
Like the current TI-RTOS/MCU+ firmware, this is a prebuilt example
firmware for TI K3 remote cores. It is an alternative to the echo test
demo currently provided by "ti-rtos-firmware" recipe. In addition to
supporting rpmsg_client_sample just as the current firmware does, it
also provides:

 * A serial console with shell on the MCU UART port
 * A console over RPMSG at /dev/ttyRPMSG0
 * Example usage of the MCU GPIO/I2C/SPI from this shell
 * And many other Zephyr default enabled features..

It does all this using the Zephyr RTOS, a scalable real-time operating
system, optimized for resource constrained devices, and built with
security in mind. Zephyr is a Linux Foundation project. For more
info see here[0][1].

Zephyr firmware like this can also be built as part of the Yocto build
using meta-zephyr. Although this is a prebuilt currently, we intend
to build this from source to reduce meta-ti's dependence on firmware
blobs.

This currently works with the AM62 M4F. Support for additional SoCs
and cores is in progress.

[0] https://www.zephyrproject.org/
[1] https://docs.zephyrproject.org/latest/introduction/index.html

Signed-off-by: Andrew Davis <afd@ti.com>
---
 .../zephyr-fw/zephyr-openamp-rsc-table-fw.bb  | 83 +++++++++++++++++++
 1 file changed, 83 insertions(+)
 create mode 100644 meta-ti-bsp/recipes-bsp/zephyr-fw/zephyr-openamp-rsc-table-fw.bb
diff mbox series

Patch

diff --git a/meta-ti-bsp/recipes-bsp/zephyr-fw/zephyr-openamp-rsc-table-fw.bb b/meta-ti-bsp/recipes-bsp/zephyr-fw/zephyr-openamp-rsc-table-fw.bb
new file mode 100644
index 00000000..4efc99ac
--- /dev/null
+++ b/meta-ti-bsp/recipes-bsp/zephyr-fw/zephyr-openamp-rsc-table-fw.bb
@@ -0,0 +1,83 @@ 
+SUMMARY = "Precompiled Zephyr OpenAMP example firmware for TI K3 devices"
+
+# Name of this demo's firmware
+FW_NAME = "zephyr_openamp_rsc_table.elf"
+
+# List of cores for which this demo has a build
+FW_CORES        = ""
+FW_CORES:am62xx = "mcu-m4f0_0"
+
+# Note: Everything below is common to all our Zephyr firmwares and can be
+#       factored out to a common include file once we have more than one demo
+
+LICENSE = "Apache-2.0"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=86d3f3a95c324c9479bd8986968f4327"
+
+COMPATIBLE_MACHINE = "k3"
+
+PACKAGE_ARCH = "${MACHINE_ARCH}"
+
+SRC_URI = "git://github.com/glneo/zephyr-firmware.git;protocol=https;branch=main"
+SRCREV = "146d4f9b3930722d73685d600958f0b10ea97de2"
+PV = "3.6.0"
+#PR = "r1"
+
+S = "${WORKDIR}/git"
+
+FW_PLAT = ""
+FW_PLAT:am62xx = "am62"
+
+FW_INSTALL_DIR = "${nonarch_base_libdir}/firmware/zephyr/${FW_PLAT}"
+
+do_install() {
+    for FW_CORE in ${FW_CORES}
+    do
+        install -d ${D}${FW_INSTALL_DIR}/${FW_CORE}
+        install -m 0644 ${S}/${FW_PLAT}/${FW_CORE}/${FW_NAME} ${D}${FW_INSTALL_DIR}/${FW_CORE}
+    done
+}
+
+# Make sure that lib/firmware, and all its contents are part of the package
+FILES:${PN} = "${nonarch_base_libdir}/firmware"
+
+# This is used to prevent the build system from stripping the firmwares
+INHIBIT_PACKAGE_STRIP = "1"
+INHIBIT_SYSROOT_STRIP = "1"
+
+# This is used to prevent the build system from splitting out the firmware debug info into a separate file
+INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
+
+# This is a prebuilt with no external dependencies
+INHIBIT_DEFAULT_DEPS = "1"
+
+# Disable arch checking as firmware is likely to be a different arch from the Yocto build
+INSANE_SKIP:${PN} += "arch"
+
+# Zephyr-Firmware has no configure, compile, nor clean steps
+do_configure[noexec] = "1"
+do_compile[noexec] = "1"
+CLEANBROKEN = "1"
+
+inherit update-alternatives
+
+python fw_generate_alternatives() {
+    for fw_core_name in d.getVar('FW_CORES').split():
+        fw_plat = d.getVar('FW_PLAT')
+        fw_pkg_name = d.getVar('PN')
+        fw_core_name_full = (fw_plat + "-" + fw_core_name + "-fw")
+
+        # Create the firmware alternatives
+        d.appendVar('ALTERNATIVE:%s' % fw_pkg_name, (fw_core_name_full + " "))
+
+        # Set up firmware alternatives link names
+        fw_alt_link = ("${nonarch_base_libdir}/firmware/" + fw_core_name_full)
+        d.setVarFlag('ALTERNATIVE_LINK_NAME', fw_core_name_full, fw_alt_link)
+
+        # Set up firmware alternatives link targets
+        fw_alt_target_rename = "${FW_INSTALL_DIR}/" + fw_core_name + "/${FW_NAME}"
+        d.setVarFlag('ALTERNATIVE_TARGET_%s' % fw_pkg_name, fw_core_name_full, fw_alt_target_rename)
+}
+
+do_package[prefuncs] += "fw_generate_alternatives"
+
+ALTERNATIVE_PRIORITY = "20"