Skip to content

Latest commit

 

History

History
208 lines (116 loc) · 4.87 KB

README.rst

File metadata and controls

208 lines (116 loc) · 4.87 KB

SOPHGO EDK2

Build

  1. 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
  1. Clone repository (maybe you have done this).
git clone https://github.com/sophgo/sophgo-edk2.git
  1. Enter repository.
cd sophgo-edk2
  1. Init submodules.
git submodule sync
git submodule update --init --recursive
  1. 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
  1. Build base tools.
make -C edk2/BaseTools
  1. 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
  1. 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.
  1. 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

Deploy

  1. Mount your SD card (assume your SD card is /dev/sdc on your PC).
sudo mount /dev/sdc1 /mnt
  1. Copy SG2042.fd to your SD card in the 0:riscv64/ directory.
  • Option 1: Replace riscv64_Image directly.
sudo cp SG2042.fd /mnt/riscv64/riscv64_Image
  • Option 2: Write conf.ini in the 0: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]
  1. 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.
  • 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/

Run

  1. Connect your serial port to RISC-V debug port (UART0).
  2. Power on your board, wait untill entering the UEFI shell.
  3. 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