---
id: TASK-17
title: Implement proper sysbuild project support
status: Done
assignee: []
created_date: '2026-02-27 08:46'
updated_date: '2026-02-27 10:33'
labels: []
dependencies: []
references:
  - docs/zync/README.md
  - docs/zync/lua/zync/api/manager.lua
  - src/core/cmd.rs
  - src/core/cli.rs
  - src/core/config.rs
  - docs/spec.md
  - docs/plan.md
---

## Description

<!-- SECTION:DESCRIPTION:BEGIN -->
Align sysbuild behavior with the Zync reference (docs/zync) for listing images, selecting images by name/index, default image selection, and sysbuild-specific run/flash handling.
<!-- SECTION:DESCRIPTION:END -->

## Acceptance Criteria
<!-- AC:BEGIN -->
- [x] #1 Sysbuild run/flash behavior matches the Zync reference for list/image handling and default image selection.
- [x] #2 Non-sysbuild projects reject sysbuild-only flags with clear errors.
- [x] #3 Documentation/tests updated as needed for the new behavior.
<!-- AC:END -->

## Implementation Notes

<!-- SECTION:NOTES:BEGIN -->
Zync sysbuild command behavior (docs/zync/lua/zync/api/manager.lua):
- Configure: when sysbuild, cmake command uses `-DAPP_DIR=<project_dir>` and adds `<zephyr_base>/share/sysbuild` instead of `<project_dir>` path. Logs "Configuring sysbuild project".
- Image list: prints "Available sysbuild images:" and a 1-based list of directories excluding build dirs (.cmake, CMakeFiles, Kconfig, modules, zephyr, _sysbuild).
- Image resolve: if no image, selects first non-`mcuboot`; if numeric index, maps to image name.
- Non-sysbuild: `--list` or `--image` errors.
- Run/flash: for sysbuild, list returns early; otherwise resolve image and use image dir; run still falls back to `ninja run` if zephyr binary missing; flash builds then executes with selected image.
- Build: unchanged except reconfigure/configure handles sysbuild.
<!-- SECTION:NOTES:END -->

## Final Summary

<!-- SECTION:FINAL_SUMMARY:BEGIN -->
Implemented sysbuild support aligned with Zync: image discovery/resolution (default non-mcuboot, 1-based index, name selection), list output formatting, non-sysbuild flag rejection, sysbuild run/flash image selection, and sysbuild-specific cmake invocation (`-DAPP_DIR` + sysbuild source). Added/updated tests and docs.

Tests: `just test`
<!-- SECTION:FINAL_SUMMARY:END -->
