SlideShare a Scribd company logo
1 of 26
© 2019 Western Digital Corporation or its affiliates. All rights reserved. 1/6/2020
RISC-V Boot Process: One step
at a time
Atish Patra <Atish.Patra@wdc.com>
1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 2
Outline
• Introduction to RISC-V
• Common embedded boot flow
• Current RISC-V boot flow
• OpenSBI Project
• Upstream Status
• Future work
• Demo
1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 3
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. 4
What is RISC-V ?
Free and Open Instruction Set Architecture (ISA)
1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 5
What is RISC-V?
• Pronounced as risk-five
• An open RISC Instruction Set Architecture (ISA)
• The base ISA is incredibly small
– The ISA can be extended
• Integer (I) and Embedded (E) are part of the base ISA
• Multiply/Divide (M), Atomic (A), Single Floating Point (F), Double Floating Point (D), Quad Floating Point (Q) and
Compressed Instructions (C) are frozen already
• Virtualization (H), Vector (V), Bit Manipulation (B) are examples of draft extensions
• The General Extension (G) is shorthand for M, A, F and D
– Aimed at everything from small embedded systems to high end HPC
• Multiple CPU implementations already available
• SiFive, BOOM, Rocket64, Andes, Western Digital, QEMU, etc
• Currently heavily backed by SiFive, Microsemi, NVIDIA, Western Digital and others
Free and Open Instruction Set Architecture (ISA)
1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 6
Why RISC-V?
• An open source ISA allows anyone to use and modify the ISA without any licensing cost
– This is different to commercial companies which ship black boxes with strict NDAs
• Customization for specific applications
• Security audits to verify security in critical applications
• No license fees to use the ISA
• Community driven development approach allows input from anybody
Free and Open Instruction Set Architecture (ISA)
1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 7
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
Proprietary
Open Source
1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 8
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
Proprietary
Open
Source
RISC-V
specific
1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 9
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. 10
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. 11
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. 12
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. 13
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. 14
Platform support
• SiFive HiFive Unleashed
• Andes AE350
• Ariane FPGA SOC
• Kendryte K210
• QEMU virt machines (32-bit/64-bit)
1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 15
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. 16
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. 17
Upstream 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. 18
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. 19
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. 20
Demo 1: U-Boot MMC boot
1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 21
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. 23
Backup
1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 24
Constraints on using OpenSBI 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:
1.Program Stack
2.OpenSBI scratch space (i.e. struct sbi_scratch instance with extra space above)
• Two constraints in calling any OpenSBI functions from external firmware:
1.MSCRATCH CSR of calling HART must be set to its own OpenSBI scratch space
2.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
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. 26
Reference
• OpenSBI
– https://github.com/riscv/opensbi
• 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

U boot porting guide for SoC
U boot porting guide for SoCU boot porting guide for SoC
U boot porting guide for SoC
Macpaul Lin
 
Message Signaled Interrupts
Message Signaled InterruptsMessage Signaled Interrupts
Message Signaled Interrupts
Anshuman Biswal
 

What's hot (20)

Linux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKBLinux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKB
 
USB Drivers
USB DriversUSB Drivers
USB Drivers
 
U-Boot Porting on New Hardware
U-Boot Porting on New HardwareU-Boot Porting on New Hardware
U-Boot Porting on New Hardware
 
U-Boot presentation 2013
U-Boot presentation  2013U-Boot presentation  2013
U-Boot presentation 2013
 
U boot porting guide for SoC
U boot porting guide for SoCU boot porting guide for SoC
U boot porting guide for SoC
 
Bootloaders (U-Boot)
Bootloaders (U-Boot) Bootloaders (U-Boot)
Bootloaders (U-Boot)
 
U-Boot - An universal bootloader
U-Boot - An universal bootloader U-Boot - An universal bootloader
U-Boot - An universal bootloader
 
Trusted firmware deep_dive_v1.0_
Trusted firmware deep_dive_v1.0_Trusted firmware deep_dive_v1.0_
Trusted firmware deep_dive_v1.0_
 
Arm device tree and linux device drivers
Arm device tree and linux device driversArm device tree and linux device drivers
Arm device tree and linux device drivers
 
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...
 
PCI Drivers
PCI DriversPCI Drivers
PCI Drivers
 
