Skip to content

arduino-uno-q: fix CI build by fetching qcombin at image creation time#9642

Open
SuperKali wants to merge 2 commits intoarmbian:mainfrom
OpenSource-YYT:fix-arduino-uno-q-ci-build
Open

arduino-uno-q: fix CI build by fetching qcombin at image creation time#9642
SuperKali wants to merge 2 commits intoarmbian:mainfrom
OpenSource-YYT:fix-arduino-uno-q-ci-build

Conversation

@SuperKali
Copy link
Copy Markdown
Member

@SuperKali SuperKali commented Apr 8, 2026

Summary

  • Fix CI build failure at image-output-arduino.sh:25 where qcombin flash binaries were not fetched
  • The qcombin.sh extension used fetch_sources_tools hook which only runs during u-boot compilation — when artifacts are cached (CI), the fetch is skipped
  • Move qcombin fetch into image-output-arduino.sh using post_family_config hook which always runs
  • Remove the standalone qcombin.sh extension
  • Improve image-output extension: sfdisk JSON parsing, proper logging, cleanup handler, quoted variables

Test plan

  • Local build completes successfully
  • Output archive created with all flash binaries
  • No cleanup handler warnings
  • CI build should now pass

Summary by CodeRabbit

  • New Features

    • Arduino image output now produces a QDL-flashable archive with improved partition extraction and robust cleanup on failure.
    • Board USB gadget provisioning updated: Ubuntu receives dedicated gadget setup and service; Debian gets conditional ADB support; other distros use RNDIS gadget service.
  • Refactor

    • qcombin integration reorganized — no longer auto-enabled during family config; fetch/handling relocated.

The qcombin extension used fetch_sources_tools hook which only runs
during u-boot compilation. When artifacts are cached (CI), the fetch
is skipped and image-output-arduino fails because flash binaries
are missing.

Move qcombin fetch into image-output-arduino.sh using post_family_config
hook which always runs. Remove the standalone qcombin.sh extension.

Also improve the image-output extension:
- Use sfdisk JSON output for reliable partition parsing
- Use run_host_command_logged for proper build logging
- Add cleanup handler for loop device on failure
- Quote all variables properly
@SuperKali SuperKali requested a review from igorpecovnik as a code owner April 8, 2026 13:44
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 8, 2026

📝 Walkthrough

Walkthrough

The qcombin fetch was moved from a standalone extension into an Arduino image-output family hook; the qcombin extension file was removed and its enable call dropped from the qrb2210 family. The Arduino image conversion flow was refactored to use sfdisk+Python, loop mounts, explicit cleanup, and different archive layout.

Changes

Cohort / File(s) Summary
QRB2210 Configuration
config/sources/families/qrb2210.conf
Removed enable_extension "qcombin"; QCOMBIN_DIR declaration retained.
Arduino image-output extension
extensions/image-output-arduino.sh
Added post_family_config__fetch_qcombin() to fetch armbian/qcombin; refactored post_build_image__900_convert_to_arduino_img() to use sfdisk -J + Python for partition extraction, use loop device + mount (ARDUINO_ROOTFS_LOOP, ARDUINO_ROOTFS_MOUNT), register image_output_arduino_cleanup() via add_cleanup_handler, and change archive layout/naming.
QCombin extension removal
extensions/qcombin.sh
Deleted file and its fetch_sources_tools__qcombin() function; fetching consolidated into image-output-arduino.sh.
Board USB gadget tweaks
config/boards/arduino-uno-q.csc
Adjusted USB gadget/service install logic: conditional adbd install/enable for Debian, Ubuntu-specific usbgadget-rndis service and provisioning via new post_family_tweaks_bsp__arduino-uno-q_usb_gadget() hook; removed unconditional adbd enable.

Sequence Diagram(s)

sequenceDiagram
    participant Builder as Builder
    participant ImgExt as image-output-arduino.sh
    participant Git as Git(repo: armbian/qcombin)
    participant SFDISK as sfdisk+python
    participant Kernel as LoopDevice/Mount
    participant Archiver as tar/archive

    Builder->>ImgExt: trigger post-family config
    ImgExt->>Git: fetch armbian/qcombin (post_family_config__fetch_qcombin)
    Builder->>ImgExt: trigger post_build_image__900_convert...
    ImgExt->>SFDISK: run sfdisk -J to enumerate partitions
    SFDISK->>ImgExt: partition JSON
    ImgExt->>Kernel: setup loop device (ARDUINO_ROOTFS_LOOP) and mount (ARDUINO_ROOTFS_MOUNT)
    ImgExt->>Archiver: create flash layout, rename partitions to disk-sdcard.img.*
    Archiver->>ImgExt: produce tar archive under DESTIMG
    ImgExt->>ImgExt: add_cleanup_handler(image_output_arduino_cleanup)
    alt failure or exit
        ImgExt->>Kernel: detach loop / unmount via cleanup
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 I hopped through configs, fetched a crate,
Moved qcombin into Arduino's gate,
Partitions twirled, loops were bound,
Cleanup springs and archives found,
A rabbit's hop, a build made great.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: moving qcombin fetching to image creation time to fix CI build failures.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added size/medium PR with more then 50 and less then 250 lines 05 Milestone: Second quarter release Needs review Seeking for review Hardware Hardware related like kernel, U-Boot, ... Framework Framework components labels Apr 8, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
extensions/image-output-arduino.sh (1)

