Add gpiod support for GPIO buzzer provider (BugFix)#2627
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the CE-OEM buzzer provider to support running GPIO buzzer tests via libgpiod tools (gpioset/gpioget/gpioinfo) while preserving fallback behavior for legacy sysfs GPIO environments, and extends the GPIO_BUZZER resource format to support both global GPIO numbers and chip:line addressing.
Changes:
- Extend
GPIO_BUZZERresource parsing to accept both 3-field and 4-field formats, preserve entry order, and separate records with blank lines. - Add a gpiod-based backend to
buzzer_test.sh, including chip/line resolution, global GPIO mapping, and gpioset lifecycle cleanup. - Update buzzer job templates to pass through
chip:lineports to the test script.
Reviewed changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| contrib/checkbox-ce-oem/checkbox-provider-ce-oem/units/buzzer/jobs.pxu | Extends GPIO_BUZZER parsing and formatting to emit multiple ordered resource records and support chip:line. |
| contrib/checkbox-ce-oem/checkbox-provider-ce-oem/bin/buzzer_test.sh | Adds gpiod backend selection + gpioset control with cleanup, and keeps sysfs fallback for legacy GPIO. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Support GPIO buzzer testing with gpiod line-name resolution while keeping compatibility with legacy numeric sysfs environments. - Prefer gpiod when required tools are available, and resolve the GPIO target by line name. - Fall back to sysfs only when gpiod tools are unavailable, and require a numeric port for that fallback path. - Keep gpioset process lifecycle cleanup to avoid leaving stale line requests after exit. - Keep GPIO_BUZZER parsing compatible with 2-field and 3-field inputs, preserve input order, and emit blank-line-separated records for template job expansion. Signed-off-by: baconYao <bacon735392@gmail.com>
4bc89b1 to
8946a5f
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2627 +/- ##
=======================================
Coverage 59.83% 59.83%
=======================================
Files 485 485
Lines 48736 48736
Branches 8728 8728
=======================================
Hits 29160 29160
Misses 18658 18658
Partials 918 918 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Description
Support GPIO buzzer testing with gpiod line-name resolution while
keeping compatibility with legacy numeric sysfs environments.
Resolved issues
sysfs GPIO is not available for the target kernel path.
Documentation
No
gpiofindcommand in 2.2.1-3 gpiod deb packageflowchart TD A["Start buzzer_test.sh (GPIO mode)"] --> B["main -> setup_gpio_backend"] B --> C{"gpiod tools available?"} C -->|Yes| D{"resolve_gpio_by_name(port) success?"} D -->|No| D1["Fail: cannot resolve GPIO name"] D -->|Yes| E["Use gpiod backend (gpio_chip + gpio_offset)"] C -->|No| F["Fallback to sysfs GPIO export"] F --> G{"Port is numeric only?"} G -->|No| G1["Fail: GPIO name requires gpiod tools"] G -->|Yes| H{"sysfs /sys/class/gpio exists?"} H -->|No| H1["Fail: sysfs GPIO not available"] H -->|Yes| I["Use sysfs backend, export_gpio, set direction"] E --> J["Enable buzzer"] I --> J J --> K{"Backend is gpiod?"} K -->|Yes| L{"run_gpioset(enable) success?"} L -->|No| L1["Fail: unable to set GPIO"] L -->|Yes| M["Ask user: buzzer audible? (y/n)"] K -->|No| N["Write enable to sysfs value"] N --> M M --> O{"User answered y?"} O -->|No| O1["Result: FAILED"] O -->|Yes| P["Disable buzzer"] P --> Q{"Backend is gpiod?"} Q -->|Yes| R{"run_gpioset(disable) success?"} R -->|No| R1["Fail: unable to clear GPIO"] R -->|Yes| S["Ask user: buzzer stopped? (y/n)"] Q -->|No| T["Write disable to sysfs value"] T --> S S --> U{"User answered y?"} U -->|No| U1["Result: FAILED"] U -->|Yes| V["Result: PASSED"] D1 --> W["EXIT trap: cleanup_gpioset"] G1 --> W H1 --> W L1 --> W R1 --> W O1 --> W U1 --> W V --> W W --> END["End"]Tests
Submission: https://certification.canonical.com/hardware/202605-38787/submission/498126/test-results/?term=gpio-buzzer
GPIO_BUZZER=BUZZER_EN:1 FAKE_TEST:1BUZZER_ENis real gpio buzzer to prove the pass scenraioFAKE_TESTis dummy buzzer to prove the failed scenraio