Skip to content

Commit fa02cfe

Browse files
gman4001ona-agent
andcommitted
devcontainer: add Zephyr SDK install task to automations
Add installSdk task that: - Reads SDK_VERSION from the fetched zephyr tree - Downloads and installs the matching Zephyr SDK via west sdk install - Patches SDK host tool ELF binaries to use the system dynamic linker (the SDK sysroot uses a hardcoded OE build path that doesn't exist on standard Ubuntu) - Also adds patchelf, anytree, jsonschema to installDeps Signed-off-by: gman4001 <gamblecolton4@gmail.com> Co-authored-by: Ona <no-reply@ona.com>
1 parent 77248cf commit fa02cfe

1 file changed

Lines changed: 34 additions & 3 deletions

File tree

.ona/automations.yaml

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ tasks:
1616
libasound2-dev \
1717
libglib2.0-dev \
1818
libssl-dev \
19-
pkg-config
20-
pip3 install --user west
19+
pkg-config \
20+
patchelf
21+
pip3 install --user west anytree jsonschema
2122
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
2223
export PATH="$HOME/.local/bin:$PATH"
2324
west --version
@@ -39,6 +40,36 @@ tasks:
3940
dependsOn:
4041
- installDeps
4142

43+
installSdk:
44+
name: Install Zephyr SDK
45+
description: |
46+
Download and install the Zephyr SDK version matching the workspace
47+
(reads SDK_VERSION from the fetched zephyr tree). Patches SDK host
48+
tool binaries to use the system dynamic linker so they run on Ubuntu.
49+
command: |
50+
export PATH="$HOME/.local/bin:$PATH"
51+
SDK_VERSION=$(cat /workspaces/zephyr/SDK_VERSION)
52+
echo "Installing Zephyr SDK $SDK_VERSION"
53+
west sdk install --version "$SDK_VERSION" -t xtensa-dc233c_zephyr-elf
54+
# The SDK setup.sh -h (host tools) fails without the OE sysroot linker.
55+
# Run setup without -h then patch the ELF interpreter on all host binaries.
56+
~/zephyr-sdk-${SDK_VERSION}/setup.sh -t xtensa-dc233c_zephyr-elf
57+
SYSROOT=~/zephyr-sdk-${SDK_VERSION}/hosttools/sysroots/x86_64-pokysdk-linux
58+
SYSTEM_LD=$(ls /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 /lib64/ld-linux-x86-64.so.2 2>/dev/null | head -1)
59+
find "$SYSROOT/usr/bin" -type f -executable | while read f; do
60+
interp=$(readelf -l "$f" 2>/dev/null | grep "program interpreter" | grep -o '/[^]]*')
61+
if [ -n "$interp" ]; then
62+
patchelf --set-interpreter "$SYSTEM_LD" \
63+
--set-rpath "$SYSROOT/lib:$SYSROOT/usr/lib" "$f" 2>/dev/null
64+
fi
65+
done
66+
echo "export ZEPHYR_SDK_INSTALL_DIR=~/zephyr-sdk-${SDK_VERSION}" >> ~/.bashrc
67+
~/zephyr-sdk-${SDK_VERSION}/hosttools/sysroots/x86_64-pokysdk-linux/usr/bin/dtc --version
68+
triggeredBy:
69+
- postDevcontainerStart
70+
dependsOn:
71+
- westUpdate
72+
4273
buildTools:
4374
name: Build SOF host tools
4475
description: |
@@ -50,4 +81,4 @@ tasks:
5081
triggeredBy:
5182
- manual
5283
dependsOn:
53-
- westUpdate
84+
- installSdk

0 commit comments

Comments
 (0)