OPTEE on QEMU - Build Tutorial
OPTEE on QEMU - Build TutorialOPTEE on QEMU - Build Tutorial
OPTEE on QEMU - Build Tutorial
 
Embedded Linux on ARM
Embedded Linux on ARMEmbedded Linux on ARM
Embedded Linux on ARM
 
Linux device drivers
Linux device drivers Linux device drivers
Linux device drivers
 
Lcu14 107- op-tee on ar mv8
Lcu14 107- op-tee on ar mv8Lcu14 107- op-tee on ar mv8
Lcu14 107- op-tee on ar mv8
 
Message Signaled Interrupts
Message Signaled InterruptsMessage Signaled Interrupts
Message Signaled Interrupts
 
Embedded Linux Kernel - Build your custom kernel
Embedded Linux Kernel - Build your custom kernelEmbedded Linux Kernel - Build your custom kernel
Embedded Linux Kernel - Build your custom kernel
 
Introduction to Modern U-Boot
Introduction to Modern U-BootIntroduction to Modern U-Boot
Introduction to Modern U-Boot
 
Yocto Project introduction
Yocto Project introductionYocto Project introduction
Yocto Project introduction
 
Bootloaders
BootloadersBootloaders
Bootloaders
 

Similar to RISC-V Boot Process: One Step at a Time

"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
 
BRKSPG-2069-64bit-package.pdf
BRKSPG-2069-64bit-package.pdfBRKSPG-2069-64bit-package.pdf
BRKSPG-2069-64bit-package.pdf
Heng30
 
Srikanth_PILLI_CV_latest
Srikanth_PILLI_CV_latestSrikanth_PILLI_CV_latest
Srikanth_PILLI_CV_latest
Srikanth Pilli
 

Similar to RISC-V Boot Process: One Step at a Time (20)

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," ...
 
UEFI presentation
UEFI presentationUEFI presentation
UEFI presentation
 
TFI2014 Session II - Requirements for SDN - Brian Field
TFI2014 Session II - Requirements for SDN - Brian FieldTFI2014 Session II - Requirements for SDN - Brian Field
TFI2014 Session II - Requirements for SDN - Brian Field
 
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
 
Open source Android 10 on Orange Pi: Meth or Reality?
Open source Android 10 on Orange Pi: Meth or Reality?Open source Android 10 on Orange Pi: Meth or Reality?
Open source Android 10 on Orange Pi: Meth or Reality?
 
BRKSPG-2069-64bit-package.pdf
BRKSPG-2069-64bit-package.pdfBRKSPG-2069-64bit-package.pdf
BRKSPG-2069-64bit-package.pdf
 
Strata - Scaling Jupyter with Jupyter Enterprise Gateway
Strata - Scaling Jupyter with Jupyter Enterprise GatewayStrata - Scaling Jupyter with Jupyter Enterprise Gateway
Strata - Scaling Jupyter with Jupyter Enterprise Gateway
 
Applying Hyper-scale Design Patterns to Routing
Applying Hyper-scale Design Patterns to RoutingApplying Hyper-scale Design Patterns to Routing
Applying Hyper-scale Design Patterns to Routing
 
Embedded Linux BSP Training (Intro)
Embedded Linux BSP Training (Intro)Embedded Linux BSP Training (Intro)
Embedded Linux BSP Training (Intro)
 
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
 
Srikanth_PILLI_CV_latest
Srikanth_PILLI_CV_latestSrikanth_PILLI_CV_latest
Srikanth_PILLI_CV_latest
 
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
 
Linux on RISC-V with Open Source Hardware (Open Source Summit Japan 2020)
Linux on RISC-V with Open Source Hardware (Open Source Summit Japan 2020)Linux on RISC-V with Open Source Hardware (Open Source Summit Japan 2020)
Linux on RISC-V with Open Source Hardware (Open Source Summit Japan 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)
How to run Linux on RISC-V (FOSS North 2020)
 
XPDS14 - Xen in EFI World - Daniel Kiper, Oracle
XPDS14 - Xen in EFI World - Daniel Kiper, OracleXPDS14 - Xen in EFI World - Daniel Kiper, Oracle
XPDS14 - Xen in EFI World - Daniel Kiper, Oracle
 
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
 
