首页 > 系统相关 >RISC-V云测平台:Compiling The Fedora Linux Kernel Natively on RISC-V

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

时间:2023-08-08 19:23:24浏览次数:42  
标签:kernel chroot Natively Fedora Kernel into RISC build

 

 

注释:编译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. 发邮件到 [email protected] 进行申请

2. 加入微信讨论群:加iYuta-R2为好友后可拉入群

3. 加入QQ讨论群:906962594(RVBoards·Only RISC-V)

 

 

  • 关于RISC-V公共测试平台

     

    RISC-V高性能处理器公共测试云平台 ·快速使用指南,下载链接:https://www.kdocs.cn/l/cmnYcyFIlVRx

  • "RISC-V成长日志"BLOG

这是第一个运行在RISC-V服务器上的正式BLOG,它记录RISC-V社区的一些关于成长的动态。欢迎收藏!

htpp://blog.rvv.top:8002

 

标签:kernel,chroot,Natively,Fedora,Kernel,into,RISC,build
From: https://www.cnblogs.com/lsxd/p/17615182.html

相关文章

  • RISC-V架构的演变
    随着苹果基于ARM的硅和新的RISC-VCPU的推出,对于CPU开发来说,这是一个令人兴奋的时刻,尽管开发人员的旅程目前对后者来说有点坎坷。我最喜欢的理论是,没有发生是孤独的,而只是重复了以前发生过的事情,也许经常发生过。马克·吐温认为,生活有重演的倾向。我们可以在苹果Macintosh的CPU......
  • Linux设备树的传递及Kernel中对设备树的分析
    当U-Boot将设备树加载到内存指定位置后,ARM内核的SoC以通用寄存器r2来传递dtb在内存中的地址。kernel获取到该地址后对dtb文件做进一步的处理。设备树的传递当使用bootm加载kernel镜像时(bootz是对bootm的一种封装以及功能扩展,实质一样)。U-Boot跳转到k......
  • 架设传奇技术教程同目录下无法找到DLL文件"KERNELBASE"处理办法
    同目录下无法找到DLL文件:"KERNELBASE"】.请与作者联系.的弹窗办法和解决架设传奇版本启动引擎或者启动没多久的时候经常遇到弹窗提示【同目录下无法找到DLL文件:"KERNELBASE"】.请与作者联系.的弹窗,如上图所示,下面我来给大家介绍下如何解决这个问题。一般出现这个问题都是windows200......
  • /proc/sys/kernel 、 /proc/sys 、 /sys
    /proc/sys/kernel目录下的常用文件说明core_pattern:指定生成core文件的模式。core_uses_pid:指定是否在core文件名中包含进程ID。ctrl-alt-del:指定按下Ctrl+Alt+Del时系统的行为。dmesg_restrict:指定是否限制非特权用户访问dmesg命令。domainname:指定系统的域名。hostname:指......
  • 64核RISC-V服务器能打了吗?
    最近看到“澎峰科技”的微信公众号,看到他们发布了第一款RISC-V服务器,芯片是算能的SG2042,带64个RISC-V核心(阿里平头哥的C910v核),2.0GHz主频,最大支持128GB内存。这应该算是全球第一款RISC-V服务器吧,找了一些资料。和大家一起品品。处理器采用贴片,不是那种socket。没什么好评论的。......
  • kernel: oracle (xxxx): Using mlock ulimits for SHM_HUGETLB is deprecated
    Oracle数据库运行在linux6/7中,启用大页之后,我们经常在/var/log/messages里面会看到类似这样的记录:Jul3109:46:27p1erpdb01kernel:oracle(6444):UsingmlockulimitsforSHM_HUGETLBisdeprecated.-------官方文档HowToAddanon-rootgrouptohugetlb_shm_grou......
  • QEMU启动RISC-V架构OpenEuler并配置OSC环境
    基于Ubuntu18.04,QEMU8.0.2,OpenEuler22.09安装QEMU安装基础编译工具sudoaptinstallbuild-essentialautoconfautomakeautotools-devpkg-configbccurl\gawkgitbisonflextexinfogperflibtoolpatchutilsmingw-w64libmpc-dev\......
  • kernel源码(二十四)文件系统
     1minix文件系统minix文件系统磁盘结构如下所示图中,整个磁盘被划分为360个磁盘块(每个磁盘块1Kb)引导块,MBR就在这个磁盘块中。当计算机加电,ROMBIOS将会自动读取该磁盘块到内存并执行其中的代码。分区,一块磁盘,我们可以最多有4个主分区。MBR大小为一个扇区大小,其中446byte......
  • 编译RHEL 8.7 kernel 并重新安装
    背景:最近遇到一个bug,需要修改RHEL8.7kernelconfig的配置参数,然后重新安装该kernel。踩过一些坑,复盘整理。查询当前的kerneluname-r4.18.0-477.15.1.el8_8.x86_64这是当前运行的内核版本。版本号的不同部分表示以下信息:•4.18.0:内核的主版本号、次版本号和发布版本号......
  • QEMU 加载 uboot kernel 实例
    根文件系统放在SD卡qemu-system-arm-Mmcimx6ul-evk\-m512M\-kernel./zImage\-dtb./imx6ul-14x14-evk.dtb\-nographic\-devicesd-card,drive=mysdcard\-......