Integrating Ambiorix (AMX) into Yocto: From Layer to Running
Grow through practice
No need to finish reading — test nowConclusion first: There is an official
meta-amx(honister only); for newer Yocto releases you build your own layer — but you do not start from scratch: follow its dependency chain and recipe structure and port it.
1. A quick look at the official layer
Repository:
git clone -b honister https://gitlab.com/prpl-foundation/yocto/metalayers/meta-amx.git
bitbake-layers add-layer meta-amx
bitbake amxrt
- It is PRPL Foundation's official Ambiorix Yocto metadata (PRPL's own
sdk-builderuses it); - The
honisterbranch is still maintained (tags up tohonister_v15.17.1); maincontains only a README and is a placeholder;LAYERSERIES_COMPATonly listshonister.
So: use it directly on honister; build or port your own layer for kirkstone/scarthgap.
2. Dependency chain (the order to write recipes)
libamxc
├── libamxj (yajl)
├── libamxp (libcap-ng, bison-native, flex-native)
├── libamxd (libamxc, libamxp)
├── libamxb (libamxc, libamxp, libamxd, uriparser)
├── libamxs (libamxc, libamxp, libamxb, libamxd)
├── libamxo (libamxc, libamxp, libamxd, libamxs, bison/flex)
├── libamxrt (libamxc, libamxj, libamxp, libamxd, libamxo, libamxb, libevent, libcap-ng)
├── amxrt (libamxrt + all of the above)
└── mod-amxb-ubus (libamxc, libamxb, libamxd, ubus)
yajl,uriparser,libcap-ngandlibeventlive in meta-oe, so the layer must depend onmeta-oe.
3. Minimal layer structure
meta-ambiorix/
├── conf/layer.conf
├── classes/config-amx.bbclass
├── recipes-ambiorix/
│ ├── libamxc/libamxc_git.bb
│ ├── libamxj/libamxj_git.bb
│ ├── libamxp/libamxp_git.bb
│ ├── libamxd/libamxd_git.bb
│ ├── libamxb/libamxb_git.bb
│ ├── libamxs/libamxs_git.bb
│ ├── libamxo/libamxo_git.bb
│ ├── libamxrt/libamxrt_git.bb
│ ├── amxrt/amxrt_git.bb
│ └── mod-amxb-ubus/mod-amxb-ubus_git.bb
└── recipes-core/packagegroups/packagegroup-ambiorix.bb
conf/layer.conf:
BBPATH .= ":${LAYERDIR}"
BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
${LAYERDIR}/recipes-*/*/*.bbappend"
BBFILE_COLLECTIONS += "ambiorix"
BBFILE_PATTERN_ambiorix = "^${LAYERDIR}/"
BBFILE_PRIORITY_ambiorix = "10"
LICENSE_PATH += "${LAYERDIR}/licenses"
LAYERDEPENDS_ambiorix = "core meta-oe"
LAYERSERIES_COMPAT_ambiorix = "scarthgap styhead walnascar"
SAHis not a common SPDX license: copy the upstreamlicenses/SAHinto your layer, otherwise BitBake reportslicense SAH not found. Also,SAHis SoftAtHome's own terms — confirm licensing before shipping a product (theLICENSEfile in each repository is authoritative).
4. Recipe template (libamxc as an example)
SUMMARY = "Ambiorix generic containers"
LICENSE = "SAH & BSD-2-Clause-Patent"
LIC_FILES_CHKSUM = "file://LICENSE;md5=f8eaa5ae328592b1346db42ce2936d90"
SRC_URI = "git://gitlab.com/prpl-foundation/components/ambiorix/libraries/libamxc.git;protocol=https;nobranch=1"
SRCREV = "1623d9fc299c03c9d47adb95a884a0309cabf4eb"
S = "${WORKDIR}/git"
inherit pkgconfig
EXTRA_OEMAKE = " \
DEST=${D} \
PREFIX=${prefix} \
LIBDIR=${libdir} \
BINDIR=${bindir} \
INCLUDEDIR=${includedir} \
"
do_compile() {
oe_runmake
}
do_install() {
oe_runmake install
}
FILES:${PN} += "${libdir}/libamxc.so.*"
FILES:${PN}-dev += "${libdir}/libamxc.so ${includedir}/amxc/*.h"
FILES:${PN}-staticdev += "${libdir}/libamxc.a"
Key points:
DEST=${D}: BAF's makefile usesDESTasDESTDIR;LIBDIR=${libdir}: otherwise the makefile generates/usr/lib/aarch64-...from$(CC) -dumpmachine, and packaging will not match;PREFIX/BINDIR/INCLUDEDIRlikewise, normalized to Yocto's standard paths;- Cross-compilation relies on BitBake exporting
CC/CFLAGS/LDFLAGS; the makefile uses+=, so they are not overridden.
For the other libraries, change only SUMMARY, SRC_URI, SRCREV, the DEPENDS/RDEPENDS and FILES. Copy dependencies from the table in section 2.
5. Do we need config-amx.bbclass?
The official class really does only two things:
EXTRA_OEMAKE += "DEST=${D} D=${D}${base_prefix} PREFIX=${prefix} LIBDIR=${libdir} BINDIR=${bindir} INCLUDEDIR=${includedir}"
do_install() { oe_runmake install; }
One easy trap:
SAH_CONFIG/CONFIG_SAH_*in the recipes are BAF-era options; when building withmake, these variables are not referenced by thelibamxc/libamxo/libamxrtmakefiles. Copying them is harmless, but do not assume they do anything.
When building your own layer, put this block directly in the recipes (or copy a trimmed-down class).
6. Add it to the image
packagegroup-ambiorix.bb:
inherit packagegroup
RDEPENDS:${PN} = " \
amxrt \
libamxd \
libamxo \
mod-amxb-ubus \
"
local.conf / image recipe:
IMAGE_INSTALL:append = " packagegroup-ambiorix"
Build:
bitbake libamxc libamxp libamxd libamxb libamxo libamxrt amxrt
bitbake core-image-minimal
7. Run it: ODL + bus + systemd
A pure data-model hello.odl:
%config {
name = "hello";
}
%define {
object Hello {
string Greeting = "Hello, AMX";
uint32 Count = 0;
}
}
Start it (ubus backend):
amxrt -u ubus:/var/run/ubus/ubus.sock \
-B /usr/bin/mods/amxb/mod-amxb-ubus.so \
/etc/amx/hello/hello.odl
-A -Conly disables auto-detect and connect; you still need-Bto load a backend (such as ubus), otherwiseamxrtfails withNo backends specified. To be reachable fromubus/amx-cli, you need ubusd + the backend.
systemd unit:
[Unit]
Description=AMX hello data model
After=network.target
# How ubusd starts depends on your image: ubusd.service on systemd, or an init script on SysV
[Service]
ExecStart=/usr/bin/amxrt /etc/amx/hello/hello.odl
Restart=always
RestartSec=2
[Install]
WantedBy=multi-user.target
In the recipe:
inherit systemd
SYSTEMD_SERVICE:${PN} = "hello.service"
SYSTEMD_AUTO_ENABLE:${PN} = "enable"
SRC_URI += "file://hello.odl file://hello.service"
do_install:append() {
install -d ${D}${sysconfdir}/amx/hello
install -m 0644 ${WORKDIR}/hello.odl ${D}${sysconfdir}/amx/hello/
install -d ${D}${systemd_system_unitdir}
install -m 0644 ${WORKDIR}/hello.service ${D}${systemd_system_unitdir}/
}
FILES:${PN} += "${sysconfdir}/amx/hello/hello.odl"
Verify:
ubus list | grep Hello
ubus call Hello _get
# or (amx-cli needs the extra libamxt/libamxm/amx-cli recipes)
amx-cli -u ubus:/var/run/ubus/ubus.sock
8. What to change from honister to scarthgap
- Change
LAYERSERIES_COMPATto the target release;
- Old
FILES_${PN}→FILES:${PN}(upstream's newer recipes already use the colon form);
LICENSE +=→ setLICENSE = "..."first, so the variable is initialized;
- Do not forget
bison-native/flex-native(libamxp,libamxo);
- Replace SysV's
inherit update-rc.dwithsystemdif the image uses systemd;
- Newer components may have extra dependencies (such as
libocispec,libevent); trust each repository'sbaf.ymlrather than copying an old recipe'sDEPENDS.
9. Common errors
| Symptom | Cause |
|---|---|
cap-ng.h: No such file | missing libcap-ng (meta-oe) |
yajl/yajl_parse.h not found | missing yajl |
uriparser/Uri.h not found | missing uriparser |
cannot find -lamxc | missing DEPENDS, or not installed into the sysroot |
libamxc.so.2: cannot open | missing RDEPENDS / package not in the image |
amxrt runs but ubus list shows no object | backend not loaded / ubusd not running / wrong URI |
Installed into /usr/lib/aarch64-... | LIBDIR=${libdir} was not passed |
do_install cannot find DEST | the makefile uses DEST, not DESTDIR |
One sentence
The hard part of integrating AMX into Yocto is not recipe syntax; it is the dependency chain and the bus backend. Get
libamxc → libamxp → libamxd → libamxb → libamxo → libamxrtandDEST/LIBDIRright, and the rest is packaging and services.
Concepts: What AMXD Means · libamxd in practice Official layer: prpl-foundation/yocto/metalayers/meta-amx Runnable demo: meta-ambiorix-demo (scarthgap + QEMU + ubus + ODL + systemd) Related: prplOS vs OpenWrt
Comments 0
No comments yet — be the first!