SlideShare a Scribd company logo
© 2019 Western Digital Corporation or its affiliates. All rights reserved. 1/6/2020
An Introduction to RISC-V
Boot Flow
Atish Patra <Atish.Patra@wdc.com>
Anup Patel <Anup.Patel@wdc.com>
1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 2
Outline
• Common embedded boot flow
• Current RISC-V boot flow
• OpenSBI Project
• Tutorials
• Current Status
• Future work
• Tutorials
1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 3
Prerequisite
• Download the presentation
• Needs a Linux machine (Any distro will do)
• Linux Kernel source code build environment setup (optional)
• Instructions for Ubuntu
shorturl.at/clITU
sudo apt-get install git build-essential kernel-package fakeroot libncurses5-dev libssl-
dev bison flex
1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 4
Getting started..
• Create a working directory
• Download cross-compiling toolchain
– https://toolchains.bootlin.com/releases_riscv64.html
• Download pre-built images
– https://wdc.box.com/s/ihywc2xap5m4mflyngjtndf0sy62zha3
• Clone OpenSBI
• Clone U-Boot
shorturl.at/clITU
git clone https://github.com/riscv/opensbi.git
mkdir summit_demo; cd summit_demo
git clone https://github.com/u-boot/u-boot.git ; git checkout v2019.10
1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 5
Common boot flow
Commonly used multiple boot stages model
ROM LOADER RUNTIME BOOTLOADER OS
Loads
Jumps
• Runs from On-Chip
ROM
• Uses On-Chip SRAM
• SOC power-up and
clock setup
• DDR initialization
• Loads RUNTIME and
BOOTLOADER
• Examples:
• BIOS/UEFI
• U-Boot SPL
• Coreboot
• Runs from On-Chip SRAM or
DDR
• SOC security setup
• Runtime services as-per
specifications
• Examples:
• ATF
• BIOS/UEFI
• Runs from DDR
• Typically open-source
• Filesystem support
• Network booting
• Boot configuration
• Examples:
• U-Boot
• GRUB
• LinuxBoot
1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 6
Common boot flow in ARM64
Commonly used multiple boot stages model
ROM
Coreboot/U-Boot
SPL/ ATF BL2
ATF BL31 U-Boot OS
Loads
Jumps
Falcon mode in U-Boot
ARM64
specific
*ATF (ARM TRUSTED FIRMWARE)
1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 7
RISC-V Upstream Boot Flow
Follows commonly used multiple boot stages model
• For HiFive Unleashed hardware (only Linux capable RISC-V platform available)
• Follows a standard boot flow
• Uses U-Boot as the last stage boot loader
• U-Boot binary as the payload to OpenSBI
• FSBL is SiFive specific and will be replaced by Coreboot/U-Boot SPL
• OpenSBI is a RISC-V specific runtime service provider
Linux
(S-mode)
(OS)
ZSBL
(M-mode)
(ROM)
FSBL
(M-mode)
(LOADER)
OpenSBI
(M-mode)
(RUNTIME)
U-Boot
(S-mode)
(BOOTLOADER)
Loads
Jumps
RISC-V
specific
1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 8
RISC-V boot flow development timeline
OpenSBI
v0.1
release
U-Boot
SMP
support
U-Boot
MMC
support
U-Boot SPL
Coreboot
Legacy
Feb 18
Jan 19
Mar 19
July 19
Jul 19
Aug 19
EDK2
Oct 19
U-Boot
support for
Unleashed
Feb 19Grub
support
Nov 18
1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 9
What is SBI ?
• SBI is the RISC-V Supervisor Binary Interface
– System call style calling convention between Supervisor (S-mode OS) and Supervisor
Execution Environment (SEE)
• SEE can be:
– A M-mode RUNTIME firmware for OS/Hypervisor running in HS-mode
– A HS-mode Hypervisor for Guest OS running in VS-mode
• SBI calls help:
– Reduce duplicate platform code across OSes (Linux, FreeBSD, etc)
– Provide common drivers for an OS which can be shared by multiple platforms
– Provide an interface for direct access to hardware resources (M-mode only resources)
• Specifications being drafted by the Unix Platform Specification Working group
– Currently, SBI v0.1 in-use and SBI v0.2 in draft stage
– https://github.com/riscv/riscv-sbi-doc
SEE (M-Mode)
SBI
OS (S-Mode)
ABI ABI
App1 App2
1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 10
What is OpenSBI ?
• OpenSBI is an open-source implementation of the RISC-V Supervisor Binary Interface
(SBI) specifications
– Licensed under the terms of the BSD-2 clause license
– Helps to avoid SBI implementation fragmentation
– Maintained by the community
• Aimed at providing RUNTIME services in M-mode
– Typically used in boot stage following ROM/LOADER
• Provides support for reference platforms
– Generic simple drivers included for M-mode to operate
 PLIC, CLINT, UART 8250
– Other platforms can reuse the common code and add needed drivers
• Source
– https://github.com/riscv/opensbi
1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 11
Key Features
• Layered structure to accommodate various use cases
– Generic SBI library with platform abstraction
• Typically used with external firmware and bootloader
– EDK2 (UEFI implementation), Secure boot working group
– Platform specific library
• Similar to core library but including platform specific drivers
– Platform specific reference firmware
• Three different types of RUNTIME firmware
• Wide range of hardware features supported
– RV32 and RV64
– Hypervisor support
– Misaligned load/store handling
– Missing CSR emulation
– Protects firmware using PMP support
Platform Specific
Reference Firmware
Platform Specific
Library
SBI Library
OpenSBI Layers
1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 12
Platform support
• SiFive HiFive Unleashed
• Andes AE350
• Ariane FPGA SOC
• Kendryte K210
• QEMU virt machines (32-bit/64-bit)
• OmniXtend
1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 13
Tutorial
• Working setup
• Extract toolchain and add it to the environment path
• Change the permission of qemu binary
• Set environment variable CROSS_COMPILE and ARCH
Setup details
chmod a+x qemu-system-riscv64
export ARCH=riscv; export CROSS_COMPILE=riscv64-linux-
tar –xvf riscv64--glibc--bleeding-edge-2018.11-1.tar.bz2
export PATH=$PATH:riscv64--glibc--bleeding-edge-2018.11-1/bin/
1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 14
Tutorial-I
• Compile OpenSBI
• Run it in Qemu
Boot Linux in Qemu as a payload to OpenSBI
cd opensbi; make PLATFORM=qemu/virt FW_PAYLOAD_PATH=../linux_Image; cd ..
./qemu-system-riscv64 -M virt -m 256M -nographic 
-kernel opensbi/build/platform/qemu/virt/firmware/fw_payload.elf 
-drive file=linux_rootfs.img,format=raw,id=hd0 
-device virtio-blk-device,drive=hd0 
-append "root=/dev/vda rw console=ttyS0"
Linux kernel
imageVirt machine
in Qemu
OpenSBI
image
Linux rootfs
1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 15
Adding Support for New Platforms
• To add support for a new <xyz> platform
1. Create directory named <xyz> under /platform directory
2. Create platform configuration file <xyz>/config.mk
 config.mk will provide compiler flags, select common drivers, and select firmware options
 platform/template/config.mk can be used as reference for creating config.mk
