-
Notifications
You must be signed in to change notification settings - Fork 77
Rp2350 riscv32 tool chain #733
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
peterwang2050
merged 7 commits into
radxa-docs:main
from
nascs:rp2350_riscv32_tool-chain
Apr 23, 2025
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5eed8d4
feat: add pico2 riscv32 toolchain installation guide
nascs c2dca35
feat: port pico2-riscv32-toolchain to X5
nascs d09a8f7
fix: hide X5 since it's not released yet
nascs d10b584
Apply suggestions from code review
nascs c7d814e
fix: delete redundant blank lines
nascs 6e2ba16
fix: fix the prefix param of pico2 riscv toolchain
nascs add8541
feat: add rp2350 docs for x5
peterwang2050 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
RP2350 具有两个基于 RISC-V 的 Hazard3 核心和两个基于 Arm 的核心, 在 pico-sdk 和 pico-examples 中也增加了对 RP2350 RISC-V 核心的支持。 | ||
在操作 RISC-V 核心并使用 pico-sdk 和 pico-examples 之前,我们需要先安装对应的 RISC-V 交叉编译工具链。本文将重点讲解如何安装满足 pico-sdk 和 pico-examples 需求的 RISC-V 交叉编译工具链。 | ||
|
||
## 编译环境搭建 | ||
|
||
x86 PC | ||
|
||
Ubuntu 24.04 | ||
|
||
## 安装依赖 | ||
|
||
```bash | ||
sudo apt-get install autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev \ | ||
gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev | ||
``` | ||
|
||
## 编译 RISC-V 32 的工具链 | ||
|
||
- 克隆 RISC-V 32 工具链仓库 | ||
|
||
```bash | ||
git clone https://github.com/riscv-collab/riscv-gnu-toolchain.git | ||
``` | ||
|
||
- 创建输出目录 | ||
|
||
```bash | ||
mkdir /honme/radxa/riscv32_toolchain | ||
``` | ||
|
||
- 编译 | ||
|
||
```bash | ||
cd riscv-gnu-toolchain | ||
|
||
mkdir build | ||
|
||
cd build | ||
|
||
../configure --prefix=/honme/radxa/riscv32_toolchain --with-arch=rv32gc --with-abi=ilp32 --enable-multilib | ||
|
||
make -j$(nproc) | ||
``` | ||
|
||
## 设置环境变量 | ||
|
||
- 将以下这行添加到 /home/radxa/.bashrc 文件中 | ||
|
||
```bash | ||
echo 'export PATH=$HOME/riscv32_toolchain/bin:$PATH' >> ~/.bashrc | ||
``` | ||
|
||
## 验证 | ||
|
||
### 输出版本号 | ||
|
||
```bash | ||
radxa@radxa-Default-string:~$ riscv32-unknown-elf-gcc --version | ||
riscv32-unknown-elf-gcc (g04696df096) 14.2.0 | ||
Copyright (C) 2024 Free Software Foundation, Inc. | ||
This is free software; see the source for copying conditions. There is NO | ||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
|
||
radxa@radxa-Default-string:~$ riscv32-unknown-elf-g++ --version | ||
riscv32-unknown-elf-g++ (g04696df096) 14.2.0 | ||
Copyright (C) 2024 Free Software Foundation, Inc. | ||
This is free software; see the source for copying conditions. There is NO | ||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
``` | ||
|
||
### 看是否符合 pico-sdk 和 pico-examples 的需求 | ||
|
||
- 克隆 pico-sdk 仓库 | ||
|
||
```bash | ||
git clone https://github.com/raspberrypi/pico-sdk.git | ||
|
||
cd pico-sdk | ||
|
||
git submodule update --init | ||
``` | ||
|
||
- 克隆 pico-examples 仓库 | ||
|
||
```bash | ||
git clone https://github.com/raspberrypi/pico-examples.git --branch master | ||
``` | ||
|
||
- 编译 | ||
|
||
<pre> | ||
export PICO_SDK_PATH=path/to/pico-sdk | ||
<!-- prettier-ignore --> | ||
cd pico-examples | ||
<!-- prettier-ignore --> | ||
mkdir build | ||
<!-- prettier-ignore --> | ||
cd build | ||
<!-- prettier-ignore --> | ||
cmake .. -DPICO_PLATFORM=<b>rp2350-riscv</b> && make -j4 | ||
</pre> | ||
|
||
- 验证编译出来的程序是否为 riscv 32 的程序 | ||
|
||
```bash | ||
file blink/CMakeFiles/blink.dir/blink.c.o | ||
blink/CMakeFiles/blink.dir/blink.c.o: ELF 32-bit LSB relocatable, UCB RISC-V, RVC, soft-float ABI, version 1 (SYSV), with debug_info, not stripped | ||
``` | ||
|
||
由此,我们完成了 RP2350 pico-sdk 和 pico-examples 所需要的交叉编译工具链的安装。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
title: "Radxa X5" | ||
description: "Radxa X5" | ||
sidebar_position: 30 | ||
slug: /x/x5 | ||
--- | ||
|
||
# Radxa X5 | ||
|
||
<DocCardList /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
description: "Radxa X5 软件开发" | ||
sidebar_position: 4 | ||
--- | ||
|
||
# 软件开发 | ||
|
||
<DocCardList /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
sidebar_position: 4 | ||
--- | ||
|
||
import TOOLCHAIN from "../../../common/dev/\_pico2-riscv32-toolchain.mdx"; | ||
|
||
# 安装 RISCV32 交叉编译工具链 | ||
|
||
<TOOLCHAIN /> |
110 changes: 110 additions & 0 deletions
110
.../docusaurus-plugin-content-docs/current/common/dev/_pico2-riscv32-toolchain.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
The RP2350 has two RISC-V based Hazard3 cores and two Arm based cores, and support for the RP2350 RISC-V cores has been added to the pico-sdk and pico-examples. | ||
Before working with RISC-V cores and using pico-sdk and pico-examples, we need to install the corresponding RISC-V cross-compilation toolchain. This article will focus on how to install the RISC-V cross-compilation toolchain for pico-sdk and pico-examples. | ||
|
||
## Environment setup | ||
|
||
x86 PC | ||
|
||
Ubuntu 24.04 | ||
|
||
## Install dependencies | ||
|
||
```bash | ||
sudo apt-get install autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev \ | ||
gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev | ||
``` | ||
|
||
## Compile the RISC-V 32 toolchain | ||
|
||
- Clone the RISC-V 32 toolchain repository | ||
|
||
```bash | ||
git clone https://github.com/riscv-collab/riscv-gnu-toolchain.git | ||
``` | ||
|
||
- Create an output directory | ||
|
||
```bash | ||
mkdir /honme/radxa/riscv32_toolchain | ||
``` | ||
|
||
- Compile | ||
|
||
```bash | ||
cd riscv-gnu-toolchain | ||
|
||
mkdir build | ||
|
||
cd build | ||
|
||
../configure --prefix=/honme/radxa/riscv32_toolchain --with-arch=rv32gc --with-abi=ilp32 --enable-multilib | ||
|
||
make -j$(nproc) | ||
``` | ||
|
||
## Set environment variables | ||
|
||
- Add the following line to the /home/radxa/.bashrc file | ||
|
||
```bash | ||
echo 'export PATH=$HOME/riscv32_toolchain/bin:$PATH' >> ~/.bashrc | ||
``` | ||
|
||
## Verify | ||
|
||
### Output version number | ||
|
||
```bash | ||
radxa@radxa-Default-string:~$ riscv32-unknown-elf-gcc --version | ||
riscv32-unknown-elf-gcc (g04696df096) 14.2.0 | ||
Copyright (C) 2024 Free Software Foundation, Inc. | ||
This is free software; see the source for copying conditions. There is NO | ||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
|
||
radxa@radxa-Default-string:~$ riscv32-unknown-elf-g++ --version | ||
riscv32-unknown-elf-g++ (g04696df096) 14.2.0 | ||
Copyright (C) 2024 Free Software Foundation, Inc. | ||
This is free software; see the source for copying conditions. There is NO | ||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
``` | ||
|
||
### See if it meets the requirements of pico-sdk and pico-examples | ||
|
||
- Clone the pico-sdk repository | ||
|
||
```bash | ||
git clone https://github.com/raspberrypi/pico-sdk.git | ||
|
||
cd pico-sdk | ||
|
||
git submodule update --init | ||
``` | ||
|
||
- Clone pico-examples Repository | ||
|
||
```bash | ||
git clone https://github.com/raspberrypi/pico-examples.git --branch master | ||
``` | ||
|
||
- Compile | ||
|
||
<pre> | ||
export PICO_SDK_PATH=path/to/pico-sdk | ||
<!-- prettier-ignore --> | ||
cd pico-examples | ||
<!-- prettier-ignore --> | ||
mkdir build | ||
<!-- prettier-ignore --> | ||
cd build | ||
<!-- prettier-ignore --> | ||
cmake .. -DPICO_PLATFORM=<b>rp2350-riscv</b> && make -j4 | ||
</pre> | ||
|
||
- Verify that the compiled program is for riscv 32 | ||
|
||
```bash | ||
file blink/CMakeFiles/blink.dir/blink.c.o | ||
blink/CMakeFiles/blink.dir/blink.c.o: ELF 32-bit LSB relocatable, UCB RISC-V, RVC, soft-float ABI, version 1 (SYSV), with debug_info, not stripped | ||
``` | ||
|
||
This completes the installation of the cross-compilation toolchain required for the RP2350 pico-sdk and pico-examples. |
10 changes: 10 additions & 0 deletions
10
i18n/en/docusaurus-plugin-content-docs/current/x/x5/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
title: "Radxa X5" | ||
description: "Radxa X5" | ||
sidebar_position: 30 | ||
slug: /x/x5 | ||
--- | ||
|
||
# Radxa X5 | ||
|
||
<DocCardList /> |
8 changes: 8 additions & 0 deletions
8
i18n/en/docusaurus-plugin-content-docs/current/x/x5/software/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
description: "Radxa X5 oftware Development" | ||
sidebar_position: 4 | ||
--- | ||
|
||
# Software Development | ||
|
||
<DocCardList /> |
9 changes: 9 additions & 0 deletions
9
i18n/en/docusaurus-plugin-content-docs/current/x/x5/software/riscv32-tool-chain.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
sidebar_position: 4 | ||
--- | ||
|
||
import TOOLCHAIN from "../../../common/dev/\_pico2-riscv32-toolchain.mdx"; | ||
|
||
# Install the RISCV32 Cross-Compile Toolchain | ||
|
||
<TOOLCHAIN /> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
试试
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不加 "<!-- prettier-ignore -->" 无法转译空行