# riscv-copilot **Repository Path**: i-share-code/riscv-copilot ## Basic Information - **Project Name**: riscv-copilot - **Description**: OpenCode项目级配置,专为RISC-V64嵌入式Linux和裸机开发设计。 - **Primary Language**: 其他 - **License**: MIT - **Default Branch**: develop - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2026-03-03 - **Last Updated**: 2026-03-04 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # RISC-V64 QEMU Virt OpenCode Configuration OpenCode项目级配置,专为RISC-V64嵌入式Linux和裸机开发设计。 ## 功能特性 ### 智能体 (Agents) | 智能体 | 用途 | |--------|------| | `@linux-kernel-dev` | Linux内核和驱动开发 | | `@baremetal-developer` | 裸机固件开发 | | `@qemu-debugger` | QEMU调试专家 | | `@riscv-asmExpert` | RISC-V汇编优化 | | `@makefile-expert` | Makefile维护 | | `@test-expert` | 测试策略 | ### 自定义命令 | 命令 | 功能 | |------|------| | `/build-linux` | 构建Linux内核/模块 | | `/build-baremetal` | 构建裸机固件 | | `/debug` | 启动QEMU调试会话 | | `/qemu-run` | 运行QEMU虚拟机 | | `/gdb-connect` | 连接GDB stub | | `/disassemble` | 反汇编ELF文件 | | `/run-tests` | 运行测试 | | `/analyze-core` | 分析core dump | ### 技能 (Skills) - `riscv64-asm.md` - RISC-V64汇编编程指南 - `linux-syscall.md` - Linux系统调用参考 - `qemu-virt.md` - QEMU Virt平台配置 - `riscv-gdb.md` - GDB调试技巧 - `openSBI.md` - OpenSBI固件 - `linux-dtb.md` - 设备树 - `baremetal-hal.md` - 裸机硬件抽象层 - `hardware-interface.md` - 硬件接口配置 ### 开发模式 - **kernel-dev** - Linux内核开发 - **userspace-dev** - 用户态开发 - **baremetal-dev** - 裸机开发 - **debug-session** - 调试会话 ### MCP集成 - GDB调试通过MCP调用 --- ## 部署要求 ### 1. 安装工具链 ```bash # Ubuntu/Debian sudo apt install gcc-riscv64-linux-gnu gdb-riscv64-linux-gnu sudo apt install gcc-riscv64-elf gdb-riscv64-elf # 或者从源码编译 # https://github.com/riscv-collab/riscv-gnu-toolchain ``` ### 2. 安装QEMU ```bash # Ubuntu/Debian sudo apt install qemu-system-misc # macOS brew install qemu ``` ### 3. 验证安装 ```bash # 检查工具链 riscv64-unknown-linux-gnu-gcc --version riscv64-unknown-elf-gcc --version # 检查QEMU qemu-system-riscv64 --version ``` --- ## 快速开始 ### 1. 复制配置到项目 将以下文件复制到你的RISC-V项目根目录: ``` your-project/ ├── .opencode/ │ ├── agents/ │ ├── commands/ │ ├── skills/ │ ├── modes/ │ ├── tools/ │ ├── plugins/ │ └── themes/ ├── AGENTS.md └── opencode.json ``` ### 2. 启动OpenCode ```bash opencode . ``` ### 3. 使用示例 ```bash # 构建Linux内核 /build-linux # 构建裸机固件 /build-baremetal # 启动调试 /debug # 连接GDB /gdb-connect ``` --- ## 配置说明 ### opencode.json - **默认模型**: `minimax/minimax-m2.5-free` - **MCP**: GDB调试集成 - **主题**: riscv-dark (深色主题) ### AGENTS.md 包含项目特定规则: - 硬件规格 - 工具链配置 - 构建命令 - 调试流程 - 编码规范 --- ## 项目结构 ``` . ├── .opencode/ # OpenCode配置 │ ├── agents/ # 6个智能体 │ ├── commands/ # 8个命令 │ ├── skills/ # 8个技能 │ ├── modes/ # 4个模式 │ ├── tools/ # 4个工具 │ ├── plugins/ # 插件 │ └── themes/ # 主题 ├── src/ # 源代码 ├── include/ # 头文件 ├── Makefile # 构建文件 ├── linker.ld # 链接脚本 ├── tests/ # 测试 ├── AGENTS.md # 项目规则 ├── opencode.json # 主配置 ├── changes.md # 变更记录 ├── issues.md # 问题记录 └── README.md # 本文件 ``` --- ## 常见问题 ### Q: 工具链不在PATH中 ```bash export PATH=$PATH:/path/to/riscv64-unknown-linux-gnu/bin ``` ### Q: GDB连接失败 确保QEMU已启动并监听1234端口: ```bash qemu-system-riscv64 -gdb tcp::1234 -S ... ``` ### Q: 需要自定义测试框架 修改 `tools/test-runner.md` 中的测试命令以匹配你的项目。 --- ## 扩展配置 ### 添加更多MCP服务器 在 `opencode.json` 中添加: ```json { "mcp": { "gdb": { ... }, "serial": { "command": "screen", "args": ["/dev/ttyUSB0", "115200"] } } } ``` ### 自定义智能体 在 `.opencode/agents/` 目录下创建新的 `.md` 文件。 ### 添加新命令 在 `.opencode/commands/` 目录下创建新的 `.md` 文件。 --- ## 相关文档 - [OpenCode官方文档](https://opencode.ai/docs/) - [RISC-V工具链](https://github.com/riscv-gnu/riscv-collab-toolchain) - [QEMU RISC-V](https://wiki.qemu.org/Features/QEMU-RISCV) - [OpenSBI](https://github.com/riscv/opensbi) --- ## License 本配置基于项目需求定制,可根据需要修改。