Skip to content

Add GPIO LED blinker and PUD test for VisionFive2 Lite#12

Open
zhiyao310 wants to merge 12 commits into
ruyisdk:mainfrom
zhiyao310:main
Open

Add GPIO LED blinker and PUD test for VisionFive2 Lite#12
zhiyao310 wants to merge 12 commits into
ruyisdk:mainfrom
zhiyao310:main

Conversation

@zhiyao310
Copy link
Copy Markdown
Contributor

@zhiyao310 zhiyao310 commented May 26, 2026

Summary

This PR adds two GPIO-related documents for the VisionFive2 Lite board:

  1. boards/VisionFive2 Lite/GPIO_LED_Blink/README_zh.md: LED blink example.
  2. boards/VisionFive2 Lite/GPIO_PUD/README_zh.md: GPIO pull-up/down test.

Test Environment

  • Board: VisionFive2 Lite (eMMC version)
  • RuyiSDK: Installed via official guide (latest version)
  • Toolchain: gnu-plct (installed via ruyi install gnu-plct)

Test Results

Both example programs were compiled and executed successfully on the board. The outputs match the documented results.

Summary by Sourcery

Add Chinese-language GPIO usage guides for the VisionFive2 Lite board, covering an LED blink demo and a GPIO pull-up/down verification demo using RuyiSDK and the gnu-plct toolchain.

Documentation:

  • Document an LED blink example on VisionFive2 Lite using sysfs GPIO control and RuyiSDK toolchain setup steps.
  • Document a GPIO pull-up/down test on VisionFive2 Lite, including environment setup, sample code, and expected output.

zhiyao310 added 2 commits May 26, 2026 22:45
Perform GPIO PUD verification on VisionFive 2 Lite
Performing an LED blink benchmark test on the VisionFive 2 Lite
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented May 26, 2026

Reviewer's Guide

Adds two Chinese-language GPIO how-to documents for the VisionFive2 Lite board, covering an LED blink example and a GPIO pull-up/down verification, including full environment setup, code samples using Linux sysfs GPIO, compilation with the Ruyi gnu-plct toolchain, and run/teardown instructions.

Sequence diagram for VisionFive2 Lite LED blink example

sequenceDiagram
    actor User
    participant led_blink
    participant SysfsGPIO as Sysfs_GPIO

    User->>led_blink: run led_blink
    led_blink->>SysfsGPIO: gpio_export(GPIO_PIN)
    led_blink->>SysfsGPIO: gpio_set_output(GPIO_PIN)
    loop blink
        led_blink->>SysfsGPIO: gpio_set_value(GPIO_PIN, 1)
        led_blink->>User: print LED ON
        led_blink->>SysfsGPIO: gpio_set_value(GPIO_PIN, 0)
        led_blink->>User: print LED OFF
    end
Loading

Sequence diagram for VisionFive2 Lite GPIO PUD verification example

sequenceDiagram
    actor User
    participant gpio_pud_test
    participant SysfsGPIO as Sysfs_GPIO

    User->>gpio_pud_test: run gpio_pud_test
    gpio_pud_test->>SysfsGPIO: gpio_export(TEST_GPIO_PIN)
    gpio_pud_test->>SysfsGPIO: gpio_set_dir_in(TEST_GPIO_PIN)
    gpio_pud_test->>SysfsGPIO: gpio_set_pud_mode(TEST_GPIO_PIN, up)
    gpio_pud_test->>SysfsGPIO: gpio_read_value(TEST_GPIO_PIN)
    gpio_pud_test->>User: print Pull-Up Mode GPIO Level
    gpio_pud_test->>SysfsGPIO: gpio_set_pud_mode(TEST_GPIO_PIN, down)
    gpio_pud_test->>SysfsGPIO: gpio_read_value(TEST_GPIO_PIN)
    gpio_pud_test->>User: print Pull-Down Mode GPIO Level
    gpio_pud_test->>User: print PUD Demo Run Complete
Loading

File-Level Changes

Change Details Files
Add GPIO pull-up/down (PUD) verification guide for VisionFive2 Lite using sysfs GPIO and RuyiSDK toolchain.
  • Document RuyiSDK and gnu-plct installation prerequisites on Debian 12 for RISC-V.
  • Describe creating and activating a dedicated ruyi virtual environment for GPIO tests.
  • Provide full C example source code that exports a GPIO pin, sets it as input, toggles internal pull-up/down via /sys/class/gpio pull attribute, and reads back pin level.
  • Show static compilation command using riscv64-plct-linux-gnu-gcc and expected runtime output, including cleanup steps.
VisionFive2Lite/GPIO_PUD/README_zh.md
Add LED blink baseline test guide for VisionFive2 Lite using sysfs GPIO and RuyiSDK toolchain.
  • Document installation of libgpiod-dev dependency plus RuyiSDK and gnu-plct toolchain setup.
  • Describe creating and activating a separate ruyi virtual environment for the LED test.
  • Provide full C example source code that exports a GPIO pin, sets it as output, toggles its value in an infinite loop via /sys/class/gpio value attribute, and prints LED state to stdout.
  • Show compilation command using riscv64-plct-linux-gnu-gcc and expected blinking output plus environment deactivation steps.
