diff --git a/.gitmodules b/.gitmodules index 4bb593e..8f75cc3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -69,3 +69,40 @@ [submodule "platforms/nxp-imx93-yocto/sources/meta-freescale-distro"] path = platforms/nxp-imx93-yocto/sources/meta-freescale-distro url = https://github.com/Freescale/meta-freescale-distro.git + +[submodule "platforms/nxp-imx9-yocto/sources/base"] + path = platforms/nxp-imx9-yocto/sources/base + url = https://github.com/Freescale/fsl-community-bsp-base.git +[submodule "platforms/nxp-imx9-yocto/sources/bitbake"] + path = platforms/nxp-imx9-yocto/sources/bitbake + url = https://github.com/openembedded/bitbake.git +[submodule "platforms/nxp-imx9-yocto/sources/openembedded-core"] + path = platforms/nxp-imx9-yocto/sources/openembedded-core + url = https://github.com/openembedded/openembedded-core.git +[submodule "platforms/nxp-imx9-yocto/sources/meta-yocto"] + path = platforms/nxp-imx9-yocto/sources/meta-yocto + url = https://git.yoctoproject.org/meta-yocto +[submodule "platforms/nxp-imx9-yocto/sources/meta-arm"] + path = platforms/nxp-imx9-yocto/sources/meta-arm + url = https://git.yoctoproject.org/meta-arm +[submodule "platforms/nxp-imx9-yocto/sources/meta-freescale"] + path = platforms/nxp-imx9-yocto/sources/meta-freescale + url = https://git.yoctoproject.org/meta-freescale +[submodule "platforms/nxp-imx9-yocto/sources/meta-freescale-distro"] + path = platforms/nxp-imx9-yocto/sources/meta-freescale-distro + url = https://github.com/Freescale/meta-freescale-distro.git +[submodule "platforms/nxp-imx9-yocto/sources/meta-freescale-ml"] + path = platforms/nxp-imx9-yocto/sources/meta-freescale-ml + url = https://github.com/Freescale/meta-freescale-ml.git +[submodule "platforms/nxp-imx9-yocto/sources/meta-imx"] + path = platforms/nxp-imx9-yocto/sources/meta-imx + url = https://github.com/nxp-imx/meta-imx.git +[submodule "platforms/nxp-imx9-yocto/sources/meta-openembedded"] + path = platforms/nxp-imx9-yocto/sources/meta-openembedded + url = https://github.com/openembedded/meta-openembedded.git +[submodule "platforms/nxp-imx9-yocto/sources/meta-virtualization"] + path = platforms/nxp-imx9-yocto/sources/meta-virtualization + url = https://git.yoctoproject.org/meta-virtualization +[submodule "platforms/nxp-imx9-yocto/sources/meta-clang"] + path = platforms/nxp-imx9-yocto/sources/meta-clang + url = https://github.com/kraj/meta-clang.git diff --git a/platforms/nxp-imx9-yocto/.gitignore b/platforms/nxp-imx9-yocto/.gitignore new file mode 100644 index 0000000..ac32834 --- /dev/null +++ b/platforms/nxp-imx9-yocto/.gitignore @@ -0,0 +1,13 @@ +# Build products and local inspection/release output are never source inputs. +build-development/ +build-development-nxp-6.18.2-1.0.0/ +release-staging/ +inspection-*/ + +# Local cache locations are selected through DL_DIR and SSTATE_DIR. +downloads/ +sstate-cache/ + +# This closed, locally acquired profile is intentionally never committed. +sources/meta-geisa-community/recipes-core/geisa/files/nxp-ethosu-tflite.tar.gz +sources/meta-geisa-community/recipes-core/geisa/files/nxp-ethosu-tflite.local-origin.txt diff --git a/platforms/nxp-imx9-yocto/LICENSE b/platforms/nxp-imx9-yocto/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/platforms/nxp-imx9-yocto/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/platforms/nxp-imx9-yocto/MAINTAINERS.md b/platforms/nxp-imx9-yocto/MAINTAINERS.md new file mode 100644 index 0000000..ed2e4af --- /dev/null +++ b/platforms/nxp-imx9-yocto/MAINTAINERS.md @@ -0,0 +1,9 @@ +# Maintainers + +The `platforms/nxp-imx9-yocto` subtree is maintained by GEISA Community +contributors. Initial contribution stewardship is provided by Scott Wegener +(`swegener-rtp`). + +This maintainer record does not imply support, endorsement, certification, or +warranty by GEISA, LF Energy, NXP, PragSol Consulting LLC, Southern California +Edison, or Savoir-faire Linux. diff --git a/platforms/nxp-imx9-yocto/NOTICE.md b/platforms/nxp-imx9-yocto/NOTICE.md new file mode 100644 index 0000000..c34608b --- /dev/null +++ b/platforms/nxp-imx9-yocto/NOTICE.md @@ -0,0 +1,11 @@ +# GEISA Development Image for NXP i.MX9 Notices + +This notice applies only to community-image metadata, documentation, and helper +scripts explicitly distributed under Apache-2.0. It does not license the full +Yocto image, its packages, NXP BSP or proprietary firmware, models, media, +or third-party runtime libraries. + +Review the Yocto-generated license manifest and package-level metadata for the +exact build before redistribution. Separately distributed models and media +retain their own notices. Inclusion of this notice does not imply GEISA +endorsement, certification, or implication of official GEISA support. diff --git a/platforms/nxp-imx9-yocto/README.md b/platforms/nxp-imx9-yocto/README.md new file mode 100644 index 0000000..5e695b6 --- /dev/null +++ b/platforms/nxp-imx9-yocto/README.md @@ -0,0 +1,159 @@ + + +# GEISA Development Image for NXP i.MX9 + +Prepared by [PragSol Consulting LLC](https://www.pragsolconsulting.com). + +This community development image is based on the GEISA specification. For more +information, see . + +## Overview + +This Community-contributed development and validation image targets the NXP +FRDM-i.MX93 and FRDM-i.MX95. It uses the NXP 6.18.2-1.0.0 BSP on Whinlatter +with Linux kernel 6.18.2. + +The image provides common GEISA runtime and development tools and also enables +the relevant NPU/accelerator for the selected machine (Ethos-U or Neutron). It +is intended as a development image, not for production use. It does not include +any GEISA applications, LEE or API implementations. + +Source is available at: + + + +Community questions and issue reports belong in the +[GEISA Community issue tracker](https://github.com/geisa/community/issues). + +## Supported Boards + +| Machine | Board | Accelerator | Validation | +| ------------- | ----------- | ----------- | ---------------------------- | +| `geisa-imx93` | FRDM-i.MX93 | Ethos-U | `geisa-ethosu-smoke-test` | +| `geisa-imx95` | FRDM-i.MX95 | Neutron | `geisa-neutron-smoke-test` | + +## Image Contents + +The common image includes the GEISA application base, managed LXC containers, +cgroup v2 support, Mosquitto, protobuf, systemd services, SSH, and +development tools. The application base is installed under `/platform/base` +as SquashFS and tar archives. The `/platform` filesystem also holds execution +profiles and other image-provided validation data. `/platform` is an image +choice and not mandated by the GEISA specification at time of publishing. + +System configuration selects the accelerator support; Ethos-U for the i.MX93 +and Neutron for the i.MX95. + +The WIC layout is: + +| Disk area | Mount | Format | Size | Purpose | +| ------------- | ----------- | ------ | ----------- | --------------------------- | +| Raw boot area | Not mounted | Raw | BSP-defined | i.MX boot image and U-Boot | +| Partition 1 | `/boot` | FAT | 256 MiB | Boot files and device trees | +| Partition 2 | `/` | ext4 | 8 GiB | Operating system and tools | +| Partition 3 | `/platform` | ext4 | 6 GiB | Application base and data | + +The platform generator derives `/platform` from the active root device. The +root and platform partitions must be partitions 2 and 3 of the same MMC +device. + +### Included Tools + +The following are a subset of the included dev image tools, not a complete +package list. + +| Tool or Package | Use | +| -------------------------------- | -------------------------- | +| GCC/G++, make, CMake, Ninja | Native builds | +| Git, rsync, jq, file | Source and artifact work | +| Python/pip, Node/npm | Script and package tooling | +| protoc, protobuf, nanopb | GEISA/protobuf development | +| iproute2, ethtool, tcpdump, curl | Network diagnosis | +| LXC tools, systemctl, journalctl | Containers and services | +| vim, nano, less | Editing and log viewing | + +The complete installed package inventory is at +`/usr/share/doc/geisa-image/packages.manifest`. + +## Building the Image + +Clone the Community repository and change to the shared NXP i.MX9 platform: + +```sh +git clone https://github.com/geisa/community.git +cd community/platforms/nxp-imx9-yocto +``` + +Initialize the pinned source trees and check the selected release profile: + +```sh +git submodule update --init --recursive +./scripts/setup-sources.sh --check --release nxp-6.18.2-1.0.0 +``` + +Build the i.MX93 image with: + +```sh +ACCEPT_FSL_EULA=1 ./scripts/build.sh development \ + --release nxp-6.18.2-1.0.0 \ + --machine geisa-imx93 -- bitbake geisa-dev-image +``` + +Build the i.MX95 image with: + +```sh +ACCEPT_FSL_EULA=1 ./scripts/build.sh development \ + --release nxp-6.18.2-1.0.0 \ + --machine geisa-imx95 -- bitbake geisa-dev-image +``` + +The build uses the existing download and sstate caches when `DL_DIR` and +`SSTATE_DIR` are configured. Otherwise it uses the default cache locations +under `$HOME/yocto-cache`. + +The 12/8/8 settings have been used on a 32 GiB, 12-vCPU build host. Reduce +the make job count if the host runs short on memory: + +```sh +BB_NUMBER_THREADS=12 +PARALLEL_MAKE="-j 8" +PARALLEL_MAKEINST="-j 8" +``` + +Build outputs are written at: + +`build-development-nxp-6.18.2-1.0.0/tmp/deploy/images//` + +## On-device Scripts + +A few scripts are included for convenience: + +- `geisa-system-state` provides a refreshed view of system stats including + container usage, useful for small screens. + + - Use `geisa-system-state --once` for a single more detailed snapshot for + capturing diagnostics or logs. + + - Add `--debug` to include routes, listening sockets, and recent warning or + error messages. + +- `geisa-ethosu-smoke-test` gives a quick and dirty PASS/FAIL indication for + inferencing using the Ethos-U NPU on the i.MX93 + +- `geisa-neutron-smoke-test` does similarly for the i.MX95 Neutron NPU, with + a bit more detail and statistics. + +Both of the NPU tests are intended as simple smoke checks to ensure the required +drivers, software and permissions are usable for inferencing on the respective +boards. + +See [SD installation](https://github.com/geisa/community/tree/main/platforms/nxp-imx9-yocto/docs/sd-install.md), +[eMMC installation](https://github.com/geisa/community/tree/main/platforms/nxp-imx9-yocto/docs/emmc-install.md), +and [commissioning](https://github.com/geisa/community/tree/main/platforms/nxp-imx9-yocto/docs/commissioning.md) +for additional information. + +## Licensing + +NXP components are subject to the applicable NXP license terms. See +[`docs/licensing.md`](https://github.com/geisa/community/tree/main/platforms/nxp-imx9-yocto/docs/licensing.md) +for the image's licensing notes. diff --git a/platforms/nxp-imx9-yocto/build-configuration/LOCAL-STAGING.md b/platforms/nxp-imx9-yocto/build-configuration/LOCAL-STAGING.md new file mode 100644 index 0000000..5f3dbbb --- /dev/null +++ b/platforms/nxp-imx9-yocto/build-configuration/LOCAL-STAGING.md @@ -0,0 +1,9 @@ +# Local Build Values + +This repository intentionally does not prescribe a build-host download or +sstate-cache location. Set `DL_DIR` and `SSTATE_DIR` in the environment when a +shared cache is useful; they are local values and must not be committed. + +The source directories under `sources/` are pinned Git submodules. A release +build must use those checked-out revisions rather than a sibling development +tree. diff --git a/platforms/nxp-imx9-yocto/build-configuration/releases/nxp-6.18.2-1.0.0.conf b/platforms/nxp-imx9-yocto/build-configuration/releases/nxp-6.18.2-1.0.0.conf new file mode 100644 index 0000000..05d526c --- /dev/null +++ b/platforms/nxp-imx9-yocto/build-configuration/releases/nxp-6.18.2-1.0.0.conf @@ -0,0 +1,5 @@ +RELEASE_ID="nxp-6.18.2-1.0.0" +BUILD_DIR="build-development-nxp-6.18.2-1.0.0" +MACHINE="geisa-imx93" +DISTRO="geisa-dev" +IMAGE="geisa-dev-image" diff --git a/platforms/nxp-imx9-yocto/build-configuration/templates/bblayers.conf b/platforms/nxp-imx9-yocto/build-configuration/templates/bblayers.conf new file mode 100644 index 0000000..d5a7378 --- /dev/null +++ b/platforms/nxp-imx9-yocto/build-configuration/templates/bblayers.conf @@ -0,0 +1,18 @@ +# POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf +# changes incompatibly +POKY_BBLAYERS_CONF_VERSION = "2" + +BBPATH = "${TOPDIR}" +BBFILES ?= "" + +BBLAYERS ?= " \ + @PLATFORM_ROOT@/sources/openembedded-core/meta \ + @PLATFORM_ROOT@/sources/meta-yocto/meta-poky \ + @PLATFORM_ROOT@/sources/meta-yocto/meta-yocto-bsp \ + @PLATFORM_ROOT@/sources/meta-arm/meta-arm-bsp \ + @PLATFORM_ROOT@/sources/meta-arm/meta-arm \ + @PLATFORM_ROOT@/sources/meta-arm/meta-arm-toolchain \ + @PLATFORM_ROOT@/sources/meta-arm/meta-arm-systemready \ + @PLATFORM_ROOT@/sources/meta-freescale \ + @PLATFORM_ROOT@/sources/meta-geisa-community \ + " diff --git a/platforms/nxp-imx9-yocto/build-configuration/templates/local.conf b/platforms/nxp-imx9-yocto/build-configuration/templates/local.conf new file mode 100644 index 0000000..ccf8840 --- /dev/null +++ b/platforms/nxp-imx9-yocto/build-configuration/templates/local.conf @@ -0,0 +1,283 @@ +# +# This file is your local configuration file and is where all local user settings +# are placed. The comments in this file give some guide to the options a new user +# to the system might want to change but pretty much any configuration option can +# be set in this file. More adventurous users can look at +# local.conf.sample.extended which contains other examples of configuration which +# can be placed in this file but new users likely won't need any of them +# initially. There's also site.conf.sample which contains examples of site specific +# information such as proxy server addresses. +# +# Lines starting with the '#' character are commented out and in some cases the +# default values are provided as comments to show people example syntax. Enabling +# the option is a question of removing the # character and making any change to the +# variable as required. + +# +# Machine Selection +# +# You need to select a specific machine to target the build with. There are a selection +# of emulated machines available which can boot and run in the QEMU emulator: +# +#MACHINE ?= "qemuarm" +#MACHINE ?= "qemuarm64" +#MACHINE ?= "qemumips" +#MACHINE ?= "qemumips64" +#MACHINE ?= "qemuppc" +#MACHINE ?= "qemux86" +#MACHINE ?= "qemux86-64" +# +# There are also the following hardware board target machines included for +# demonstration purposes: +# +#MACHINE ?= "beaglebone-yocto" +#MACHINE ?= "genericarm64" +#MACHINE ?= "genericx86" +#MACHINE ?= "genericx86-64" +# +# This sets the default machine to be qemux86-64 if no other machine is selected: +MACHINE ??= "qemux86-64" + +# These are some of the more commonly used values. Looking at the files in the +# meta/conf/machine directory, or the conf/machine directory of any additional layers +# you add in will show all the available machines. + +# +# Where to place downloads +# +# During a first build the system will download many different source code tarballs +# from various upstream projects. This can take a while, particularly if your network +# connection is slow. These are all stored in DL_DIR. When wiping and rebuilding you +# can preserve this directory to speed up this part of subsequent builds. This directory +# is safe to share between multiple builds on the same machine too. +# +# The default is a downloads directory under TOPDIR which is the build directory. +# +#DL_DIR ?= "${TOPDIR}/downloads" + +# +# Where to place shared-state files +# +# BitBake has the capability to accelerate builds based on previously built output. +# This is done using "shared state" files which can be thought of as cache objects +# and this option determines where those files are placed. +# +# You can wipe out TMPDIR leaving this directory intact and the build would regenerate +# from these files if no changes were made to the configuration. If changes were made +# to the configuration, only shared state files where the state was still valid would +# be used (done using checksums). +# +# The default is a sstate-cache directory under TOPDIR. +# +#SSTATE_DIR ?= "${TOPDIR}/sstate-cache" + +# +# Where to place the build output +# +# This option specifies where the bulk of the building work should be done and +# where BitBake should place its temporary files and output. Keep in mind that +# this includes the extraction and compilation of many applications and the toolchain +# which can use Gigabytes of hard disk space. +# +# The default is a tmp directory under TOPDIR. +# +#TMPDIR = "${TOPDIR}/tmp" + +# +# Default policy config +# +# The distribution setting controls which policy settings are used as defaults. +# The default value is fine for general Yocto project use, at least initially. +# Ultimately when creating custom policy, people will likely end up subclassing +# these defaults. +# +DISTRO ?= "poky" +# As an example of a subclass there is a "bleeding" edge policy configuration +# where many versions are set to the absolute latest code from the upstream +# source control systems. This is just mentioned here as an example, its not +# useful to most new users. +# DISTRO ?= "poky-bleeding" + +# +# Package Management configuration +# +# This variable lists which packaging formats to enable. Multiple package backends +# can be enabled at once and the first item listed in the variable will be used +# to generate the root filesystems. +# Options are: +# - 'package_deb' for debian style deb files +# - 'package_ipk' for ipk files are used by opkg (a debian style embedded package manager) +# - 'package_rpm' for rpm style packages +# E.g.: PACKAGE_CLASSES ?= "package_rpm package_deb package_ipk" +# OE-Core defaults to ipkg, whilst Poky defaults to rpm: +# PACKAGE_CLASSES ?= "package_rpm" + +# +# SDK target architecture +# +# This variable specifies the architecture to build SDK items for and means +# you can build the SDK packages for architectures other than the machine you are +# running the build on (i.e. building i686 packages on an x86_64 host). +# Supported values are i686, x86_64, aarch64 +#SDKMACHINE ?= "i686" + +# +# Extra image configuration defaults +# +# The EXTRA_IMAGE_FEATURES variable allows extra packages to be added to the generated +# images. Some of these options are added to certain image types automatically. The +# variable can contain the following options: +# "dbg-pkgs" - add -dbg packages for all installed packages +# (adds symbol information for debugging/profiling) +# "src-pkgs" - add -src packages for all installed packages +# (adds source code for debugging) +# "dev-pkgs" - add -dev packages for all installed packages +# (useful if you want to develop against libs in the image) +# "ptest-pkgs" - add -ptest packages for all ptest-enabled packages +# (useful if you want to run the package test suites) +# "tools-sdk" - add development tools (gcc, make, pkgconfig etc.) +# "tools-debug" - add debugging tools (gdb, strace) +# "eclipse-debug" - add Eclipse remote debugging support +# "tools-profile" - add profiling tools (oprofile, lttng, valgrind) +# "tools-testapps" - add useful testing tools (ts_print, aplay, arecord etc.) +# There are other application targets that can be used here too, see +# meta/classes-recipe/image.bbclass and +# meta/classes-recipe/core-image.bbclass for more details. +# Explicit development access features preserve the historical development image behavior. +EXTRA_IMAGE_FEATURES ?= "allow-empty-password empty-root-password allow-root-login" + +# +# Additional image features +# +# The following is a list of additional classes to use when building images which +# enable extra features. Some available options which can be included in this variable +# are: +# - 'buildstats' collect build statistics +USER_CLASSES ?= "buildstats" + +# +# Runtime testing of images +# +# The build system can test booting virtual machine images under qemu (an emulator) +# after any root filesystems are created and run tests against those images. It can also +# run tests against any SDK that are built. To enable this uncomment these lines. +# See meta/classes-recipe/test{image,sdk}.bbclass for further details. +#IMAGE_CLASSES += "testimage testsdk" +#TESTIMAGE_AUTO:qemuall = "1" + +# +# Interactive shell configuration +# +# Under certain circumstances the system may need input from you and to do this it +# can launch an interactive shell. It needs to do this since the build is +# multithreaded and needs to be able to handle the case where more than one parallel +# process may require the user's attention. The default is iterate over the available +# terminal types to find one that works. +# +# Examples of the occasions this may happen are when resolving patches which cannot +# be applied, to use the devshell or the kernel menuconfig +# +# Supported values are auto, gnome, xfce, rxvt, screen, konsole (KDE 3.x only), none +# Note: currently, Konsole support only works for KDE 3.x due to the way +# newer Konsole versions behave +#OE_TERMINAL = "auto" +# By default disable interactive patch resolution (tasks will just fail instead): +PATCHRESOLVE = "noop" + +# +# Disk Space Monitoring during the build +# +# Monitor the disk space during the build. If there is less that 1GB of space or less +# than 100K inodes in any key build location (TMPDIR, DL_DIR, SSTATE_DIR), gracefully +# shutdown the build. If there is less than 100MB or 1K inodes, perform a hard halt +# of the build. The reason for this is that running completely out of space can corrupt +# files and damages the build in ways which may not be easily recoverable. +# It's necessary to monitor /tmp, if there is no space left the build will fail +# with very exotic errors. +BB_DISKMON_DIRS ??= "\ + STOPTASKS,${TMPDIR},1G,100K \ + STOPTASKS,${DL_DIR},1G,100K \ + STOPTASKS,${SSTATE_DIR},1G,100K \ + STOPTASKS,/tmp,100M,100K \ + HALT,${TMPDIR},100M,1K \ + HALT,${DL_DIR},100M,1K \ + HALT,${SSTATE_DIR},100M,1K \ + HALT,/tmp,10M,1K" + +# +# Shared-state files from other locations +# +# As mentioned above, shared state files are prebuilt cache data objects which can be +# used to accelerate build time. This variable can be used to configure the system +# to search other mirror locations for these objects before it builds the data itself. +# +# This can be a filesystem directory, or a remote url such as https or ftp. These +# would contain the sstate-cache results from previous builds (possibly from other +# machines). This variable works like fetcher MIRRORS/PREMIRRORS and points to the +# cache locations to check for the shared objects. +# NOTE: if the mirror uses the same structure as SSTATE_DIR, you need to add PATH +# at the end as shown in the examples below. This will be substituted with the +# correct path within the directory structure. +#SSTATE_MIRRORS ?= "\ +#file://.* https://someserver.tld/share/sstate/PATH;downloadfilename=PATH \ +#file://.* file:///some/local/dir/sstate/PATH" + +# +# Yocto Project SState Mirror +# +# The Yocto Project has prebuilt artefacts available for its releases, you can enable +# use of these by uncommenting some of the following lines. This will mean the build uses +# the network to check for artefacts at the start of builds, which does slow it down +# initially but it will then speed up the builds by not having to build things if they are +# present in the cache. It assumes you can download something faster than you can build it +# which will depend on your network. +# Note: For this to work you also need hash-equivalence passthrough to the matching server +# There is a choice between our sstate server directly and a faster content delivery network +# (CDN) kindly provided by JSDelivr, uncomment one of the SSTATE_MIRRORS lines, not both. +# Using the CDN rather than the yoctoproject.org address is suggested/preferred. +# +#BB_HASHSERVE_UPSTREAM = 'wss://hashserv.yoctoproject.org/ws' +#SSTATE_MIRRORS ?= "file://.* http://sstate.yoctoproject.org/all/PATH;downloadfilename=PATH" + +# +# Qemu configuration +# +# By default native qemu will build with a builtin VNC server where graphical output can be +# seen. The line below enables the SDL UI frontend too. +PACKAGECONFIG:append:pn-qemu-system-native = " sdl" +# By default libsdl2-native will be built, if you want to use your host's libSDL instead of +# the minimal libsdl built by libsdl2-native then uncomment the ASSUME_PROVIDED line below. +#ASSUME_PROVIDED += "libsdl2-native" + +# You can also enable the Gtk UI frontend, which takes somewhat longer to build, but adds +# a handy set of menus for controlling the emulator. +#PACKAGECONFIG:append:pn-qemu-system-native = " gtk+" + +# +# Hash Equivalence +# +# Enable support for automatically running a local hash equivalence server and +# instruct bitbake to use a hash equivalence aware signature generator. Hash +# equivalence improves reuse of sstate by detecting when a given sstate +# artifact can be reused as equivalent, even if the current task hash doesn't +# match the one that generated the artifact. +# +# A shared hash equivalent server can be set with ":" format +# +#BB_HASHSERVE = "auto" +#BB_SIGNATURE_HANDLER = "OEEquivHash" + +# +# Memory Resident Bitbake +# +# Bitbake's server component can stay in memory after the UI for the current command +# has completed. This means subsequent commands can run faster since there is no need +# for bitbake to reload cache files and so on. Number is in seconds, after which the +# server will shut down. +# +#BB_SERVER_TIMEOUT = "60" + +# CONF_VERSION is increased each time build/conf/ changes incompatibly and is used to +# track the version of this file when it was generated. This can safely be ignored if +# this doesn't mean anything to you. +CONF_VERSION = "2" diff --git a/platforms/nxp-imx9-yocto/docs/architecture.md b/platforms/nxp-imx9-yocto/docs/architecture.md new file mode 100644 index 0000000..6aec934 --- /dev/null +++ b/platforms/nxp-imx9-yocto/docs/architecture.md @@ -0,0 +1,40 @@ +# Architecture + +This tree contains a shared Yocto platform for the NXP FRDM-i.MX93 and +FRDM-i.MX95. Common image and runtime metadata lives in +`sources/meta-geisa-community`. The `geisa-imx93` and `geisa-imx95` machine +files are thin wrappers around the NXP board includes and shared i.MX9 +settings. + +## Shared Platform + +The common image provides the GEISA runtime defaults, systemd integration, +Mosquitto, LXC, LXC networking, kernel modules, and development image support. +The `geisa-dev-image` recipe also builds a separate `geisa-application-base` +image through the `geisa-container` multiconfig. It copies that image's +SquashFS and tar outputs to `/platform/base`. + +The image creates `/platform/base`, `/platform/profiles`, and `/platform/inputs`. +A root-relative systemd generator accepts an active root at +`/dev/mmcblkXp2` and derives `/dev/mmcblkXp3` for `/platform`. Unsupported root +sources fail closed. This keeps a cloned SD or eMMC image from selecting a +platform partition on another MMC device. + +The image includes the kernel, userspace, and service support used by a +higher-level platform implementation to place applications in cgroup v2 and +apply resource limits. Application-specific placement and limits are outside +this image. + +## System Selection + +System configuration sets the accelerator package group, runtime, device +group, and profile settings. The selection is implemented through system +variables and package groups; there is no separate generic accelerator layer. + +| System | Accelerator | System-specific content | +| ------------- | ----------- | --------------------------------------------------------- | +| `geisa-imx93` | Ethos-U | Ethos-U runtime, device policy, and TFLite profile | +| `geisa-imx95` | Neutron | Neutron runtime, device policy, and qualification fixture | + +The i.MX93 provides a platform profile path for Ethos-U. The i.MX95 uses the +Neutron runtime without a platform profile path. diff --git a/platforms/nxp-imx9-yocto/docs/build.md b/platforms/nxp-imx9-yocto/docs/build.md new file mode 100644 index 0000000..64ad8c8 --- /dev/null +++ b/platforms/nxp-imx9-yocto/docs/build.md @@ -0,0 +1,89 @@ +# Build Requirements + +Build on Linux with normal filesystem support for ownership, permissions, +symbolic links, hard links, and extended attributes. Allow at least 16 GiB of +RAM and 300 GiB of free disk space when retaining downloads, sstate, and build +outputs. + +## Source Setup + +Initialize the pinned source trees, then check the default release profile: + +```sh +git submodule update --init --recursive +./scripts/setup-sources.sh --check --release nxp-6.18.2-1.0.0 +``` + +The default profile is `nxp-6.18.2-1.0.0`, using NXP 6.18.2 on Whinlatter. +The check requires each profile source to be initialized and at its pinned +commit. It reports whether each source checkout has tracked or untracked +changes, but does not reject those changes. It does not fetch, switch, reset, +or otherwise change repositories. + +The build records the Community repository revision and dirty state separately +from the pinned source check. A dirty Community tree is therefore allowed for +development builds and is recorded in the generated image metadata. A dirty +source checkout is also reported, but a source-changing setup operation will +refuse to switch it to another commit. + +## Build + +The build script requires local NXP license acceptance for every invocation: + +```sh +ACCEPT_FSL_EULA=1 ./scripts/build.sh development \ + --release nxp-6.18.2-1.0.0 \ + --machine geisa-imx93 -- bitbake geisa-dev-image +``` + +For i.MX95, use: + +```sh +ACCEPT_FSL_EULA=1 ./scripts/build.sh development \ + --release nxp-6.18.2-1.0.0 \ + --machine geisa-imx95 -- bitbake geisa-dev-image +``` + +Omitting `--machine` is supported, but selects `geisa-imx93` by default. Use +an explicit machine for reproducible board builds. + +The script uses `DL_DIR` and `SSTATE_DIR` from the environment when set. +Otherwise it uses: + +```text +$HOME/yocto-cache/downloads +$HOME/yocto-cache/sstate +``` + +The following settings have been used on a 32 GiB, 12-vCPU build host: + +```sh +BB_NUMBER_THREADS=12 +PARALLEL_MAKE="-j 8" +PARALLEL_MAKEINST="-j 8" +``` + +Reduce the make job count if your build host runs short on memory. + +## Checks and Outputs + +Run a parse-only check with the same release and machine selection used for +the build: + +```sh +ACCEPT_FSL_EULA=1 ./scripts/build.sh development \ + --release nxp-6.18.2-1.0.0 \ + --machine geisa-imx93 -- bitbake -p +``` + +Use `--machine geisa-imx95` for the i.MX95 parse check. The build outputs are +written below: + +```text +build-development-nxp-6.18.2-1.0.0/tmp/deploy/images// +``` + +The build script requires `ACCEPT_FSL_EULA=1` after reviewing the applicable +NXP terms in `sources/meta-freescale/EULA` and `sources/meta-imx/LICENSE.txt`. +That setting enables the local build flow; it does not grant redistribution +rights for generated images or other build outputs. diff --git a/platforms/nxp-imx9-yocto/docs/commissioning.md b/platforms/nxp-imx9-yocto/docs/commissioning.md new file mode 100644 index 0000000..cd57d7a --- /dev/null +++ b/platforms/nxp-imx9-yocto/docs/commissioning.md @@ -0,0 +1,15 @@ +# Commissioning + +The development image intentionally contains no operator accounts, SSH keys, +site network configuration, applications, or private credentials. If intended +for normal usage, provision those items after first boot through your preferred +local deployment and configuration process, but ensure these do not leak into +any repo updates if making contributions. Keep private credentials outside of +the image and outside this repository. + +This image includes sudo policy for a configured operator account, but account +creation and user-specific sudo membership are part of the post-boot +commissioning. + +Verify the host with `geisa-system-state --once`, inspect the network and time +configuration, and record the exact image manifest before adding applications. diff --git a/platforms/nxp-imx9-yocto/docs/emmc-install.md b/platforms/nxp-imx9-yocto/docs/emmc-install.md new file mode 100644 index 0000000..0e80f28 --- /dev/null +++ b/platforms/nxp-imx9-yocto/docs/emmc-install.md @@ -0,0 +1,23 @@ +# eMMC Installation + +eMMC installation and boot were validated on a specific FRDM-i.MX93 test board +used for this development image. This document covers that i.MX93 validation +only; it is not a universal installer procedure. The shared image also supports +FRDM-i.MX95, but no i.MX95 eMMC procedure is validated here. Do not assume the +i.MX93 result or boot process applies to i.MX95. + +Validate an exact WIC on removable media first, retain that media as recovery +media, and make a verified backup of existing eMMC contents before any +destructive operation. + +After eMMC boot, confirm root is eMMC partition 2 and `/platform` is the +matching eMMC partition 3. The image derives `/platform` from the active root +device, so both sources must have the same `mmcblkX` number. + +The i.MX95 uses a distinct FRDM U-Boot and boot configuration. Establish its +eMMC installation and validation separately before using an i.MX95 image on +eMMC. + +This document does not include a generic destructive write command. Board boot +settings and recovery steps must be established for the specific i.MX board +and image. diff --git a/platforms/nxp-imx9-yocto/docs/known-issues.md b/platforms/nxp-imx9-yocto/docs/known-issues.md new file mode 100644 index 0000000..4f9517c --- /dev/null +++ b/platforms/nxp-imx9-yocto/docs/known-issues.md @@ -0,0 +1,12 @@ +# Known Issues + +## Older e2fsprogs cannot inspect generated filesystems + +The WIC root and `/platform` filesystems use the ext4 `orphan_file` feature. +e2fsprogs versions older than 1.47 may report this as `FEATURE_C12` and +exit with status 12 during offline inspection. That result does *not* imply +that the filesystem is corrupt. + +Use e2fsprogs 1.47 or newer for offline checks. `scripts/inspect-wic.sh` +selects the build's compatible native tools when available, or accepts an +explicit tool directory through `GEISA_E2FSPROGS_BIN_DIR`. diff --git a/platforms/nxp-imx9-yocto/docs/licensing.md b/platforms/nxp-imx9-yocto/docs/licensing.md new file mode 100644 index 0000000..c4f4a9a --- /dev/null +++ b/platforms/nxp-imx9-yocto/docs/licensing.md @@ -0,0 +1,21 @@ +# Licensing + +Apache-2.0 applies to Community-owned metadata, scripts, and documentation +where stated. It does not license the Yocto image as a whole, NXP BSP content, +firmware, models, media, or third-party runtime components. + +Review the same-build package manifest, SPDX archive, and generated license +material before distributing any WIC. NXP EULA acceptance enables local build +handling; it is not blanket permission to redistribute binaries. + +The i.MX95 Neutron image includes separately licensed NXP runtime, driver, and +firmware packages. The Community smoke-test package includes the qualification +fixture, but that packaging does not change the license or notice obligations +for the included model or NXP components. + +The NXP Ethos-U/TFLite profile is generated from declared NXP/Yocto runtime +outputs and a checksum-pinned public PyAV wheel. The Community source tree does +not redistribute a preassembled profile archive. A WIC that includes the +generated profile still requires same-build SPDX and package-license review for +the NXP components and the PyAV wheel's bundled multimedia libraries before +binary redistribution. diff --git a/platforms/nxp-imx9-yocto/docs/nxp-ethosu-tflite-profile.md b/platforms/nxp-imx9-yocto/docs/nxp-ethosu-tflite-profile.md new file mode 100644 index 0000000..bb78e81 --- /dev/null +++ b/platforms/nxp-imx9-yocto/docs/nxp-ethosu-tflite-profile.md @@ -0,0 +1,36 @@ +# NXP Ethos-U/TFLite Execution Profile + +The `nxp-ethosu-tflite` profile is generated during the Community image build. +It is not a checked-in archive and does not require a locally curated profile +input. + +The generator copies the following pinned Yocto runtime outputs from its +recipe sysroot: + +- `tensorflow-lite` +- `tensorflow-lite-ethosu-delegate` +- `ethos-u-driver-stack` +- `python3-numpy` + +It also fetches the exact public PyAV 18.0.0 aarch64 wheel from PyPI through +BitBake. The URL, filename, tag, and SHA-256 are in +`geisa-nxp-ethosu-tflite-profile.bb`; a changed or unavailable wheel fails the +build. The profile's `profile.json` records this input and its generated file +inventory. + +The generated `profile.json` currently declares: + +- `loader.pythonpath = python` +- `loader.library-path = ["lib", "python/av.libs"]` + +That makes the profile a mixed runtime: it is self-contained for its private +delegate, TensorFlow Lite, `libethosu`, NumPy, and PyAV payloads, while still +using the host Python interpreter, `/dev/ethosu0`, and the host kernel/firmware +stack. The host-side `geisa-ethosu-smoke-test --profile ...` path applies that +loader metadata directly and reports the module and library paths it loaded. + +The PyAV project declares BSD-3-Clause for its wheel metadata. The wheel also +contains bundled multimedia libraries. The source tree does not redistribute +the wheel, but a release WIC containing the generated profile should undergo the +SPDX and package license review, including the NXP BSP and bundled multimedia +components, before binary redistribution. diff --git a/platforms/nxp-imx9-yocto/docs/sd-install.md b/platforms/nxp-imx9-yocto/docs/sd-install.md new file mode 100644 index 0000000..1219fcf --- /dev/null +++ b/platforms/nxp-imx9-yocto/docs/sd-install.md @@ -0,0 +1,11 @@ +# SD Installation + +Verify the selected WIC SHA-256 and confirm the removable target by model, +capacity, and path before writing. Decompress the exact WIC to the whole SD +device, flush it, then inspect the resulting partition table. + +Boot manually and confirm that root is the SD partition 2 and `/platform` is +the matching SD partition 3. The image derives `/platform` from the active +root device; both sources must have the same `mmcblkX` number. Preserve the SD +card as recovery media until the target artifact has completed its documented +hardware validation. diff --git a/platforms/nxp-imx9-yocto/images/development/README.md b/platforms/nxp-imx9-yocto/images/development/README.md new file mode 100644 index 0000000..35f8de6 --- /dev/null +++ b/platforms/nxp-imx9-yocto/images/development/README.md @@ -0,0 +1 @@ +Development artifacts are generated locally and are not source-controlled. diff --git a/platforms/nxp-imx9-yocto/images/production/README.md b/platforms/nxp-imx9-yocto/images/production/README.md new file mode 100644 index 0000000..d572aa6 --- /dev/null +++ b/platforms/nxp-imx9-yocto/images/production/README.md @@ -0,0 +1,6 @@ +# Production Image Status + +No production image recipe, security policy, or release artifact is included in +this FRDM-i.MX93/i.MX95 development-image contribution. Production work must +be designed, reviewed, and validated separately. This directory is retained +for the future production-image documentation. diff --git a/platforms/nxp-imx9-yocto/releases/default b/platforms/nxp-imx9-yocto/releases/default new file mode 100644 index 0000000..5b2de3d --- /dev/null +++ b/platforms/nxp-imx9-yocto/releases/default @@ -0,0 +1 @@ +DEFAULT_RELEASE="nxp-6.18.2-1.0.0" diff --git a/platforms/nxp-imx9-yocto/releases/nxp-6.18.2-1.0.0.conf b/platforms/nxp-imx9-yocto/releases/nxp-6.18.2-1.0.0.conf new file mode 100644 index 0000000..a029324 --- /dev/null +++ b/platforms/nxp-imx9-yocto/releases/nxp-6.18.2-1.0.0.conf @@ -0,0 +1,32 @@ +RELEASE_ID="nxp-6.18.2-1.0.0" +STATUS="experimental" +NXP_BSP_VERSION="6.18.2-1.0.0" +YOCTO_SERIES="whinlatter" +BUILD_DIR="build-development-nxp-6.18.2-1.0.0" +IMAGE="geisa-dev-image" +DISTRO="geisa-dev" +SOURCE_IDS="base bitbake openembedded-core meta-yocto meta-arm meta-freescale meta-freescale-distro meta-freescale-ml meta-imx meta-openembedded meta-virtualization meta-clang" +LAYER_PATHS="sources/meta-freescale-distro sources/meta-freescale-ml sources/meta-imx/meta-imx-bsp sources/meta-imx/meta-imx-ml sources/meta-imx/meta-imx-sdk sources/meta-openembedded/meta-oe sources/meta-openembedded/meta-python sources/meta-openembedded/meta-networking sources/meta-openembedded/meta-filesystems sources/meta-openembedded/meta-multimedia sources/meta-openembedded/meta-gnome sources/meta-openembedded/meta-webserver sources/meta-openembedded/meta-perl sources/meta-virtualization sources/meta-clang" +BBMASK_PATHS="" +MACHINE_IMX93="geisa-imx93" +MACHINE_IMX95="geisa-imx95" +GEISA_NXP_MACHINE_INCLUDE_IMX93="conf/machine/imx93-11x11-lpddr4x-frdm.conf" +GEISA_NXP_MACHINE_INCLUDE_IMX95="conf/machine/imx95-15x15-lpddr4x-frdm.conf" +GEISA_MACHINE_INCLUDE_IMX93="conf/machine/geisa-imx93-6.18.inc" +GEISA_MACHINE_INCLUDE_IMX95="conf/machine/geisa-imx95-6.18.inc" +KERNEL_VERSION="6.18.2" +KERNEL_SRCREV="f49f45233f7b10006ce7e9c826ee882bb14ac8b5" +UBOOT_VERSION="2025.04" +UBOOT_SRCREV="99518e6b6f20cb6a2bf19115e355db9f58100af8" +SOURCE_BASE="e2b65583ca857eed5d7aa675a77712fa58096bb0" +SOURCE_BITBAKE="6e511d035a3d1e4129dab7b0dfbf216bd8e99b47" +SOURCE_OPENEMBEDDED_CORE="9964fa3da2fa1e7243fba1a826e59f7bb1813706" +SOURCE_META_YOCTO="d02d3faaf4d6075ea03e9eb47654ec7639f929a0" +SOURCE_META_ARM="3752c4e4478a6dbdf7a722a261d16ebc7a4a99e5" +SOURCE_META_FREESCALE="2781242e499e601ef9454009aceed16186a48d9e" +SOURCE_META_FREESCALE_DISTRO="8001652aa3e2c6436c2bfce744e99f398c680858" +SOURCE_META_FREESCALE_ML="b364d313706d247fadf12feb68136559d7ff3d52" +SOURCE_META_IMX="fb0e606e90fbaecc273b832a9965bfef9f8b0b91" +SOURCE_META_OPENEMBEDDED="a4e768dcfae181dd99e39c4286fa0729ca7f4e47" +SOURCE_META_VIRTUALIZATION="b9a29d2423407c1e50f19dc3f3e154d164c5f0ec" +SOURCE_META_CLANG="cf20f8bd1366d41094c945597b95dd746e87b871" diff --git a/platforms/nxp-imx9-yocto/scripts/build.sh b/platforms/nxp-imx9-yocto/scripts/build.sh new file mode 100755 index 0000000..16f6b0b --- /dev/null +++ b/platforms/nxp-imx9-yocto/scripts/build.sh @@ -0,0 +1,120 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: Apache-2.0 +# Copyright (C) 2026 PragSol Consulting, LLC +# Website: https://www.pragsolconsulting.com/ +# +set -euo pipefail +[ "${1:-}" = development ] || { + echo "usage: ACCEPT_FSL_EULA=1 $0 development [--release RELEASE] [-- bitbake-command ...]" >&2 + exit 2 +} +[ "${ACCEPT_FSL_EULA:-}" = 1 ] || { + echo "ACCEPT_FSL_EULA=1 is required before building; review sources/meta-freescale/EULA and sources/meta-imx/LICENSE.txt" >&2 + exit 2 +} +shift +root="$(cd "$(dirname "$0")/.." && pwd -P)" +export GEISA_PLATFORM_ROOT="$root" +# shellcheck source=release-profile.sh +. "$root/scripts/release-profile.sh" + +release= +machine= +while [ "$#" -gt 0 ]; do + case "$1" in + --release) + [ "$#" -ge 2 ] || { + echo "--release requires a release identifier" >&2 + exit 2 + } + release="$2" + shift 2 + ;; + --machine) + [ "$#" -ge 2 ] || { echo "--machine requires a machine" >&2; exit 2; } + machine="$2" + shift 2 + ;; + --) + shift + break + ;; + *) + echo "unknown build option: $1" >&2 + exit 2 + ;; + esac +done + +release_profile_select "$release" +release_profile_check_complete +case "$machine" in + "") machine="${MACHINE_IMX93}"; machine_include="${GEISA_MACHINE_INCLUDE_IMX93}"; nxp_machine_include="${GEISA_NXP_MACHINE_INCLUDE_IMX93}";; + "$MACHINE_IMX93") machine_include="${GEISA_MACHINE_INCLUDE_IMX93}"; nxp_machine_include="${GEISA_NXP_MACHINE_INCLUDE_IMX93}";; + "$MACHINE_IMX95") machine_include="${GEISA_MACHINE_INCLUDE_IMX95}"; nxp_machine_include="${GEISA_NXP_MACHINE_INCLUDE_IMX95}";; + *) echo "unsupported machine for $RELEASE_ID: $machine" >&2; exit 2;; +esac +build_config="$root/build-configuration/releases/$RELEASE_ID.conf" +[ -r "$build_config" ] || { + echo "missing build configuration for $RELEASE_ID: $build_config" >&2 + exit 1 +} +for setting in RELEASE_ID BUILD_DIR DISTRO IMAGE; do + profile_value="${!setting}" + grep -Fqx "$setting=\"$profile_value\"" "$build_config" || { + echo "build configuration disagrees with release profile: $setting" >&2 + exit 1 + } +done +release_profile_check_sources --check + +build="$root/$BUILD_DIR" +mkdir -p "$build/conf" +sed "s|@PLATFORM_ROOT@|$root|g" "$root/build-configuration/templates/bblayers.conf" > "$build/conf/bblayers.conf" +layer_fragment="$build/conf/geisa-release-layers.conf" +: > "$layer_fragment" +printf '# Generated for %s (%s)\nBBLAYERS += " \\\n' "$RELEASE_ID" "$RELEASE_PROFILE_STATUS" >> "$layer_fragment" +declare -A layer_seen=() +for layer_path in $LAYER_PATHS; do + [ -z "${layer_seen[$layer_path]+x}" ] || { + echo "duplicate layer path for $RELEASE_ID: $layer_path" >&2 + exit 1 + } + layer_seen[$layer_path]=1 + [ -d "$root/$layer_path" ] || { + echo "missing layer path for $RELEASE_ID: $root/$layer_path" >&2 + exit 1 + } + printf ' %s/%s \\\n' "$root" "$layer_path" >> "$layer_fragment" +done +printf ' "\n' >> "$layer_fragment" +printf '\nBBMASK:append = " \\\n' >> "$layer_fragment" +declare -A mask_seen=() +for mask_path in $BBMASK_PATHS; do + [ -z "${mask_seen[$mask_path]+x}" ] || { + echo "duplicate BBMASK path for $RELEASE_ID: $mask_path" >&2 + exit 1 + } + mask_seen[$mask_path]=1 + printf ' %s \\\n' "$mask_path" >> "$layer_fragment" +done +printf ' "\n' >> "$layer_fragment" +printf '\ninclude conf/geisa-release-layers.conf\n' >> "$build/conf/bblayers.conf" +cp "$root/build-configuration/templates/local.conf" "$build/conf/local.conf" +state_file="$build/conf/geisa-source-state.conf" +rm -f "$state_file" +"$root/scripts/geisa-source-state.sh" --release "$RELEASE_ID" "$state_file" +cat > "$build/conf/auto.conf" </dev/null +set -u +[ "$#" -gt 0 ] || set -- bitbake "$IMAGE" +"$@" diff --git a/platforms/nxp-imx9-yocto/scripts/collect-release.sh b/platforms/nxp-imx9-yocto/scripts/collect-release.sh new file mode 100755 index 0000000..e9bff6a --- /dev/null +++ b/platforms/nxp-imx9-yocto/scripts/collect-release.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: Apache-2.0 +# Copyright (C) 2026 PragSol Consulting, LLC +# Website: https://www.pragsolconsulting.com/ +# +set -euo pipefail + +platform_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +export GEISA_PLATFORM_ROOT="${platform_root}" +# shellcheck source=release-profile.sh +. "${platform_root}/scripts/release-profile.sh" +release_profile_select "${GEISA_RELEASE:-}" + +if [ "$#" -eq 1 ]; then + machine="${MACHINE_IMX93}" + build_id="$1" +elif [ "$#" -eq 2 ]; then + machine="$1" + build_id="$2" +else + echo "usage: $0 [geisa-imx93|geisa-imx95] " >&2 + exit 2 +fi +case "${machine}" in + "${MACHINE_IMX93}"|"${MACHINE_IMX95}") ;; + *) echo "unsupported machine: ${machine}" >&2; exit 2 ;; +esac +deploy_dir="${platform_root}/${BUILD_DIR}/tmp/deploy/images/${machine}" +case "${build_id}" in + *[!0-9]*|'') echo "Build identifier must be a timestamp such as 20260729045937." >&2; exit 2 ;; +esac +artifact="${deploy_dir}/geisa-dev-image-${machine}.rootfs-${build_id}.wic.zst" +[ -f "${artifact}" ] || { echo "No development WIC artifact found for ${build_id}." >&2; exit 1; } + +base="${artifact%.wic.zst}" +release_id="$(basename "${base%.rootfs}")" +stage_dir="${platform_root}/release-staging/${release_id}" +[ ! -e "${stage_dir}" ] || { echo "Release destination already exists: ${stage_dir}" >&2; exit 1; } +install -d -m 0755 "${stage_dir}" + +for suffix in wic.zst wic.bmap manifest image-manifest.json spdx.json; do + source="${base}.${suffix}" + [ -f "${source}" ] || { echo "Missing release input: ${source}" >&2; exit 1; } + install -m 0644 "${source}" "${stage_dir}/" +done + +( + cd "${stage_dir}" + sha256sum *.wic.zst *.wic.bmap *.manifest *.image-manifest.json *.spdx.json > SHA256SUMS +) +printf "%s\n" "${stage_dir}" diff --git a/platforms/nxp-imx9-yocto/scripts/geisa-source-state.sh b/platforms/nxp-imx9-yocto/scripts/geisa-source-state.sh new file mode 100755 index 0000000..30f54d2 --- /dev/null +++ b/platforms/nxp-imx9-yocto/scripts/geisa-source-state.sh @@ -0,0 +1,137 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: Apache-2.0 +# Copyright (C) 2026 PragSol Consulting, LLC +# Website: https://www.pragsolconsulting.com/ +# +set -euo pipefail + +out= +release= +while [ "$#" -gt 0 ]; do + case "$1" in + --release) + [ "$#" -ge 2 ] || { echo "--release requires an identifier" >&2; exit 2; } + release="$2" + shift 2 + ;; + --) + shift + break + ;; + *) + if [ -z "$out" ]; then + out="$1" + shift + else + echo "unexpected argument: $1" >&2 + exit 2 + fi + ;; + esac +done +[ -n "$out" ] || { echo "usage: $0 [--release RELEASE] OUTPUT" >&2; exit 2; } + +platform_root="$(cd "$(dirname "$0")/.." && pwd -P)" +export GEISA_PLATFORM_ROOT="$platform_root" +# shellcheck source=release-profile.sh +. "$platform_root/scripts/release-profile.sh" +release_profile_select "$release" +release_profile_check_complete +release_profile_check_sources --check >/dev/null + +git_root="$(git -C "$platform_root" rev-parse --show-toplevel)" +prefix="$(git -C "$platform_root" rev-parse --show-prefix)" +tmp="$out.tmp.$$" +rm -f "$out" "$tmp" +cleanup() { rm -f "$tmp"; } +trap cleanup EXIT HUP INT TERM + +source_state_path() { + printf '%s/%s' "$platform_root" "$(release_profile_source_path "$1")" +} + +outer_generated_excludes=( + ":(exclude)${prefix}build-*" +) + +outer_source_excludes=() +for source_id in "${release_profile_source_ids[@]}"; do + outer_source_excludes+=(":(exclude)${prefix}$(release_profile_source_path "$source_id")") +done + +outer_status_filtered() { + local line + while IFS= read -r line || [ -n "$line" ]; do + [ -n "$line" ] || continue + printf '%s\n' "$line" + done < <(git -C "$git_root" status --porcelain=v1 --untracked-files=normal -- . "${outer_generated_excludes[@]}") +} + +outer_excludes=("${outer_source_excludes[@]}" "${outer_generated_excludes[@]}") + +source_dirty=false +# shellcheck disable=SC2154 +source_state_lines= +# shellcheck disable=SC2154 +for source_id in "${release_profile_source_ids[@]}"; do + source_var="$(release_profile_source_var "$source_id")" + expected="${!source_var}" + actual="$(git -C "$(source_state_path "$source_id")" rev-parse HEAD)" + dirty=false + release_profile_source_dirty "$source_id" && dirty=true + [ "$dirty" = true ] && source_dirty=true + key="${source_id^^}" + key="${key//-/_}" + source_state_lines+="GEISA_SOURCE_EXPECTED_$key = \"$expected\"\n" + source_state_lines+="GEISA_SOURCE_ACTUAL_$key = \"$actual\"\n" + source_state_lines+="GEISA_SOURCE_DIRTY_$key = \"$dirty\"\n" +done + +outer_status="$(outer_status_filtered)" +outer_dirty=false +[ -n "$outer_status" ] && outer_dirty=true +dirty=false +[ "$outer_dirty" = true ] && dirty=true +[ "$source_dirty" = true ] && dirty=true + +if [ "$dirty" = true ]; then + digest="$( + { + git -C "$git_root" diff --no-ext-diff --binary HEAD -- . "${outer_excludes[@]}" + git -C "$git_root" diff --cached --no-ext-diff --binary HEAD -- . "${outer_excludes[@]}" + printf '%s\n' "$outer_status" +# shellcheck disable=SC2154 + for source_id in "${release_profile_source_ids[@]}"; do + source_path="$(source_state_path "$source_id")" + printf 'SOURCE %s\n' "$source_id" + git -C "$source_path" diff --no-ext-diff --binary HEAD + git -C "$source_path" diff --cached --no-ext-diff --binary HEAD + git -C "$source_path" status --porcelain=v1 --untracked-files=all + git -C "$source_path" ls-files --stage + git -C "$source_path" ls-files --others --exclude-standard -z | + LC_ALL=C sort -z | xargs -0 -r sha256sum + done + } | sha256sum | awk '{print $1}' + )" +else + digest=clean +fi + +{ + printf 'GEISA_RELEASE_ID = "%s"\n' "$RELEASE_ID" + printf 'GEISA_RELEASE_STATUS = "%s"\n' "$RELEASE_PROFILE_STATUS" + printf 'GEISA_NXP_BSP_VERSION = "%s"\n' "$NXP_BSP_VERSION" + printf 'GEISA_YOCTO_SERIES = "%s"\n' "$YOCTO_SERIES" + printf 'GEISA_RELEASE_PROFILE_SHA256 = "%s"\n' "$RELEASE_PROFILE_HASH" + printf 'GEISA_SOURCE_REVISION = "%s"\n' "$(git -C "$git_root" rev-parse HEAD)" + printf 'GEISA_SOURCE_DIRTY = "%s"\n' "$dirty" + printf 'GEISA_SOURCE_DIRTY_DIGEST = "%s"\n' "$digest" + printf 'GEISA_SOURCE_RELEASE_MATCH = "true"\n' + printf 'GEISA_EXPECTED_KERNEL_VERSION = "%s"\n' "$KERNEL_VERSION" + printf 'GEISA_EXPECTED_KERNEL_SRCREV = "%s"\n' "$KERNEL_SRCREV" + printf 'GEISA_EXPECTED_UBOOT_VERSION = "%s"\n' "$UBOOT_VERSION" + printf 'GEISA_EXPECTED_UBOOT_SRCREV = "%s"\n' "$UBOOT_SRCREV" + printf '%b' "$source_state_lines" +} > "$tmp" +mv -f "$tmp" "$out" +trap - EXIT HUP INT TERM diff --git a/platforms/nxp-imx9-yocto/scripts/inspect-wic.sh b/platforms/nxp-imx9-yocto/scripts/inspect-wic.sh new file mode 100755 index 0000000..d7213c2 --- /dev/null +++ b/platforms/nxp-imx9-yocto/scripts/inspect-wic.sh @@ -0,0 +1,126 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: Apache-2.0 +# Copyright (C) 2026 PragSol Consulting, LLC +# Website: https://www.pragsolconsulting.com/ +# +set -euo pipefail + +platform_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +export GEISA_PLATFORM_ROOT="${platform_root}" +# shellcheck source=release-profile.sh +. "${platform_root}/scripts/release-profile.sh" +release_profile_select "${GEISA_RELEASE:-}" + +machine="${GEISA_MACHINE:-${MACHINE_IMX93}}" +artifact= +case "$#" in + 0) ;; + 1) + case "$1" in + "${MACHINE_IMX93}"|"${MACHINE_IMX95}") machine="$1" ;; + *) artifact="$1" ;; + esac + ;; + 2) machine="$1"; artifact="$2" ;; + *) echo "usage: $0 [geisa-imx93|geisa-imx95] [artifact.wic.zst]" >&2; exit 2 ;; +esac +case "${machine}" in + "${MACHINE_IMX93}"|"${MACHINE_IMX95}") ;; + *) echo "unsupported machine: ${machine}" >&2; exit 2 ;; +esac +build_dir="${platform_root}/${BUILD_DIR}" +deploy_dir="${build_dir}/tmp/deploy/images/${machine}" +if [ -z "${artifact}" ]; then + artifact="$(find "${deploy_dir}" -maxdepth 1 -type f -name "geisa-dev-image-${machine}.rootfs-*.wic.zst" -printf "%T@ %p\n" | sort -nr | head -1 | cut -d" " -f2-)" +fi +[ -f "${artifact}" ] || { echo "WIC artifact not found: ${artifact}" >&2; exit 1; } + +version_is_compatible() { + local version="$1" major minor + major="${version%%.*}" + minor="${version#*.}" + minor="${minor%%.*}" + [[ "${major}" =~ ^[0-9]+$ && "${minor}" =~ ^[0-9]+$ ]] || return 1 + (( major > 1 || (major == 1 && minor >= 47) )) +} + +select_e2fsprogs() { + local candidate version + + if [ -n "${GEISA_E2FSPROGS_BIN_DIR:-}" ]; then + candidate="${GEISA_E2FSPROGS_BIN_DIR}" + else + candidate="$(find "${build_dir}/tmp/sysroots-components" \ + -path '*/e2fsprogs-native/sbin/e2fsck' -printf '%h\n' 2>/dev/null | \ + sort -u | tail -1)" + fi + + if [ -z "${candidate}" ]; then + candidate="$(dirname "$(command -v e2fsck)")" + fi + + E2FSCK="${candidate}/e2fsck" + DUMPE2FS="${candidate}/dumpe2fs" + TUNE2FS="${candidate}/tune2fs" + for tool in "${E2FSCK}" "${DUMPE2FS}" "${TUNE2FS}"; do + [ -x "${tool}" ] || { + echo "Compatible e2fsprogs tools are incomplete in ${candidate}" >&2 + exit 2 + } + done + + version="$(${E2FSCK} -V 2>&1 | sed -n 's/^e2fsck \([^ ]*\).*/\1/p' | head -1)" + version_is_compatible "${version}" || { + echo "Unsupported e2fsprogs ${version:-unknown} at ${candidate}; " \ + "need e2fsprogs 1.47 or later for ext4 orphan_file." >&2 + exit 2 + } + echo "Using e2fsprogs ${version} from ${candidate}" +} + +select_e2fsprogs +sha256sum "${artifact}" +zstd -l "${artifact}" +temporary="$(mktemp "${TMPDIR:-/tmp}/geisa-wic.XXXXXX")" +workspace="$(mktemp -d "${TMPDIR:-/tmp}/geisa-wic-check.XXXXXX")" +trap 'rm -f "${temporary}"; rm -rf "${workspace}"' EXIT +zstd -dc "${artifact}" > "${temporary}" +parted -ms "${temporary}" unit B print +fdisk -l "${temporary}" + +check_ext4_partition() { + local number="$1" label="$2" record start end size extracted status + record="$(parted -ms "${temporary}" unit B print | awk -F: -v n="${number}" '$1 == n { print $2 ":" $3; exit }')" + [ -n "${record}" ] || { echo "Missing partition ${number} (${label})" >&2; return 1; } + start="${record%%:*}" + end="${record##*:}" + start="${start%B}" + end="${end%B}" + size=$((end - start + 1)) + extracted="${workspace}/${label}.ext4" + + # Extract one partition at a time so e2fsck can inspect it without writes. + dd if="${temporary}" of="${extracted}" iflag=skip_bytes,count_bytes \ + skip="${start}" count="${size}" status=none + echo "${label} ext4 superblock:" + "${DUMPE2FS}" -h "${extracted}" 2>/dev/null | \ + grep -E '^Filesystem (features|state):' + echo "${label} ext4 summary:" + "${TUNE2FS}" -l "${extracted}" 2>/dev/null | \ + grep -E '^Filesystem (features|state):' + echo "Checking ${label} with e2fsck -fn" + if "${E2FSCK}" -fn "${extracted}"; then + return 0 + else + status=$? + if [ "${status}" -eq 12 ]; then + echo "${label}: selected e2fsprogs cannot inspect this filesystem" >&2 + return 2 + fi + echo "${label}: e2fsck reported filesystem errors (status ${status})" >&2 + return "${status}" + fi +} + +check_ext4_partition 2 rootfs +check_ext4_partition 3 platform diff --git a/platforms/nxp-imx9-yocto/scripts/release-profile.sh b/platforms/nxp-imx9-yocto/scripts/release-profile.sh new file mode 100644 index 0000000..8318cef --- /dev/null +++ b/platforms/nxp-imx9-yocto/scripts/release-profile.sh @@ -0,0 +1,130 @@ +#!/usr/bin/env bash +set -euo pipefail + +GEISA_PLATFORM_ROOT="${GEISA_PLATFORM_ROOT:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)}" +release_profile_error() { printf 'release profile error: %s\n' "$*" >&2; return 1; } + +release_profile_known_source_ids=(base bitbake openembedded-core meta-yocto meta-arm meta-freescale meta-freescale-distro meta-freescale-ml meta-imx meta-openembedded meta-virtualization meta-clang) +release_profile_source_path() { + case "$1" in + base) echo sources/base;; bitbake) echo sources/bitbake;; openembedded-core) echo sources/openembedded-core;; meta-yocto) echo sources/meta-yocto;; + meta-arm) echo sources/meta-arm;; meta-freescale) echo sources/meta-freescale;; meta-freescale-distro) echo sources/meta-freescale-distro;; + meta-freescale-ml) echo sources/meta-freescale-ml;; meta-imx) echo sources/meta-imx;; meta-openembedded) echo sources/meta-openembedded;; + meta-virtualization) echo sources/meta-virtualization;; meta-clang) echo sources/meta-clang;; + *) release_profile_error "unknown source id: $1";; + esac +} +release_profile_source_var() { + case "$1" in + base) echo SOURCE_BASE;; bitbake) echo SOURCE_BITBAKE;; openembedded-core) echo SOURCE_OPENEMBEDDED_CORE;; meta-yocto) echo SOURCE_META_YOCTO;; + meta-arm) echo SOURCE_META_ARM;; meta-freescale) echo SOURCE_META_FREESCALE;; meta-freescale-distro) echo SOURCE_META_FREESCALE_DISTRO;; + meta-freescale-ml) echo SOURCE_META_FREESCALE_ML;; meta-imx) echo SOURCE_META_IMX;; meta-openembedded) echo SOURCE_META_OPENEMBEDDED;; + meta-virtualization) echo SOURCE_META_VIRTUALIZATION;; meta-clang) echo SOURCE_META_CLANG;; + *) release_profile_error "unknown source id: $1";; + esac +} +release_profile_validate_inventory() { + local id var value + local -A seen=() + release_profile_source_ids=() + [ -n "${SOURCE_IDS:-}" ] || { release_profile_error "SOURCE_IDS is empty"; return 1; } + for id in $SOURCE_IDS; do + [ -z "${seen[$id]+x}" ] || { release_profile_error "duplicate source ID: $id"; return 1; } + release_profile_source_path "$id" >/dev/null || return 1 + seen[$id]=1; release_profile_source_ids+=("$id") + done + for id in "${release_profile_known_source_ids[@]}"; do + var="$(release_profile_source_var "$id")"; value="${!var:-}" + if [ -n "${seen[$id]+x}" ]; then + [[ "$value" =~ ^[0-9a-fA-F]{40}$ ]] || { release_profile_error "$var must be a full commit"; return 1; } + elif [ -n "$value" ]; then + release_profile_error "$var is set for an unselected source $id"; return 1 + fi + done +} +release_profile_validate_layer_paths() { + local p; local -A seen=() + [ -n "${LAYER_PATHS:-}" ] || { release_profile_error "LAYER_PATHS is empty"; return 1; } + for p in $LAYER_PATHS; do + [ -z "${seen[$p]+x}" ] || { release_profile_error "duplicate layer path: $p"; return 1; } + [[ "$p" != /* && "$p" != *..* ]] || { release_profile_error "unsafe layer path: $p"; return 1; } + seen[$p]=1 + done +} +release_profile_default_id() { + sed -n 's/^DEFAULT_RELEASE="\([A-Za-z0-9._+-]*\)"$/\1/p' "$GEISA_PLATFORM_ROOT/releases/default" | head -1 +} +release_profile_load() { + local file="$1" line key value + [ -r "$file" ] || { release_profile_error "missing profile: $file"; return 1; } + unset RELEASE_ID STATUS NXP_BSP_VERSION YOCTO_SERIES BUILD_DIR IMAGE DISTRO SOURCE_IDS LAYER_PATHS BBMASK_PATHS \ + MACHINE_IMX93 MACHINE_IMX95 GEISA_NXP_MACHINE_INCLUDE_IMX93 GEISA_NXP_MACHINE_INCLUDE_IMX95 \ + GEISA_MACHINE_INCLUDE_IMX93 GEISA_MACHINE_INCLUDE_IMX95 KERNEL_VERSION KERNEL_SRCREV UBOOT_VERSION UBOOT_SRCREV \ + SOURCE_BASE SOURCE_BITBAKE SOURCE_OPENEMBEDDED_CORE SOURCE_META_YOCTO SOURCE_META_ARM SOURCE_META_FREESCALE \ + SOURCE_META_FREESCALE_DISTRO SOURCE_META_FREESCALE_ML SOURCE_META_IMX SOURCE_META_OPENEMBEDDED \ + SOURCE_META_VIRTUALIZATION SOURCE_META_CLANG + while IFS= read -r line || [ -n "$line" ]; do + [ -z "$line" ] || [[ "$line" == \#* ]] && continue + [[ "$line" =~ ^([A-Z][A-Z0-9_]*)=\"([^\"]*)\"$ ]] || { release_profile_error "invalid profile line: $line"; return 1; } + key="${BASH_REMATCH[1]}"; value="${BASH_REMATCH[2]}" + case "$key" in + RELEASE_ID|STATUS|NXP_BSP_VERSION|YOCTO_SERIES|BUILD_DIR|IMAGE|DISTRO|SOURCE_IDS|LAYER_PATHS|BBMASK_PATHS|MACHINE_IMX93|MACHINE_IMX95|GEISA_NXP_MACHINE_INCLUDE_IMX93|GEISA_NXP_MACHINE_INCLUDE_IMX95|GEISA_MACHINE_INCLUDE_IMX93|GEISA_MACHINE_INCLUDE_IMX95|KERNEL_VERSION|KERNEL_SRCREV|UBOOT_VERSION|UBOOT_SRCREV|SOURCE_BASE|SOURCE_BITBAKE|SOURCE_OPENEMBEDDED_CORE|SOURCE_META_YOCTO|SOURCE_META_ARM|SOURCE_META_FREESCALE|SOURCE_META_FREESCALE_DISTRO|SOURCE_META_FREESCALE_ML|SOURCE_META_IMX|SOURCE_META_OPENEMBEDDED|SOURCE_META_VIRTUALIZATION|SOURCE_META_CLANG) ;; + *) release_profile_error "unknown key $key"; return 1;; + esac + printf -v "$key" '%s' "$value" + done < "$file" + [ "$RELEASE_ID" = "$(basename "$file" .conf)" ] || { release_profile_error "profile ID mismatch"; return 1; } + [[ "$STATUS" = experimental ]] || { release_profile_error "invalid status"; return 1; } + for key in RELEASE_ID NXP_BSP_VERSION YOCTO_SERIES BUILD_DIR IMAGE DISTRO SOURCE_IDS LAYER_PATHS MACHINE_IMX93 MACHINE_IMX95 GEISA_NXP_MACHINE_INCLUDE_IMX93 GEISA_NXP_MACHINE_INCLUDE_IMX95 GEISA_MACHINE_INCLUDE_IMX93 GEISA_MACHINE_INCLUDE_IMX95 KERNEL_VERSION KERNEL_SRCREV UBOOT_VERSION UBOOT_SRCREV; do + [ -n "${!key:-}" ] || { release_profile_error "missing $key"; return 1; } + done + release_profile_validate_inventory + release_profile_validate_layer_paths + RELEASE_PROFILE_FILE="$file" + RELEASE_PROFILE_HASH="$(sha256sum "$file" | awk '{print $1}')" + RELEASE_PROFILE_STATUS="$STATUS" +} +release_profile_select() { + local id="${1:-$(release_profile_default_id)}" + [[ "$id" =~ ^[A-Za-z0-9._+-]+$ ]] || { release_profile_error "invalid release ID"; return 1; } + release_profile_load "$GEISA_PLATFORM_ROOT/releases/$id.conf" +} +release_profile_check_complete() { + local id var + for id in "${release_profile_source_ids[@]}"; do + var="$(release_profile_source_var "$id")"; [[ "${!var:-}" =~ ^[0-9a-fA-F]{40}$ ]] || { release_profile_error "missing $var"; return 1; } + done +} +release_profile_source_actual() { git -C "$GEISA_PLATFORM_ROOT/$(release_profile_source_path "$1")" rev-parse HEAD 2>/dev/null; } +release_profile_source_dirty() { [ -n "$(git -C "$GEISA_PLATFORM_ROOT/$(release_profile_source_path "$1")" status --porcelain=v1 --untracked-files=normal 2>/dev/null || true)" ]; } +release_profile_check_sources() { + local id var expected actual dirty mismatch=0 + release_profile_check_complete + for id in "${release_profile_source_ids[@]}"; do + var="$(release_profile_source_var "$id")"; expected="${!var}" + if ! actual="$(release_profile_source_actual "$id")"; then echo "source $id is not initialized" >&2; mismatch=1; continue; fi + dirty=false; release_profile_source_dirty "$id" && dirty=true + printf 'source %-22s expected=%s actual=%s dirty=%s\n' "$id" "$expected" "$actual" "$dirty" + [ "$actual" = "$expected" ] || mismatch=1 + done + [ "$mismatch" -eq 0 ] || { release_profile_error "source checkout does not match $RELEASE_ID"; return 1; } +} +release_profile_setup_sources() { + local id path var expected actual dirty + release_profile_check_complete + for id in "${release_profile_source_ids[@]}"; do + path="$GEISA_PLATFORM_ROOT/$(release_profile_source_path "$id")" + if ! git -C "$path" rev-parse --is-inside-work-tree >/dev/null 2>&1; then + git -C "$GEISA_PLATFORM_ROOT" submodule update --init --no-fetch -- "$(release_profile_source_path "$id")" || { release_profile_error "source $id unavailable without fetch"; return 1; } + fi + var="$(release_profile_source_var "$id")"; expected="${!var}" + git -C "$path" cat-file -e "$expected^{commit}" 2>/dev/null || { release_profile_error "expected commit unavailable for $id"; return 1; } + actual="$(release_profile_source_actual "$id")"; dirty=false; release_profile_source_dirty "$id" && dirty=true + [ "$dirty" = false ] || [ "$actual" = "$expected" ] || { release_profile_error "refusing to switch dirty source $id"; return 1; } + done + for id in "${release_profile_source_ids[@]}"; do + path="$GEISA_PLATFORM_ROOT/$(release_profile_source_path "$id")"; var="$(release_profile_source_var "$id")"; expected="${!var}"; actual="$(release_profile_source_actual "$id")" + [ "$actual" = "$expected" ] || git -C "$path" checkout --detach "$expected" + done + release_profile_check_sources +} diff --git a/platforms/nxp-imx9-yocto/scripts/setup-sources.sh b/platforms/nxp-imx9-yocto/scripts/setup-sources.sh new file mode 100755 index 0000000..9cf1c89 --- /dev/null +++ b/platforms/nxp-imx9-yocto/scripts/setup-sources.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: Apache-2.0 +# Copyright (C) 2026 PragSol Consulting, LLC +# Website: https://www.pragsolconsulting.com/ +# + +set -euo pipefail + +script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" +platform_root="$(cd "$script_dir/.." && pwd -P)" +export GEISA_PLATFORM_ROOT="$platform_root" +# shellcheck source=release-profile.sh +. "$script_dir/release-profile.sh" + +release= +check=false +usage() { + printf '%s\n' \ + "usage: $0 [--release RELEASE] [--check]" \ + " $0 --help" +} + +while [ "$#" -gt 0 ]; do + case "$1" in + --release) + [ "$#" -ge 2 ] || { + usage >&2 + exit 2 + } + release="$2" + shift 2 + ;; + --check) + check=true + shift + ;; + --help|-h) + usage + exit 0 + ;; + *) + printf 'unknown option: %s\n' "$1" >&2 + usage >&2 + exit 2 + ;; + esac +done + +release_profile_select "$release" +printf 'selected release: %s (%s)\n' "$RELEASE_ID" "$RELEASE_PROFILE_STATUS" +printf 'profile: %s\n' "$RELEASE_PROFILE_FILE" + +if [ "$check" = true ]; then + release_profile_check_sources --check +else + release_profile_setup_sources +fi diff --git a/platforms/nxp-imx9-yocto/scripts/test-release-profiles.sh b/platforms/nxp-imx9-yocto/scripts/test-release-profiles.sh new file mode 100755 index 0000000..ba20b7b --- /dev/null +++ b/platforms/nxp-imx9-yocto/scripts/test-release-profiles.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +set -euo pipefail + +platform_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)" +export GEISA_PLATFORM_ROOT="$platform_root" +. "$platform_root/scripts/release-profile.sh" +setup="$platform_root/scripts/setup-sources.sh" +state="$platform_root/scripts/geisa-source-state.sh" +tmp_root="$(mktemp -d "${TMPDIR:-/tmp}/geisa-release-profile-tests.XXXXXX")" +source_test_file="$platform_root/sources/meta-geisa-community/.geisa-source-state-test.$$" +generated_test_root="$(mktemp -d "${TMPDIR:-/tmp}/geisa-source-state-test.XXXXXX")" +trap 'rm -rf "$tmp_root" "$source_test_file" "$generated_test_root"' EXIT + +"$setup" --check --release nxp-6.18.2-1.0.0 >"$tmp_root/sources" +grep -Fq 'nxp-6.18.2-1.0.0' "$tmp_root/sources" + +release_profile_select nxp-6.18.2-1.0.0 +release_profile_check_complete +[[ "$MACHINE_IMX93" = geisa-imx93 && "$MACHINE_IMX95" = geisa-imx95 ]] +[[ "$GEISA_NXP_MACHINE_INCLUDE_IMX93" = conf/machine/imx93-11x11-lpddr4x-frdm.conf ]] +[[ "$GEISA_NXP_MACHINE_INCLUDE_IMX95" = conf/machine/imx95-15x15-lpddr4x-frdm.conf ]] +[[ "$KERNEL_VERSION" = 6.18.2 ]] +[[ "$KERNEL_SRCREV" = f49f45233f7b10006ce7e9c826ee882bb14ac8b5 ]] +[[ "$UBOOT_VERSION" = 2025.04 ]] +[[ "$UBOOT_SRCREV" = 99518e6b6f20cb6a2bf19115e355db9f58100af8 ]] +[[ " $SOURCE_IDS " = *' bitbake '* && " $SOURCE_IDS " = *' openembedded-core '* ]] +[[ " $SOURCE_IDS " = *' meta-yocto '* && " $SOURCE_IDS " != *' poky '* ]] +[[ " $LAYER_PATHS " = *' sources/meta-imx/meta-imx-ml '* ]] +[[ " $LAYER_PATHS " = *' sources/meta-imx/meta-imx-sdk '* ]] +[[ -z "${BBMASK_PATHS:-}" ]] + +"$state" --release nxp-6.18.2-1.0.0 "$tmp_root/state-a" +"$state" --release nxp-6.18.2-1.0.0 "$tmp_root/state-b" +cmp "$tmp_root/state-a" "$tmp_root/state-b" + +mkdir -p "$generated_test_root/tmp" +printf '%s\n' generated >"$generated_test_root/tmp/generated-file" +"$state" --release nxp-6.18.2-1.0.0 "$tmp_root/state-generated" +cmp "$tmp_root/state-a" "$tmp_root/state-generated" + +printf '%s\n' untracked >"$source_test_file" +"$state" --release nxp-6.18.2-1.0.0 "$tmp_root/state-untracked" +grep -Fqx 'GEISA_SOURCE_DIRTY = "true"' "$tmp_root/state-untracked" + +echo "release profile tests passed" diff --git a/platforms/nxp-imx9-yocto/scripts/validate-release.sh b/platforms/nxp-imx9-yocto/scripts/validate-release.sh new file mode 100755 index 0000000..6134a9d --- /dev/null +++ b/platforms/nxp-imx9-yocto/scripts/validate-release.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: Apache-2.0 +# Copyright (C) 2026 PragSol Consulting, LLC +# Website: https://www.pragsolconsulting.com/ +# +set -euo pipefail + +platform_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +stage_dir="${1:-}" +if [ -z "${stage_dir}" ]; then stage_dir="$(find "${platform_root}/release-staging" -mindepth 1 -maxdepth 1 -type d -printf "%T@ %p\n" | sort -nr | head -1 | cut -d" " -f2-)"; fi +[ -d "${stage_dir}" ] || { echo "Release staging directory not found." >&2; exit 1; } +for pattern in '*.wic.zst' '*.wic.bmap' '*.manifest' '*.image-manifest.json' '*.spdx.json'; do compgen -G "${stage_dir}/${pattern}" >/dev/null || { echo "Missing ${pattern}" >&2; exit 1; }; done +(cd "${stage_dir}" && sha256sum -c SHA256SUMS) +artifact="$(find "${stage_dir}" -maxdepth 1 -type f -name '*.wic.zst' -printf '%p\n' | sort | head -1)" +[ -n "${artifact}" ] || { echo "Missing WIC artifact for filesystem validation" >&2; exit 1; } +"${platform_root}/scripts/inspect-wic.sh" "${artifact}" diff --git a/platforms/nxp-imx9-yocto/sources/base b/platforms/nxp-imx9-yocto/sources/base new file mode 160000 index 0000000..e2b6558 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/base @@ -0,0 +1 @@ +Subproject commit e2b65583ca857eed5d7aa675a77712fa58096bb0 diff --git a/platforms/nxp-imx9-yocto/sources/bitbake b/platforms/nxp-imx9-yocto/sources/bitbake new file mode 160000 index 0000000..6e511d0 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/bitbake @@ -0,0 +1 @@ +Subproject commit 6e511d035a3d1e4129dab7b0dfbf216bd8e99b47 diff --git a/platforms/nxp-imx9-yocto/sources/meta-arm b/platforms/nxp-imx9-yocto/sources/meta-arm new file mode 160000 index 0000000..3752c4e --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-arm @@ -0,0 +1 @@ +Subproject commit 3752c4e4478a6dbdf7a722a261d16ebc7a4a99e5 diff --git a/platforms/nxp-imx9-yocto/sources/meta-clang b/platforms/nxp-imx9-yocto/sources/meta-clang new file mode 160000 index 0000000..cf20f8b --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-clang @@ -0,0 +1 @@ +Subproject commit cf20f8bd1366d41094c945597b95dd746e87b871 diff --git a/platforms/nxp-imx9-yocto/sources/meta-freescale b/platforms/nxp-imx9-yocto/sources/meta-freescale new file mode 160000 index 0000000..2781242 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-freescale @@ -0,0 +1 @@ +Subproject commit 2781242e499e601ef9454009aceed16186a48d9e diff --git a/platforms/nxp-imx9-yocto/sources/meta-freescale-distro b/platforms/nxp-imx9-yocto/sources/meta-freescale-distro new file mode 160000 index 0000000..8001652 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-freescale-distro @@ -0,0 +1 @@ +Subproject commit 8001652aa3e2c6436c2bfce744e99f398c680858 diff --git a/platforms/nxp-imx9-yocto/sources/meta-freescale-ml b/platforms/nxp-imx9-yocto/sources/meta-freescale-ml new file mode 160000 index 0000000..b364d31 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-freescale-ml @@ -0,0 +1 @@ +Subproject commit b364d313706d247fadf12feb68136559d7ff3d52 diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/conf/distro/geisa-container.conf b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/conf/distro/geisa-container.conf new file mode 100644 index 0000000..de28bb5 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/conf/distro/geisa-container.conf @@ -0,0 +1,29 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2025 Southern California Edison +# + +# Distro based on poky +require conf/distro/poky.conf + +# Distro description +DISTRO = "geisa-container" +DISTRO_NAME = "GEISA container distribution" +DISTRO_VERSION = "1.0" + +# Use systemd as default +INIT_MANAGER = "systemd" + +# No need for x11 and wayland +DISTRO_FEATURES:remove = "x11" +DISTRO_FEATURES:remove = "wayland" + +# Active buildhistory +INHERIT += "buildhistory" +BUILDHISTORY_COMMIT = "1" + +# Create /etc/build +INHERIT += "image-buildinfo" + +EXTRA_IMAGE_FEATURES:append = " read-only-rootfs" +SKIP_META_VIRT_SANITY_CHECK = "1" diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/conf/distro/geisa-dev.conf b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/conf/distro/geisa-dev.conf new file mode 100644 index 0000000..b490218 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/conf/distro/geisa-dev.conf @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Distro based on poky. Production policy is intentionally not inherited here. +require conf/distro/poky.conf + +DISTRO = "geisa-dev" +DISTRO_NAME:geisa-imx93 = "GEISA FRDM-i.MX93 Development Image" +DISTRO_NAME:geisa-imx95 = "GEISA FRDM-i.MX95 Development Image" +DISTRO_VERSION = "1.0" + +INIT_MANAGER = "systemd" +DISTRO_FEATURES:remove = "x11 wayland" +DISTRO_FEATURES:append = " virtualization" + +INHERIT += "buildhistory image-buildinfo" +BUILDHISTORY_COMMIT = "1" diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/conf/layer.conf b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/conf/layer.conf new file mode 100644 index 0000000..2c3328c --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/conf/layer.conf @@ -0,0 +1,14 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# 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 += "meta-geisa-community" +BBFILE_PATTERN_meta-geisa-community = "^${LAYERDIR}/" +BBFILE_PRIORITY_meta-geisa-community = "60" + +LAYERSERIES_COMPAT_meta-geisa-community = "whinlatter" diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/conf/machine/geisa-imx9.inc b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/conf/machine/geisa-imx9.inc new file mode 100644 index 0000000..0441982 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/conf/machine/geisa-imx9.inc @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: Apache-2.0 + +BBMULTICONFIG += "geisa-container" +MACHINEOVERRIDES =. "geisa-imx9-machine:" +WKS_FILE = "geisa-imx-partitioning.wks.in" diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/conf/machine/geisa-imx93-6.18.inc b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/conf/machine/geisa-imx93-6.18.inc new file mode 100644 index 0000000..58d83f2 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/conf/machine/geisa-imx93-6.18.inc @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: Apache-2.0 + +require conf/machine/geisa-imx93.inc + +GEISA_TFLITE_RUNTIME_VERSION = "2.19.0" diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/conf/machine/geisa-imx93.conf b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/conf/machine/geisa-imx93.conf new file mode 100644 index 0000000..196ba1e --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/conf/machine/geisa-imx93.conf @@ -0,0 +1,14 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2025 Southern California Edison +# + +#@TYPE: Machine +#@NAME: +#@DESCRIPTION: GEISA machine wrapper for the selected NXP FRDM release + +MACHINE = "geisa-imx93" +require ${GEISA_NXP_MACHINE_INCLUDE} +require conf/machine/geisa-imx9.inc +require ${GEISA_MACHINE_INCLUDE} +PREFERRED_PROVIDER_virtual/kernel = "linux-imx" diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/conf/machine/geisa-imx93.inc b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/conf/machine/geisa-imx93.inc new file mode 100644 index 0000000..a6b7669 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/conf/machine/geisa-imx93.inc @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: Apache-2.0 + +GEISA_ACCELERATOR = "ethosu" +GEISA_ACCELERATOR_PACKAGEGROUP = "packagegroup-geisa-imx93-ethosu-dev" +GEISA_ACCELERATOR_RUNTIME = "tensorflow-lite-ethosu-delegate" +GEISA_ACCELERATOR_DEVICE_GROUP = "ethosu" +GEISA_ACCELERATOR_PROFILE = "geisa-nxp-ethosu-tflite-profile" +GEISA_ACCELERATOR_PROFILE_PATH = "/platform/profiles/nxp-ethosu-tflite" diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/conf/machine/geisa-imx95-6.18.inc b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/conf/machine/geisa-imx95-6.18.inc new file mode 100644 index 0000000..7d30049 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/conf/machine/geisa-imx95-6.18.inc @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: Apache-2.0 + +require conf/machine/geisa-imx95.inc + +GEISA_TFLITE_RUNTIME_VERSION = "2.19.0" diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/conf/machine/geisa-imx95.conf b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/conf/machine/geisa-imx95.conf new file mode 100644 index 0000000..224f074 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/conf/machine/geisa-imx95.conf @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: Apache-2.0 + +MACHINE = "geisa-imx95" +require ${GEISA_NXP_MACHINE_INCLUDE} +require conf/machine/geisa-imx9.inc +require ${GEISA_MACHINE_INCLUDE} diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/conf/machine/geisa-imx95.inc b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/conf/machine/geisa-imx95.inc new file mode 100644 index 0000000..2dcfc6c --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/conf/machine/geisa-imx95.inc @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: Apache-2.0 + +GEISA_ACCELERATOR = "neutron" +GEISA_ACCELERATOR_PACKAGEGROUP = "packagegroup-geisa-imx95-neutron-dev" +GEISA_ACCELERATOR_RUNTIME = "tensorflow-lite-neutron-delegate" +GEISA_ACCELERATOR_DEVICE_GROUP = "neutron" +GEISA_ACCELERATOR_PROFILE = "" +GEISA_ACCELERATOR_PROFILE_PATH = "" + +# meta-freescale also provides an imx95-evk.inc include whose legacy +# _evk_defconfig suffix does not match the FRDM U-Boot config in NXP's +# Whinlatter source. Keep the FRDM SD build explicit here. +UBOOT_CONFIG[sd] = "${UBOOT_CONFIG_BASENAME}_defconfig,sdcard" diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/conf/multiconfig/geisa-container.conf b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/conf/multiconfig/geisa-container.conf new file mode 100644 index 0000000..73728cb --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/conf/multiconfig/geisa-container.conf @@ -0,0 +1,2 @@ +DISTRO = "geisa-container" +TMPDIR = "${TOPDIR}/tmp-geisa-container" diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-bsp/base-files/base-files/fstab b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-bsp/base-files/base-files/fstab new file mode 100644 index 0000000..7c06b01 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-bsp/base-files/base-files/fstab @@ -0,0 +1,8 @@ +/dev/root / auto ro 1 0 +proc /proc proc defaults 0 0 +devpts /dev/pts devpts mode=0620,ptmxmode=0666,gid=5 0 0 +tmpfs /run tmpfs mode=0755,nodev,nosuid,strictatime 0 0 +tmpfs /var/volatile tmpfs defaults 0 0 + +# /platform is mounted by geisa-platform-generator from partition 3 on the +# same physical device that supplies the active root filesystem. diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-bsp/base-files/base-files_%.bbappend b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-bsp/base-files/base-files_%.bbappend new file mode 100644 index 0000000..4350355 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-bsp/base-files/base-files_%.bbappend @@ -0,0 +1 @@ +FILESEXTRAPATHS:prepend := "${THISDIR}/base-files:" diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-bsp/firmware-imx/firmware-nxp-wifi_%.bbappend b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-bsp/firmware-imx/firmware-nxp-wifi_%.bbappend new file mode 100644 index 0000000..e2c034e --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-bsp/firmware-imx/firmware-nxp-wifi_%.bbappend @@ -0,0 +1,8 @@ +# The pinned NXP FRDM append adds this package even though the base recipe +# already declares it. Normalize the final package list so package QA remains +# enabled while preserving the base recipe's package split. +python __anonymous() { + packages = (d.getVar("PACKAGES") or "").split() + unique_packages = list(dict.fromkeys(packages)) + d.setVar("PACKAGES", " ".join(unique_packages)) +} diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-connectivity/bluez5/bluez5_%.bbappend b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-connectivity/bluez5/bluez5_%.bbappend new file mode 100644 index 0000000..725387d --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-connectivity/bluez5/bluez5_%.bbappend @@ -0,0 +1,11 @@ +# BlueZ packages /etc/bluetooth as 0755 while bluetooth.service requests 0555. +# Match the service's ConfigurationDirectory contract to the packaged directory. +FILESEXTRAPATHS:prepend := "${THISDIR}/files:" +SRC_URI += "file://geisa-bluetooth.conf" + +do_install:append() { + install -D -m 0644 ${UNPACKDIR}/geisa-bluetooth.conf \ + ${D}${systemd_system_unitdir}/bluetooth.service.d/geisa.conf +} + +FILES:${PN} += "${systemd_system_unitdir}/bluetooth.service.d/geisa.conf" diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-connectivity/bluez5/files/geisa-bluetooth.conf b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-connectivity/bluez5/files/geisa-bluetooth.conf new file mode 100644 index 0000000..2268c46 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-connectivity/bluez5/files/geisa-bluetooth.conf @@ -0,0 +1,2 @@ +[Service] +ConfigurationDirectoryMode=0755 diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/geisa-image-documentation/files/Apache-2.0.txt b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/geisa-image-documentation/files/Apache-2.0.txt new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/geisa-image-documentation/files/Apache-2.0.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/geisa-image-documentation/files/NOTICE.md b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/geisa-image-documentation/files/NOTICE.md new file mode 100644 index 0000000..c34608b --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/geisa-image-documentation/files/NOTICE.md @@ -0,0 +1,11 @@ +# GEISA Development Image for NXP i.MX9 Notices + +This notice applies only to community-image metadata, documentation, and helper +scripts explicitly distributed under Apache-2.0. It does not license the full +Yocto image, its packages, NXP BSP or proprietary firmware, models, media, +or third-party runtime libraries. + +Review the Yocto-generated license manifest and package-level metadata for the +exact build before redistribution. Separately distributed models and media +retain their own notices. Inclusion of this notice does not imply GEISA +endorsement, certification, or implication of official GEISA support. diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/geisa-image-documentation/files/README.md b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/geisa-image-documentation/files/README.md new file mode 100644 index 0000000..5e695b6 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/geisa-image-documentation/files/README.md @@ -0,0 +1,159 @@ + + +# GEISA Development Image for NXP i.MX9 + +Prepared by [PragSol Consulting LLC](https://www.pragsolconsulting.com). + +This community development image is based on the GEISA specification. For more +information, see . + +## Overview + +This Community-contributed development and validation image targets the NXP +FRDM-i.MX93 and FRDM-i.MX95. It uses the NXP 6.18.2-1.0.0 BSP on Whinlatter +with Linux kernel 6.18.2. + +The image provides common GEISA runtime and development tools and also enables +the relevant NPU/accelerator for the selected machine (Ethos-U or Neutron). It +is intended as a development image, not for production use. It does not include +any GEISA applications, LEE or API implementations. + +Source is available at: + + + +Community questions and issue reports belong in the +[GEISA Community issue tracker](https://github.com/geisa/community/issues). + +## Supported Boards + +| Machine | Board | Accelerator | Validation | +| ------------- | ----------- | ----------- | ---------------------------- | +| `geisa-imx93` | FRDM-i.MX93 | Ethos-U | `geisa-ethosu-smoke-test` | +| `geisa-imx95` | FRDM-i.MX95 | Neutron | `geisa-neutron-smoke-test` | + +## Image Contents + +The common image includes the GEISA application base, managed LXC containers, +cgroup v2 support, Mosquitto, protobuf, systemd services, SSH, and +development tools. The application base is installed under `/platform/base` +as SquashFS and tar archives. The `/platform` filesystem also holds execution +profiles and other image-provided validation data. `/platform` is an image +choice and not mandated by the GEISA specification at time of publishing. + +System configuration selects the accelerator support; Ethos-U for the i.MX93 +and Neutron for the i.MX95. + +The WIC layout is: + +| Disk area | Mount | Format | Size | Purpose | +| ------------- | ----------- | ------ | ----------- | --------------------------- | +| Raw boot area | Not mounted | Raw | BSP-defined | i.MX boot image and U-Boot | +| Partition 1 | `/boot` | FAT | 256 MiB | Boot files and device trees | +| Partition 2 | `/` | ext4 | 8 GiB | Operating system and tools | +| Partition 3 | `/platform` | ext4 | 6 GiB | Application base and data | + +The platform generator derives `/platform` from the active root device. The +root and platform partitions must be partitions 2 and 3 of the same MMC +device. + +### Included Tools + +The following are a subset of the included dev image tools, not a complete +package list. + +| Tool or Package | Use | +| -------------------------------- | -------------------------- | +| GCC/G++, make, CMake, Ninja | Native builds | +| Git, rsync, jq, file | Source and artifact work | +| Python/pip, Node/npm | Script and package tooling | +| protoc, protobuf, nanopb | GEISA/protobuf development | +| iproute2, ethtool, tcpdump, curl | Network diagnosis | +| LXC tools, systemctl, journalctl | Containers and services | +| vim, nano, less | Editing and log viewing | + +The complete installed package inventory is at +`/usr/share/doc/geisa-image/packages.manifest`. + +## Building the Image + +Clone the Community repository and change to the shared NXP i.MX9 platform: + +```sh +git clone https://github.com/geisa/community.git +cd community/platforms/nxp-imx9-yocto +``` + +Initialize the pinned source trees and check the selected release profile: + +```sh +git submodule update --init --recursive +./scripts/setup-sources.sh --check --release nxp-6.18.2-1.0.0 +``` + +Build the i.MX93 image with: + +```sh +ACCEPT_FSL_EULA=1 ./scripts/build.sh development \ + --release nxp-6.18.2-1.0.0 \ + --machine geisa-imx93 -- bitbake geisa-dev-image +``` + +Build the i.MX95 image with: + +```sh +ACCEPT_FSL_EULA=1 ./scripts/build.sh development \ + --release nxp-6.18.2-1.0.0 \ + --machine geisa-imx95 -- bitbake geisa-dev-image +``` + +The build uses the existing download and sstate caches when `DL_DIR` and +`SSTATE_DIR` are configured. Otherwise it uses the default cache locations +under `$HOME/yocto-cache`. + +The 12/8/8 settings have been used on a 32 GiB, 12-vCPU build host. Reduce +the make job count if the host runs short on memory: + +```sh +BB_NUMBER_THREADS=12 +PARALLEL_MAKE="-j 8" +PARALLEL_MAKEINST="-j 8" +``` + +Build outputs are written at: + +`build-development-nxp-6.18.2-1.0.0/tmp/deploy/images//` + +## On-device Scripts + +A few scripts are included for convenience: + +- `geisa-system-state` provides a refreshed view of system stats including + container usage, useful for small screens. + + - Use `geisa-system-state --once` for a single more detailed snapshot for + capturing diagnostics or logs. + + - Add `--debug` to include routes, listening sockets, and recent warning or + error messages. + +- `geisa-ethosu-smoke-test` gives a quick and dirty PASS/FAIL indication for + inferencing using the Ethos-U NPU on the i.MX93 + +- `geisa-neutron-smoke-test` does similarly for the i.MX95 Neutron NPU, with + a bit more detail and statistics. + +Both of the NPU tests are intended as simple smoke checks to ensure the required +drivers, software and permissions are usable for inferencing on the respective +boards. + +See [SD installation](https://github.com/geisa/community/tree/main/platforms/nxp-imx9-yocto/docs/sd-install.md), +[eMMC installation](https://github.com/geisa/community/tree/main/platforms/nxp-imx9-yocto/docs/emmc-install.md), +and [commissioning](https://github.com/geisa/community/tree/main/platforms/nxp-imx9-yocto/docs/commissioning.md) +for additional information. + +## Licensing + +NXP components are subject to the applicable NXP license terms. See +[`docs/licensing.md`](https://github.com/geisa/community/tree/main/platforms/nxp-imx9-yocto/docs/licensing.md) +for the image's licensing notes. diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/geisa-image-documentation/geisa-image-documentation.bb b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/geisa-image-documentation/geisa-image-documentation.bb new file mode 100644 index 0000000..af115af --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/geisa-image-documentation/geisa-image-documentation.bb @@ -0,0 +1,20 @@ +# SPDX-License-Identifier: Apache-2.0 + +SUMMARY = "GEISA shared NXP i.MX9 community image documentation" +DESCRIPTION = "Installs the canonical community-image documentation and license material." +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10" +SRC_URI = "file://README.md file://NOTICE.md file://Apache-2.0.txt" +S = "${UNPACKDIR}" +inherit allarch + +do_install() { + install -d -m 0755 ${D}${datadir}/doc/geisa-image/LICENSES + install -m 0644 ${UNPACKDIR}/README.md ${D}${datadir}/doc/geisa-image/README.md + install -m 0644 ${UNPACKDIR}/NOTICE.md ${D}${datadir}/doc/geisa-image/NOTICE.md + install -m 0644 ${UNPACKDIR}/Apache-2.0.txt ${D}${datadir}/doc/geisa-image/LICENSES/Apache-2.0.txt +} + +# Keep the published image documentation in the installable main package. +FILES:${PN}-doc = "" +FILES:${PN} = "${datadir}/doc/geisa-image" diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/geisa-sudo-policy/files/10-sudo-group b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/geisa-sudo-policy/files/10-sudo-group new file mode 100644 index 0000000..3a2372d --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/geisa-sudo-policy/files/10-sudo-group @@ -0,0 +1,2 @@ +# Members of the standard administrative group authenticate before using sudo. +%sudo ALL=(ALL:ALL) ALL diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/geisa-sudo-policy/geisa-sudo-policy.bb b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/geisa-sudo-policy/geisa-sudo-policy.bb new file mode 100644 index 0000000..acff9e1 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/geisa-sudo-policy/geisa-sudo-policy.bb @@ -0,0 +1,21 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2026 PragSol Consulting, LLC +# + +SUMMARY = "GEISA development-image sudo policy" +DESCRIPTION = "Enables authenticated sudo for members of the standard sudo group." +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10" + +SRC_URI = "file://10-sudo-group" +S = "${UNPACKDIR}" + +RDEPENDS:${PN} = "sudo" + +do_install() { + install -d -m 0750 ${D}${sysconfdir}/sudoers.d + install -m 0440 ${UNPACKDIR}/10-sudo-group ${D}${sysconfdir}/sudoers.d/10-sudo-group +} + +FILES:${PN} = "${sysconfdir}/sudoers.d/10-sudo-group" diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/geisa/files/assemble-nxp-ethosu-tflite-profile.py b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/geisa/files/assemble-nxp-ethosu-tflite-profile.py new file mode 100755 index 0000000..90fbfa1 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/geisa/files/assemble-nxp-ethosu-tflite-profile.py @@ -0,0 +1,306 @@ +#!/usr/bin/env python3 +"""Assemble and verify the reproducible NXP Ethos-U/TFLite profile.""" + +from __future__ import annotations + +import argparse +import hashlib +import json +from pathlib import Path +import re +import shutil +import stat +import zipfile + +PROFILE = "nxp-ethosu-tflite" +PROFILE_VERSION = "2" +PYAV_WHEEL = "av-18.0.0-cp311-abi3-manylinux_2_28_aarch64.whl" +PYAV_SHA256 = "4d683b7747a0ba9222b8a5f81e41db5f796e7f64473454ec4fe2548e083c2fa0" +PYAV_TAG = "cp311-abi3-manylinux_2_28_aarch64" +PYAV_URL = ( + "https://files.pythonhosted.org/packages/84/74/" + "6732f17b96dc23fd23b876b2805435855abdc8a3b397142be4e581165de8/" + "av-18.0.0-cp311-abi3-manylinux_2_28_aarch64.whl" +) + +NATIVE_SOURCES = { + "lib/libethosu_delegate.so": "usr/lib/libethosu_delegate.so", + "lib/libethosu.so.1.0.0": "usr/lib/libethosu.so.1.0.0", +} +NUMPY_EXCLUDES = { + "_pyinstaller", + "distutils", + "doc", + "f2py", + "include", + "test", + "tests", + "__pycache__", +} +PROHIBITED_PARTS = { + "build", + "doc", + "docs", + "examples", + "headers", + "include", + "pip", + "sboms", + "setuptools", + "test", + "tests", + "vela", + "wheel", +} +PROHIBITED_SUFFIXES = (".a", ".c", ".h", ".pxd", ".pyx", ".whl") + + +def sha256(path: Path) -> str: + digest = hashlib.sha256() + with path.open("rb") as source: + for block in iter(lambda: source.read(1024 * 1024), b""): + digest.update(block) + return digest.hexdigest() + + +def tensorflow_lite_library(sysroot: Path) -> tuple[str, str]: + libraries = sorted( + path + for path in (sysroot / "usr/lib").glob("libtensorflow-lite.so.*") + if path.is_file() + ) + if len(libraries) != 1: + raise ValueError(f"expected one TensorFlow Lite runtime library, found: {libraries}") + name = libraries[0].name + return name, f"usr/lib/{name}" + + +def python_site(sysroot: Path) -> Path: + sites = sorted( + path + for path in (sysroot / "usr/lib").glob("python*/site-packages") + if path.is_dir() and (path / "tflite_runtime").is_dir() + ) + if len(sites) != 1: + raise ValueError(f"expected one Python runtime site-packages tree, found: {sites}") + return sites[0].relative_to(sysroot) + + +def python_soabi(sysroot: Path, site: Path) -> str: + dynload = sysroot / site.parent / "lib-dynload" + values = set() + for path in dynload.glob("*.cpython-*.so"): + match = re.search(r"\.(cpython-[^.]+)\.so$", path.name) + if match: + values.add(match.group(1)) + if len(values) != 1: + raise ValueError(f"expected one CPython SOABI in {dynload}, found: {sorted(values)}") + return values.pop() + + +def ensure_safe_relative(name: str) -> Path: + path = Path(name) + if not name or path.is_absolute() or ".." in path.parts: + raise ValueError(f"unsafe path: {name}") + return path + + +def copy_file(source: Path, destination: Path) -> None: + destination.parent.mkdir(parents=True, exist_ok=True) + shutil.copy2(source, destination) + + +def copy_tree(source: Path, destination: Path, excluded_parts: set[str]) -> None: + if not source.is_dir(): + raise ValueError(f"missing source tree: {source}") + for path in sorted(source.rglob("*")): + relative = path.relative_to(source) + if excluded_parts.intersection(part.lower() for part in relative.parts): + continue + if path.is_symlink(): + target = path.readlink() + if target.is_absolute() or ".." in target.parts: + raise ValueError(f"unsafe source symlink: {path}") + output = destination / relative + output.parent.mkdir(parents=True, exist_ok=True) + output.symlink_to(target) + elif path.is_file(): + if path.name == "setup.py" or path.suffix in PROHIBITED_SUFFIXES: + continue + copy_file(path, destination / relative) + + +def records(root: Path) -> list[dict[str, object]]: + result: list[dict[str, object]] = [] + for path in sorted(root.rglob("*")): + relative = str(path.relative_to(root)) + mode = stat.S_IMODE(path.lstat().st_mode) + if path.is_symlink(): + result.append( + { + "mode": mode, + "path": relative, + "target": path.readlink().as_posix(), + "type": "symlink", + } + ) + elif path.is_file(): + result.append( + { + "mode": mode, + "path": relative, + "sha256": sha256(path), + "size-bytes": path.stat().st_size, + "type": "file", + } + ) + return result + + +def tree_sha256(items: list[dict[str, object]]) -> str: + encoded = json.dumps(items, sort_keys=True, separators=(",", ":")).encode("utf-8") + return hashlib.sha256(encoded).hexdigest() + + +def extract_pyav(wheel: Path, destination: Path) -> dict[str, object]: + if wheel.name != PYAV_WHEEL or sha256(wheel) != PYAV_SHA256: + raise ValueError("PyAV wheel identity mismatch") + with zipfile.ZipFile(wheel) as archive: + names = archive.namelist() + if any(Path(name).is_absolute() or ".." in Path(name).parts for name in names): + raise ValueError("unsafe PyAV wheel member") + metadata_name = "av-18.0.0.dist-info/METADATA" + wheel_name = "av-18.0.0.dist-info/WHEEL" + if metadata_name not in names or wheel_name not in names: + raise ValueError("PyAV wheel metadata is missing") + metadata = archive.read(metadata_name).decode("utf-8", errors="strict") + tags = [line.removeprefix("Tag: ") for line in archive.read(wheel_name).decode().splitlines() if line.startswith("Tag: ")] + if "Name: av" not in metadata or "Version: 18.0.0" not in metadata or tags != [PYAV_TAG]: + raise ValueError("PyAV wheel metadata drift") + for member in archive.infolist(): + name = member.filename + if member.is_dir(): + continue + path = ensure_safe_relative(name) + parts = path.parts + allowed = ( + parts[0] in {"av", "av.libs"} + or (parts[0] == "av-18.0.0.dist-info" and (name.endswith("/METADATA") or "/licenses/" in name)) + ) + if not allowed: + continue + if path.suffix in PROHIBITED_SUFFIXES or PROHIBITED_PARTS.intersection(part.lower() for part in parts): + continue + output = destination / path + output.parent.mkdir(parents=True, exist_ok=True) + with archive.open(member) as source, output.open("wb") as target: + shutil.copyfileobj(source, target) + return {"filename": PYAV_WHEEL, "sha256": PYAV_SHA256, "url": PYAV_URL, "tag": PYAV_TAG} + + +def assert_profile_safe(root: Path) -> None: + for record in records(root): + relative = str(record["path"]) + path = ensure_safe_relative(relative) + if PROHIBITED_PARTS.intersection(part.lower() for part in path.parts): + raise ValueError(f"prohibited profile content: {relative}") + if relative.endswith(PROHIBITED_SUFFIXES) or relative.endswith((".mp4", ".tflite")): + raise ValueError(f"prohibited profile content: {relative}") + if record["type"] == "file" and int(record["mode"]) & (stat.S_ISUID | stat.S_ISGID | stat.S_IWOTH): + raise ValueError(f"unsafe profile permissions: {relative}") + if record["type"] == "symlink": + target = Path(str(record["target"])) + if target.is_absolute() or ".." in target.parts: + raise ValueError(f"unsafe profile symlink: {relative}") + + +def assemble(sysroot: Path, wheel: Path, output: Path, source_revision: str) -> None: + if output.exists(): + raise ValueError(f"refusing to replace profile output: {output}") + output.mkdir(parents=True) + tensorflow_library, tensorflow_source = tensorflow_lite_library(sysroot) + native_sources = { + **NATIVE_SOURCES, + f"lib/{tensorflow_library}": tensorflow_source, + } + links = { + "lib/libethosu.so": "libethosu.so.1.0.0", + "lib/libethosu.so.1": "libethosu.so.1.0.0", + "lib/libtensorflow-lite.so": tensorflow_library, + } + site = python_site(sysroot) + soabi = python_soabi(sysroot, site) + for destination, source in native_sources.items(): + candidate = sysroot / source + if not candidate.is_file(): + raise ValueError(f"missing declared Yocto runtime input: {candidate}") + copy_file(candidate, output / destination) + copy_tree(sysroot / site / "tflite_runtime", output / "python" / "tflite_runtime", {"test", "tests", "__pycache__"}) + copy_tree(sysroot / site / "numpy", output / "python" / "numpy", NUMPY_EXCLUDES) + for destination, target in links.items(): + link = output / destination + link.parent.mkdir(parents=True, exist_ok=True) + link.symlink_to(target) + pyav = extract_pyav(wheel, output / "python") + assert_profile_safe(output) + for path in sorted(output.rglob("*"), reverse=True): + if not path.is_symlink(): + path.chmod(path.stat().st_mode & ~(stat.S_IWGRP | stat.S_IWOTH)) + file_records = records(output) + document = { + "schema-version": "geisa.nxp-ethosu-tflite-profile.v1", + "profile": PROFILE, + "profile-version": PROFILE_VERSION, + "architecture": "aarch64", + "python-soabi": soabi, + "loader": {"pythonpath": "python", "library-path": ["lib", "python/av.libs"]}, + "provenance": { + "generated-by": "meta-geisa-community", + "source-revision": source_revision, + "yocto-inputs": [ + "tensorflow-lite", + "tensorflow-lite-ethosu-delegate", + "ethos-u-driver-stack", + "python3-numpy", + ], + "pyav-wheel": pyav, + }, + "files": file_records, + "tree-sha256": tree_sha256(file_records), + } + (output / "profile.json").write_text(json.dumps(document, indent=2, sort_keys=True) + "\n", encoding="utf-8") + + +def verify(root: Path) -> None: + document = json.loads((root / "profile.json").read_text(encoding="utf-8")) + if document.get("profile") != PROFILE or str(document.get("profile-version")) != PROFILE_VERSION: + raise ValueError("profile identity mismatch") + if document.get("architecture") != "aarch64" or not re.fullmatch(r"cpython-[0-9]+-[a-z0-9_]+-linux-gnu", str(document.get("python-soabi", ""))): + raise ValueError("profile architecture or Python ABI mismatch") + if document.get("loader") != {"pythonpath": "python", "library-path": ["lib", "python/av.libs"]}: + raise ValueError("profile loader configuration mismatch") + expected = [item for item in document.get("files", []) if item.get("path") != "profile.json"] + actual = [item for item in records(root) if item.get("path") != "profile.json"] + if expected != actual or document.get("tree-sha256") != tree_sha256(actual): + raise ValueError("profile inventory mismatch") + assert_profile_safe(root) + + +def main() -> None: + parser = argparse.ArgumentParser() + parser.add_argument("command", choices=("assemble", "verify")) + parser.add_argument("--sysroot", type=Path) + parser.add_argument("--wheel", type=Path) + parser.add_argument("--root", type=Path, required=True) + parser.add_argument("--source-revision", default="unknown") + args = parser.parse_args() + if args.command == "assemble": + if not args.sysroot or not args.wheel: + raise SystemExit("assemble requires --sysroot and --wheel") + assemble(args.sysroot, args.wheel, args.root, args.source_revision) + else: + verify(args.root) + + +if __name__ == "__main__": + main() diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/geisa/files/geisa b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/geisa/files/geisa new file mode 100644 index 0000000..61e66a7 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/geisa/files/geisa @@ -0,0 +1,4 @@ +# GEISA image runtime defaults. Site and deployment identity are commissioned +# after first boot rather than embedded in the image. +GEISA_RUNTIME_USER=geisa +GEISA_RUNTIME_GROUP=geisa diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/geisa/geisa-nxp-ethosu-tflite-profile.bb b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/geisa/geisa-nxp-ethosu-tflite-profile.bb new file mode 100644 index 0000000..9bd83af --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/geisa/geisa-nxp-ethosu-tflite-profile.bb @@ -0,0 +1,52 @@ +# SPDX-License-Identifier: Apache-2.0 +# +SUMMARY = "Reproducible GEISA NXP Ethos-U TensorFlow Lite profile root" +DESCRIPTION = "Constructs the managed Ethos-U/TFLite profile from declared Yocto dependencies and a pinned PyAV wheel." + +# The generated profile combines NXP BSP runtime outputs with a third-party +# binary wheel. Its component licenses are recorded by the same-build SPDX and +# package manifests; binary redistribution requires their separate review. +LICENSE = "CLOSED" + +PYAV_WHEEL = "av-18.0.0-cp311-abi3-manylinux_2_28_aarch64.whl" +PYAV_URL = "https://files.pythonhosted.org/packages/84/74/6732f17b96dc23fd23b876b2805435855abdc8a3b397142be4e581165de8/${PYAV_WHEEL}" +PYAV_SHA256 = "4d683b7747a0ba9222b8a5f81e41db5f796e7f64473454ec4fe2548e083c2fa0" + +SRC_URI = " \ + file://assemble-nxp-ethosu-tflite-profile.py \ + ${PYAV_URL};name=pyav;downloadfilename=${PYAV_WHEEL};unpack=0 \ +" +SRC_URI[pyav.sha256sum] = "${PYAV_SHA256}" + +S = "${UNPACKDIR}" +include ${TOPDIR}/conf/geisa-source-state.conf +PACKAGE_ARCH = "${MACHINE_ARCH}" + +DEPENDS = " \ + ethos-u-driver-stack \ + python3-numpy \ + tensorflow-lite \ + tensorflow-lite-ethosu-delegate \ +" +RDEPENDS:${PN} += "geisa-runtime-groups" + +do_install() { + output="${D}/platform/profiles/nxp-ethosu-tflite" + rm -rf "$output" + python3 "${UNPACKDIR}/assemble-nxp-ethosu-tflite-profile.py" assemble \ + --sysroot "${RECIPE_SYSROOT}" \ + --wheel "${DL_DIR}/${PYAV_WHEEL}" \ + --root "$output" \ + --source-revision "${GEISA_SOURCE_REVISION}" + python3 "${UNPACKDIR}/assemble-nxp-ethosu-tflite-profile.py" verify --root "$output" + chown -R 0:0 "$output" + chmod -R go-w "$output" +} + +FILES:${PN} = "/platform/profiles/nxp-ethosu-tflite" +# These libraries are deliberately private to the read-only profile; managed +# applications load them through the profile's explicit library path. +PRIVATE_LIBS:${PN} = "libethosu.so.1.0.0 libethosu_delegate.so libtensorflow-lite.so.${GEISA_TFLITE_RUNTIME_VERSION}" +INSANE_SKIP:${PN} += "already-stripped dev-so file-rdeps ldflags" +SKIP_FILEDEPS:${PN} = "1" +do_install[vardeps] += "PYAV_SHA256 PYAV_URL GEISA_SOURCE_REVISION" diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/geisa/geisa-runtime-defaults.bb b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/geisa/geisa-runtime-defaults.bb new file mode 100644 index 0000000..c014e20 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/geisa/geisa-runtime-defaults.bb @@ -0,0 +1,19 @@ +# SPDX-License-Identifier: Apache-2.0 +# +SUMMARY = "GEISA runtime defaults" +DESCRIPTION = "Installs shared GEISA runtime defaults for clean FRDM-i.MX9 images." +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10" + +SRC_URI = "file://geisa" + +S = "${UNPACKDIR}" + +inherit allarch + +do_install() { + install -d ${D}${sysconfdir}/default + install -m 0644 ${UNPACKDIR}/geisa ${D}${sysconfdir}/default/geisa +} + +FILES:${PN} = "${sysconfdir}/default/geisa" diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/packagegroups/packagegroup-geisa-dev-tools.bb b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/packagegroups/packagegroup-geisa-dev-tools.bb new file mode 100644 index 0000000..11c88c9 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/packagegroups/packagegroup-geisa-dev-tools.bb @@ -0,0 +1,68 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2026 PragSol Consulting, LLC +# + +SUMMARY = "GEISA developer and bring-up tools" +DESCRIPTION = "Convenience tools for GEISA platform development, inspection, and board bring-up." +LICENSE = "Apache-2.0" + +inherit packagegroup + +RDEPENDS:${PN} = " \ + curl \ + dtc \ + ethtool \ + file \ + bpftool \ + can-utils \ + xz \ + which \ + tree \ + tar \ + sed \ + less \ + gzip \ + grep \ + gawk \ + findutils \ + diffutils \ + bzip2 \ + bash \ + bluez5 \ + htop \ + i2c-tools \ + iperf3 \ + iproute2 \ + iproute2-ss \ + iproute2-tc \ + iputils \ + ldd \ + iw \ + libgpiod-tools \ + libxml2-utils \ + jq \ + lrzsz \ + lsof \ + nftables \ + openssh-misc \ + perf \ + rfkill \ + gdb \ + gdbserver \ + mmc-utils \ + procps \ + rsync \ + strace \ + tcpdump \ + xmlstarlet \ + wireless-regdb-static \ + netcat \ + nano \ + geisa-system-state \ + psmisc \ + socat \ + vim \ + usbutils \ + util-linux \ +" diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/packagegroups/packagegroup-geisa-imx93-ethosu-dev.bb b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/packagegroups/packagegroup-geisa-imx93-ethosu-dev.bb new file mode 100644 index 0000000..7ff9919 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/packagegroups/packagegroup-geisa-imx93-ethosu-dev.bb @@ -0,0 +1,22 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2026 PragSol Consulting, LLC +# + +SUMMARY = "GEISA i.MX93 Ethos-U development dependencies" +DESCRIPTION = "Target runtime and validation dependencies for FRDM-i.MX93 Ethos-U." +LICENSE = "Apache-2.0" + +inherit packagegroup + +# Keep this packagegroup limited to package names that are safe in allarch +# packagegroups. Dynamically renamed shlib packages, such as tensorflow-lite, +# are installed directly by geisa-dev-image instead. +RDEPENDS:${PN} = " \ + ethos-u-driver-stack \ + ethos-u-firmware \ + ethos-u-vela \ + geisa-ethosu-device-permissions \ + geisa-ethosu-smoke-test \ + tensorflow-lite-ethosu-delegate \ +" diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/packagegroups/packagegroup-geisa-imx95-neutron-dev.bb b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/packagegroups/packagegroup-geisa-imx95-neutron-dev.bb new file mode 100644 index 0000000..cada045 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/packagegroups/packagegroup-geisa-imx95-neutron-dev.bb @@ -0,0 +1,14 @@ +# SPDX-License-Identifier: Apache-2.0 + +SUMMARY = "GEISA i.MX95 Neutron development dependencies" +DESCRIPTION = "Minimal target runtime dependencies for FRDM-i.MX95 Neutron." +LICENSE = "Apache-2.0" + +inherit packagegroup + +RDEPENDS:${PN} = " \ + neutron \ + tensorflow-lite-neutron-delegate \ + geisa-neutron-device-permissions \ + geisa-neutron-smoke-test \ +" diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/packagegroups/packagegroup-geisa-platform-builder-deps.bb b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/packagegroups/packagegroup-geisa-platform-builder-deps.bb new file mode 100644 index 0000000..7bc3267 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/packagegroups/packagegroup-geisa-platform-builder-deps.bb @@ -0,0 +1,37 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2026 PragSol Consulting, LLC +# + +SUMMARY = "GEISA target-local builder dependencies" +DESCRIPTION = "Optional on-target build and packaging tools for GEISA platform work." +LICENSE = "Apache-2.0" + +inherit packagegroup + +# Keep this packagegroup limited to stable tool/packagegroup names. Libraries +# that are dynamically renamed by shlib packaging are installed directly by +# geisa-dev-image while the dev image remains broad. +RDEPENDS:${PN} = " \ + iproute2-ip \ + ca-certificates \ + cmake \ + dosfstools \ + e2fsprogs-mke2fs \ + git \ + mosquitto-dev \ + make \ + mbedtls \ + nanopb-generator \ + nodejs-npm \ + ninja \ + openssl \ + packagegroup-core-buildessential \ + pkgconfig \ + python3 \ + python3-jsonschema \ + python3-pip \ + python3-protobuf \ + python3-pyyaml \ + squashfs-tools \ +" diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/systemd/systemd/10-geisa-end0.link b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/systemd/systemd/10-geisa-end0.link new file mode 100644 index 0000000..4e1e4a0 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/systemd/systemd/10-geisa-end0.link @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2026 PragSol Consulting, LLC +# +# Keep the primary Ethernet identity stable for DHCP reservations +# without baking a globally duplicated MAC address into the publishable image. + +[Match] +OriginalName=end0 + +[Link] +Name=end0 +MACAddressPolicy=persistent diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/systemd/systemd_%.bbappend b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/systemd/systemd_%.bbappend new file mode 100644 index 0000000..f8900ce --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/systemd/systemd_%.bbappend @@ -0,0 +1,22 @@ +# SPDX-License-Identifier: Apache-2.0 +# +FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" + +PACKAGECONFIG:remove:geisa-container = "sysvinit" + +SRC_URI:append = " \ + file://10-geisa-end0.link \ +" + +do_install:append() { + if [ -n "${WATCHDOG_TIMEOUT}" ]; then + sed -i -e 's/#RuntimeWatchdogSec=off/RuntimeWatchdogSec=${WATCHDOG_TIMEOUT}/' \ + ${D}/${sysconfdir}/systemd/system.conf + fi + + install -d ${D}/${sysconfdir}/systemd/network + install -m 0644 ${UNPACKDIR}/10-geisa-end0.link \ + ${D}/${sysconfdir}/systemd/network/10-geisa-end0.link +} + +FILES:${PN}:append = " ${sysconfdir}/systemd/network/10-geisa-end0.link" diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/udev/geisa-ethosu-device-permissions.bb b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/udev/geisa-ethosu-device-permissions.bb new file mode 100644 index 0000000..408583d --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/udev/geisa-ethosu-device-permissions.bb @@ -0,0 +1,33 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2026 PragSol Consulting, LLC +# + +SUMMARY = "GEISA Ethos-U device permissions" +DESCRIPTION = "Installs the GEISA Ethos-U runtime group and udev rule." +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10" + +SRC_URI = "file://99-geisa-ethosu.rules" + +S = "${UNPACKDIR}" + +inherit allarch useradd + +USERADD_PACKAGES = "${PN}" +GROUPADD_PARAM:${PN} = "--system ethosu" +GROUPMEMS_PARAM:${PN} = "--group ethosu --add geisa" + +do_install() { + install -d ${D}${nonarch_base_libdir}/udev/rules.d + install -m 0644 ${UNPACKDIR}/99-geisa-ethosu.rules \ + ${D}${nonarch_base_libdir}/udev/rules.d/99-geisa-ethosu.rules +} + +FILES:${PN} = " \ + ${nonarch_base_libdir}/udev/rules.d/99-geisa-ethosu.rules \ +" + +RDEPENDS:${PN} += "udev geisa-runtime-groups" + +DEPENDS += "geisa-runtime-groups" diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/udev/geisa-ethosu-device-permissions/99-geisa-ethosu.rules b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/udev/geisa-ethosu-device-permissions/99-geisa-ethosu.rules new file mode 100644 index 0000000..9a42933 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/udev/geisa-ethosu-device-permissions/99-geisa-ethosu.rules @@ -0,0 +1 @@ +KERNEL=="ethosu*", GROUP="ethosu", MODE="0660" diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/udev/geisa-neutron-device-permissions.bb b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/udev/geisa-neutron-device-permissions.bb new file mode 100644 index 0000000..43a6579 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/udev/geisa-neutron-device-permissions.bb @@ -0,0 +1,25 @@ +# SPDX-License-Identifier: Apache-2.0 + +SUMMARY = "GEISA Neutron device permissions" +DESCRIPTION = "Installs the GEISA Neutron runtime group and udev rule." +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10" + +SRC_URI = "file://99-geisa-neutron.rules" +S = "${UNPACKDIR}" + +inherit allarch useradd + +USERADD_PACKAGES = "${PN}" +GROUPADD_PARAM:${PN} = "--system neutron" +GROUPMEMS_PARAM:${PN} = "--group neutron --add geisa" + +do_install() { + install -d ${D}${nonarch_base_libdir}/udev/rules.d + install -m 0644 ${UNPACKDIR}/99-geisa-neutron.rules \ + ${D}${nonarch_base_libdir}/udev/rules.d/99-geisa-neutron.rules +} + +FILES:${PN} = "${nonarch_base_libdir}/udev/rules.d/99-geisa-neutron.rules" +RDEPENDS:${PN} += "udev geisa-runtime-groups" +DEPENDS += "geisa-runtime-groups" diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/udev/geisa-neutron-device-permissions/99-geisa-neutron.rules b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/udev/geisa-neutron-device-permissions/99-geisa-neutron.rules new file mode 100644 index 0000000..e9a6d6f --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/udev/geisa-neutron-device-permissions/99-geisa-neutron.rules @@ -0,0 +1 @@ +KERNEL=="neutron*", GROUP="neutron", MODE="0660" diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/users/geisa-runtime-groups.bb b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/users/geisa-runtime-groups.bb new file mode 100644 index 0000000..0f29488 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-core/users/geisa-runtime-groups.bb @@ -0,0 +1,28 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2026 PragSol Consulting, LLC +# + +SUMMARY = "GEISA runtime identity" +DESCRIPTION = "Creates the GEISA runtime system user and group for image services." +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10" + +inherit useradd + +USERADD_PACKAGES = "${PN}" +GROUPADD_PARAM:${PN} = "--system geisa" +USERADD_PARAM:${PN} = "--system --no-create-home --home-dir /var/lib/geisa --shell /sbin/nologin --gid geisa --password '*' geisa" + +do_install() { + install -d -m 0755 ${D}${sysconfdir}/geisa + install -d -m 0755 ${D}${localstatedir}/lib/geisa + chown 0:0 ${D}${localstatedir}/lib/geisa +} + +FILES:${PN} = " \ + ${sysconfdir}/geisa \ + ${localstatedir}/lib/geisa \ +" + +ALLOW_EMPTY:${PN} = "1" diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-devtools/nanopb/nanopb-runtime_%.bbappend b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-devtools/nanopb/nanopb-runtime_%.bbappend new file mode 100644 index 0000000..89cbb62 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-devtools/nanopb/nanopb-runtime_%.bbappend @@ -0,0 +1,25 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2026 PragSol Consulting, LLC +# Website: https://www.pragsolconsulting.com/ +# +# Keep the development source interface aligned with the nanopb runtime +# compiled by the base recipe. This does not replace its normal debug-source +# package or create a second source fetch. + +PACKAGES += "${PN}-source" +FILES:${PN}-source = "${prefix}/src/nanopb" + +do_install:append() { + install -d ${D}${prefix}/src/nanopb + for source in \ + pb.h \ + pb_common.c \ + pb_common.h \ + pb_decode.c \ + pb_decode.h \ + pb_encode.c \ + pb_encode.h; do + install -m 0644 ${S}/$source ${D}${prefix}/src/nanopb/$source + done +} diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-devtools/protobuf/protobuf_%.bbappend b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-devtools/protobuf/protobuf_%.bbappend new file mode 100644 index 0000000..5350a32 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-devtools/protobuf/protobuf_%.bbappend @@ -0,0 +1,3 @@ +# Build protoc for GEISA reference/development images. The compiler package is +# installed only by geisa-dev-image; application images use the runtime only. +PACKAGECONFIG:append = " compiler" diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-devtools/pseudo/files/older-glibc-symbols.patch b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-devtools/pseudo/files/older-glibc-symbols.patch new file mode 100644 index 0000000..89c97ef --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-devtools/pseudo/files/older-glibc-symbols.patch @@ -0,0 +1,66 @@ +If we link against a newer glibc 2.34 and then try and our LD_PRELOAD is run against a +binary on a host with an older libc, we see symbol errors since in glibc 2.34, pthread +and dl are merged into libc itself. + +We need to use the older form of linking so use glibc binaries from an older release +to force this. We only use minimal symbols from these anyway. + +pthread_atfork is problematic, particularly on arm so use the internal glibc routine +it maps too. This was always present in the main libc from 2.3.2 onwards. + +Yes this is horrible. Better solutions welcome. + +There is more info in the bug: [YOCTO #14521] + +Upstream-Status: Inappropriate [this patch is native and nativesdk] +Signed-off-by: Richard Purdie + +Tweak library search order, make prebuilt lib ahead of recipe lib +Signed-off-by: Hongxu Jia +--- + Makefile.in | 2 +- + pseudo_wrappers.c | 5 ++++- + 2 files changed, 5 insertions(+), 2 deletions(-) + +diff --git a/Makefile.in b/Makefile.in +--- a/Makefile.in ++++ b/Makefile.in +@@ -125,4 +125,4 @@ +-$(LIBPSEUDO): $(WRAPOBJS) pseudo_client.o pseudo_client_scanf.o pseudo_ipc.o $(SHOBJS) | $(LIB) +- $(CC) $(CFLAGS) $(CFLAGS_PSEUDO) -shared -o $(LIBPSEUDO) \ +- pseudo_client.o pseudo_client_scanf.o pseudo_ipc.o \ +- $(WRAPOBJS) $(SHOBJS) $(LDFLAGS) $(CLIENT_LDFLAGS) ++$(LIBPSEUDO): $(WRAPOBJS) pseudo_client.o pseudo_client_scanf.o pseudo_ipc.o $(SHOBJS) | $(LIB) ++ $(CC) $(CFLAGS) -Lprebuilt/$(shell uname -m)-linux/lib/ $(CFLAGS_PSEUDO) -shared -o $(LIBPSEUDO) \ ++ pseudo_client.o pseudo_client_scanf.o pseudo_ipc.o \ ++ $(WRAPOBJS) $(SHOBJS) $(LDFLAGS) $(CLIENT_LDFLAGS) + +diff --git a/pseudo_wrappers.c b/pseudo_wrappers.c +--- a/pseudo_wrappers.c ++++ b/pseudo_wrappers.c +@@ -100,10 +100,13 @@ +- pseudo_mutex_holder = 0; +-} +- +-static void +-_libpseudo_init(void) { +- if (!_libpseudo_initted) +- pthread_atfork(NULL, NULL, libpseudo_atfork_child); +- +- pseudo_getlock(); +- pseudo_antimagic(); ++ pseudo_mutex_holder = 0; ++} ++ ++extern void *__dso_handle; ++extern int __register_atfork (void (*) (void), void (*) (void), void (*) (void), void *); ++ ++static void ++_libpseudo_init(void) { ++ if (!_libpseudo_initted) ++ __register_atfork (NULL, NULL, libpseudo_atfork_child, &__dso_handle == NULL ? NULL : __dso_handle); ++ ++ pseudo_getlock(); ++ pseudo_antimagic(); +-- +2.27.0 diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-devtools/pseudo/pseudo_git.bbappend b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-devtools/pseudo/pseudo_git.bbappend new file mode 100644 index 0000000..daa1422 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-devtools/pseudo/pseudo_git.bbappend @@ -0,0 +1,15 @@ +# The pinned pseudo revision relies on host-facing patches that are incompatible +# with the current build host. Use the validated pseudo revision, +# provide its matching older-glibc context, and make the native sqlite3 +# dependency explicit for fakeroot setscene tasks. +FILESEXTRAPATHS:prepend := "${THISDIR}/files:" +SRC_URI:remove = " \ + file://0001-configure-Prune-PIE-flags.patch \ + file://glibc238.patch \ +" +SRCREV = "9ab513512d8b5180a430ae4fa738cb531154cdef" +PV = "1.9.3+git" + +PSEUDO_SETSCENE_DEPS = "" +PSEUDO_SETSCENE_DEPS:class-native = "sqlite3-native:do_populate_sysroot" +do_populate_sysroot_setscene[depends] += "${PSEUDO_SETSCENE_DEPS}" diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-image/images/geisa-application-base.bb b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-image/images/geisa-application-base.bb new file mode 100644 index 0000000..da1bcfe --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-image/images/geisa-application-base.bb @@ -0,0 +1,67 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2025 Southern California Edison +# + +DESCRIPTION = "A base image for GEISA application" +LICENSE = "Apache-2.0" +require recipes-core/images/core-image-minimal.bb + +IMAGE_FSTYPES = "squashfs tar.gz" + +IMAGE_INSTALL:append = " \ + coreutils \ + libasyncns \ + libatomic \ + libmosquitto1 \ + protobuf \ + python3 \ + tensorflow-lite \ + ${GEISA_ACCELERATOR_RUNTIME} \ +" + +ROOTFS_POSTPROCESS_COMMAND += "geisa_assert_lee_base_libraries;" +geisa_assert_lee_base_libraries() { + for library in \ + libasyncns.so.* \ + libatomic.so.* \ + libcrypto.so.* \ + libutil.so.* \ + libz.so.* \ + libmosquitto.so.* \ + libprotobuf.so.*; do + find "${IMAGE_ROOTFS}${libdir}" -maxdepth 1 \ + \( -type f -o -type l \) -name "$library" -print -quit | grep -q . || \ + bbfatal "GEISA LEE base library is missing: $library" + done + + for library in \ + libc.so.* \ + libgcc_s.so.* \ + libstdc++.so.* \ + libcrypt.so.* \ + libdl.so.* \ + libm.so.* \ + libnsl.so.* \ + libpthread.so.* \ + libresolv.so.* \ + librt.so.* \ + libcap.so.*; do + if ! find "${IMAGE_ROOTFS}${libdir}" -maxdepth 1 \ + \( -type f -o -type l \) -name "$library" -print -quit | grep -q .; then + bbnote "GEISA LEE toolchain runtime library is not independently packaged: $library" + fi + done +} + +ROOTFS_POSTPROCESS_COMMAND += "geisa_application_base_eth0_dhcp;" +geisa_application_base_eth0_dhcp() { + install -d ${IMAGE_ROOTFS}${sysconfdir}/systemd/network + cat > ${IMAGE_ROOTFS}${sysconfdir}/systemd/network/10-eth0.network <<'EOF' +[Match] +Name=eth0 + +[Network] +DHCP=ipv4 +EOF +} diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-image/images/geisa-common.inc b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-image/images/geisa-common.inc new file mode 100644 index 0000000..7b60e68 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-image/images/geisa-common.inc @@ -0,0 +1,134 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2025 Southern California Edison +# + +DESCRIPTION = "A common base for GEISA images" +LICENSE = "Apache-2.0" +require recipes-core/images/core-image-minimal.bb +include ${TOPDIR}/conf/geisa-source-state.conf + +# zst compression has the fastest flashing time without a hardware accelerator +IMAGE_FSTYPES += "tar.gz wic.zst wic.bmap" + +GEISA_ROOTFS_FIXED_SIZE ?= "1024" +GEISA_PLATFORM_FIXED_SIZE ?= "256" + +IMAGE_FEATURES:append = " ssh-server-openssh allow-root-login" + +# Keep common images limited to platform substrate. Mock/reference +# implementations belong in packagegroup-geisa-mock-reference or a +# conformance/demo image. +IMAGE_INSTALL:append = " \ + geisa-runtime-defaults \ + geisa-runtime-groups \ + geisa-image-documentation \ + glibc-utils \ + kernel-modules \ + lxc \ + lxc-networking \ + mosquitto \ +" + +DEPLOY_DIR_GEISA_CONTAINER ?= "${TOPDIR}/tmp-geisa-container/deploy/images/${MACHINE}" + +addtask copy_application_base_image before do_image after do_rootfs +do_copy_application_base_image[mcdepends] += "mc::geisa-container:geisa-application-base:do_image_complete" +fakeroot do_copy_application_base_image() { + install -d ${IMAGE_ROOTFS}/platform/base + + install -m 0644 -o 0 -g 0 ${DEPLOY_DIR_GEISA_CONTAINER}/geisa-application-base-${MACHINE}.rootfs.squashfs ${IMAGE_ROOTFS}/platform/base/ + install -m 0644 -o 0 -g 0 ${DEPLOY_DIR_GEISA_CONTAINER}/geisa-application-base-${MACHINE}.rootfs.tar.gz ${IMAGE_ROOTFS}/platform/base/ + + # This image-owned marker is the first authority for GEISA validation. + # It intentionally describes only seeded, immutable image inputs. + install -d -m 0755 ${IMAGE_ROOTFS}${sysconfdir}/geisa + app_base_tar="${IMAGE_ROOTFS}/platform/base/geisa-application-base-${MACHINE}.rootfs.tar.gz" + app_base_squashfs="${IMAGE_ROOTFS}/platform/base/geisa-application-base-${MACHINE}.rootfs.squashfs" + profile_path="${GEISA_ACCELERATOR_PROFILE_PATH}" + profile_root="${IMAGE_ROOTFS}${profile_path}" + build_timestamp="$(date -u +%Y-%m-%dT%H:%M:%SZ)" + app_base_tar_sha256="$(sha256sum "$app_base_tar" | awk '{print $1}')" + app_base_squashfs_sha256="$(sha256sum "$app_base_squashfs" | awk '{print $1}')" + profile_json="[]" + if [ -d "$profile_root" ] && [ -n "$profile_path" ]; then + profile_tree_sha256="$(find "$profile_root" -type f -print | LC_ALL=C sort | xargs sha256sum | sha256sum | awk '{print $1}')" + profile_json="[{\"path\":\"$profile_path\",\"tree_sha256\":\"$profile_tree_sha256\"}]" + else + profile_tree_sha256="absent" + fi + cat >${IMAGE_ROOTFS}${sysconfdir}/geisa/image-manifest.json <${IMAGE_ROOTFS}${sysconfdir}/geisa-image-release <> ${IMAGE_ROOTFS}/etc/issue +} + +# Clear REPRODUCIBLE_TIMESTAMP_ROOTFS variable to get the build time in /etc/version +# An NFS CI requires a timestamp to distinguish boots. +unset REPRODUCIBLE_TIMESTAMP_ROOTFS + +# geisa-dev-image is the board-owner validation image. It intentionally boots +# with a writable rootfs so platform and managed-application development flows +# can be tested directly. Production policy is outside this initial release. +IMAGE_FEATURES:remove = "read-only-rootfs" +GEISA_ROOTFS_FIXED_SIZE = "8192" +GEISA_PLATFORM_FIXED_SIZE = "6144" + +ROOTFS_POSTPROCESS_COMMAND += "geisa_dev_rootfs_rw;" +geisa_dev_rootfs_rw() { + sed -i -e 's#^/dev/root[[:space:]]\+/[[:space:]]\+auto[[:space:]]\+ro#/dev/root / auto rw#' \ + ${IMAGE_ROOTFS}${sysconfdir}/fstab +} + +# Runtime tools needed by the development image. coreutils provides +# /usr/bin/install and /usr/bin/timeout; nodejs supports local development. +GEISA_DEV_RUNTIME_INSTALL = " \ + coreutils \ + libasyncns \ + geisa-platform-mount \ + geisa-sudo-policy \ + mosquitto-clients \ + nodejs \ + systemd-analyze \ +" + +# The FRDM boards use the NXP IW612 SDIO/UART module. This exact package is +# supplied by the pinned NXP BSP and contains the kernel-requested Bluetooth +# firmware path. Keep the assertion close to the selected development image. +GEISA_DEV_IW612_FIRMWARE_INSTALL = "firmware-nxp-wifi-nxpiw612-sdio" + +ROOTFS_POSTPROCESS_COMMAND += "geisa_assert_iw612_bluetooth_firmware;" +geisa_assert_iw612_bluetooth_firmware() { + test -r ${IMAGE_ROOTFS}${nonarch_base_libdir}/firmware/nxp/uartspi_n61x_v1.bin.se || \ + bbfatal "IW612 Bluetooth firmware is missing from the development image" +} + +# The selected kernel loads regulatory.db as firmware. Its configuration +# determines whether the detached PKCS#7 signature is also mandatory. +ROOTFS_POSTPROCESS_COMMAND += "geisa_assert_regulatory_database;" +geisa_assert_regulatory_database() { + kernel_config="${STAGING_KERNEL_BUILDDIR}/.config" + + test -r "$kernel_config" || \ + bbfatal "selected kernel configuration is unavailable for regdb validation" + grep -qx "CONFIG_CFG80211=y" "$kernel_config" || return 0 + test -r ${IMAGE_ROOTFS}${nonarch_base_libdir}/firmware/regulatory.db || \ + bbfatal "kernel regulatory database is missing from the development image" + if grep -qx "CONFIG_CFG80211_REQUIRE_SIGNED_REGDB=y" "$kernel_config"; then + test -r ${IMAGE_ROOTFS}${nonarch_base_libdir}/firmware/regulatory.db.p7s || \ + bbfatal "signed kernel regulatory database is missing from the development image" + fi +} + +# Dynamically renamed shlib packages must not live inside allarch packagegroups. +# Keep them directly in the dev image while this image intentionally remains +# broad enough to build, package, and validate GEISA application flows locally. +GEISA_DEV_DYNAMIC_RENAMED_INSTALL = " \ + gnutls \ + libcoap \ + nanopb-runtime \ + nanopb-runtime-dev \ + nanopb-runtime-source \ + protobuf \ + protobuf-compiler \ + protobuf-dev \ + protobuf-c \ + tensorflow-lite \ + tensorflow-lite-host-tools \ + yajl \ + yajl-bin \ +" + +# Default GEISA developer image packagegroups. +# +# The dev image is intentionally broad while capability enablers and +# package-install behavior are still being refined. It includes target-local +# build/toolchain dependencies so the board can build, package, and validate +# GEISA application flows directly. +IMAGE_INSTALL += " \ + packagegroup-geisa-dev-tools \ + packagegroup-geisa-platform-builder-deps \ + ${GEISA_ACCELERATOR_PACKAGEGROUP} \ + ${@bb.utils.contains('GEISA_ACCELERATOR', 'ethosu', 'geisa-nxp-ethosu-tflite-profile', '', d)} \ + ${GEISA_DEV_IW612_FIRMWARE_INSTALL} \ + ${GEISA_DEV_RUNTIME_INSTALL} \ + ${GEISA_DEV_DYNAMIC_RENAMED_INSTALL} \ +" diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-kernel/linux/linux-imx/container.cfg b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-kernel/linux/linux-imx/container.cfg new file mode 100644 index 0000000..87c38aa --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-kernel/linux/linux-imx/container.cfg @@ -0,0 +1,6 @@ +# CONFIG_NETFILTER_XT_TARGET_CT is not set +# CONFIG_NETFILTER_XT_TARGET_NOTRACK is not set +# CONFIG_NETFILTER_XT_TARGET_TRACE is not set +CONFIG_IP_NF_RAW=m +CONFIG_IP6_NF_RAW=m +CONFIG_CFS_BANDWIDTH=y diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-kernel/linux/linux-imx/development.cfg b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-kernel/linux/linux-imx/development.cfg new file mode 100644 index 0000000..3792896 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-kernel/linux/linux-imx/development.cfg @@ -0,0 +1,31 @@ +# Checkpoint/restore and socket diagnostics are inert until a diagnostic tool +# uses them. Keep CRIU itself optional: the development image has the kernel +# baseline without adding a service or a large userspace dependency chain. +CONFIG_CHECKPOINT_RESTORE=y +CONFIG_UNIX_DIAG=m +CONFIG_PACKET_DIAG=m +CONFIG_NETLINK_DIAG=m +CONFIG_INET_UDP_DIAG=m + +# Common development adapters and virtual/serial CAN paths. They remain +# loadable modules rather than broad, always-resident protocol support. +CONFIG_USB_SERIAL_CH341=m +CONFIG_CAN_VCAN=m +CONFIG_CAN_SLCAN=m +CONFIG_CAN_GS_USB=m + +# Trace facilities and dynamic probes are disabled until explicitly used. They +# support field diagnosis alongside the existing perf and BPF kernel support. +CONFIG_KPROBES=y +CONFIG_KPROBE_EVENTS=y +CONFIG_UPROBE_EVENTS=y +CONFIG_FTRACE=y +CONFIG_FUNCTION_TRACER=y +CONFIG_FUNCTION_GRAPH_TRACER=y +CONFIG_DYNAMIC_FTRACE=y + +# cfg80211 is built in and requests regulatory.db before the root filesystem +# becomes available. Embed the signed database and detached signature from the +# checksum-verified wireless-regdb recipe in the kernel image. +CONFIG_EXTRA_FIRMWARE="regulatory.db regulatory.db.p7s" +CONFIG_EXTRA_FIRMWARE_DIR="firmware" diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-kernel/linux/linux-imx_6.18.bbappend b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-kernel/linux/linux-imx_6.18.bbappend new file mode 100644 index 0000000..0d55538 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-kernel/linux/linux-imx_6.18.bbappend @@ -0,0 +1,22 @@ +# SPDX-License-Identifier: Apache-2.0 + +FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" + +# Whinlatter linux-yocto rejects DELTA_KERNEL_DEFCONFIG. The supported +# kernel-yocto path is to supply ordinary .cfg fragments through SRC_URI. +SRC_URI:append = " \ + file://container.cfg \ + file://development.cfg \ +" + +DEPENDS:append = " wireless-regdb" +SYSROOT_DIRS:append = " ${nonarch_base_libdir}/firmware" + +do_configure:prepend() { + for firmware in regulatory.db regulatory.db.p7s; do + source="${RECIPE_SYSROOT}${nonarch_base_libdir}/firmware/${firmware}" + test -r "$source" || \ + bbfatal "wireless-regdb did not stage required firmware: $source" + install -D -m 0644 "$source" "${S}/firmware/${firmware}" + done +} diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-libraries/tensorflow-lite/tensorflow-lite-host-tools_2.19.0.bbappend b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-libraries/tensorflow-lite/tensorflow-lite-host-tools_2.19.0.bbappend new file mode 100644 index 0000000..19107c9 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-libraries/tensorflow-lite/tensorflow-lite-host-tools_2.19.0.bbappend @@ -0,0 +1,14 @@ +# SPDX-License-Identifier: Apache-2.0 + +# protobuf.cmake derives the native-tools module path from this TensorFlow +# Lite source root when the native_tools subdirectory is configured directly. +DEPENDS:append:class-target = " flatbuffers-native" +EXTRA_OECMAKE:append:class-target = " \ + -DFLATC_INSTALL_PREFIX=${B}/flatbuffers-flatc-install \ + -DTFLITE_SOURCE_DIR=${S}/tensorflow/lite \ + -DTFLITE_HOST_TOOLS_DIR=${STAGING_BINDIR_NATIVE} \ + -DTFLITE_NATIVE_TOOLS_BUILD_PROTOC=OFF \ +" +EXTRA_OECMAKE:append:class-native = " \ + -DTFLITE_NATIVE_TOOLS_BUILD_PROTOC=ON \ +" diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-libraries/tensorflow-lite/tensorflow-lite_2.19.0.bbappend b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-libraries/tensorflow-lite/tensorflow-lite_2.19.0.bbappend new file mode 100644 index 0000000..1f7f0e7 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-libraries/tensorflow-lite/tensorflow-lite_2.19.0.bbappend @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: Apache-2.0 + +# native_utils.cmake appends /bin to this value when locating protoc. The +# NXP recipe passes STAGING_BINDIR_NATIVE, which produces an invalid /bin/bin +# path for the 2.19 cross-compile. +EXTRA_OECMAKE:append = " -DTFLITE_HOST_TOOLS_DIR=${STAGING_DIR_NATIVE}/usr" diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-ml/tensorflow-lite/tensorflow-lite_%.bbappend b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-ml/tensorflow-lite/tensorflow-lite_%.bbappend new file mode 100644 index 0000000..6c27353 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-ml/tensorflow-lite/tensorflow-lite_%.bbappend @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: Apache-2.0 + +# pip writes this host-specific provenance file during the target package install. +do_install:append() { + rm -f ${D}/${PYTHON_SITEPACKAGES_DIR}/tflite_runtime-*.dist-info/direct_url.json +} diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-support/geisa-ethosu-smoke-test/files/README b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-support/geisa-ethosu-smoke-test/files/README new file mode 100644 index 0000000..40473ab --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-support/geisa-ethosu-smoke-test/files/README @@ -0,0 +1,60 @@ + + +# Ethos-U Profile and Smoke Test + +The `geisa-imx93` image selects the NXP Ethos-U runtime and the +`geisa-nxp-ethosu-tflite-profile` package. The profile is generated during the +build at: + + /platform/profiles/nxp-ethosu-tflite + +It contains the private TensorFlow Lite runtime, Ethos-U delegate and runtime +libraries, NumPy, and PyAV needed by the profile loader. The image also provides +the Ethos-U driver stack, firmware, Vela, device permissions, and the +`tensorflow-lite-ethosu-delegate` package. The device used by the runtime is +`/dev/ethosu0`. + +The profile is selected by the `geisa-imx93` system configuration. It is not a +checked-in archive. The build assembles it from Yocto runtime outputs and a +checksum-pinned PyAV wheel. + +## Smoke Test + +`geisa-ethosu-smoke-test` is a platform/enabler qualification command. It is +not a GEISA application, managed application, or performance benchmark. + +Run the image-level check with the system runtime: + + geisa-ethosu-smoke-test + +Run through the generated profile when qualifying the profile itself: + + geisa-ethosu-smoke-test --profile /platform/profiles/nxp-ethosu-tflite + +The helper checks the supplied TensorFlow Lite model checksum, compiles a +temporary model with Vela for `ethos-u65-256`, loads the Ethos-U delegate, and +runs the Grace Hopper image example through `/dev/ethosu0`. A successful run +requires the expected inference result and a delegate message showing at least +one delegated graph node. This confirms delegated inference rather than device +presence, firmware startup, or CPU-only execution. + +The command prints the model and compiled-model checksums, delegation evidence, +the inference result, and an explicit final status: + + PASS: Ethos-U accelerated inference verified + +Generated files are removed on exit. The command does not require network +access or starting of an LXC container. + +Failures end with `FAIL:` and include the captured diagnostic output. The +command is intended as a simple check the NPU is operational and usable and +not intended as any form of performance benchmark. + +The generated profile combines NXP runtime components with the PyAV wheel and +bundled multimedia libraries. See [the image licensing notes](https://github.com/geisa/community/tree/main/platforms/nxp-imx9-yocto/docs/licensing.md) +for the package and redistribution review required before distributing an image +that includes it. diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-support/geisa-ethosu-smoke-test/files/geisa-ethosu-smoke-test b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-support/geisa-ethosu-smoke-test/files/geisa-ethosu-smoke-test new file mode 100755 index 0000000..5876d4a --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-support/geisa-ethosu-smoke-test/files/geisa-ethosu-smoke-test @@ -0,0 +1,208 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: Apache-2.0 +# Copyright (C) 2026 PragSol Consulting, LLC +# Website: https://www.pragsolconsulting.com/ +# +# A small host-side diagnostic for the image-provided Ethos-U software stack. +# It deliberately creates all generated output in a temporary directory. + +set -euo pipefail + +fail() { + if [ -s "${failure_log:-}" ]; then + echo "--- Ethos-U inference output ---" >&2 + cat "$failure_log" >&2 + echo "--- end Ethos-U inference output ---" >&2 + fi + echo "FAIL: Ethos-U $*" >&2 + exit 1 +} + +verbose=false +profile= +while [ "$#" -gt 0 ]; do + case "$1" in + --verbose) + verbose=true + shift + ;; + --profile) + [ "$#" -ge 2 ] || { + fail "--profile requires a path" + } + profile="$2" + shift 2 + ;; + *) + fail "usage: $(basename "$0") [--verbose] [--profile PATH]" + ;; + esac +done + +tflite_examples="/usr/bin/tensorflow-lite-@GEISA_TFLITE_RUNTIME_VERSION@/examples" +model="${GEISA_ETHOSU_SMOKE_MODEL:-${tflite_examples}/mobilenet_v1_1.0_224_quant.tflite}" +input="${GEISA_ETHOSU_SMOKE_INPUT:-${tflite_examples}/grace_hopper.bmp}" +delegate="${GEISA_ETHOSU_SMOKE_DELEGATE:-/usr/lib/libethosu_delegate.so}" +device="${GEISA_ETHOSU_SMOKE_DEVICE:-/dev/ethosu0}" +vela="${GEISA_ETHOSU_SMOKE_VELA:-/usr/bin/vela}" +python="${GEISA_ETHOSU_SMOKE_PYTHON:-/usr/bin/python3}" +json_python="${GEISA_ETHOSU_SMOKE_JSON_PYTHON:-/usr/bin/python3}" +expected_argmax="${GEISA_ETHOSU_SMOKE_EXPECTED_ARGMAX:-653}" +expected_model_sha256="${GEISA_ETHOSU_SMOKE_EXPECTED_MODEL_SHA256:-ecc3a67c47c5a609ec35f6a58a7d97532834e43df4cb7d3f1204a8164b7d20dd}" +pythonpath= +profile_library_path= + +for path in "$model" "$input" "$device" "$vela" "$python" "$json_python"; do + [ -r "$path" ] || fail "prerequisite is not readable: $path" +done +[ -w "$device" ] || fail "device is not accessible: $device" + +model_sha256="$(sha256sum "$model" | awk '{print $1}')" +[ "$model_sha256" = "$expected_model_sha256" ] || { + fail "unexpected model SHA-256: $model_sha256" +} + +if [ -n "$profile" ]; then + profile_json="${profile}/profile.json" + [ -r "$profile_json" ] || fail "profile metadata is not readable: $profile_json" + mapfile -t profile_loader < <("$json_python" - "$profile_json" <<'PY' +import json +import pathlib +import sys + +profile_json = pathlib.Path(sys.argv[1]).resolve() +profile_root = profile_json.parent +document = json.loads(profile_json.read_text(encoding="utf-8")) +loader = document.get("loader", {}) +pythonpath = loader.get("pythonpath") +library_path = loader.get("library-path", []) +if not pythonpath or not isinstance(library_path, list) or not library_path: + raise SystemExit("profile loader metadata is incomplete") +print((profile_root / pythonpath).resolve()) +print(":".join(str((profile_root / item).resolve()) for item in library_path)) +PY +) + [ "${#profile_loader[@]}" -eq 2 ] || { + fail "unable to load profile runtime metadata from: $profile_json" + } + pythonpath="${profile_loader[0]}" + profile_library_path="${profile_loader[1]}" + delegate="${profile}/lib/libethosu_delegate.so" + for path in "$profile" "$profile_json" "$pythonpath" "$delegate"; do + [ -r "$path" ] || { + fail "profile prerequisite is not readable: $path" + } + done +fi + +[ -r "$delegate" ] || fail "delegate is not readable: $delegate" + +workdir="$(mktemp -d "${TMPDIR:-/tmp}/geisa-ethosu-smoke.XXXXXX")" +trap 'rm -rf "$workdir"' EXIT +compiled_model="${workdir}/$(basename "${model%.tflite}")_vela.tflite" +start_seconds="$(date +%s)" +failure_log= + +echo "GEISA Ethos-U smoke test" + +if [ -n "$profile" ]; then + echo "Mode: profile" + echo "Profile: $profile" + echo "Profile pythonpath: $pythonpath" + echo "Profile library path: $profile_library_path" +else + echo "Mode: host" +fi +echo "Model: $model ($model_sha256)" +echo "Input: $input" +echo "Delegate: $delegate" +echo "Device: $device" + +vela_log="${workdir}/vela.log" +failure_log="$vela_log" +"$vela" --accelerator-config ethos-u65-256 --output-dir "$workdir" "$model" >"$vela_log" 2>&1 || { + fail "Vela compilation failed" +} +[ -r "$compiled_model" ] || fail "Vela did not create the expected compiled model" +compiled_model_sha256="$(sha256sum "$compiled_model" | awk '{print $1}')" +echo "Compiled model: $compiled_model ($compiled_model_sha256)" +[ "$verbose" = true ] && cat "$vela_log" + +inference_log="${workdir}/inference.log" +failure_log="$inference_log" +if +"${python}" - "$compiled_model" "$input" "$delegate" "$expected_argmax" "$profile" "$pythonpath" "$profile_library_path" >"$inference_log" 2>&1 <<'PY' +import os +import pathlib +import sys +import time + +model, image_path, delegate_path, expected_argmax, profile_root, profile_pythonpath, profile_library_path = sys.argv[1:] + +if profile_root: + os.environ["PYTHONDONTWRITEBYTECODE"] = "1" + os.environ["PYTHONPATH"] = profile_pythonpath + os.environ["LD_LIBRARY_PATH"] = profile_library_path + sys.path.insert(0, profile_pythonpath) +import numpy as np +from PIL import Image +import tflite_runtime +from tflite_runtime.interpreter import Interpreter, load_delegate + +def first_loaded_path(needle): + for line in pathlib.Path("/proc/self/maps").read_text(encoding="utf-8").splitlines(): + if needle in line and "/" in line: + return line.rsplit(None, 1)[-1] + return "" + +if profile_root: + import av + print(f"Python: {sys.executable}") + print(f"tflite_runtime module: {pathlib.Path(tflite_runtime.__file__).resolve()}") + print(f"NumPy module: {pathlib.Path(np.__file__).resolve()}") + print(f"PyAV module: {pathlib.Path(av.__file__).resolve()}") + +resolved_delegate = pathlib.Path(delegate_path).resolve() +interpreter = Interpreter( + model_path=model, + experimental_delegates=[load_delegate(delegate_path)], +) +interpreter.allocate_tensors() +if profile_root: + print(f"Loaded delegate: {first_loaded_path('libethosu_delegate.so')}") + print(f"Loaded libethosu: {first_loaded_path('libethosu.so.1.0.0')}") + print( + "Loaded TFLite wrapper: " + f"{first_loaded_path('_pywrap_tensorflow_interpreter_wrapper.so')}" + ) + print(f"Resolved delegate path: {resolved_delegate}") +input_detail = interpreter.get_input_details()[0] +shape = input_detail["shape"] +image = Image.open(image_path).convert("RGB").resize((int(shape[2]), int(shape[1]))) +input_data = np.asarray(image, dtype=input_detail["dtype"])[None, ...] +interpreter.set_tensor(input_detail["index"], input_data) +started = time.monotonic() +interpreter.invoke() +elapsed_ms = int((time.monotonic() - started) * 1000) +output = interpreter.get_tensor(interpreter.get_output_details()[0]["index"]) +result = int(np.argmax(output)) +print(f"Result: argmax={result} expected={expected_argmax} inference_ms={elapsed_ms}") +if result != int(expected_argmax): + raise SystemExit("unexpected inference result") +PY +then + : +else + fail "inference execution failed" +fi + +cat "$inference_log" +if ! grep -Eq 'EthosuDelegate:.*[1-9][0-9]* nodes? delegated out of' "$inference_log"; then + fail "delegate reported no delegated graph nodes; refusing CPU fallback" +fi + +delegated="$(grep -E 'EthosuDelegate:.*[1-9][0-9]* nodes? delegated out of' "$inference_log" | head -1)" +elapsed_seconds=$(( $(date +%s) - start_seconds )) +echo "Delegation: $delegated" +echo "Ethos-U smoke test passed in ${elapsed_seconds}s" +echo "PASS: Ethos-U accelerated inference verified" diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-support/geisa-ethosu-smoke-test/geisa-ethosu-smoke-test_1.0.bb b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-support/geisa-ethosu-smoke-test/geisa-ethosu-smoke-test_1.0.bb new file mode 100644 index 0000000..37f6c68 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-support/geisa-ethosu-smoke-test/geisa-ethosu-smoke-test_1.0.bb @@ -0,0 +1,46 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2026 PragSol Consulting, LLC +# Website: https://www.pragsolconsulting.com/ +# + +SUMMARY = "Small on-device Ethos-U diagnostic" +DESCRIPTION = "Runs a single image through Vela, the TFLite Ethos-U delegate, and /dev/ethosu0." +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10" + +SRC_URI = " \ + file://geisa-ethosu-smoke-test \ + file://README \ +" + +S = "${WORKDIR}" + +inherit allarch + +RDEPENDS:${PN} = " \ + bash \ + coreutils \ + ethos-u-driver-stack \ + ethos-u-vela \ + python3-numpy \ + python3-pillow \ + tensorflow-lite \ + tensorflow-lite-ethosu-delegate \ +" + +do_install() { + install -d ${D}${bindir} + install -m 0755 ${S}/geisa-ethosu-smoke-test \ + ${D}${bindir}/geisa-ethosu-smoke-test + sed -i -e 's/@GEISA_TFLITE_RUNTIME_VERSION@/${GEISA_TFLITE_RUNTIME_VERSION}/g' \ + ${D}${bindir}/geisa-ethosu-smoke-test + install -d ${D}${datadir}/geisa/examples/ethosu-smoke + install -m 0644 ${S}/README \ + ${D}${datadir}/geisa/examples/ethosu-smoke/README +} + +FILES:${PN} = " \ + ${bindir}/geisa-ethosu-smoke-test \ + ${datadir}/geisa/examples/ethosu-smoke/README \ +" diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-support/geisa-ethosu-smoke-test/geisa-ethosu-smoke-test_1.0.bbappend b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-support/geisa-ethosu-smoke-test/geisa-ethosu-smoke-test_1.0.bbappend new file mode 100644 index 0000000..9a0c64f --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-support/geisa-ethosu-smoke-test/geisa-ethosu-smoke-test_1.0.bbappend @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: Apache-2.0 + +S = "${UNPACKDIR}" diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-support/geisa-ethosu-smoke-test/tests/test-geisa-ethosu-smoke-test.sh b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-support/geisa-ethosu-smoke-test/tests/test-geisa-ethosu-smoke-test.sh new file mode 100755 index 0000000..1286b96 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-support/geisa-ethosu-smoke-test/tests/test-geisa-ethosu-smoke-test.sh @@ -0,0 +1,87 @@ +#!/bin/sh +# SPDX-License-Identifier: Apache-2.0 +# Copyright (C) 2026 PragSol Consulting, LLC +# Website: https://www.pragsolconsulting.com/ +# + +set -eu + +script_dir=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) +script="$script_dir/files/geisa-ethosu-smoke-test" +workdir=$(mktemp -d "${TMPDIR:-/tmp}/geisa-ethosu-smoke-test.XXXXXX") +trap 'rm -rf "$workdir"' EXIT +mkdir -p "$workdir/bin" +profile="$workdir/profile" +mkdir -p "$profile/lib" "$profile/python" + +model="$workdir/model.tflite" +input="$workdir/input.bmp" +delegate="$workdir/delegate.so" +device="$workdir/ethosu0" +printf 'model fixture\n' > "$model" +printf 'input fixture\n' > "$input" +: > "$delegate" +: > "$device" +model_sha256=$(sha256sum "$model" | awk '{print $1}') + +cat > "$workdir/bin/vela" <<'EOF' +#!/bin/sh +output_dir= +while [ "$#" -gt 0 ]; do + case "$1" in + --output-dir) output_dir=$2; shift 2 ;; + *) model=$1; shift ;; + esac +done +cp "$model" "$output_dir/$(basename "${model%.tflite}")_vela.tflite" +EOF +chmod +x "$workdir/bin/vela" + +cat > "$workdir/bin/python3" <<'EOF' +#!/bin/sh +cat >/dev/null +echo 'EthosuDelegate: 1 nodes delegated out of 1 nodes' +echo 'Result: argmax=653 expected=653 inference_ms=1' +EOF +chmod +x "$workdir/bin/python3" + +cat > "$profile/profile.json" < "$profile/lib/libethosu_delegate.so" +mkdir -p "$profile/python/av.libs" + +GEISA_ETHOSU_SMOKE_MODEL="$model" \ +GEISA_ETHOSU_SMOKE_INPUT="$input" \ +GEISA_ETHOSU_SMOKE_DELEGATE="$delegate" \ +GEISA_ETHOSU_SMOKE_DEVICE="$device" \ +GEISA_ETHOSU_SMOKE_VELA="$workdir/bin/vela" \ +GEISA_ETHOSU_SMOKE_PYTHON="$workdir/bin/python3" \ +GEISA_ETHOSU_SMOKE_EXPECTED_MODEL_SHA256="$model_sha256" \ +"$script" > "$workdir/output" + +grep -F 'Delegation: EthosuDelegate: 1 nodes delegated out of 1 nodes' "$workdir/output" +grep -F 'Compiled model:' "$workdir/output" +grep -F 'GEISA Ethos-U smoke test' "$workdir/output" +grep -F 'PASS: Ethos-U accelerated inference verified' "$workdir/output" + +GEISA_ETHOSU_SMOKE_MODEL="$model" \ +GEISA_ETHOSU_SMOKE_INPUT="$input" \ +GEISA_ETHOSU_SMOKE_DEVICE="$device" \ +GEISA_ETHOSU_SMOKE_VELA="$workdir/bin/vela" \ +GEISA_ETHOSU_SMOKE_PYTHON="$workdir/bin/python3" \ +GEISA_ETHOSU_SMOKE_EXPECTED_MODEL_SHA256="$model_sha256" \ +"$script" --profile "$profile" > "$workdir/profile-output" + +grep -F 'Mode: profile' "$workdir/profile-output" +grep -F "Profile: $profile" "$workdir/profile-output" +grep -F "Profile pythonpath: $profile/python" "$workdir/profile-output" +grep -F "Profile library path: $profile/lib:$profile/python/av.libs" "$workdir/profile-output" +grep -F "Delegate: $profile/lib/libethosu_delegate.so" "$workdir/profile-output" +grep -F 'Compiled model:' "$workdir/profile-output" +grep -F 'PASS: Ethos-U accelerated inference verified' "$workdir/profile-output" diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-support/geisa-neutron-smoke-test/files/README b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-support/geisa-neutron-smoke-test/files/README new file mode 100644 index 0000000..138c113 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-support/geisa-neutron-smoke-test/files/README @@ -0,0 +1,60 @@ + + +# Neutron Smoke Test + +The `geisa-imx95` machine selects the NXP Neutron runtime for the FRDM-i.MX95 +image. The image provides the Neutron firmware and driver libraries, the +TensorFlow Lite 2.19 Neutron delegate, and the qualification device policy: + + /usr/lib/firmware/NeutronFirmware.elf + /usr/lib/libNeutronDriver.so + /usr/lib/libneutron_delegate.so + /dev/neutron0 + +The udev rule creates the `neutron` group and grants `geisa` access to the +device with mode `0660`. The delegate and driver manage the firmware lifecycle; +the smoke test does not write remoteproc controls or change device permissions. + +## Qualification Fixture + +The smoke-test package installs this converted MobileNet model: + + /usr/share/geisa/examples/neutron-smoke/mobilenet_v1_1.0_224_quant_neutron_imx95.tflite + +Its SHA-256 is: + + 89e1746ebeae7d54dd4e1017e2c8ef52b2b351dd6eb74791dfc50fa11f106198 + +The recipe verifies this digest during the image build. + +## Smoke Test + +Run: + + geisa-neutron-smoke-test + +The command runs TensorFlow Lite's `benchmark_model` with the external Neutron +delegate and operator profiling enabled. It requires readable runtime files, +writable access to `/dev/neutron0`, the expected fixture digest, a successful +benchmark, nonzero delegated nodes and partitions, and `NeutronDelegate` in the +regular-run profiling section. Delegate errors, unresolved `NeutronGraph`, +permission errors, CPU fallback, and zero delegation fail the test. Residual +host operators such as `SOFTMAX` and `QUANTIZE` are allowed. + +This proves that the fixture executed through the Neutron delegate during an +inference run. It is stronger than checking firmware startup, library loading, +or device-node presence alone. Successful output ends with: + + PASS: Neutron accelerated inference verified + +Failures end with `FAIL:` and include the captured diagnostic output. The +command is intended as a simple check the NPU is operational and usable and +not intended as any form of performance benchmark. + +The Neutron runtime is distributed under NXP's terms. Review [the image +licensing notes](https://github.com/geisa/community/tree/main/platforms/nxp-imx9-yocto/docs/licensing.md) +before distributing an image that includes it. diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-support/geisa-neutron-smoke-test/files/geisa-neutron-smoke-test b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-support/geisa-neutron-smoke-test/files/geisa-neutron-smoke-test new file mode 100755 index 0000000..4d6b2f0 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-support/geisa-neutron-smoke-test/files/geisa-neutron-smoke-test @@ -0,0 +1,96 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: Apache-2.0 +# Copyright (C) 2026 PragSol Consulting, LLC +# Website: https://www.pragsolconsulting.com/ + +set -euo pipefail + +model="${GEISA_NEUTRON_SMOKE_MODEL:-/usr/share/geisa/examples/neutron-smoke/mobilenet_v1_1.0_224_quant_neutron_imx95.tflite}" +delegate="${GEISA_NEUTRON_SMOKE_DELEGATE:-/usr/lib/libneutron_delegate.so}" +driver="${GEISA_NEUTRON_SMOKE_DRIVER:-/usr/lib/libNeutronDriver.so}" +firmware="${GEISA_NEUTRON_SMOKE_FIRMWARE:-/usr/lib/firmware/NeutronFirmware.elf}" +device="${GEISA_NEUTRON_SMOKE_DEVICE:-/dev/neutron0}" +tflite_examples="/usr/bin/tensorflow-lite-2.19.0/examples" +benchmark="${GEISA_NEUTRON_SMOKE_BENCHMARK:-${tflite_examples}/benchmark_model}" +expected_model_sha256="${GEISA_NEUTRON_SMOKE_EXPECTED_MODEL_SHA256:-89e1746ebeae7d54dd4e1017e2c8ef52b2b351dd6eb74791dfc50fa11f106198}" +workdir="$(mktemp -d "${TMPDIR:-/tmp}/geisa-neutron-smoke.XXXXXX")" +trap 'rm -rf "$workdir"' EXIT + +fail() { + if [ -s "${log:-}" ]; then + echo "--- benchmark output ---" >&2 + cat "$log" >&2 + echo "--- end benchmark output ---" >&2 + fi + echo "FAIL: Neutron $*" >&2 + exit 1 +} + +[ -r "$model" ] || fail "model is not readable: $model" +[ -r "$delegate" ] || fail "delegate is not readable: $delegate" +[ -r "$driver" ] || fail "driver is not readable: $driver" +[ -r "$firmware" ] || fail "firmware is not readable: $firmware" +[ -r "$benchmark" ] || fail "benchmark_model is not readable: $benchmark" +[ -e "$device" ] && [ -r "$device" ] && [ -w "$device" ] \ + || fail "Neutron device is not accessible: $device" + +model_sha256="$(sha256sum "$model" | awk '{print $1}')" +[ "$model_sha256" = "$expected_model_sha256" ] \ + || fail "unexpected model SHA-256: $model_sha256" +firmware_sha256="$(sha256sum "$firmware" | awk '{print $1}')" + +log="$workdir/benchmark.log" +"$benchmark" \ + --graph="$model" \ + --external_delegate_path="$delegate" \ + --warmup_runs=2 \ + --num_runs=5 \ + --min_secs=0 \ + --warmup_min_secs=0 \ + --enable_op_profiling=true \ + >"$log" 2>&1 || { + fail "benchmark_model returned a failure" + } + +delegation_line="$(grep -E 'NeutronDelegate delegate: [0-9]+ nodes delegated out of [0-9]+ nodes with [0-9]+ partitions\.?$' "$log" | head -n 1 || true)" +[ -n "$delegation_line" ] || fail "expected Neutron delegation evidence is missing" +read -r delegated_nodes total_nodes delegated_partitions <"$model" +: >"$delegate" +: >"$driver" +: >"$firmware" +: >"$device" +model_sha256=$(sha256sum "$model" | awk '{print $1}') + +cat >"$benchmark" <<'EOF' +#!/bin/sh +case " $* " in + *" --enable_op_profiling=true "*) ;; + *) echo 'missing profiling option' >&2; exit 2 ;; +esac +case " $* " in + *" --warmup_runs=2 "*) ;; + *) echo 'missing warmup_runs option' >&2; exit 2 ;; +esac +cat <<'LOG' +INFO: NeutronDelegate delegate: 1 nodes delegated out of 3 nodes with 1 partitions +NeutronDelegate delegate version: v1.0.0-test zerocp enabled +INFO: Created TensorFlow Lite XNNPACK delegate for CPU. +Operator-wise Profiling Info for Regular Benchmark Runs: +============================== Run Order ============================== +NeutronDelegate 1.100 ms +SOFTMAX 0.024 ms +QUANTIZE 0.005 ms +LOG +EOF +chmod +x "$benchmark" + +run() { + GEISA_NEUTRON_SMOKE_MODEL="$model" \ + GEISA_NEUTRON_SMOKE_DELEGATE="$delegate" \ + GEISA_NEUTRON_SMOKE_DRIVER="$driver" \ + GEISA_NEUTRON_SMOKE_FIRMWARE="$firmware" \ + GEISA_NEUTRON_SMOKE_DEVICE="$device" \ + GEISA_NEUTRON_SMOKE_BENCHMARK="$benchmark" \ + GEISA_NEUTRON_SMOKE_EXPECTED_MODEL_SHA256="$model_sha256" \ + "$script" +} + +run >"$workdir/pass" +grep -F 'GEISA Neutron smoke test' "$workdir/pass" +grep -F 'Delegation: 1/3 nodes, 1 partitions' "$workdir/pass" +grep -F 'PASS: Neutron accelerated inference verified' "$workdir/pass" +! grep -F 'benchmark output' "$workdir/pass" + +expect_fail() { + if "$@" >"$workdir/fail" 2>&1; then + echo "expected failure did not occur: $*" >&2 + exit 1 + fi +} + +expect_fail env GEISA_NEUTRON_SMOKE_MODEL="$model" \ + GEISA_NEUTRON_SMOKE_DELEGATE="$delegate" GEISA_NEUTRON_SMOKE_DRIVER="$driver" \ + GEISA_NEUTRON_SMOKE_FIRMWARE="$firmware" GEISA_NEUTRON_SMOKE_DEVICE="$device" \ + GEISA_NEUTRON_SMOKE_BENCHMARK="$benchmark" \ + GEISA_NEUTRON_SMOKE_EXPECTED_MODEL_SHA256=wrong "$script" +expect_fail env GEISA_NEUTRON_SMOKE_MODEL="$workdir/missing-model" \ + GEISA_NEUTRON_SMOKE_DELEGATE="$delegate" GEISA_NEUTRON_SMOKE_DRIVER="$driver" \ + GEISA_NEUTRON_SMOKE_FIRMWARE="$firmware" GEISA_NEUTRON_SMOKE_DEVICE="$device" \ + GEISA_NEUTRON_SMOKE_BENCHMARK="$benchmark" "$script" +rm "$delegate" +expect_fail run +touch "$delegate" +rm "$driver" +expect_fail run +touch "$driver" +rm "$firmware" +expect_fail run +touch "$firmware" +rm "$device" +expect_fail run +touch "$device" +cat >"$benchmark" <<'EOF' +#!/bin/sh +echo 'INFO: NeutronDelegate delegate: 0 nodes delegated out of 31 nodes with 0 partitions.' +EOF +chmod +x "$benchmark" +expect_fail run + +cat >"$benchmark" <<'EOF' +#!/bin/sh +echo 'INFO: NeutronDelegate delegate: 1 nodes delegated out of 3 nodes with 0 partitions.' +EOF +chmod +x "$benchmark" +expect_fail run + +cat >"$benchmark" <<'EOF' +#!/bin/sh +echo 'INFO: NeutronDelegate delegate: malformed summary' +EOF +chmod +x "$benchmark" +expect_fail run + +cat >"$benchmark" <<'EOF' +#!/bin/sh +echo 'INFO: NeutronDelegate delegate: 0 nodes delegated out of 31 nodes with 0 partitions.' +echo '============================== Run Order ==============================' +echo 'CONV_2D 4.0 ms' +EOF +chmod +x "$benchmark" +expect_fail run + +cat >"$benchmark" <<'EOF' +#!/bin/sh +echo 'NeutronDelegate delegate: 1 nodes delegated out of 3 nodes with 1 partitions' +echo 'Operator-wise Profiling Info for Regular Benchmark Runs:' +echo '============================== Run Order ==============================' +echo 'CONV_2D 4.0 ms' +EOF +chmod +x "$benchmark" +expect_fail run + +cat >"$benchmark" <<'EOF' +#!/bin/sh +echo 'INFO: NeutronDelegate delegate: 1 nodes delegated out of 3 nodes with 1 partitions.' +echo 'ERROR: unresolved custom op: NeutronGraph' +EOF +chmod +x "$benchmark" +expect_fail run + +cat >"$benchmark" <<'EOF' +#!/bin/sh +echo 'NeutronDelegate delegate: 1 nodes delegated out of 3 nodes with 1 partitions' +echo 'Operator-wise Profiling Info for Regular Benchmark Runs:' +EOF +chmod +x "$benchmark" +expect_fail run +grep -F 'NeutronDelegate delegate: 1 nodes delegated out of 3 nodes with 1 partitions' "$workdir/fail" + +cat >"$benchmark" <<'EOF' +#!/bin/sh +echo 'NeutronDelegate delegate: 1 nodes delegated out of 3 nodes with 1 partitions' +echo 'benchmark stderr: delegate application failed' +EOF +chmod +x "$benchmark" +expect_fail run + +cat >"$benchmark" <<'EOF' +#!/bin/sh +echo 'NeutronDelegate delegate: 1 nodes delegated out of 3 nodes with 1 partitions' +echo 'Operator-wise Profiling Info for Regular Benchmark Runs:' +echo '============================== Run Order ==============================' +echo 'NeutronDelegate 1.0 ms' +echo 'SOFTMAX 0.1 ms' +echo 'QUANTIZE 0.1 ms' +EOF +chmod +x "$benchmark" +chmod 000 "$device" +expect_fail run +chmod 600 "$device" + +cat >"$benchmark" <<'EOF' +#!/bin/sh +echo 'benchmark output before failure' >&2 +exit 1 +EOF +chmod +x "$benchmark" +expect_fail run +grep -F 'benchmark output before failure' "$workdir/fail" + +echo 'geisa-neutron-smoke-test fixture tests: PASS' diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-support/geisa-platform-mount/files/geisa-platform-generator b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-support/geisa-platform-mount/files/geisa-platform-generator new file mode 100755 index 0000000..1d22695 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-support/geisa-platform-mount/files/geisa-platform-generator @@ -0,0 +1,81 @@ +#!/bin/sh +# Derive /platform from the actual root mount so cloned SD and eMMC images +# cannot be mixed by identical filesystem labels or partition identifiers. +set -eu + +normal_dir=${1:?missing normal generator output directory} +findmnt_bin=${GEISA_PLATFORM_FINDMNT:-/usr/bin/findmnt} + +link_required() { + mkdir -p "${normal_dir}/local-fs.target.requires" + ln -sf "../$1" "${normal_dir}/local-fs.target.requires/$1" +} + +fail_closed() { + printf '%s\n' "geisa-platform-generator: $*" >&2 + cat >"${normal_dir}/geisa-platform-root-invalid.service" <<'EOF' +[Unit] +Description=GEISA platform mount configuration is invalid +DefaultDependencies=no +Before=local-fs.target + +[Service] +Type=oneshot +ExecStart=/bin/false +EOF + link_required geisa-platform-root-invalid.service + exit 0 +} + +[ -x "${findmnt_bin}" ] || fail_closed "findmnt is unavailable" +root_source="$(${findmnt_bin} -nr -o SOURCE / 2>/dev/null || true)" + +case "${root_source}" in + /dev/mmcblk*p2) + root_disk=${root_source%p2} + index=${root_disk#/dev/mmcblk} + ;; + *) + fail_closed "unsupported root source: ${root_source:-unavailable}" + ;; +esac + +case "${index}" in + ''|*[!0-9]*) + fail_closed "unsupported root source: ${root_source}" + ;; +esac + +platform_source="/dev/mmcblk${index}p3" +platform_device_unit="dev-mmcblk${index}p3.device" + +cat >"${normal_dir}/geisa-platform-fsck.service" <"${normal_dir}/platform.mount" <"$fake/findmnt" <<'EOF' +#!/bin/sh +printf '%s\n' "${GEISA_TEST_ROOT_SOURCE:-}" +EOF +chmod +x "$fake/findmnt" + +run_generator() { + name=$1 + source=$2 + out="$work/$name" + mkdir -p "$out/normal" "$out/early" "$out/late" + GEISA_PLATFORM_FINDMNT="$fake/findmnt" GEISA_TEST_ROOT_SOURCE="$source" \ + "$generator" "$out/normal" "$out/early" "$out/late" + printf '%s\n' "$out/normal" +} + +assert_file_contains() { + grep -Fqx "$2" "$1" >/dev/null || { + printf 'missing in %s: %s\n' "$1" "$2" >&2 + exit 1 + } +} + +emmc=$(run_generator emmc /dev/mmcblk0p2) +assert_file_contains "$emmc/platform.mount" 'What=/dev/mmcblk0p3' +assert_file_contains "$emmc/geisa-platform-fsck.service" 'Type=oneshot' +assert_file_contains "$emmc/geisa-platform-fsck.service" 'RemainAfterExit=yes' +assert_file_contains "$emmc/geisa-platform-fsck.service" 'Requires=dev-mmcblk0p3.device' +assert_file_contains "$emmc/geisa-platform-fsck.service" 'After=dev-mmcblk0p3.device' +assert_file_contains "$emmc/geisa-platform-fsck.service" 'Before=platform.mount local-fs.target' +assert_file_contains "$emmc/geisa-platform-fsck.service" 'ExecStart=/usr/sbin/fsck -a /dev/mmcblk0p3' +assert_file_contains "$emmc/platform.mount" 'Requires=dev-mmcblk0p3.device geisa-platform-fsck.service' +assert_file_contains "$emmc/platform.mount" 'After=dev-mmcblk0p3.device geisa-platform-fsck.service' +[ "$(readlink "$emmc/local-fs.target.requires/platform.mount")" = '../platform.mount' ] +[ "$(find "$emmc/local-fs.target.requires" -maxdepth 1 -type l -printf '%f\n' | sort)" = 'platform.mount' ] +[ ! -e "$emmc/local-fs.target.requires/geisa-platform-fsck.service" ] + +sd=$(run_generator sd /dev/mmcblk1p2) +assert_file_contains "$sd/platform.mount" 'What=/dev/mmcblk1p3' +assert_file_contains "$sd/geisa-platform-fsck.service" 'Requires=dev-mmcblk1p3.device' +assert_file_contains "$sd/platform.mount" 'Requires=dev-mmcblk1p3.device geisa-platform-fsck.service' +assert_file_contains "$sd/geisa-platform-fsck.service" 'ExecStart=/usr/sbin/fsck -a /dev/mmcblk1p3' +[ ! -e "$sd/local-fs.target.requires/geisa-platform-fsck.service" ] + +# Duplicate labels are intentionally irrelevant: the generator only uses the +# active root mount source and never inspects fstab or filesystem labels. +duplicate=$(run_generator duplicate-labels /dev/mmcblk1p2) +printf '%s\n' 'LABEL=platform /platform ext4 defaults 0 2' >"$work/duplicate-fstab" +assert_file_contains "$duplicate/platform.mount" 'What=/dev/mmcblk1p3' +! grep -q 'LABEL=' "$duplicate/platform.mount" + +invalid=$(run_generator invalid /dev/nvme0n1p2) +[ ! -e "$invalid/platform.mount" ] +[ ! -e "$invalid/geisa-platform-fsck.service" ] +[ -f "$invalid/geisa-platform-root-invalid.service" ] +[ "$(readlink "$invalid/local-fs.target.requires/geisa-platform-root-invalid.service")" = '../geisa-platform-root-invalid.service' ] +[ "$(find "$invalid/local-fs.target.requires" -maxdepth 1 -type l -printf '%f\n')" = 'geisa-platform-root-invalid.service' ] + +malformed=$(run_generator malformed /dev/mmcblk1p3) +[ ! -e "$malformed/platform.mount" ] +[ ! -e "$malformed/geisa-platform-fsck.service" ] +[ -f "$malformed/geisa-platform-root-invalid.service" ] + +printf 'geisa-platform-generator fixture tests: PASS\n' diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-support/geisa-system-state/files/geisa-system-state b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-support/geisa-system-state/files/geisa-system-state new file mode 100755 index 0000000..84d7aff --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-support/geisa-system-state/files/geisa-system-state @@ -0,0 +1,297 @@ +#!/bin/sh +# +# geisa-system-state - Lightweight GEISA edge host state reporter. +# +# Copyright 2026 PragSol Consulting, LLC +# Website: https://www.pragsolconsulting.com/ +# +# Licensed under the Apache License, Version 2.0. +# SPDX-License-Identifier: Apache-2.0 +# +# This utility deliberately uses only base-image tools. Each section is +# independent so an uncommissioned host or an unavailable optional facility +# never prevents the rest of the health report from being useful. + +INTERVAL="${INTERVAL:-2}" +ONCE=0 +DEBUG=0 +SYSFS_ROOT="${SYSFS_ROOT:-/sys}" +PROC_ROOT="${PROC_ROOT:-/proc}" +GEISA_STATE_ROOT="${GEISA_STATE_ROOT:-/var/lib/geisa}" +GEISA_LXC_LS_PATH="${GEISA_LXC_LS_PATH:-}" + +usage() { + cat <<'EOF' +Usage: + geisa-system-state [--once] [--debug] + +Environment: + INTERVAL=2 Refresh interval in seconds. + NO_CLEAR=1 Do not clear screen between interactive samples. +EOF +} + +while [ "$#" -gt 0 ]; do + case "$1" in + --once) ONCE=1 ;; + --debug) DEBUG=1 ;; + -h|--help) usage; exit 0 ;; + *) printf 'unsupported option: %s\n' "$1" >&2; usage >&2; exit 2 ;; + esac + shift +done + +have() { command -v "$1" >/dev/null 2>&1; } +read_file() { cat "$1" 2>/dev/null || true; } + +format_temp() { + raw="$1" + if [ -n "$raw" ] && have awk; then + awk -v value="$raw" 'BEGIN { printf "%.1f C", value / 1000 }' + elif [ -n "$raw" ]; then + printf '%s C' "$((raw / 1000))" + else + printf 'unavailable' + fi +} + +print_header() { + printf 'GEISA system state: %s\n' "$(date -u '+%Y-%m-%d %H:%M:%S UTC' 2>/dev/null || date)" + printf 'Hostname: %s\n' "$(hostname 2>/dev/null || printf unknown)" +} + +print_geisa_identity() { + printf 'GEISA account: ' + if have id && id geisa >/dev/null 2>&1; then + id geisa 2>/dev/null || printf 'geisa account unavailable\n' + else + printf 'geisa account unavailable\n' + fi +} + +print_cgroup() { + printf 'Cgroups: ' + if [ -d "$SYSFS_ROOT/fs/cgroup" ]; then + fs_type="$(stat -fc '%T' "$SYSFS_ROOT/fs/cgroup" 2>/dev/null || printf unknown)" + controllers="$(read_file "$SYSFS_ROOT/fs/cgroup/cgroup.controllers")" + printf '%s controllers=%s\n' "$fs_type" "${controllers:-unavailable}" + else + printf 'not mounted\n' + fi +} + +print_network() { + printf 'Network: ' + if ! have ip; then + printf 'ip unavailable\n' + return + fi + + rows="$(ip -o -4 addr show 2>/dev/null | awk '{ print $2, $4 }' || true)" + links="$(ip -o link show 2>/dev/null || true)" + summary="" + if [ -n "$links" ]; then + interfaces="$(printf '%s\n' "$links" | awk -F': ' ' + $2 != "" { + split($2, fields, " ") + if (fields[1] != "lo") { + state = "UNKNOWN" + if (match($0, /state [^ ]+/)) { + state = substr($0, RSTART + 6, RLENGTH - 6) + } + print fields[1] "|" state + } + } + ')" + while IFS='|' read -r name state; do + [ -n "$name" ] || continue + address="$(printf '%s\n' "$rows" | awk -v interface="$name" '$1 == interface { print $2; exit }')" + [ -z "$summary" ] || summary="$summary " + summary="${summary}${name} ${state:-UNKNOWN} ${address:-}" + done </dev/null 2>&1; then + df -hP / /platform 2>/dev/null || printf 'unavailable\n' + else + df -hP / 2>/dev/null || printf 'unavailable\n' + fi + else + printf 'df unavailable\n' + fi +} + +print_resources() { + printf '\nResources:\n' + uptime 2>/dev/null || printf 'uptime unavailable\n' + if have free; then + free -m 2>/dev/null | sed -n '1,3p' || true + else + awk '/MemTotal|MemAvailable|SwapTotal|SwapFree/ { print }' "$PROC_ROOT/meminfo" 2>/dev/null || true + fi +} + +print_lxc() { + printf '\nLXC:\n' + lxc_ls="$GEISA_LXC_LS_PATH" + if [ -z "$lxc_ls" ] && have lxc-ls; then + lxc_ls="$(command -v lxc-ls)" + elif [ -z "$lxc_ls" ]; then + for candidate in /usr/bin/lxc-ls /usr/sbin/lxc-ls /bin/lxc-ls; do + if [ -x "$candidate" ]; then + lxc_ls="$candidate" + break + fi + done + fi + if [ -z "$lxc_ls" ]; then + printf 'lxc tooling unavailable (lxc-ls not found)\n' + return + fi + if [ ! -x "$lxc_ls" ]; then + printf 'lxc tooling unavailable (lxc-ls not found)\n' + return + fi + if [ "$(id -u 2>/dev/null || printf 1)" = 0 ]; then + output="$($lxc_ls --fancy -F NAME,STATE,AUTOSTART,GROUPS,IPV4,UNPRIVILEGED 2>/dev/null)" + lxc_rc=$? + elif have sudo && sudo -n true >/dev/null 2>&1; then + output="$(sudo -n "$lxc_ls" --fancy -F NAME,STATE,AUTOSTART,GROUPS,IPV4,UNPRIVILEGED 2>/dev/null)" + lxc_rc=$? + else + output="$($lxc_ls --fancy -F NAME,STATE,AUTOSTART,GROUPS,IPV4,UNPRIVILEGED 2>/dev/null)" + lxc_rc=$? + fi + if [ "$lxc_rc" -ne 0 ]; then + printf 'lxc inventory unavailable (permission denied or command failed)\n' + return + fi + # lxc-ls prints its column heading even when there are no containers. + rows="$(printf '%s\n' "$output" | sed -n '2,$p' | sed '/^[[:space:]]*$/d')" + if [ -n "$output" ] && [ -n "$rows" ]; then + printf '%s\n' "$output" + else + printf 'none\n' + fi +} + +print_managed_apps() { + printf '\nManaged applications:\n' + registry="$GEISA_STATE_ROOT/app-registry/managed-apps.json" + if ! have python3 || [ ! -r "$registry" ]; then + printf 'runtime not installed or registry unavailable\n' + return + fi + python3 - "$registry" <<'PYAPPS' +import json +import sys + +try: + with open(sys.argv[1], encoding="utf-8") as source: + document = json.load(source) +except (OSError, ValueError): + print("registry unavailable") + raise SystemExit(0) + +rows = [] +for app in document.get("app_instances", []): + if app.get("install_state") != "installed": + continue + app_id = app.get("app_id") or "unknown" + name = app.get("display_name") or app_id + rows.append((name, app_id, app.get("execution_state") or "unknown")) + +for name, app_id, state in sorted(rows): + label = f"{name} ({app_id})" if name != app_id else app_id + print(f"{label} state={state}") +if not rows: + print("none installed") +PYAPPS +} + +print_systemd() { + failed="" + if have systemctl; then + failed="$(systemctl --failed --no-legend 2>/dev/null | sed '/^[[:space:]]*$/d' || true)" + fi + if [ -z "$failed" ]; then + printf '\nSystemd: failed=0\n' + else + count="$(printf '%s\n' "$failed" | wc -l | tr -d '[:space:]')" + printf '\nSystemd: failed=%s\n' "$count" + [ "$DEBUG" -eq 1 ] && printf '%s\n' "$failed" + fi +} + +print_debug() { + [ "$DEBUG" -eq 1 ] || return 0 + printf '\nDebug network routes:\n' + ip route 2>/dev/null || true + printf '\nDebug listening sockets:\n' + ss -lntup 2>/dev/null || true + printf '\nDebug recent warnings/errors:\n' + if have journalctl; then + journalctl -b -p warning..alert --no-pager -n 40 2>/dev/null || true + else + dmesg 2>/dev/null | grep -Ei 'warn|error|fail|oom|ethosu|remoteproc|rpmsg|lxc|mosquitto|cgroup' | tail -40 || true + fi +} + +print_report() { + print_header + print_cgroup + print_geisa_identity + print_network + print_thermal + print_managed_apps + print_systemd + print_lxc + print_filesystems + print_resources + print_debug +} + +while :; do + # Clear only interactive refreshes. Redirected output remains log-friendly. + if [ "$ONCE" -ne 1 ] && [ "${NO_CLEAR:-0}" != 1 ] && [ -t 1 ]; then + clear 2>/dev/null || true + fi + print_report + [ "$ONCE" -eq 1 ] && exit 0 + sleep "$INTERVAL" +done diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-support/geisa-system-state/geisa-system-state_1.0.bb b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-support/geisa-system-state/geisa-system-state_1.0.bb new file mode 100644 index 0000000..9787527 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-support/geisa-system-state/geisa-system-state_1.0.bb @@ -0,0 +1,23 @@ +# Copyright 2026 PragSol Consulting, LLC +# Website: https://www.pragsolconsulting.com/ +# +# Licensed under the Apache License, Version 2.0. +# SPDX-License-Identifier: Apache-2.0 + +SUMMARY = "GEISA system state helper" +DESCRIPTION = "Installs a compact shell diagnostic helper for GEISA board bring-up and image validation." +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10" + +SRC_URI = "file://geisa-system-state" + +S = "${UNPACKDIR}" + +inherit allarch + +do_install() { + install -d ${D}${bindir} + install -m 0755 ${UNPACKDIR}/geisa-system-state ${D}${bindir}/geisa-system-state +} + +FILES:${PN} = "${bindir}/geisa-system-state" diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-support/libasyncns/libasyncns_0.8.bb b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-support/libasyncns/libasyncns_0.8.bb new file mode 100644 index 0000000..a4d6e0e --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/recipes-support/libasyncns/libasyncns_0.8.bb @@ -0,0 +1,17 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +SUMMARY = "Asynchronous name service library" +DESCRIPTION = "Asynchronous DNS resolution library for applications" +HOMEPAGE = "https://0pointer.de/lennart/projects/libasyncns/" +SECTION = "libs" +LICENSE = "LGPL-2.1-or-later" +LIC_FILES_CHKSUM = "file://LICENSE;md5=fad9b3332be894bab9bc501572864b29" + +SRC_URI = "https://deb.debian.org/debian/pool/main/liba/libasyncns/libasyncns_${PV}.orig.tar.gz" +SRC_URI[sha256sum] = "4f1a66e746cbe54ff3c2fbada5843df4fbbbe7481d80be003e8d11161935ab74" + +S = "${UNPACKDIR}/libasyncns-${PV}" + +inherit autotools pkgconfig + +EXTRA_OECONF = "--disable-static" diff --git a/platforms/nxp-imx9-yocto/sources/meta-geisa-community/wic/geisa-imx-partitioning.wks.in b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/wic/geisa-imx-partitioning.wks.in new file mode 100644 index 0000000..a938496 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-geisa-community/wic/geisa-imx-partitioning.wks.in @@ -0,0 +1,22 @@ +# short-description: Create SD card image with a boot partition +# long-description: +# Create an image that can be written onto a SD card using dd for use +# with i.MX SoC family +# It uses u-boot + other binaries gathered together on imx-boot file +# +# The disk layout used is: +# - ---------- -------------- -------------- +# | | imx-boot | boot | rootfs | +# - ---------- -------------- -------------- +# ^ ^ ^ ^ ^ +# | | | | | +# 0 | 8MiB 264MiB 264MiB + rootfs + IMAGE_EXTRA_SPACE +# rootfs and /platform default to GEISA_*_FIXED_SIZE MiB when set by the image. +# ${IMX_BOOT_SEEK} 32 or 33kiB, see reference manual +# +part u-boot --source rawcopy --sourceparams="file=imx-boot.tagged" --ondisk mmcblk --no-table --align ${IMX_BOOT_SEEK} +part /boot --source bootimg-partition --ondisk mmcblk --fstype=vfat --label boot --active --align 8192 --fixed-size 256 +part / --source rootfs --exclude-path platform/ --ondisk mmcblk --fstype=ext4 --label root --align 8192 --fixed-size ${GEISA_ROOTFS_FIXED_SIZE} +part /platform --source rootfs --rootfs-dir=${IMAGE_ROOTFS}/platform --ondisk mmcblk --fstype=ext4 --label platform --align 8192 --use-uuid --fixed-size ${GEISA_PLATFORM_FIXED_SIZE} + +bootloader --ptable msdos diff --git a/platforms/nxp-imx9-yocto/sources/meta-imx b/platforms/nxp-imx9-yocto/sources/meta-imx new file mode 160000 index 0000000..fb0e606 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-imx @@ -0,0 +1 @@ +Subproject commit fb0e606e90fbaecc273b832a9965bfef9f8b0b91 diff --git a/platforms/nxp-imx9-yocto/sources/meta-openembedded b/platforms/nxp-imx9-yocto/sources/meta-openembedded new file mode 160000 index 0000000..a4e768d --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-openembedded @@ -0,0 +1 @@ +Subproject commit a4e768dcfae181dd99e39c4286fa0729ca7f4e47 diff --git a/platforms/nxp-imx9-yocto/sources/meta-virtualization b/platforms/nxp-imx9-yocto/sources/meta-virtualization new file mode 160000 index 0000000..b9a29d2 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-virtualization @@ -0,0 +1 @@ +Subproject commit b9a29d2423407c1e50f19dc3f3e154d164c5f0ec diff --git a/platforms/nxp-imx9-yocto/sources/meta-yocto b/platforms/nxp-imx9-yocto/sources/meta-yocto new file mode 160000 index 0000000..d02d3fa --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/meta-yocto @@ -0,0 +1 @@ +Subproject commit d02d3faaf4d6075ea03e9eb47654ec7639f929a0 diff --git a/platforms/nxp-imx9-yocto/sources/openembedded-core b/platforms/nxp-imx9-yocto/sources/openembedded-core new file mode 160000 index 0000000..9964fa3 --- /dev/null +++ b/platforms/nxp-imx9-yocto/sources/openembedded-core @@ -0,0 +1 @@ +Subproject commit 9964fa3da2fa1e7243fba1a826e59f7bb1813706