24-29: Consider caching sfdisk output to avoid redundant invocations.

The same sfdisk -J command is executed four times. Parsing once would be more efficient.

♻️ Suggested optimization
 	# Extract partition offsets using sfdisk JSON output
 	local p1_start p1_size p2_start p2_size
-	p1_start=$(sfdisk -J "${img}" | python3 -c "import sys,json; p=json.load(sys.stdin)['partitiontable']['partitions']; print(p[0]['start'])")
-	p1_size=$(sfdisk -J "${img}" | python3 -c "import sys,json; p=json.load(sys.stdin)['partitiontable']['partitions']; print(p[0]['size'])")
-	p2_start=$(sfdisk -J "${img}" | python3 -c "import sys,json; p=json.load(sys.stdin)['partitiontable']['partitions']; print(p[1]['start'])")
-	p2_size=$(sfdisk -J "${img}" | python3 -c "import sys,json; p=json.load(sys.stdin)['partitiontable']['partitions']; print(p[1]['size'])")
+	local sfdisk_json
+	sfdisk_json=$(sfdisk -J "${img}")
+	read -r p1_start p1_size p2_start p2_size < <(
+		echo "${sfdisk_json}" | python3 -c "
+import sys, json
+p = json.load(sys.stdin)['partitiontable']['partitions']
+print(p[0]['start'], p[0]['size'], p[1]['start'], p[1]['size'])
+"
+	)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@extensions/image-output-arduino.sh` around lines 24 - 29, The four repeated
invocations of sfdisk -J are inefficient; capture the JSON once and reuse it
when setting p1_start, p1_size, p2_start, and p2_size. Run sfdisk -J "${img}" a
single time into a variable or temp file (e.g., sfdisk_json) and then parse that
single JSON with the existing python3 one-liners (or jq) to assign p1_start,
p1_size, p2_start, p2_size, replacing the repeated sfdisk calls.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@extensions/image-output-arduino.sh`:
- Around line 4-7: The repo fetch function post_family_config__fetch_qcombin
clones qcombin but never sets QCOMBIN_DIR, causing later references to be unset;
after calling
fetch_from_repo("https://github.com/armbian/qcombin","qcombin","branch:main")
set and export QCOMBIN_DIR to the path used by fetch_from_repo (e.g.
${SRC}/cache/sources/qcombin) and optionally validate it exists (fail/alert if
missing) so subsequent uses of QCOMBIN_DIR resolve correctly; update
post_family_config__fetch_qcombin to perform this assignment and export
immediately after the fetch.

---

Nitpick comments:
In `@extensions/image-output-arduino.sh`:
- Around line 24-29: The four repeated invocations of sfdisk -J are inefficient;
capture the JSON once and reuse it when setting p1_start, p1_size, p2_start, and
p2_size. Run sfdisk -J "${img}" a single time into a variable or temp file
(e.g., sfdisk_json) and then parse that single JSON with the existing python3
one-liners (or jq) to assign p1_start, p1_size, p2_start, p2_size, replacing the
repeated sfdisk calls.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4118036c-28d7-471d-8272-afe2e0972ecf

📥 Commits

Reviewing files that changed from the base of the PR and between 31f8803 and d88af26.

📒 Files selected for processing (3)
  • config/sources/families/qrb2210.conf
  • extensions/image-output-arduino.sh
  • extensions/qcombin.sh
💤 Files with no reviewable changes (2)
  • config/sources/families/qrb2210.conf
  • extensions/qcombin.sh

