RISC-V云测平台:Compiling The Fedora Linux Kernel Natively on RISC-V

图片

图片

 注释:编译Fedora,HS-2 64核RISC-V服务器比Ryzen5700x快两倍!

--- 以下是blog 正文 --- 

# Compiling The Fedora Linux Kernel Natively on RISC-V

## Fedora RISC-V Support

There is ongoing work to Fedora to support RISC-V hardware. As of right now the Fedora documentation officially only shows how to install the distribution on the SiFive HiFive Unleashed 

board. Although there is another board which is unofficially supported by Fedora. This board is the Sispeed LicheePi 4A which I have been planning on getting for Project Andre and Fedora development.

## Setting Up A Fedora Chroot Environment On The PerfXLab System

The PerfXLab RISC-V server is running Ubuntu 22.10, so getting a Fedora environment to compile the kernel in took a bit of tinkering. I knew I needed a container or a chroot environment to

be able to get into the appropriate build environment as not to run into any issues with the build or contaminate the host system.

I started out by looking for a pre-compiled RISC-V Fedora rootfs to use as my chroot environment. During my search I found a pre-built RISC-V raw image. This raw image was perfect! It was

essentially a premade rootfs originally designed for coincidentally the Licheepi 4A and T-Head variants! 

Once I downloaded the image to the PerXLab system I started mounting the raw image as a loopback device. One of the easiest ways to dissect a raw image is by doing this quick hack! I then

found the root partition (usually the largest partition) then mounted it, so I can work on chrooting into it. 

Once I got the partition mounted I started setting up the pre-requisites for a fully functioning chroot environment. I reffered to the trust Linux From Scratch book like I often do with

this type of work and started mounting the virtual kernel filesystems. 

```

# Just for ease of running the commands :)

LFS="/home/maxinehayes90/fedora_rv_mnt"

# Populate /dev

sudo mount -v --bind /dev $LFS/dev

# Mount virtual kernel filesystems

mount -v --bind /dev/pts $LFS/dev/pts

mount -vt proc proc $LFS/proc

mount -vt sysfs sysfs $LFS/sys

mount -vt tmpfs tmpfs $LFS/run

```

Now that /dev and the VKFS are mounted I could chroot into the Fedora rootfs by simply just running ```sudo chroot $LFS /bin/bash```. In the chroot I made sure to test if I had a network

connection by running a dnf search for a package. I got an error where dnf couldn't download the metadata, so I made sure to copy /etc/resolv.conf on the host to the chroot environment. I

then ran into the issue of not being able to copy it due to it being a symlink. Once I tracked down the symlink I saw that it was pointed to /run/systemd/resolve/stub-resolv.conf. I copied

this file into the chroot as /etc/resolv.conf. Success! Dnf was able to download the metadata! 

## Building The Fedora Kernel In The Chroot Environment

For Fedora there is a Koji that supplies RISC-V package builds. I went to the Koji hosted at http://fedora.riscv.rocks/koji/ and downloaded the kernel source RPM into the chroot using wget.

To build the kernel source I initially installed mock and looked for a RISC-V config. I unfortunately didn't find one it in /etc/mock. After finding that out I went with plan b by using rpmbuild. 

To build the source code with rpmbuild I first had to install the dependencies that the specfile requires using ```dnf builddep SPECS/kernel.spec```. Once I did that I was set to build the kernel! I started the build using ```time rpmbuild -bb SPECS/kernel.spec``` then waited a few minutes to see if it would error which it did after about 7 minutes. So I tried a different

version of the kernel which had the same issue. After walking away for a while I relized what the error was. I ran out of disk space in the chroot! 

The root partition I mounted and chrooted into was only a few gigabytes in size and when building the kernel I had forgotten this detail. What I did to resolve the issue was to unmount all

of the virtual kernel filesystems and /dev. I then copied the mounted rootfs to a directory on the host. After that I remounted the VKFS then chrooted back in where I restarted the build.

Once I restarted the build I sat and waited again for about 20 minutes to see if I would run into another error. When I was sure there wouldn't be the possibility of an error I walked away

and came back the next day to find it build without any issues! To my surprise the build took 1 hour and 37 minutes to complete!

## Resources

Image used: https://openkoji.iscas.ac.cn/pub/dl/riscv/T-Head/th1520_light/images/fedora-disk-minimal_thead_th1520-f38-20230511-210358.n.0-sda.raw.xz

Fedora T-Head Documentation: https://fedoraproject.org/wiki/Architectures/RISC-V/T-Head

Linux From Scratch VKFS Page: https://www.linuxfromscratch.org/lfs/view/stable/chapter07/kernfs.html

PerfXLab (Thank you Paul Wang for giving me access to the RISC-V Server!): http://www.perfxlab.com/

  • About HS-2

HS-2 RISC-V通用主板是澎峰科技与合作伙伴共同研发的一款专为开发者设计的标准mATX主板,它预装了澎峰科技为RISC-V高性能服务器定制开发的软件包,包括各种标准bencmark、支持V扩展

的GCC编译器、计算库、中间件以及多种典型服务器应用程序。

