From Fedora Project Wiki
Idea.png
您有疑问?
请加入 Fedora riscv 的 IRC: #fedora-riscv[?] 位于 Libera

在Lichee Pi 4A上启动Fedora 38的最简说明

Lichee Pi 4A is a single board computer (SBC) powered by Alibaba T-Head TH1520 quad-core RISC-V Xuantie C920 processor @ 2.0 GHz with an Imagination GPU and a 4 TOPS NPU for AI . This is a placeholder page to collect all information about running Fedora on T-Head platform.

Not: Currently T-Head platform is not officially supported by Fedora community.


预编译的镜像文件

We have prebuild image for TH1520 platform. You can download from here.

For booting it on TH1520 platform, what you need to do just:

解压镜像文件

unxz fedora-disk-multi-desktops_thead_th1520-f38-20230516-002100.n.0-sda.raw.xz

写入一个TF卡 (必须大于或等于16GB)

sudo wipefs -a /dev/sdX
sudo dd if=fedora-disk-multi-desktops_thead_th1520-f38-20230516-002100.n.0-sda.raw of=/dev/sdX status=progress bs=4M

请在烧录前一定要使用wipefs清理备份的GPT分区表,否则会出现这种问题:Architectures/RISC-V/Allwinner/zh-cn#内核无法访挂载rootfs

对于dd命令,有一个GUI工具:balena-etcher-electron,简单好用,但wipefs依然是必须在之前执行,切记!

烧入针对特定的开发板的 u-boot 到 EMMC

Once you flash the Image into SD card, you can get the u-boot for the specific board in boot partition. For example, for Lichee Pi 4A, the u-boot binary path is <boot partition>/u-boot-with-spl_lpi4a.bin.

Plaese flash it into EMMC by the fastboot command of android-tools package:

sudo fastboot flash uboot /path/to/u-boot-with-spl_lpi4a.bin ;sudo fastboot reboot
sleep 10
sudo fastboot flash uboot /path/to/u-boot-with-spl_lpi4a.bin ;sudo fastboot reboot

Note: the modified u-boot can boot Fedora Image from SD automatically by

  • 1, import uboot_thead_th1520.env from efi partition
  • 2, import uEnv_thead_th1520.txt from boot partition
  • 3, sysboot with extlinux/extlinux.conf

插入TF卡并上电

  • 默认从 HDMI 显示:

硬件信息

IP 信息

平头哥: 玄铁 C920 RISC-V

T-Head Wujian 600 has been tailored specifically for developing edge SoCs. With enhanced CPU capability and heterogeneous architecture for high-performance embedded and edge products, the platform facilitates the design of SoCs in embedded applications, including home robots, medical imaging and video conferencing. It also includes an optimised software stack to help speed up the rollout of products to the market.

Available for licensing, the platform aims to aid global developers by reducing the development costs and shortening the design cycle of chips, making the mass production of RISC-V based high-performance SoCs a reality.

The Alibaba T-Head TH1520 quad-core Xuantie C920 processor clocked at up to 2.5GHz with a 4 TOPS NPU, and support for 64-bit DDR at up 4266 MT.

The TH1520 is born out of the Wujian 600 platform unveiled by Alibaba in August 2022, and is capable of running desktop-level applications such as Firefox browser and LibreOffice office suite on Fedora 37, 38 and more.

Soc & Development boardinfo =