3. Create platform objects file <xyz>/objects.mk for listing platform-specific objects to be compiled
 platform/template/objects.mk can be used as reference for creating objects.mk
4. Create platform source file <xyz>/platform.c providing “struct sbi_platform” instance
 platform/template/platform.c can be used as reference for creating platform.c
• The <xyz> platform support directory can also placed outside OpenSBI sources
1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 16
Reference Firmwares
• OpenSBI provides several types of reference firmware, all platform-specific
– FW_PAYLOAD
• Firmware with the next booting stage as a payload
• Default firmware being used in Linux capable RISC-V hardware
– FW_JUMP
• Firmware with fixed jump address to the next booting stage
• Default method for QEMU
– FW_DYNAMIC
• Firmware with dynamic information on the next booting stage
• U-Boot SPL/Coreboot is using FW_DYNAMIC
• SOC Vendors may choose:
– Use one of OpenSBI reference firmwares as their M-mode RUNTIME firmware
– Build M-mode RUNTIME firmware from scratch with OpenSBI as library
– Extend existing M-mode firmwares (U-Boot_M_mode/EDK2) with OpenSBI as library
1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 17
U-Boot
• Most commonly used in embedded systems
• Used as a last stage boot loader
• Support
– many ISAs (x86, ARM, AARCH64, RISC-V, ARC..)
– Peripherals (UART, SPI, I2C, ethernet, SD, USB..)
– Multiple file systems
– Various network protocols
• Can load images from network, file system, removable devices
• Easy command line interface for management
• Lot of customization
– U-Boot SPL (a redacted version of U-Boot used as first stage boot loader)
– Falcon mode (for fast booting)
An universal boot loader
1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 18
Tutorial - II
• Compile U-Boot
• Compile OpenSBI
• Run it in Qemu
Boot Linux in Qemu using U-Boot proper
cd opensbi; make PLATFORM=qemu/virt; cd ..
virt machine in Qemu
./qemu-system-riscv64 -M virt -smp 4 -m 256M -nographic 
-bios opensbi/build/platform/qemu/virt/firmware/fw_jump.elf 
-kernel u-boot/u-boot.bin -device loader,file=linux_Image,addr=0x84000000 
-drive file=linux_rootfs.img,format=raw,id=hd0 
-device virtio-blk-device,drive=hd0
OpenSBI firmware
(fw_jump)
Kernel address
expected by U-
boot
cd u-boot; make qemu-riscv64_smode_defconfig; make; cd ..
No payload!!
1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 19
Tutorial - II
• At U-Boot prompt
Boot Linux in Qemu using U-Boot proper
=>setenv bootargs "root=/dev/vda rw console=ttyS0 earlycon=sbi"
=>cp.l ${fdtcontroladdr} ${fdt_addr_r} 0x10000
=>booti ${kernel_addr_r} - ${fdt_addr_r}
1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 20
Boot flow using OpenSBI dynamic firmware
• OpenSBI firmware with dynamic information about the next booting
stage
• Coreboot support available on both hardware & QEMU
• U-Boot SPL available for QEMU and Andes AE350
• HiFive Unleashed U-Boot SPL support not available yet
Passed via ‘a2’ register
Linux
(S-mode)
(OS)
ZSBL
(M-mode)
(ROM)
U-Boot SPL/
Coreboot
(M-mode)
OpenSBI
(M-mode)
(RUNTIME)
U-Boot
(S-mode)
(BOOTLOADER)
Loads
Jumps
Proprietary
Open
Source
RISC-V
specific
struct
fw_dynamic_info
1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 21
cd opensbi; make PLATFORM=qemu/virt; cd ..
Tutorial - III
• Compile OpenSBI
• Compile U-Boot SPL
• Run it in Qemu
Boot Linux in Qemu using U-Boot SPL
cd u-boot; export OPENSBI=../opensbi/build/platform/qemu/virt/firmware/fw_dynamic.bin;
ARCH=riscv CROSS_COMPILE=riscv64-linux- make qemu-riscv64_spl_defconfig
ARCH=riscv CROSS_COMPILE=riscv64-linux- make; cd ..
No payload!!
./qemu-system-riscv64 -nographic -machine virt -m 2G -bios u-boot/spl/u-boot-spl 
-kernel u-boot/u-boot.itb -device loader,file=linux_Image,addr=0x86000000 
-drive file=linux_rootfs.img,format=raw,id=hd0 
-device virtio-blk-device,drive=hd0
U-Boot SPL binary
FIT image
(OpenSBI + U-Boot
proper
Path to OpenSBI
dynamic firmware
1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 22
Tutorial - III
• At U-Boot prompt
Boot Linux in Qemu using U-Boot proper
=>cp.b 0x86000000 ${kernel_addr_r} 0x1000000
=>setenv bootargs "root=/dev/vda rw console=ttyS0 earlycon=sbi"
=>cp.l ${fdtcontroladdr} ${fdt_addr_r} 0x10000
=>booti ${kernel_addr_r} - ${fdt_addr_r}
1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 23
Boot flow using OpenSBI as a library
• OpenSBI as a part of external firmware source
code
• Must configure program stack and scratch
space for OpenSBI
• Same GCC target option for external firmware
and OpenSBI
• Currently EDK2 integration with OpenSBI
– HPE leading this effort
– Available in EDK2 mailing list for U540 on Xilinx VC707
FPGA
– OpenSBI built with EDK2 build environment
– OpenSBI used as library in Pre-EFI Initialization (PEI)
phase
1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 24
Constraints on using OpenSBI as a Library
• Same GCC target options (i.e. -march, -mabi, and -mcmodel) need to be used for the
external firmware and OpenSBI sources
• External firmware must create per-HART non-overlapping:
– Program Stack
– OpenSBI scratch space (i.e. struct sbi_scratch instance with extra space above)
• Two constraints in calling any OpenSBI functions from external firmware:
– MSCRATCH CSR of calling HART must be set to its own OpenSBI scratch space
– SP register (i.e. the stack pointer) of calling HART must be set to its own stack
• External firmware must also ensure that:
– Interrupts are disabled in the MSTATUS and MIE CSRs when calling sbi_init()
– sbi_init() is called for each HART that is powered-up at boot-time or in response to a CPU hotplug event
– sbi_trap_handler() is called for M-mode interrupts and M-mode traps
1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 25
Current status
• OpenSBI
– Actively developed and maintained
– Version 0.5 released
– Default in Buildroot, Yocto/OpenEmbedded and
the QEMU “BIOS”
– Fedora/Debian provides images available with
OpenSBI binary
• U-Boot
– U-Boot-2019.10 release has full support HiFive
Unleashed S-mode
– Boot via network/MMC supported
– FIT image support
– EFI support for RISC-V available
• Grub
– RISC-V support available upstream
• Linux Kernel
– Upstream kernel boots in QEMU
– Device tree hosted in Kernel
– v5.3 kernel works with OpenSBI+U-Boot
on HiFive Unleashed
Rapid progress: traditional full boot support expected by year end
1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 26
Future boot support
• EFI stub support in Linux kernel for full UEFI support in progress
– Enterprise class boot environment
• U-Boot SPL support for HiFive Unleashed
• SMP support in coreboot
• EDK2 project upstreaming (in progress)
• Oreboot (Coreboot written in Rust)
• LinuxBoot ?
• Other bootloaders ?
Toward a stable and easy to use boot ecosystem
1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 27
Ongoing work
• SBI specifications
– SBI v0.2 specification
– Hart state management extension in SBI
– Legacy SBI extension replacement in SBI
• OpenSBI
– Sequential cpu boot via CPU hotplug
– Support other M-mode boot loader such as
Coreboot/U-Boot SPL
– Hypervisor support when specification changes
– More platforms support
• Need hardware !
• Linux kernel
– SBI v0.2 implementation (patches are under
review)
– EFI stub in Linux kernel (work in progress)
– SBI legacy extension replacements
– Sequential booting
– CPU hotplug
Toward a stable and easy to use boot ecosystem
1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 28
Acknowledgements
• U-Boot
– Lukas Auler
– Bin Meng
– Anup Patel
• Coreboot
– Ron Minnich
– Jonathan Neuschäfer
– Patrick Rudolph
– Philip Hug
• EDK2
– Abner Chang
• And others
1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 29
Thank you!!
• Q&A ?
© 2019 Western Digital Corporation or its affiliates. All rights reserved. 1/6/2020
1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 31
Backup
1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 32
EDK2 implementation details
• OpenSBI used as library
• Open Source EDK2 (UEFI implementation) OpenSBI integration
– HPE leading this effort
– Available in EDK2 staging area for U540 on Xilinx VC707 FPGA
– OpenSBI built with EDK2 build environment
Passed via ‘a2’ register
ZSBL
(M-mode)
(ROM)
Bootloader
(Grub/U-
Boot)
Loads
Jumps
Open
Source
RISC-V
specific
EDK2
FSBL
(M-mode)
(ROM)
Linux
(S-Mode)
OS
SEC
phase
PEI phase
(M-Mode)
DXE phase
(S-Mode)
BDS phase
(S-Mode)
EDK2 OpenSBI DXE Driver
(S-Mode)
OpenSBI library
(M-Mode)
1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 33
Reference
• SBI
– https://github.com/riscv/riscv-sbi-doc
• EDK2
– https://edk2.groups.io/g/devel/message/46479?p=,,,20,0,0,0::Created,,riscv,20,2,0,33047245

More Related Content

What's hot

Running Android on the Raspberry Pi: Android Pie meets Raspberry Pi
Running Android on the Raspberry Pi: Android Pie meets Raspberry PiRunning Android on the Raspberry Pi: Android Pie meets Raspberry Pi
Running Android on the Raspberry Pi: Android Pie meets Raspberry Pi
Chris Simmonds
 
Spi drivers
Spi driversSpi drivers
Spi drivers
pradeep_tewani
 
Qemu Introduction
Qemu IntroductionQemu Introduction
Qemu Introduction
Chiawei Wang
 
BeagleBone Black Bootloaders
BeagleBone Black BootloadersBeagleBone Black Bootloaders
BeagleBone Black Bootloaders
SysPlay eLearning Academy for You
 
SFO15-TR9: PSCI, ACPI (and UEFI to boot)
SFO15-TR9: PSCI, ACPI (and UEFI to boot)SFO15-TR9: PSCI, ACPI (and UEFI to boot)
SFO15-TR9: PSCI, ACPI (and UEFI to boot)
Linaro
 
I2c drivers
I2c driversI2c drivers
I2c drivers
pradeep_tewani
 
The Linux Block Layer - Built for Fast Storage
The Linux Block Layer - Built for Fast StorageThe Linux Block Layer - Built for Fast Storage
The Linux Block Layer - Built for Fast Storage
Kernel TLV
 
Jagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratchJagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratch
linuxlab_conf
 
Linux power management: are you doing it right?
Linux power management: are you doing it right?Linux power management: are you doing it right?
Linux power management: are you doing it right?
Chris Simmonds
 
Secure Boot on ARM systems – Building a complete Chain of Trust upon existing...
Secure Boot on ARM systems – Building a complete Chain of Trust upon existing...Secure Boot on ARM systems – Building a complete Chain of Trust upon existing...
Secure Boot on ARM systems – Building a complete Chain of Trust upon existing...
Linaro
 
Embedded_Linux_Booting
Embedded_Linux_BootingEmbedded_Linux_Booting
Embedded_Linux_BootingRashila Rr
 
qemu + gdb + sample_code: Run sample code in QEMU OS and observe Linux Kernel...
qemu + gdb + sample_code: Run sample code in QEMU OS and observe Linux Kernel...qemu + gdb + sample_code: Run sample code in QEMU OS and observe Linux Kernel...
qemu + gdb + sample_code: Run sample code in QEMU OS and observe Linux Kernel...
Adrian Huang
 
Decompressed vmlinux: linux kernel initialization from page table configurati...
Decompressed vmlinux: linux kernel initialization from page table configurati...Decompressed vmlinux: linux kernel initialization from page table configurati...
Decompressed vmlinux: linux kernel initialization from page table configurati...
Adrian Huang
 
Linux Initialization Process (2)
Linux Initialization Process (2)Linux Initialization Process (2)
Linux Initialization Process (2)
shimosawa
 
Qemu Pcie
Qemu PcieQemu Pcie
Embedded Linux Quick Start Guide v1.5
Embedded Linux Quick Start Guide v1.5Embedded Linux Quick Start Guide v1.5
Embedded Linux Quick Start Guide v1.5
Chris Simmonds
 
Exploring Your Apple M1 devices with Open Source Tools
Exploring Your Apple M1 devices with Open Source ToolsExploring Your Apple M1 devices with Open Source Tools
Exploring Your Apple M1 devices with Open Source Tools
Koan-Sin Tan
 
Embedded linux network device driver development
Embedded linux network device driver developmentEmbedded linux network device driver development
Embedded linux network device driver development
Amr Ali (ISTQB CTAL Full, CSM, ITIL Foundation)
 
Deploying IPv6 in OpenStack Environments
Deploying IPv6 in OpenStack EnvironmentsDeploying IPv6 in OpenStack Environments
Deploying IPv6 in OpenStack Environments
Shannon McFarland
 
Linux device drivers
Linux device drivers Linux device drivers

What's hot (20)

Running Android on the Raspberry Pi: Android Pie meets Raspberry Pi
Running Android on the Raspberry Pi: Android Pie meets Raspberry PiRunning Android on the Raspberry Pi: Android Pie meets Raspberry Pi
Running Android on the Raspberry Pi: Android Pie meets Raspberry Pi
 
Spi drivers
Spi driversSpi drivers
Spi drivers
 
Qemu Introduction
Qemu IntroductionQemu Introduction
Qemu Introduction
 
BeagleBone Black Bootloaders
BeagleBone Black BootloadersBeagleBone Black Bootloaders
BeagleBone Black Bootloaders
 
SFO15-TR9: PSCI, ACPI (and UEFI to boot)
SFO15-TR9: PSCI, ACPI (and UEFI to boot)SFO15-TR9: PSCI, ACPI (and UEFI to boot)
SFO15-TR9: PSCI, ACPI (and UEFI to boot)
 
I2c drivers
I2c driversI2c drivers
I2c drivers
 
The Linux Block Layer - Built for Fast Storage
The Linux Block Layer - Built for Fast StorageThe Linux Block Layer - Built for Fast Storage
The Linux Block Layer - Built for Fast Storage
 
Jagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratchJagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratch
 
Linux power management: are you doing it right?
Linux power management: are you doing it right?Linux power management: are you doing it right?
Linux power management: are you doing it right?
 
Secure Boot on ARM systems – Building a complete Chain of Trust upon existing...
Secure Boot on ARM systems – Building a complete Chain of Trust upon existing...Secure Boot on ARM systems – Building a complete Chain of Trust upon existing...
Secure Boot on ARM systems – Building a complete Chain of Trust upon existing...
 
Embedded_Linux_Booting
Embedded_Linux_BootingEmbedded_Linux_Booting
Embedded_Linux_Booting
 
qemu + gdb + sample_code: Run sample code in QEMU OS and observe Linux Kernel...
qemu + gdb + sample_code: Run sample code in QEMU OS and observe Linux Kernel...qemu + gdb + sample_code: Run sample code in QEMU OS and observe Linux Kernel...
qemu + gdb + sample_code: Run sample code in QEMU OS and observe Linux Kernel...
 
Decompressed vmlinux: linux kernel initialization from page table configurati...
Decompressed vmlinux: linux kernel initialization from page table configurati...Decompressed vmlinux: linux kernel initialization from page table configurati...
Decompressed vmlinux: linux kernel initialization from page table configurati...
 
Linux Initialization Process (2)
Linux Initialization Process (2)Linux Initialization Process (2)
Linux Initialization Process (2)
 
Qemu Pcie
Qemu PcieQemu Pcie
Qemu Pcie
 
Embedded Linux Quick Start Guide v1.5
Embedded Linux Quick Start Guide v1.5Embedded Linux Quick Start Guide v1.5
Embedded Linux Quick Start Guide v1.5
 
Exploring Your Apple M1 devices with Open Source Tools
Exploring Your Apple M1 devices with Open Source ToolsExploring Your Apple M1 devices with Open Source Tools
Exploring Your Apple M1 devices with Open Source Tools
 
Embedded linux network device driver development
Embedded linux network device driver developmentEmbedded linux network device driver development
Embedded linux network device driver development
 
Deploying IPv6 in OpenStack Environments
Deploying IPv6 in OpenStack EnvironmentsDeploying IPv6 in OpenStack Environments
Deploying IPv6 in OpenStack Environments
 
Linux device drivers
Linux device drivers Linux device drivers
Linux device drivers
 

Similar to An Introduction to RISC-V bootflow

RISC-V Boot Process: One Step at a Time
RISC-V Boot Process: One Step at a TimeRISC-V Boot Process: One Step at a Time
RISC-V Boot Process: One Step at a Time
Atish Patra
 
The role of_open_source_firmware_in_risc-v
The role of_open_source_firmware_in_risc-vThe role of_open_source_firmware_in_risc-v
The role of_open_source_firmware_in_risc-v
Atish Patra
 
The future of RISC-V Supervisor Binary Interface(SBI)
The future of RISC-V Supervisor Binary Interface(SBI)The future of RISC-V Supervisor Binary Interface(SBI)
The future of RISC-V Supervisor Binary Interface(SBI)
Atish Patra
 
"Building Complete Embedded Vision Systems on Linux—From Camera to Display," ...
"Building Complete Embedded Vision Systems on Linux—From Camera to Display," ..."Building Complete Embedded Vision Systems on Linux—From Camera to Display," ...
"Building Complete Embedded Vision Systems on Linux—From Camera to Display," ...
Edge AI and Vision Alliance
 
Embedded Linux BSP Training (Intro)
Embedded Linux BSP Training (Intro)Embedded Linux BSP Training (Intro)
Embedded Linux BSP Training (Intro)
RuggedBoardGroup
 
Embedded Fest 2019. Wei Fu. Linux on RISC-V--Fedora and Firmware in practice
Embedded Fest 2019. Wei Fu. Linux on RISC-V--Fedora and Firmware in practiceEmbedded Fest 2019. Wei Fu. Linux on RISC-V--Fedora and Firmware in practice
Embedded Fest 2019. Wei Fu. Linux on RISC-V--Fedora and Firmware in practice
EmbeddedFest
 
FOSDEM_2019_Buildroot_RISCV.pdf
FOSDEM_2019_Buildroot_RISCV.pdfFOSDEM_2019_Buildroot_RISCV.pdf
FOSDEM_2019_Buildroot_RISCV.pdf
ssuser30e7d2
 
oSSN19 - openSUSE on ARM
oSSN19 - openSUSE on ARMoSSN19 - openSUSE on ARM
oSSN19 - openSUSE on ARM
Guillaume GARDET
 
UplinQ - ubuntu linux on the qualcomm® snapdragon™ 600 processor
UplinQ - ubuntu linux on the qualcomm® snapdragon™ 600 processorUplinQ - ubuntu linux on the qualcomm® snapdragon™ 600 processor
UplinQ - ubuntu linux on the qualcomm® snapdragon™ 600 processor
Satya Harish
 
oSC19 openSUSE on ARM
oSC19 openSUSE on ARMoSC19 openSUSE on ARM
oSC19 openSUSE on ARM
Guillaume GARDET
 
Fedora on risc-v_tokyo_30_sep_2019_v4
Fedora on risc-v_tokyo_30_sep_2019_v4Fedora on risc-v_tokyo_30_sep_2019_v4
Fedora on risc-v_tokyo_30_sep_2019_v4
Wei Fu
 
Building PoC ready ODM Platforms with Arm SystemReady v5.2.pdf
Building PoC ready ODM Platforms with Arm SystemReady v5.2.pdfBuilding PoC ready ODM Platforms with Arm SystemReady v5.2.pdf
Building PoC ready ODM Platforms with Arm SystemReady v5.2.pdf
Paul Yang
 
UEFI presentation
UEFI presentationUEFI presentation
UEFI presentation
Bruno Cornec
 
Building
BuildingBuilding
Building
Satpal Parmar
 
Rasperry Pi and TI CC2650 IPv6 border router
Rasperry Pi and TI CC2650 IPv6 border routerRasperry Pi and TI CC2650 IPv6 border router
Rasperry Pi and TI CC2650 IPv6 border router
Nikolaos Monios
 
XPDS14: Xen 4.5 Roadmap - Konrad Wilk, Oracle
XPDS14: Xen 4.5 Roadmap - Konrad Wilk, OracleXPDS14: Xen 4.5 Roadmap - Konrad Wilk, Oracle
XPDS14: Xen 4.5 Roadmap - Konrad Wilk, Oracle
The Linux Foundation
 
A Tour of Open Source on the Mainframe
A Tour of Open Source on the MainframeA Tour of Open Source on the Mainframe
A Tour of Open Source on the Mainframe
All Things Open
 
How to run Linux on RISC-V (FOSS North 2020)
How to run Linux on RISC-V (FOSS North 2020)How to run Linux on RISC-V (FOSS North 2020)
How to run Linux on RISC-V (FOSS North 2020)
Drew Fustini
 
OSDC 2014: Nat Morris - Open Network Install Environment
OSDC 2014: Nat Morris - Open Network Install EnvironmentOSDC 2014: Nat Morris - Open Network Install Environment
OSDC 2014: Nat Morris - Open Network Install Environment
NETWAYS
 

Similar to An Introduction to RISC-V bootflow (20)

RISC-V Boot Process: One Step at a Time
RISC-V Boot Process: One Step at a TimeRISC-V Boot Process: One Step at a Time
RISC-V Boot Process: One Step at a Time
 
The role of_open_source_firmware_in_risc-v
The role of_open_source_firmware_in_risc-vThe role of_open_source_firmware_in_risc-v
The role of_open_source_firmware_in_risc-v
 
The future of RISC-V Supervisor Binary Interface(SBI)
The future of RISC-V Supervisor Binary Interface(SBI)The future of RISC-V Supervisor Binary Interface(SBI)
The future of RISC-V Supervisor Binary Interface(SBI)
 
"Building Complete Embedded Vision Systems on Linux—From Camera to Display," ...
"Building Complete Embedded Vision Systems on Linux—From Camera to Display," ..."Building Complete Embedded Vision Systems on Linux—From Camera to Display," ...
"Building Complete Embedded Vision Systems on Linux—From Camera to Display," ...
 
Embedded Linux BSP Training (Intro)
Embedded Linux BSP Training (Intro)Embedded Linux BSP Training (Intro)
Embedded Linux BSP Training (Intro)
 
Embedded Fest 2019. Wei Fu. Linux on RISC-V--Fedora and Firmware in practice
Embedded Fest 2019. Wei Fu. Linux on RISC-V--Fedora and Firmware in practiceEmbedded Fest 2019. Wei Fu. Linux on RISC-V--Fedora and Firmware in practice
Embedded Fest 2019. Wei Fu. Linux on RISC-V--Fedora and Firmware in practice
 
FOSDEM_2019_Buildroot_RISCV.pdf
FOSDEM_2019_Buildroot_RISCV.pdfFOSDEM_2019_Buildroot_RISCV.pdf
FOSDEM_2019_Buildroot_RISCV.pdf
 
Slimline Open Firmware
Slimline Open FirmwareSlimline Open Firmware
Slimline Open Firmware
 
oSSN19 - openSUSE on ARM
oSSN19 - openSUSE on ARMoSSN19 - openSUSE on ARM
oSSN19 - openSUSE on ARM
 
UplinQ - ubuntu linux on the qualcomm® snapdragon™ 600 processor
UplinQ - ubuntu linux on the qualcomm® snapdragon™ 600 processorUplinQ - ubuntu linux on the qualcomm® snapdragon™ 600 processor
UplinQ - ubuntu linux on the qualcomm® snapdragon™ 600 processor
 
oSC19 openSUSE on ARM
oSC19 openSUSE on ARMoSC19 openSUSE on ARM
oSC19 openSUSE on ARM
 
Fedora on risc-v_tokyo_30_sep_2019_v4
Fedora on risc-v_tokyo_30_sep_2019_v4Fedora on risc-v_tokyo_30_sep_2019_v4
Fedora on risc-v_tokyo_30_sep_2019_v4
 
Building PoC ready ODM Platforms with Arm SystemReady v5.2.pdf
Building PoC ready ODM Platforms with Arm SystemReady v5.2.pdfBuilding PoC ready ODM Platforms with Arm SystemReady v5.2.pdf
Building PoC ready ODM Platforms with Arm SystemReady v5.2.pdf
 
UEFI presentation
UEFI presentationUEFI presentation
UEFI presentation
 
Building
BuildingBuilding
Building
 
Rasperry Pi and TI CC2650 IPv6 border router
Rasperry Pi and TI CC2650 IPv6 border routerRasperry Pi and TI CC2650 IPv6 border router
Rasperry Pi and TI CC2650 IPv6 border router
 
XPDS14: Xen 4.5 Roadmap - Konrad Wilk, Oracle
XPDS14: Xen 4.5 Roadmap - Konrad Wilk, OracleXPDS14: Xen 4.5 Roadmap - Konrad Wilk, Oracle
XPDS14: Xen 4.5 Roadmap - Konrad Wilk, Oracle
 
A Tour of Open Source on the Mainframe
A Tour of Open Source on the MainframeA Tour of Open Source on the Mainframe
A Tour of Open Source on the Mainframe
 
How to run Linux on RISC-V (FOSS North 2020)
How to run Linux on RISC-V (FOSS North 2020)How to run Linux on RISC-V (FOSS North 2020)
How to run Linux on RISC-V (FOSS North 2020)
 
OSDC 2014: Nat Morris - Open Network Install Environment
OSDC 2014: Nat Morris - Open Network Install EnvironmentOSDC 2014: Nat Morris - Open Network Install Environment
OSDC 2014: Nat Morris - Open Network Install Environment
 

Recently uploaded

Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
vrstrong314
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
WSO2
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
Tendenci - The Open Source AMS (Association Management Software)
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 

Recently uploaded (20)

Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 

An Introduction to RISC-V bootflow

  • 1. © 2019 Western Digital Corporation or its affiliates. All rights reserved. 1/6/2020 An Introduction to RISC-V Boot Flow Atish Patra <Atish.Patra@wdc.com> Anup Patel <Anup.Patel@wdc.com>
  • 2. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 2 Outline • Common embedded boot flow • Current RISC-V boot flow • OpenSBI Project • Tutorials • Current Status • Future work • Tutorials
  • 3. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 3 Prerequisite • Download the presentation • Needs a Linux machine (Any distro will do) • Linux Kernel source code build environment setup (optional) • Instructions for Ubuntu shorturl.at/clITU sudo apt-get install git build-essential kernel-package fakeroot libncurses5-dev libssl- dev bison flex
  • 4. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 4 Getting started.. • Create a working directory • Download cross-compiling toolchain – https://toolchains.bootlin.com/releases_riscv64.html • Download pre-built images – https://wdc.box.com/s/ihywc2xap5m4mflyngjtndf0sy62zha3 • Clone OpenSBI • Clone U-Boot shorturl.at/clITU git clone https://github.com/riscv/opensbi.git mkdir summit_demo; cd summit_demo git clone https://github.com/u-boot/u-boot.git ; git checkout v2019.10
  • 5. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 5 Common boot flow Commonly used multiple boot stages model ROM LOADER RUNTIME BOOTLOADER OS Loads Jumps • Runs from On-Chip ROM • Uses On-Chip SRAM • SOC power-up and clock setup • DDR initialization • Loads RUNTIME and BOOTLOADER • Examples: • BIOS/UEFI • U-Boot SPL • Coreboot • Runs from On-Chip SRAM or DDR • SOC security setup • Runtime services as-per specifications • Examples: • ATF • BIOS/UEFI • Runs from DDR • Typically open-source • Filesystem support • Network booting • Boot configuration • Examples: • U-Boot • GRUB • LinuxBoot
  • 6. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 6 Common boot flow in ARM64 Commonly used multiple boot stages model ROM Coreboot/U-Boot SPL/ ATF BL2 ATF BL31 U-Boot OS Loads Jumps Falcon mode in U-Boot ARM64 specific *ATF (ARM TRUSTED FIRMWARE)
  • 7. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 7 RISC-V Upstream Boot Flow Follows commonly used multiple boot stages model • For HiFive Unleashed hardware (only Linux capable RISC-V platform available) • Follows a standard boot flow • Uses U-Boot as the last stage boot loader • U-Boot binary as the payload to OpenSBI • FSBL is SiFive specific and will be replaced by Coreboot/U-Boot SPL • OpenSBI is a RISC-V specific runtime service provider Linux (S-mode) (OS) ZSBL (M-mode) (ROM) FSBL (M-mode) (LOADER) OpenSBI (M-mode) (RUNTIME) U-Boot (S-mode) (BOOTLOADER) Loads Jumps RISC-V specific
  • 8. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 8 RISC-V boot flow development timeline OpenSBI v0.1 release U-Boot SMP support U-Boot MMC support U-Boot SPL Coreboot Legacy Feb 18 Jan 19 Mar 19 July 19 Jul 19 Aug 19 EDK2 Oct 19 U-Boot support for Unleashed Feb 19Grub support Nov 18
  • 9. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 9 What is SBI ? • SBI is the RISC-V Supervisor Binary Interface – System call style calling convention between Supervisor (S-mode OS) and Supervisor Execution Environment (SEE) • SEE can be: – A M-mode RUNTIME firmware for OS/Hypervisor running in HS-mode – A HS-mode Hypervisor for Guest OS running in VS-mode • SBI calls help: – Reduce duplicate platform code across OSes (Linux, FreeBSD, etc) – Provide common drivers for an OS which can be shared by multiple platforms – Provide an interface for direct access to hardware resources (M-mode only resources) • Specifications being drafted by the Unix Platform Specification Working group – Currently, SBI v0.1 in-use and SBI v0.2 in draft stage – https://github.com/riscv/riscv-sbi-doc SEE (M-Mode) SBI OS (S-Mode) ABI ABI App1 App2
  • 10. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 10 What is OpenSBI ? • OpenSBI is an open-source implementation of the RISC-V Supervisor Binary Interface (SBI) specifications – Licensed under the terms of the BSD-2 clause license – Helps to avoid SBI implementation fragmentation – Maintained by the community • Aimed at providing RUNTIME services in M-mode – Typically used in boot stage following ROM/LOADER • Provides support for reference platforms – Generic simple drivers included for M-mode to operate  PLIC, CLINT, UART 8250 – Other platforms can reuse the common code and add needed drivers • Source – https://github.com/riscv/opensbi
  • 11. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 11 Key Features • Layered structure to accommodate various use cases – Generic SBI library with platform abstraction • Typically used with external firmware and bootloader – EDK2 (UEFI implementation), Secure boot working group – Platform specific library • Similar to core library but including platform specific drivers – Platform specific reference firmware • Three different types of RUNTIME firmware • Wide range of hardware features supported – RV32 and RV64 – Hypervisor support – Misaligned load/store handling – Missing CSR emulation – Protects firmware using PMP support Platform Specific Reference Firmware Platform Specific Library SBI Library OpenSBI Layers
  • 12. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 12 Platform support • SiFive HiFive Unleashed • Andes AE350 • Ariane FPGA SOC • Kendryte K210 • QEMU virt machines (32-bit/64-bit) • OmniXtend
  • 13. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 13 Tutorial • Working setup • Extract toolchain and add it to the environment path • Change the permission of qemu binary • Set environment variable CROSS_COMPILE and ARCH Setup details chmod a+x qemu-system-riscv64 export ARCH=riscv; export CROSS_COMPILE=riscv64-linux- tar –xvf riscv64--glibc--bleeding-edge-2018.11-1.tar.bz2 export PATH=$PATH:riscv64--glibc--bleeding-edge-2018.11-1/bin/
  • 14. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 14 Tutorial-I • Compile OpenSBI • Run it in Qemu Boot Linux in Qemu as a payload to OpenSBI cd opensbi; make PLATFORM=qemu/virt FW_PAYLOAD_PATH=../linux_Image; cd .. ./qemu-system-riscv64 -M virt -m 256M -nographic -kernel opensbi/build/platform/qemu/virt/firmware/fw_payload.elf -drive file=linux_rootfs.img,format=raw,id=hd0 -device virtio-blk-device,drive=hd0 -append "root=/dev/vda rw console=ttyS0" Linux kernel imageVirt machine in Qemu OpenSBI image Linux rootfs
  • 15. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 15 Adding Support for New Platforms • To add support for a new <xyz> platform 1. Create directory named <xyz> under /platform directory 2. Create platform configuration file <xyz>/config.mk  config.mk will provide compiler flags, select common drivers, and select firmware options  platform/template/config.mk can be used as reference for creating config.mk 3. Create platform objects file <xyz>/objects.mk for listing platform-specific objects to be compiled  platform/template/objects.mk can be used as reference for creating objects.mk 4. Create platform source file <xyz>/platform.c providing “struct sbi_platform” instance  platform/template/platform.c can be used as reference for creating platform.c • The <xyz> platform support directory can also placed outside OpenSBI sources
  • 16. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 16 Reference Firmwares • OpenSBI provides several types of reference firmware, all platform-specific – FW_PAYLOAD • Firmware with the next booting stage as a payload • Default firmware being used in Linux capable RISC-V hardware – FW_JUMP • Firmware with fixed jump address to the next booting stage • Default method for QEMU – FW_DYNAMIC • Firmware with dynamic information on the next booting stage • U-Boot SPL/Coreboot is using FW_DYNAMIC • SOC Vendors may choose: – Use one of OpenSBI reference firmwares as their M-mode RUNTIME firmware – Build M-mode RUNTIME firmware from scratch with OpenSBI as library – Extend existing M-mode firmwares (U-Boot_M_mode/EDK2) with OpenSBI as library
  • 17. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 17 U-Boot • Most commonly used in embedded systems • Used as a last stage boot loader • Support – many ISAs (x86, ARM, AARCH64, RISC-V, ARC..) – Peripherals (UART, SPI, I2C, ethernet, SD, USB..) – Multiple file systems – Various network protocols • Can load images from network, file system, removable devices • Easy command line interface for management • Lot of customization – U-Boot SPL (a redacted version of U-Boot used as first stage boot loader) – Falcon mode (for fast booting) An universal boot loader
  • 18. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 18 Tutorial - II • Compile U-Boot • Compile OpenSBI • Run it in Qemu Boot Linux in Qemu using U-Boot proper cd opensbi; make PLATFORM=qemu/virt; cd .. virt machine in Qemu ./qemu-system-riscv64 -M virt -smp 4 -m 256M -nographic -bios opensbi/build/platform/qemu/virt/firmware/fw_jump.elf -kernel u-boot/u-boot.bin -device loader,file=linux_Image,addr=0x84000000 -drive file=linux_rootfs.img,format=raw,id=hd0 -device virtio-blk-device,drive=hd0 OpenSBI firmware (fw_jump) Kernel address expected by U- boot cd u-boot; make qemu-riscv64_smode_defconfig; make; cd .. No payload!!
  • 19. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 19 Tutorial - II • At U-Boot prompt Boot Linux in Qemu using U-Boot proper =>setenv bootargs "root=/dev/vda rw console=ttyS0 earlycon=sbi" =>cp.l ${fdtcontroladdr} ${fdt_addr_r} 0x10000 =>booti ${kernel_addr_r} - ${fdt_addr_r}
  • 20. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 20 Boot flow using OpenSBI dynamic firmware • OpenSBI firmware with dynamic information about the next booting stage • Coreboot support available on both hardware & QEMU • U-Boot SPL available for QEMU and Andes AE350 • HiFive Unleashed U-Boot SPL support not available yet Passed via ‘a2’ register Linux (S-mode) (OS) ZSBL (M-mode) (ROM) U-Boot SPL/ Coreboot (M-mode) OpenSBI (M-mode) (RUNTIME) U-Boot (S-mode) (BOOTLOADER) Loads Jumps Proprietary Open Source RISC-V specific struct fw_dynamic_info
  • 21. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 21 cd opensbi; make PLATFORM=qemu/virt; cd .. Tutorial - III • Compile OpenSBI • Compile U-Boot SPL • Run it in Qemu Boot Linux in Qemu using U-Boot SPL cd u-boot; export OPENSBI=../opensbi/build/platform/qemu/virt/firmware/fw_dynamic.bin; ARCH=riscv CROSS_COMPILE=riscv64-linux- make qemu-riscv64_spl_defconfig ARCH=riscv CROSS_COMPILE=riscv64-linux- make; cd .. No payload!! ./qemu-system-riscv64 -nographic -machine virt -m 2G -bios u-boot/spl/u-boot-spl -kernel u-boot/u-boot.itb -device loader,file=linux_Image,addr=0x86000000 -drive file=linux_rootfs.img,format=raw,id=hd0 -device virtio-blk-device,drive=hd0 U-Boot SPL binary FIT image (OpenSBI + U-Boot proper Path to OpenSBI dynamic firmware
  • 22. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 22 Tutorial - III • At U-Boot prompt Boot Linux in Qemu using U-Boot proper =>cp.b 0x86000000 ${kernel_addr_r} 0x1000000 =>setenv bootargs "root=/dev/vda rw console=ttyS0 earlycon=sbi" =>cp.l ${fdtcontroladdr} ${fdt_addr_r} 0x10000 =>booti ${kernel_addr_r} - ${fdt_addr_r}
  • 23. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 23 Boot flow using OpenSBI as a library • OpenSBI as a part of external firmware source code • Must configure program stack and scratch space for OpenSBI • Same GCC target option for external firmware and OpenSBI • Currently EDK2 integration with OpenSBI – HPE leading this effort – Available in EDK2 mailing list for U540 on Xilinx VC707 FPGA – OpenSBI built with EDK2 build environment – OpenSBI used as library in Pre-EFI Initialization (PEI) phase
  • 24. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 24 Constraints on using OpenSBI as a Library • Same GCC target options (i.e. -march, -mabi, and -mcmodel) need to be used for the external firmware and OpenSBI sources • External firmware must create per-HART non-overlapping: – Program Stack – OpenSBI scratch space (i.e. struct sbi_scratch instance with extra space above) • Two constraints in calling any OpenSBI functions from external firmware: – MSCRATCH CSR of calling HART must be set to its own OpenSBI scratch space – SP register (i.e. the stack pointer) of calling HART must be set to its own stack • External firmware must also ensure that: – Interrupts are disabled in the MSTATUS and MIE CSRs when calling sbi_init() – sbi_init() is called for each HART that is powered-up at boot-time or in response to a CPU hotplug event – sbi_trap_handler() is called for M-mode interrupts and M-mode traps
  • 25. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 25 Current status • OpenSBI – Actively developed and maintained – Version 0.5 released – Default in Buildroot, Yocto/OpenEmbedded and the QEMU “BIOS” – Fedora/Debian provides images available with OpenSBI binary • U-Boot – U-Boot-2019.10 release has full support HiFive Unleashed S-mode – Boot via network/MMC supported – FIT image support – EFI support for RISC-V available • Grub – RISC-V support available upstream • Linux Kernel – Upstream kernel boots in QEMU – Device tree hosted in Kernel – v5.3 kernel works with OpenSBI+U-Boot on HiFive Unleashed Rapid progress: traditional full boot support expected by year end
  • 26. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 26 Future boot support • EFI stub support in Linux kernel for full UEFI support in progress – Enterprise class boot environment • U-Boot SPL support for HiFive Unleashed • SMP support in coreboot • EDK2 project upstreaming (in progress) • Oreboot (Coreboot written in Rust) • LinuxBoot ? • Other bootloaders ? Toward a stable and easy to use boot ecosystem
  • 27. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 27 Ongoing work • SBI specifications – SBI v0.2 specification – Hart state management extension in SBI – Legacy SBI extension replacement in SBI • OpenSBI – Sequential cpu boot via CPU hotplug – Support other M-mode boot loader such as Coreboot/U-Boot SPL – Hypervisor support when specification changes – More platforms support • Need hardware ! • Linux kernel – SBI v0.2 implementation (patches are under review) – EFI stub in Linux kernel (work in progress) – SBI legacy extension replacements – Sequential booting – CPU hotplug Toward a stable and easy to use boot ecosystem
  • 28. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 28 Acknowledgements • U-Boot – Lukas Auler – Bin Meng – Anup Patel • Coreboot – Ron Minnich – Jonathan Neuschäfer – Patrick Rudolph – Philip Hug • EDK2 – Abner Chang • And others
  • 29. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 29 Thank you!! • Q&A ?
  • 30. © 2019 Western Digital Corporation or its affiliates. All rights reserved. 1/6/2020
  • 31. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 31 Backup
  • 32. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 32 EDK2 implementation details • OpenSBI used as library • Open Source EDK2 (UEFI implementation) OpenSBI integration – HPE leading this effort – Available in EDK2 staging area for U540 on Xilinx VC707 FPGA – OpenSBI built with EDK2 build environment Passed via ‘a2’ register ZSBL (M-mode) (ROM) Bootloader (Grub/U- Boot) Loads Jumps Open Source RISC-V specific EDK2 FSBL (M-mode) (ROM) Linux (S-Mode) OS SEC phase PEI phase (M-Mode) DXE phase (S-Mode) BDS phase (S-Mode) EDK2 OpenSBI DXE Driver (S-Mode) OpenSBI library (M-Mode)
  • 33. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 33 Reference • SBI – https://github.com/riscv/riscv-sbi-doc • EDK2 – https://edk2.groups.io/g/devel/message/46479?p=,,,20,0,0,0::Created,,riscv,20,2,0,33047245

Editor's Notes

  1. U-Boot supports MMC card & tftpbooting Why another runtime service Provider ? Why OpenSBI ?? Qemu can load super
  2. That’s the personification of RISC-V I could come up with which tells how incapable is right brain is  Legacy – BBL + Vmlinux as a single binary Grub was ported to RISC-V were upstreamed sometime in last year. UEFI support in U-Boot was done even before that time. But it was way ahead of its time as there was no effort in separating supervisor binary interface implementation from the Linux.
  3. Maintain and evolve the SBI specifications
  4. 20K lines of code 49K – dynamic firmware
  5. SPL (Secondary Program Loader) is a small binary, generated from U-Boot source, that fits in the SRAM and loads the main U-Boot into system RAM. SPL also support network/mmc boot.
  6. OpenSBI firmware with dynamic information about the next booting stage The next stage booting stage (i.e. BOOTLADER) and FW_DYNAMIC are loaded by the previous booting stage (i.e. LOADER) The previous booting stage (i.e. LOADER) passes the location of struct fw_dynamic_info to FW_DYNAMIC via ‘a2’ register Down-side: Previous booting stage (i.e. LOADER) needs to be aware of struct fw_dynamic_info