HS-2 RISC-V通用主板搭载了一颗国产RISC-V 64核处理器(SG2042)。SG2042是目前已量产的性能最高的RISC-V处理器,主要针对高性能计算领域需求设计,适用于科学计算、工程计算、AI计算、融合计算等大算力应用场景。

图片

RISC-V公共测试云平台系列文章

1. RISC-V公测平台发布 ·Stream带宽完整测试

2. RISC-V公测平台发布 · 我的世界MohistMC

3. RISC-V公测平台发布 · 第一个WEB Server“Hello RISC-V world!”

4. RISC-V公测平台发布 ·如何在SG2042上玩转k3s

5.“RISC-V成长日记” blog发布,第一个运行在RISC-V服务器上的blog?

6. RISC-V公测平台发布:如何在SG2042上玩转OpenMPI

7. RISC-V公测平台发布:Compiling The Fedora Linux Kernel Natively on RISC-V(本篇)

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/58912.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

机器学习基础知识(1)

什么是机器学习 机器学习是一种通过输入大量数据来构建一种模型(网络),这个训练好的模型将会被用来预测或执行某些操作,这个训练的过程和方法就是机器学习。 我们也可以理解为构建一个“函数”,使得这个函数面对我们…

【项目学习1】如何将java对象转化为XML字符串

如何将java对象转化为XML字符串 将java对象转化为XML字符串,可以使用Java的XML操作库JAXB,具体操作步骤如下: 主要分为以下几步: 1、创建JAXBContext对象,用于映射Java类和XML。 JAXBContext jaxbContext JAXBConte…

三、web核心防御机制(下)

文章目录 核心防御机制2.3处理攻击者2.3.1 处理错误2.3.2 维护审计日志2.3.3 向管理员发出警报2.3.4 应对攻击 2.4 管理应用程序 核心防御机制 2.3处理攻击者 任何设计安全应用程序的开发人员必须基于这样一个假设:应用程序将成为蓄意破坏且经验丰富的攻击者的直接…

Semantic Kernel 入门系列:Memory内存

了解的运作原理之后,就可以开始使用Semantic Kernel来制作应用了。 Semantic Kernel将embedding的功能封装到了Memory中,用来存储上下文信息,就好像电脑的内存一样,而LLM就像是CPU一样,我们所需要做的就是从内存中取出…

部署模型并与 TVM 集成

本篇文章译自英文文档 Deploy Models and Integrate TVM tvm 0.14.dev0 documentation 更多 TVM 中文文档可访问 →Apache TVM 是一个端到端的深度学习编译框架,适用于 CPU、GPU 和各种机器学习加速芯片。 | Apache TVM 中文站 本节介绍如何将 TVM 部署到各种平台&…

现代C++中的从头开始深度学习:【5/8】卷积

一、说明 在上一个故事中,我们介绍了机器学习的一些最相关的编码方面,例如 functional 规划、矢量化和线性代数规划。 现在,让我们通过使用 2D 卷积实现实际编码深度学习模型来开始我们的道路。让我们开始吧。 二、关于本系列 我们将学习如何…

【阻止IE强制跳转到Edge浏览器】

由于微软开始限制用户使用Internet Explorer浏览网站,IE浏览器打开一些网页时会自动跳转到新版Edge浏览器,那应该怎么禁止跳转呢? 1、点击电脑左下角的“搜索框”或者按一下windows键。 2、输入“internet”,点击【Internet选项…

springboot工程使用阿里云OSS传输文件

在application.yml文件中引入对应的配置,一个是对应的节点,两个是密钥和账号,还有一个是对应文件的名称; 采用这样方式进行解耦,便于后期修改。 然后需要设置一个properties类,去读对应的配置信息 用到了…

【前端】Vue生命周期函数(详细讲解+中文图解)

目录 一、何为生命周期1、含义2、理解 二、生命周期定义(官网)1、vue22、vue3 三、生命周期图解1、vue2生命周期图解2、vue3生命周期图解 四、Vue的生命周期五、Vue2生命周期和Vue3生命周期的区别六、Vue生命周期的主要阶段以及8个周期函数1、options AP…

使用MyEclipse如何部署Descriptor (XML)编辑器?

Descriptor (XML) Editor编辑器包含了高级的XML编辑功能,在本文中您将了解到这些编辑功能、Web XML编辑等,此功能包含在MyEclipse中可用。 MyEclipse v2023.1.2离线版下载 1. Web XML 编辑器 MyEclipse Web XML编辑器包括高级XML编辑功能,…

OpenLayers入门,OpenLayers涂鸦手绘线条、圆形和多边形,涂鸦线条自动收尾连接成多边形

专栏目录: OpenLayers入门教程汇总目录 前言 本章再次讲解OpenLayers绘制图形功能,上一章中《OpenLayers图形绘制,OpenLayers实现在地图上绘制线段、圆形和多边形》我们已经讲过多种图形的绘制,本章主要讲解自由涂鸦手绘绘制线条,圆形和任意形状。 二、依赖和使用 &q…

C#在自动化领域的应用前景与潜力

人机界面(HMI)开发:使用C#开发人机界面软件,实现与自动化设备的交互和监控。C#的图形界面设计能力和丰富的控件库使得开发人员能够创建直观、易用的界面。 数据采集与处理:C#可以与各种传感器、设备进行数据通信和采集…