T-Head: [https:// TH1520 SoC Introduction]

Software

[[File: |center|1024px]]

Reference source code

Original source code

  • T-Head: [https:// ]
  • Alternative: [https:// ]

Tekkaman's REPO

Tekkaman REPOs for Fedora Image

Firmware Build order

OpenSBI

RISC-V Open Source Supervisor Binary Interface, like arm-TF

Tekkaman's OpenSBI REPO

Build binary
git clone https://github.com/tekkamanninja/opensbi -b master
pushd opensbi
CROSS_COMPILE=riscv64-linux-gnu- PLATFORM=generic FW_PIC=y BUILD_INFO=y make
popd

The build/platform/generic/firmware/fw_dynamic.bin will be used to make u-boot.toc1 below.

U-boot

Using Smaeul's patches, but enable more features and add some default env for auto-booting into GRUB, and also rebase to the latest upstream U-boot.

Tekkaman's U-boot REPO

Build binary
git clone https://github.com/tekkamanninja/u-boot -b 
pushd u-boot
make CROSS_COMPILE=riscv64-linux-gnu- ARCH=riscv _defconfig
make CROSS_COMPILE=riscv64-linux-gnu- ARCH=riscv menuconfig
make CROSS_COMPILE=riscv64-linux-gnu- ARCH=riscv u-boot.bin u-boot.dtb
popd

Flash u-boot.bin to EMMC

sudo fastboot flash uboot /path/to/u-boot-with-spl_lpi4a.bin ;sudo fastboot reboot
sleep 10
sudo fastboot flash uboot /path/to/u-boot-with-spl_lpi4a.bin ;sudo fastboot reboot

Linux kernel from T-Head

[http://]

Linux kernel for upstream

Important reference
  • [https://]


Build Linux Kernel for TH1520
Checkout Source
git clone https://github.com/
pushd linux
git checkout 
popd

Branches: * are all for TH1520

Config
pushd linux
make CROSS_COMPILE=riscv64-linux-gnu- ARCH=riscv _defconfig
make CROSS_COMPILE=riscv64-linux-gnu- ARCH=riscv menuconfig
popd
Cross Build and install
# RISCV_ROOTFS_BOOT is the mount point of the boot partition in SD card 
# RISCV_ROOTFS_BOOT=/run/media/../boot
# RISCV_ROOTFS  is the mount point of the Fedora rootfs partition in SD card 
# RISCV_ROOTFS=/run/media/../rootfs
pushd linux
make CROSS_COMPILE=riscv64-linux-gnu- ARCH=riscv
make CROSS_COMPILE=riscv64-linux-gnu- ARCH=riscv INSTALL_PATH=${RISCV_ROOTFS_BOOT} zinstall
make CROSS_COMPILE=riscv64-linux-gnu- ARCH=riscv INSTALL_MOD_PATH=${RISCV_ROOTFS} modules_install
popd

How to Build RPM package for TH1520

using rpmbuild on QEMU

How to boot Fedora on QEMU, please reference Architectures/RISC-V/Build Bootable Image#Run_Fedora_on_QEMU

  • Boot into Fedora on QEMU, then:
  1. prepare directory tree: Put spec file to /rpmbuild/SPECS and all source files to /rpmbuild/SOURCES
  2. For building RPM package:
#From spec file
$ rpmbuild -ba ~/rpmbuild/SPECS/pakcage.spec

#'''OR''' to build from an existing SRPM file:
$ rpmbuild -ra package.src.rpm

Please reference to How to Create a GNU Hello World RPM Package for more RPM info.

using mock with Qemu usermod

We also can build riscv64 RPMS on x86_64 machine by mock and Qemu usermode.[WIP]

How to Build your own Fedora Remix Image

Please reference to RISC-V: Build Bootable Image

How to make TH1520 as a Koji Builder WIP

If we have already deployed a koji hub(like openkoji,then we can add a TH1520 as koji builder.

For example:

Please follow the simple instruction below:

  • NEED: koji CA certificate and builder authentication certificate: They are provided by koji hub admin.
  • Install necessary packages
# dnf install koji-builder
  • Modifying /etc/kojid.conf
  1. server=<koji hub XMLRPC server URL>
  2. topurl=<koji HTT file share URL>
  3. allowed_scms=<SCM repo rules>
  4. cert=<builder certificate>
  5. serverca=<koji CA certificate>
  • Trust koji hub's CA cert
cp koji_ca_cert.crt /etc/pki/ca-trust/source/anchors/
update-ca-trust
  • add host on koji hub (operated by koji hub admin)
koji add-host <hostname> riscv64
#The *hostname* should be same in authentication certificate.
  • Enable and start kojid
systemctl enable --now kojid
  • Verify koji builder online on koji hub (operated by koji hub admin):
koji list-hosts
# After initialization: The new added builder's status should be ready in the list.
  • NOTICE:* builder won't ready until free space on /var/lib/mock is greater than 8GiB, and /var/lib/mock on NFS is not supported. Thus, using a high capacity SD card for builder and resize root file system to adapt all free space on SD is necessary.