No edit summary |
|||
(5 intermediate revisions by the same user not shown) | |||
Line 7: | Line 7: | ||
[[File:K230.jpg|thumb]] | [[File:K230.jpg|thumb]] | ||
== | == 快速开始 == | ||
CanMV-K230 Fedora 固件下载地址 | CanMV-K230 Fedora 固件下载地址 | ||
Line 13: | Line 13: | ||
其中 | 其中 | ||
- | |||
rv64-canmv-rv64 (s64lp64+u64lp64) | <pre> | ||
rv32-canmv-rv64 (s64lp64+u32ilp32) | - rv64-canmv-rv64 (s64lp64+u64lp64) | ||
rv32-canmv-rv64ilp32 (s64ilp64 + u32ilp32) | - rv32-canmv-rv64 (s64lp64+u32ilp32) | ||
- rv32-canmv-rv64ilp32 (s64ilp64 + u32ilp32) | |||
</pre> | |||
以下是各个版本的内存开销对比 (相比传统64位 k230,新32位Linux避免39%的内存开销): | 以下是各个版本的内存开销对比 (相比传统64位 k230,新32位Linux避免39%的内存开销): | ||
s64lp64 + u64lp64: | s64lp64 + u64lp64: | ||
- | <pre> | ||
free -h | - free -h | ||
total used free shared buff/cache available | - total used free shared buff/cache available | ||
Mem: 107Mi 39Mi 15Mi 1.0Mi 52Mi 53Mi | - Mem: 107Mi 39Mi 15Mi 1.0Mi 52Mi 53Mi | ||
</pre> | |||
s64lp64 + u32ilp32: | s64lp64 + u32ilp32: | ||
<pre> | |||
free -h | free -h | ||
total used free shared buff/cache available | total used free shared buff/cache available | ||
Mem: 107Mi 33Mi 31Mi 1.0Mi 41Mi 67Mi | Mem: 107Mi 33Mi 31Mi 1.0Mi 41Mi 67Mi | ||
</pre> | |||
s64ilp32 + u32ilp32: | s64ilp32 + u32ilp32: | ||
<pre> | |||
free -h | free -h | ||
total used free shared buff/cache available | total used free shared buff/cache available | ||
Mem: 108Mi 28Mi 41Mi 1.0Mi 38Mi 73Mi | Mem: 108Mi 28Mi 41Mi 1.0Mi 38Mi 73Mi | ||
</pre> | |||
(used: 39MB -> 33MB -> 28MB, Prevent 39% memory waste in s64ilp32 + u32ilp32 | (used: 39MB -> 33MB -> 28MB, Prevent 39% memory waste in s64ilp32 + u32ilp32 | ||
== 固件烧录 == | == 固件烧录 == | ||
首先解压zst文件 | 首先解压zst文件 | ||
<pre> | |||
zstd -d k230-sdcard-fedora_rv32-canmv-rv64ilp32.img.zst | zstd -d k230-sdcard-fedora_rv32-canmv-rv64ilp32.img.zst | ||
</pre> | |||
使用 lsblk 查看TF卡设备路径,假设为/dev/sdb,执行以下指令烧录(谨慎) | 使用 lsblk 查看TF卡设备路径,假设为/dev/sdb,执行以下指令烧录(谨慎) | ||
<pre> | |||
wipefs -a /dev/sdb | wipefs -a /dev/sdb | ||
dd if=k230-sdcard-fedora_rv32-canmv-rv64ilp32.img of=/dev/sdb bs=1M status=progress | dd if=k230-sdcard-fedora_rv32-canmv-rv64ilp32.img of=/dev/sdb bs=1M status=progress | ||
sync | sync | ||
eject | eject | ||
Linux 内核编译 | </pre> | ||
== Linux 内核编译 == | |||
访问 https://github.com/ruyisdk/riscv-gnu-toolchain-rv64ilp32 获取工具链。 | 访问 https://github.com/ruyisdk/riscv-gnu-toolchain-rv64ilp32 获取工具链。 | ||
获取 Linux 内核: | 获取 Linux 内核: | ||
<pre> | |||
git clone https://github.com/ruyisdk/k230-rv64ilp32-linux-kernel.git -b k230-6.6-ilp32-128M --depth=1 | git clone https://github.com/ruyisdk/k230-rv64ilp32-linux-kernel.git -b k230-6.6-ilp32-128M --depth=1 | ||
cd k230-rv64ilp32-linux-kernel | cd k230-rv64ilp32-linux-kernel | ||
</pre> | </pre> | ||
构建传统 s64lp64 Linux 内核: | |||
<pre> | <pre> | ||
make ARCH=riscv CROSS_COMPILE=<YOUR PATH>/riscv/bin/riscv64-unknown-elf- k230_evb_linux_enable_vector_defconfig all | |||
</pre> | </pre> | ||
构建新32位Linux 内核,只需在以上命令附上 64ilp64.config 配置即可,示例如下: | |||
<pre> | <pre> | ||
make ARCH=riscv CROSS_COMPILE=<YOUR PATH>/riscv/bin/riscv64-unknown-elf- k230_evb_linux_enable_vector_defconfig 64ilp32.config all | |||
</pre> | </pre> | ||
Latest revision as of 17:45, 5 March 2024
什么是rv64ilp32?
AIoT技术进步推动了对微控制器(MCU)和应用处理器(AP)更高计算能力的需求,凸显了32位架构的局限。内存访问和原子操作指令难以满足现代系统要求,催生了向64位架构的转型。此转型面临挑战:32位软件在64位硬件上运行时,指针与寄存器宽度不匹配影响性能。为应对这一问题,阿里巴巴-达摩院-玄铁团队提出了松弛扩展寻址模式(Relaxed-Addressing Mode),并与中科院软件所-PLCT实验室联合发布了业界首款RISC-V新32位产品级开源工具链(rv64ilp32 toolchain),专为固件、RTOS 和 Linux内核等设计,优化了性能与成本。新32位Linux内核在性能上大幅超越传统方案,ebpf性能提升300%,iperf-tcp提升17%。 Fedora 社区针对 RISC-V 拥有丰富的软件生态,与传统的64位方案相比,新32位构建能够节省39%的内存。这一优势使 Fedora RISC-V 能在嵌入式领域有更广泛的应用。正因为看到了新32位的潜力,在PLCT实验室的协助下,我们尝试了新32位 Fedora Remix移植,目前已可以运行在嘉楠 k230 开发板上:
快速开始
CanMV-K230 Fedora 固件下载地址
[Release 2024.03.03-128m · ruyisdk/mkimg-k230-rv64ilp32](https://github.com/ruyisdk/mkimg-k230-rv64ilp32/releases/tag/2024.03.03-128m)
其中
- rv64-canmv-rv64 (s64lp64+u64lp64) - rv32-canmv-rv64 (s64lp64+u32ilp32) - rv32-canmv-rv64ilp32 (s64ilp64 + u32ilp32)
以下是各个版本的内存开销对比 (相比传统64位 k230,新32位Linux避免39%的内存开销): s64lp64 + u64lp64:
- free -h - total used free shared buff/cache available - Mem: 107Mi 39Mi 15Mi 1.0Mi 52Mi 53Mi
s64lp64 + u32ilp32:
free -h total used free shared buff/cache available Mem: 107Mi 33Mi 31Mi 1.0Mi 41Mi 67Mi
s64ilp32 + u32ilp32:
free -h total used free shared buff/cache available Mem: 108Mi 28Mi 41Mi 1.0Mi 38Mi 73Mi
(used: 39MB -> 33MB -> 28MB, Prevent 39% memory waste in s64ilp32 + u32ilp32
固件烧录
首先解压zst文件
zstd -d k230-sdcard-fedora_rv32-canmv-rv64ilp32.img.zst
使用 lsblk 查看TF卡设备路径,假设为/dev/sdb,执行以下指令烧录(谨慎)
wipefs -a /dev/sdb dd if=k230-sdcard-fedora_rv32-canmv-rv64ilp32.img of=/dev/sdb bs=1M status=progress sync eject
Linux 内核编译
访问 https://github.com/ruyisdk/riscv-gnu-toolchain-rv64ilp32 获取工具链。
获取 Linux 内核:
git clone https://github.com/ruyisdk/k230-rv64ilp32-linux-kernel.git -b k230-6.6-ilp32-128M --depth=1 cd k230-rv64ilp32-linux-kernel
构建传统 s64lp64 Linux 内核:
make ARCH=riscv CROSS_COMPILE=<YOUR PATH>/riscv/bin/riscv64-unknown-elf- k230_evb_linux_enable_vector_defconfig all
构建新32位Linux 内核,只需在以上命令附上 64ilp64.config 配置即可,示例如下:
make ARCH=riscv CROSS_COMPILE=<YOUR PATH>/riscv/bin/riscv64-unknown-elf- k230_evb_linux_enable_vector_defconfig 64ilp32.config all