Install
openclaw skills install sonic-buildBuild SONiC (Software for Open Networking in the Cloud) switch images from sonic-buildimage. Use when building VS/ASIC images, configuring build parallelism/memory/caching, debugging build failures, managing submodules, cleaning artifacts, or optimizing build performance. Covers all platforms (VS, broadcom, mellanox, marvell, nvidia-bluefield).
openclaw skills install sonic-buildcd sonic-buildimage
make init
make configure PLATFORM=vs # or broadcom, mellanox, etc.
make SONIC_BUILD_JOBS=4 target/sonic-vs.img.gz
For dev builds (skip tests): add BUILD_SKIP_TEST=y.
Two-phase build via GNU Make → slave.mk → sonic-slave Docker container:
target/debs/bookworm/target/debs/trixie/Makefile invokes Makefile.work with different BLDENV per phase. The configure target creates per-distro directories.
All knobs in rules/config. Override in rules/config.user (gitignored, persists across rebases).
| Knob | Default | Recommended | Effect |
|---|---|---|---|
SONIC_CONFIG_BUILD_JOBS | 1 | 4 | Parallel top-level package builds |
SONIC_CONFIG_MAKE_JOBS | $(nproc) | default | Compiler threads per package |
BUILD_SKIP_TEST | n | y (dev) | Skip unit tests |
SONIC_BUILD_MEMORY | unset | 24g | Docker --memory — contains OOM in container |
SONIC_DPKG_CACHE_METHOD | none | rwcache | Cache .deb packages for incremental builds |
DEFAULT_BUILD_LOG_TIMESTAMP | none | simple | Timestamps in build logs |
SONIC_CONFIG_USE_NATIVE_DOCKERD_FOR_BUILD | unset | y | Host Docker daemon instead of DinD |
rules/config.userSONIC_CONFIG_BUILD_JOBS = 4
BUILD_SKIP_TEST = y
SONIC_BUILD_MEMORY = 24g
DEFAULT_BUILD_LOG_TIMESTAMP = simple
Rule of thumb: JOBS × 6GB ≤ available RAM.
Why JOBS=1 is slow: 64/194 packages depend on libswsscommon (critical path bottleneck). JOBS=1 leaves most cores idle.
Without limits, parallel builds can trigger the kernel OOM killer on any host process.
# Container-scoped OOM (host stays healthy):
SONIC_BUILD_MEMORY = 24g
# Or via CLI:
make SONIC_BUILDER_EXTRA_CMDLINE="--memory=24g" ...
SONIC_DPKG_CACHE_METHOD = rwcache
SONIC_DPKG_CACHE_SOURCE = /var/cache/sonic/artifacts
SONIC_VERSION_CACHE_METHOD = cache
make target/debs/bookworm/sonic-utilities_1.2-1_all.deb
make target/docker-syncd-vs.gz
ls target/debs/bookworm/ | grep <name>
When to clean: after branch switch, rebase, or unexplained failures.
rm -rf target/* # always full clean, not selective
make configure PLATFORM=vs
make SONIC_BUILD_JOBS=4 target/sonic-vs.img.gz
Stale artifacts (
.bin, squashfs) confuse make into skipping phases.
make init # after clone or pull
git submodule update --init --force src/<module> # fix corrupted submodule
SSH clone is more reliable than HTTPS (HTTPS can give HTTP 500).
For detailed troubleshooting, see references/troubleshooting.md.
See references/prerequisites.md for host setup (Docker, Python, jinjanator).
See references/vs-platform.md for VS-specific details (TAP devices, port mapping, sai.profile, oper speed).
git commit -s for DCO sign-offBUILD_SKIP_TEST=n at least once