Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 25 additions & 28 deletions IDE/cases/sipeed-lpi4a-ide-hello-world.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Sipeed Lichee Pi 4A: 在 RuyiSDK IDE 中构建 Hello World 项目
# Sipeed Lichee Pi 4A: 在 RuyiSDK IDE 中构建并调试 Hello World 项目

## 测试环境

操作系统: Ubuntu 22.04.5 x86_64
IDE: Eclipse IDE for Embedded C/C++ Developers 2025.12
- 操作系统: Ubuntu 24.04 x86_64
- IDE: Eclipse IDE for Embedded C/C++ Developers 2026-06 (4.40.0)

## 使用 IDE 安装 Ruyi 包管理器

Expand All @@ -29,49 +29,46 @@ IDE: Eclipse IDE for Embedded C/C++ Developers 2025.12

![new-project-3-toolchain](image/sipeed-lpi4a-ide-hello-world/new-project-3-toolchain.jpg)

此时该项目可能无法构建
此时不需要构建该项目

## 为新项目创建虚拟环境

展开顶部菜单栏的 "RuyiSDK",单击 "Venv (Virtual Environments)" 打开 "Ruyi Venv" 视图
在 "Project Explorer" 中右键单击刚才的项目,在 "RuyiSDK" 中单击 "New Venv..." 打开 "New virtual environment" 窗口。在 "Profiles" 中选择 "sipeed-lpi4a";在 "Toolchains" 中选择最新的 "gnu-plct-xthead";勾选 "Emulators" 右侧的 "Enable" 并选择最新的 "qemu-user-riscv-xthead"。完成各项选择后,单击 "Finish" 并等待创建完毕

![menu-ruyi-venv-view](image/sipeed-lpi4a-ide-hello-world/menu-ruyi-venv-view.jpg)
![project-new-venv-conf](image/sipeed-lpi4a-ide-hello-world/project-new-venv-conf.jpg)

单击视图中的 "New virtual environment..." 打开 "New virtual environment" 窗口。在 "Profiles" 中选择 "sipeed-lpi4a";在 "Toolchains" 中选择最新的 "gnu-plct-xthead";勾选 "Emulators" 右侧的 "Enable" 并选择最新的 "qemu-user-riscv-xthead"。完成各项选择后,单击 "Next >"。
## 应用虚拟环境并构建项目

![new-venv-0-conf](image/sipeed-lpi4a-ide-hello-world/new-venv-0-conf.jpg)
在 "Project Explorer" 中右键单击刚才的项目,在 "RuyiSDK" 中单击 "Apply Venv..." 打开 "Apply venv" 窗口。在列表中选择一个虚拟环境并单击 "OK"。

确认 "Summary" 中的信息无误后,在 "Venv Name" 中为新的虚拟环境起名,在 "Venv Path" 中选择刚才创建的项目的路径。完成各项信息填写后,单击 "Finish"。
![project-apply-venv](image/sipeed-lpi4a-ide-hello-world/project-apply-venv.jpg)

![new-venv-1-location](image/sipeed-lpi4a-ide-hello-world/new-venv-1-location.jpg)
请留意提示框中包含的 Run 与 Debug 启动配置的名称。

稍等片刻,窗口自动关闭,"Ruyi Venv" 视图的表格中出现刚才创建的虚拟环境。
![venv-apply-info-dialog](image/sipeed-lpi4a-ide-hello-world/venv-apply-info-dialog.jpg)

## 应用虚拟环境并构建项目
在 "Project Explorer" 中右键单击刚才的项目,单击 "Build Project"。

在 "Ruyi Venv" 视图的表格中选择刚才的虚拟环境,单击 "Apply to Project"。
![project-building](image/sipeed-lpi4a-ide-hello-world/project-building.jpg)

![venv-application](image/sipeed-lpi4a-ide-hello-world/venv-application.jpg)
项目构建成功,生成文件名以 ".elf" 结尾的可执行程序。

在 "Project Explorer" 中右键单击刚才的项目,单击 "Build Project"。
## 使用 QEMU 运行或调试构建出的程序

![project-building](image/sipeed-lpi4a-ide-hello-world/project-building.jpg)
### 运行

在 IDE 顶部工具栏中找到绿色播放按钮,单击其右侧的向下箭头,再单击 "Run Configurations..." 打开 "Run Configurations" 窗口。在左侧列表中展开 "C/C++ Application",找到与刚才的项目和虚拟环境关联的条目。单击 "Run" 运行构建出的程序。

项目构建成功,生成扩展名为 ".elf" 的可执行程序。
![toolbar-run-configuration-result](image/sipeed-lpi4a-ide-hello-world/toolbar-run-configuration-result.jpg)

## 使用 QEMU 运行构建出的程序
程序执行成功。

目前只能手动执行程序,用户可按需修改命令。
### 调试

"Project Explorer" 中右键单击刚才的项目,展开 "Show in Local Terminal",单击 "Terminal" 打开终端并执行下列命令:
IDE 顶部工具栏中找到绿色昆虫按钮,单击其右侧的向下箭头,再单击 "Debug Configurations..." 打开 "Debug Configurations" 窗口。在左侧列表中展开 "C/C++ Remote Application",找到与刚才的项目和虚拟环境关联的条目。单击 "Debug" 调试构建出的程序。

```bash input="1,2,4"
$ source ./.venv/bin/ruyi-activate
«Ruyi .venv» $ ruyi-qemu ./Debug/hello-risc5.elf
Hello RISC-V World!
«Ruyi .venv» $
```
![toolbar-debug-configuration](image/sipeed-lpi4a-ide-hello-world/toolbar-debug-configuration.jpg)

![terminal-execution](image/sipeed-lpi4a-ide-hello-world/terminal-execution.jpg)
![debug-in-progress](image/sipeed-lpi4a-ide-hello-world/debug-in-progress.jpg)

程序执行成功
可见线程、栈帧和数据类型等信息
Loading