VisionFive2Lite/GPIO_LED/README_zh.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 3 issues, and left some high level feedback:

  • In VisionFive2Lite/GPIO_PUD/README_zh.md, the narrative mentions using libgpiod and GPIO31, but the example code uses the sysfs interface and TEST_GPIO_PIN 44; consider aligning the text, pin number, and described library with the actual code or updating the code to match the description.
  • In the PUD README, the file name in the instructions (gpio_pud_test.c vs gpio_pud_test.cpp) is inconsistent; standardize on one name and extension so users can follow the steps without confusion.
  • In VisionFive2Lite/GPIO_LED/README_zh.md, you install libgpiod-dev and the section title refers to compiling a GPIO PUD test, but the example uses the sysfs GPIO interface for LED blinking; adjust the dependency list and section heading so they accurately reflect the example’s implementation.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `VisionFive2Lite/GPIO_PUD/README_zh.md`, the narrative mentions using libgpiod and GPIO31, but the example code uses the sysfs interface and `TEST_GPIO_PIN 44`; consider aligning the text, pin number, and described library with the actual code or updating the code to match the description.
- In the PUD README, the file name in the instructions (`gpio_pud_test.c` vs `gpio_pud_test.cpp`) is inconsistent; standardize on one name and extension so users can follow the steps without confusion.
- In `VisionFive2Lite/GPIO_LED/README_zh.md`, you install `libgpiod-dev` and the section title refers to compiling a GPIO PUD test, but the example uses the sysfs GPIO interface for LED blinking; adjust the dependency list and section heading so they accurately reflect the example’s implementation.

## Individual Comments

### Comment 1
<location path="VisionFive2Lite/GPIO_PUD/README_zh.md" line_range="58" />
<code_context>
+     nano gpio_pud_test.c
+     ```
+
+     将以下代码粘贴进`gpio_pud_test.cpp`:
+
+     ```c
</code_context>
<issue_to_address>
**issue (typo):** File extension in the text (`.cpp`) doesn’t match the file created with nano (`.c`).

You have users create `gpio_pud_test.c`, but then refer to `gpio_pud_test.cpp`. Please align the filename in both places to use the same extension.

```suggestion
     将以下代码粘贴进`gpio_pud_test.c`:
```
</issue_to_address>

### Comment 2
<location path="VisionFive2Lite/GPIO_PUD/README_zh.md" line_range="9-18" />
<code_context>
+status: gpio
+last_update: 2026-05-24
+
+model: VisionFive2 Lite
+profile: GPIO_LED Blink
+
</code_context>
<issue_to_address>
**suggestion (typo):** Inconsistent spelling of the board name (`VisionFive2` vs `VisionFive 2`).

The front matter uses `VisionFive2 Lite`, while the section heading uses `VisionFive 2 Lite`. Please standardize on one spelling across the document for consistency and searchability.

Suggested implementation:

```
model: VisionFive 2 Lite

```

To fully implement the suggestion, update all other occurrences of the board name in this document (e.g. section headings, paragraphs, code comments) so they consistently use `VisionFive 2 Lite` instead of `VisionFive2 Lite`.
</issue_to_address>

### Comment 3
<location path="VisionFive2Lite/GPIO_LED/README_zh.md" line_range="49" />
<code_context>
+  . ~/led-env/bin/ruyi-activate
+  ```
+
+- #### 使用 ruyi 工具链编译 GPIO PUD 测试代码
+
+  1. **创建测试代码目录并编写代码**
</code_context>
<issue_to_address>
**issue (typo):** Section title mentions "GPIO PUD" in an LED blink example, which looks like a copy-paste error.

Please update the header to match the LED blink example, for instance by renaming it to “GPIO LED 测试代码” or similar.

```suggestion
- #### 使用 ruyi 工具链编译 GPIO LED 测试代码
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

nano gpio_pud_test.c
```

将以下代码粘贴进`gpio_pud_test.cpp`:
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.

issue (typo): File extension in the text (.cpp) doesn’t match the file created with nano (.c).

You have users create gpio_pud_test.c, but then refer to gpio_pud_test.cpp. Please align the filename in both places to use the same extension.

Suggested change
将以下代码粘贴进`gpio_pud_test.cpp`:
将以下代码粘贴进`gpio_pud_test.c`:

Comment on lines +9 to +18
model: VisionFive2 Lite
profile: GPIO_PUD

---

# RuyiSDK GPIO功能示例

- **安装依赖包**

```bash
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.

suggestion (typo): Inconsistent spelling of the board name (VisionFive2 vs VisionFive 2).

The front matter uses VisionFive2 Lite, while the section heading uses VisionFive 2 Lite. Please standardize on one spelling across the document for consistency and searchability.

Suggested implementation:

model: VisionFive 2 Lite

To fully implement the suggestion, update all other occurrences of the board name in this document (e.g. section headings, paragraphs, code comments) so they consistently use VisionFive 2 Lite instead of VisionFive2 Lite.

Comment thread VisionFive2Lite/GPIO_LED/README_zh.md Outdated
. ~/led-env/bin/ruyi-activate
```

- #### 使用 ruyi 工具链编译 GPIO PUD 测试代码
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.

issue (typo): Section title mentions "GPIO PUD" in an LED blink example, which looks like a copy-paste error.

Please update the header to match the LED blink example, for instance by renaming it to “GPIO LED 测试代码” or similar.

Suggested change
- #### 使用 ruyi 工具链编译 GPIO PUD 测试代码
- #### 使用 ruyi 工具链编译 GPIO LED 测试代码

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant