Skip to content

Commit ce39a6a

Browse files
committed
fix init_container script, fix container file ownership, add container info to readme.
1 parent 03c641a commit ce39a6a

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

ports/zephyr-cp/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,33 @@ make BOARD=nordic_nrf7002dk
2828
This uses Zephyr's cmake to generate Makefiles that then delegate to
2929
`tools/cpbuild/build_circuitpython.py` to build the CircuitPython bits in parallel.
3030

31+
## Native simulator build container
32+
33+
Building the native sim requires `libsdl2-dev:i386` and other 32bit dependencies that
34+
can cause conflicts on 64bit systems resulting in the removal of 64bit versions of critical
35+
software such as the display manager and network manager. A Containerfile and a few scripts
36+
are provided to set up a container to make the native sim build inside without affecting the
37+
host system.
38+
39+
The container automatically mounts this instance of the circuitpython repo inside at
40+
`/home/dev/circuitpython`. Changes made in the repo inside the container and on the host PC
41+
will sync automatically between host and container.
42+
43+
To use the container file:
44+
45+
1. Build the container with `podman build -t zephyr-cp-dev -f native_sim_build_Containerfile .`
46+
2. Run/Start the container by running `./native_sim_build_run_container.sh` on the host PC.
47+
The script will automatically run or start based on whether the container has been run before.
48+
3. Init requirements inside the container with `./native_sim_build_init_container.sh`
49+
50+
To delete the container and cleanup associated files:
51+
```sh
52+
podman ps -a --filter ancestor=zephyr-cp-dev -q | xargs -r podman rm -f
53+
podman rmi zephyr-cp-dev
54+
podman image prune -f
55+
podman rm -f zcp
56+
```
57+
3158
## Running the native simulator
3259

3360
From `ports/zephyr-cp`, run:

ports/zephyr-cp/native_sim_build_Containerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ RUN dpkg --add-architecture i386 && apt-get update && apt-get install -y --no-in
1212
protobuf-compiler sudo \
1313
&& rm -rf /var/lib/apt/lists/*
1414

15-
RUN useradd -m -s /bin/bash dev \
15+
# Remove the default ubuntu:24.04 'ubuntu' user (UID 1000) so 'dev' can take
16+
# UID 1000 — required for --userns=keep-id to map host UID 1000 to 'dev'.
17+
RUN userdel -r ubuntu 2>/dev/null || true \
18+
&& useradd -m -u 1000 -s /bin/bash dev \
1619
&& echo 'dev ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/dev \
1720
&& chmod 440 /etc/sudoers.d/dev
1821
USER dev

ports/zephyr-cp/native_sim_build_init_container.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99
# Safe to re-run; west/pip/etc. are idempotent.
1010
set -euo pipefail
1111

12+
git config --global --add safe.directory /home/dev/circuitpython
13+
1214
cd "$(dirname "${BASH_SOURCE[0]}")"
1315

1416
echo "==> west init"
15-
if [ ! -d ../../.west ]; then
17+
if [ ! -d .west ]; then
1618
west init -l zephyr-config
1719
else
1820
echo " (already initialized, skipping)"
@@ -34,7 +36,6 @@ echo "==> west sdk install (x86_64-zephyr-elf)"
3436
west sdk install -t x86_64-zephyr-elf
3537

3638
echo "==> fetch port submodules"
37-
git config --global --add safe.directory /home/dev/circuitpython
3839
python ../../tools/ci_fetch_deps.py zephyr-cp
3940

4041
echo

0 commit comments

Comments
 (0)