Use adbd on Debian where available, fall back to USB gadget network
with unudhcpd on Ubuntu where adbd is not packaged.
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@config/boards/arduino-uno-q.csc`:
- Around line 22-36: The else branch currently enables usbgadget-rndis.service
for all non-Debian DISTROs causing failure on non-Ubuntu systems because
post_family_tweaks_bsp__arduino-uno-q_usb_gadget() only installs the service on
Ubuntu; change the logic to explicitly detect Ubuntu (e.g., replace the generic
else with an elif checking [[ "${DISTRIBUTION}" == "Ubuntu" ]]) before running
the Armbian repo swap, installing unudhcpd and calling chroot_sdcard systemctl
enable usbgadget-rndis.service, and leave other distributions to the default
path so systemctl enable is only invoked when the service file is present (refer
to the usbgadget-rndis.service name and
post_family_tweaks_bsp__arduino-uno-q_usb_gadget()).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1e35236d-3b10-4a7b-99c6-763e0163e359

📥 Commits

Reviewing files that changed from the base of the PR and between d88af26 and e2ef212.

📒 Files selected for processing (1)
  • config/boards/arduino-uno-q.csc

Comment on lines +22 to +36
# USB access: adbd on Debian, USB gadget network on Ubuntu (adbd not available)
if [[ "${DISTRIBUTION}" == "Debian" ]]; then
do_with_retries 3 chroot_sdcard_apt_get_install adbd
chroot_sdcard sed -i 's/"Debian"/"Armbian"/' /usr/lib/android-sdk/platform-tools/adbd-usb-gadget
chroot_sdcard sed -i 's/"ADB device"/"Arduino UNO Q"/' /usr/lib/android-sdk/platform-tools/adbd-usb-gadget
chroot_sdcard systemctl enable adbd.service
else
# unudhcpd is in the Armbian repo
mv "${SDCARD}"/etc/apt/sources.list.d/armbian.sources.disabled "${SDCARD}"/etc/apt/sources.list.d/armbian.sources
do_with_retries 3 chroot_sdcard_apt_get_update
do_with_retries 3 chroot_sdcard_apt_get_install unudhcpd
mv "${SDCARD}"/etc/apt/sources.list.d/armbian.sources "${SDCARD}"/etc/apt/sources.list.d/armbian.sources.disabled
do_with_retries 3 chroot_sdcard_apt_get_update
chroot_sdcard systemctl enable usbgadget-rndis.service
fi
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Distribution mismatch: else branch handles all non-Debian, but BSP hook only installs for Ubuntu.

Line 35 enables usbgadget-rndis.service for all non-Debian distributions (the else branch), but the service file is only installed for Ubuntu in post_family_tweaks_bsp__arduino-uno-q_usb_gadget() (line 44: [[ "${DISTRIBUTION}" != "Ubuntu" ]] && return 0).

If a distribution other than Debian or Ubuntu is used, systemctl enable will fail because the service file won't exist.

Consider explicitly checking for Ubuntu:

Proposed fix
-	else
+	elif [[ "${DISTRIBUTION}" == "Ubuntu" ]]; then
 		# unudhcpd is in the Armbian repo
 		mv "${SDCARD}"/etc/apt/sources.list.d/armbian.sources.disabled "${SDCARD}"/etc/apt/sources.list.d/armbian.sources
 		do_with_retries 3 chroot_sdcard_apt_get_update
 		do_with_retries 3 chroot_sdcard_apt_get_install unudhcpd
 		mv "${SDCARD}"/etc/apt/sources.list.d/armbian.sources "${SDCARD}"/etc/apt/sources.list.d/armbian.sources.disabled
 		do_with_retries 3 chroot_sdcard_apt_get_update
 		chroot_sdcard systemctl enable usbgadget-rndis.service
+	else
+		display_alert "USB gadget not configured" "unsupported distribution: ${DISTRIBUTION}" "wrn"
 	fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@config/boards/arduino-uno-q.csc` around lines 22 - 36, The else branch
currently enables usbgadget-rndis.service for all non-Debian DISTROs causing
failure on non-Ubuntu systems because
post_family_tweaks_bsp__arduino-uno-q_usb_gadget() only installs the service on
Ubuntu; change the logic to explicitly detect Ubuntu (e.g., replace the generic
else with an elif checking [[ "${DISTRIBUTION}" == "Ubuntu" ]]) before running
the Armbian repo swap, installing unudhcpd and calling chroot_sdcard systemctl
enable usbgadget-rndis.service, and leave other distributions to the default
path so systemctl enable is only invoked when the service file is present (refer
to the usbgadget-rndis.service name and
post_family_tweaks_bsp__arduino-uno-q_usb_gadget()).

@github-actions github-actions bot added the Ready to merge Reviewed, tested and ready for merge label Apr 8, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

✅ This PR has been reviewed and approved — all set for merge!

@github-actions github-actions bot removed the Needs review Seeking for review label Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

05 Milestone: Second quarter release Framework Framework components Hardware Hardware related like kernel, U-Boot, ... Ready to merge Reviewed, tested and ready for merge size/medium PR with more then 50 and less then 250 lines

Development

Successfully merging this pull request may close these issues.

2 participants