Linux 101
Linux 101Linux 101
Linux 101
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Recently uploaded (20)

CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Quantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingQuantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation Computing
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Choreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringChoreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software Engineering
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Navigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseNavigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern Enterprise
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
API Governance and Monetization - The evolution of API governance
API Governance and Monetization -  The evolution of API governanceAPI Governance and Monetization -  The evolution of API governance
API Governance and Monetization - The evolution of API governance
 

RISC-V Boot Process: One Step at a Time

  • 1. © 2019 Western Digital Corporation or its affiliates. All rights reserved. 1/6/2020 RISC-V Boot Process: One step at a time Atish Patra <Atish.Patra@wdc.com>
  • 2. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 2 Outline • Introduction to RISC-V • Common embedded boot flow • Current RISC-V boot flow • OpenSBI Project • Upstream Status • Future work • Demo
  • 3. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 3 Acknowledgements • U-Boot – Lukas Auler – Bin Meng – Anup Patel • Coreboot – Ron Minnich – Jonathan Neuschäfer – Patrick Rudolph – Philip Hug • EDK2 – Abner Chang • And others
  • 4. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 4 What is RISC-V ? Free and Open Instruction Set Architecture (ISA)
  • 5. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 5 What is RISC-V? • Pronounced as risk-five • An open RISC Instruction Set Architecture (ISA) • The base ISA is incredibly small – The ISA can be extended • Integer (I) and Embedded (E) are part of the base ISA • Multiply/Divide (M), Atomic (A), Single Floating Point (F), Double Floating Point (D), Quad Floating Point (Q) and Compressed Instructions (C) are frozen already • Virtualization (H), Vector (V), Bit Manipulation (B) are examples of draft extensions • The General Extension (G) is shorthand for M, A, F and D – Aimed at everything from small embedded systems to high end HPC • Multiple CPU implementations already available • SiFive, BOOM, Rocket64, Andes, Western Digital, QEMU, etc • Currently heavily backed by SiFive, Microsemi, NVIDIA, Western Digital and others Free and Open Instruction Set Architecture (ISA)
  • 6. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 6 Why RISC-V? • An open source ISA allows anyone to use and modify the ISA without any licensing cost – This is different to commercial companies which ship black boxes with strict NDAs • Customization for specific applications • Security audits to verify security in critical applications • No license fees to use the ISA • Community driven development approach allows input from anybody Free and Open Instruction Set Architecture (ISA)
  • 7. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 7 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 Proprietary Open Source
  • 8. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 8 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 Proprietary Open Source RISC-V specific
  • 9. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 9 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
  • 10. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 10 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
  • 11. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 11 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
  • 12. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 12 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
  • 13. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 13 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
  • 14. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 14 Platform support • SiFive HiFive Unleashed • Andes AE350 • Ariane FPGA SOC • Kendryte K210 • QEMU virt machines (32-bit/64-bit)
  • 15. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 15 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
  • 16. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 16 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
  • 17. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 17 Upstream 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
  • 18. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 18 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
  • 19. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 19 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
  • 20. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 20 Demo 1: U-Boot MMC boot
  • 21. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 21 Thank you!! • Q&A ?
  • 22. © 2019 Western Digital Corporation or its affiliates. All rights reserved. 1/6/2020
  • 23. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 23 Backup
  • 24. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 24 Constraints on using OpenSBI 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: 1.Program Stack 2.OpenSBI scratch space (i.e. struct sbi_scratch instance with extra space above) • Two constraints in calling any OpenSBI functions from external firmware: 1.MSCRATCH CSR of calling HART must be set to its own OpenSBI scratch space 2.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 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)
  • 26. 1/6/2020© 2019 Western Digital Corporation or its affiliates. All rights reserved. 26 Reference • OpenSBI – https://github.com/riscv/opensbi • 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. Meant for world domination – So ISA is designed so that microcontroller to enterprise server, everything can ba handled
  2. There were some questions about why part RISC-V bof last night. So I will quickly address them. Community driven development – Individual membership is free
  3. U-Boot supports MMC card & tftpbooting Why another runtime service Provider ? Why OpenSBI ?? Qemu can load super
  4. 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.
  5. Maintain and evolve the SBI specifications
  6. 20K lines of code 49K – dynamic firmware
  7. 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