- Install dependencies.
sudo apt-get install autoconf automake autotools-dev curl python3 libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev ninja-build uuid-dev gcc-riscv64-unknown-elf
- Clone repository (maybe you have done this).
git clone https://github.com/sophgo/sophgo-edk2.git
- Enter repository.
cd sophgo-edk2
- Init submodules.
git submodule sync git submodule update --init --recursive
- Setup environments.
export WORKSPACE=`pwd` export PACKAGES_PATH=$WORKSPACE/edk2:$WORKSPACE/edk2-platforms:$WORKSPACE/edk2-non-osi export GCC5_RISCV64_PREFIX=riscv64-unknown-elf- source edk2/edksetup.sh
- Build base tools.
make -C edk2/BaseTools
Build binaries for SG2042.
Final output is
$WORKSPACE/Build/SG2042_EVB/DEBUG_GCC5/FV/SG2042.fd
.
build -a RISCV64 -t GCC5 -p Platform/Sophgo/SG2042_EVB_Board/SG2042.dsc
Enable
MultiArchUefiPkg
for graphics cards supporting UEFI.Final output is
$WORKSPACE/Build/SG2042_EVB/RELEASE_GCC5/FV/SG2042.fd
.
build -a RISCV64 -t GCC5 -b RELEASE -D X64EMU_ENABLE -p Platform/Sophgo/SG2042_EVB_Board/SG2042.dsc
Note
-D X64EMU_ENABLE
is an option to enable MultiArchUefiPkg, an emulator for x64 OpRoms, or not. Please see the link https://github.com/intel/MultiArchUefiPkg for more details.- If you use
-b DEBUG
to replace-b RELEASE
to build, MultiArchUefiPkg maybe not work.
Enable ACPI for SG2042.
Final output is
$WORKSPACE/Build/SG2042_EVB/RELEASE_GCC5/FV/SG2042.fd
.
build -a RISCV64 -t GCC5 -b RELEASE -D ACPI_ENABLE -p Platform/Sophgo/SG2042_EVB_Board/SG2042.dsc
Note
-D ACPI_ENABLE
is an option to enable ACPI. However, ACPI support is currently only provided for SG2042 x4 EVB.- To enable the ACPI feature in the linux kernel on the SG2042 platform, see the link https://github.com/sophgo/linux-riscv/tree/sg2042-dev-6.6-acpi.
- Mount your SD card (assume your SD card is
/dev/sdc
on your PC).
sudo mount /dev/sdc1 /mnt
- Copy
SG2042.fd
to your SD card in the0:riscv64/
directory.
- Option 1: Replace
riscv64_Image
directly.
sudo cp SG2042.fd /mnt/riscv64/riscv64_Image
Option 2: Write
conf.ini
in the0:riscv64/
directory.The example is as follows:
[sophgo-config] [devicetree] name = mango-sophgo-x8evb.dtb ; name = mango-sophgo-x4evb.dtb ; name = mango-milkv-pioneer.dtb ; name = mango-sophgo-pisces.dtb [kernel] name = SG2042.fd [eof]
- Build GRUB 2. Please see How to build and config GRUB2.
Option 1. Place
grubriscv64.efi
in the EFI partition of your SSD.- Ubuntu: place the
grub.cfg
in the EFI partition. - Fedora: modify
grub.cfg
in the BOOT partition of your SSD.
- Ubuntu: place the
Option 2. Automatically identify GRUB 2 during startup.
- Ubuntu:
sudo cp grubriscv64/ubuntu-rootfs/grubriscv64.efi /mnt/EFI/BOOT/BOOTRISCV64.EFI sudo cp grubriscv64/ubuntu-rootfs/grubriscv64.efi /mnt/EFI/ubuntu/ sudo cp grubriscv64/ubuntu.cfg /mnt/EFI/ubuntu/grub.cfg
Create grub.cfg
. Put it to boot/grub/grub.cfg
.
kernel_version=`ls /home/ubuntu/bsp-debs/linux-image-[0-9]*.deb | cut -d '-' -f 4 | cut -d '.' -f 1-3` set default=0 set timeout_style=menu set timeout=2 set term="vt100" menuentry 'Ubuntu on SG2042' { linux /boot/vmlinuz-$kernel_version console=ttyS0,115200 root=LABEL=cloudimg-rootfs rootfstype=ext4 rootwait rw earlycon selinux=0 LANG=en_US.UTF-8 initrd /boot/initrd.img-$kernel_version }
Put it to boot/grub/grub.cfg
.
sudo mount /dev/sdc2 /media sudo mkdir /media/boot/grub sudo cp grub.cfg /media/boot/grub/
- Connect your serial port to RISC-V debug port (UART0).
- Power on your board, wait untill entering the UEFI shell.
- Boot Linux kernel using GRUB2. Type commands in the UEFI Shell as follows or put a
startup.nsh
file in the EFI partition of your SSD.
fs0: grubriscv64.efi