COPYRIGHT 2020 SIFIVE. ALL RIGHTS RESERVED.
Rapid Embedded Prototyping withSiFive Software
April 2020
COPYRIGHT 2020 SIFIVE. ALL RIGHTS RESERVED.55
CUSTOM SILICON FOR ALL.
CORES SoC SECURITY
IP SILICON ECOSYSTEM
DESIGN
VALIDATION
IMPLEMENTATION
PRODUCTION
OPEN ARCHITECTURE
OPEN DESIGN
PARTNERS
FOUNDRY
EDA
SoC IP
TOOLS
SOFTWARE
COPYRIGHT 2020 SIFIVE. ALL RIGHTS RESERVED.66
Eclipse C/C++ Development Environment
● SiFive RISC-V Cross Compiler● SiFive OpenOCD Debugger● SEGGER J-LINK Debugger● SiFive QEMU emulator● SiFive Freedom E SDK software
FreedomStudio
COPYRIGHT 2020 SIFIVE. ALL RIGHTS RESERVED.77
RISC-V development tools
● GNU Newlib Toolchain● OpenOCD● QEMU● SDK Utilities● Trace Decoder● XC3SPROG
Eclipse C/C++ Development Environment
● SiFive RISC-V Cross Compiler● SiFive OpenOCD Debugger● SEGGER J-LINK Debugger● SiFive QEMU emulator● SiFive Freedom E SDK software
Freedom ToolsFreedomStudio
COPYRIGHT 2020 SIFIVE. ALL RIGHTS RESERVED.88
RISC-V development tools
● GNU Newlib Toolchain● OpenOCD● QEMU● SDK Utilities● Trace Decoder● XC3SPROG
Embedded Linux software development
● Yocto / OpenEmbedded● Board support● Bootloaders● Device tree binary● Linux kernel images● Disk images
Eclipse C/C++ Development Environment
● SiFive RISC-V Cross Compiler● SiFive OpenOCD Debugger● SEGGER J-LINK Debugger● SiFive QEMU emulator● SiFive Freedom E SDK software
Freedom U SDK
Freedom ToolsFreedomStudio
COPYRIGHT 2020 SIFIVE. ALL RIGHTS RESERVED.99
RISC-V development tools
● GNU Newlib Toolchain● OpenOCD● QEMU● SDK Utilities● Trace Decoder● XC3SPROG
Embedded Linux software development
● Yocto / OpenEmbedded● Board support● Bootloaders● Device tree binary● Linux kernel images● Disk images
Bare metal software development
● Example programs● Industry standard benchmarks● Board support● Metal library
Eclipse C/C++ Development Environment
● SiFive RISC-V Cross Compiler● SiFive OpenOCD Debugger● SEGGER J-LINK Debugger● SiFive QEMU emulator● SiFive Freedom E SDK software
Freedom E SDK Freedom U SDK
Freedom ToolsFreedomStudio
> make
COPYRIGHT 2020 SIFIVE. ALL RIGHTS RESERVED.111111
Supported by standard tools andOperating Systems
(e.g., Linux and FreeRTOS) on bothsilicon and FPGA platforms
Single and multi-core versions of Sifive RISC-V core IP
(e.g., HiFive1 Rev B andHiFive Unleashed)
Multiple Prototyping Platforms
Ranging from cost effectiveto very high capacity allowing for
efficient prototyping ofany SiFive configurable core
Silicon Development Boards FPGA Development Boards Fully Functional Software
COPYRIGHT 2020 SIFIVE. ALL RIGHTS RESERVED.121212
Supported by standard tools andOperating Systems
(e.g., Linux and FreeRTOS) on bothsilicon and FPGA platforms
Single and multi-core versions of Sifive RISC-V core IP
(e.g., HiFive1 Rev B andHiFive Unleashed)
Multiple Prototyping Platforms
Ranging from cost effectiveto very high capacity allowing for
efficient prototyping ofany SiFive configurable core
Silicon Development Boards FPGA Development Boards Fully Functional Software
COPYRIGHT 2020 SIFIVE. ALL RIGHTS RESERVED.131313
Embedded Software Ecosystem
Open source solutions
Commercial solutions
COPYRIGHT 2020 SIFIVE. ALL RIGHTS RESERVED.141414
Embedded software development kit providing a command line driven workflowfor SiFive RISC-V development boards and RISC-V core IP
Dual licensed under Apache 2.0 and MIT
Download from SiFive Core Designer: https://scs.sifive.com/
Clone from Github: https://github.com/sifive/freedom-e-sdk
Freedom E SDK
Freedom Studio
IP Delivery Dev Board FPGA
cpu init drivers libgloss
Metal library
Board support Examples
Freedom E SDKBoard support
● SiFive development boards● FPGA development boards● Simulation (RTL and QEMU)
Metal library
● Portable programming interface across devices and configurations
Example programs
● Peripherals and interrupts● Multi-core● FreeRTOS
Industry standard benchmarks
● Coremark● Dhrystone
COPYRIGHT 2020 SIFIVE. ALL RIGHTS RESERVED.151515
Exploring the Freedom E SDK
freedom-e-sdk % tree
.
├── bsp
├── doc
├── freedom-devicetree-tools
├── freedom-metal
├── scripts
├── software
├── LICENSE
├── LICENSE.Apache2
├── LICENSE.MIT
├── Makefile
├── README.md
├── debug.mk
├── release.mk
└── wit-manifest.json
6 directories, 8 files
freedom-e-sdk %
bsp % tree
.
├── freedom-e310-arty
├── qemu-sifive-e31
├── qemu-sifive-s51
├── qemu-sifive-u54
├── qemu-sifive-u54mc
├── sifive-hifive-unleashed
├── sifive-hifive1
├── sifive-hifive1-revb
└── update-targets.sh
8 directories, 1 file
bsp %
software % tree
.
├── cflush
├── clic-hardware-vector-interrupts
├── clic-selective-vector-interrupts
├── clic-vector-interrupts
├── coremark
├── dhrystone
├── empty
├── example-itim
├── example-pmp
├── example-rtc
├── example-spi
├── example-user-mode
├── example-user-syscall
├── example-watchdog
├── hello
├── local-interrupt
├── local-vector-interrupts
├── multicore-hello
├── plic-interrupts
├── return-fail
├── return-pass
├── sifive-welcome
├── software-interrupt
├── test-coreip
└── timer-interrupt
25 directories, 0 files
software %
API
COPYRIGHT 2020 SIFIVE. ALL RIGHTS RESERVED.171717
Board support
design.dts● Hardware description of the device in the devicetree.org format generated by SiFive
devicetree-tools● Transform design.dts into header files (*.h), linker scripts (*.lds) and makefile settings
Board support file Description of generated files
settings.mk Make settings used to set -march and -mabi arguments during the RISC-V GNU toolchain build
metal.h Device header file which is used internally by the Metal library to instantiate structures to support the target
metal-platform.h - Sub file of metal.h containing memory mapped peripheral and configuration definition macros
metal-inline.h - Sub file of metal.h containing function prototypes and structures for the device peripherals
metal.*.lds Linker scripts for building programs to execute from different memory configurations (e.g., metal.ramrodata.lds)
openocd.cfg Custom configuration used to program and debug the machine with OpenOCD
freedom-e-sdk % cd bsp ; mkdir mybsp
bsp % cp <path-to>/design.dts mybsp
bsp % ./update-targets.sh --target-name mybsp --sdk-path=./../ --target-dts=./mybsp/design.dts
bsp %
COPYRIGHT 2020 SIFIVE. ALL RIGHTS RESERVED.181818
user1 % which git make riscv64-unknown-elf-gcc qemu-system-riscv32 jlink
/usr/bin/git
/usr/bin/make
/tools/v2019.08/riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-apple-darwin/bin/riscv64-unknown-elf-gcc
/tools/v2019.08/riscv-qemu-4.1.0-2019.08.0-x86_64-apple-darwin/bin/qemu-system-riscv324
jlink not found
user1 % git clone --recursive https://github.com/sifive/freedom-e-sdk.git ; cd freedom-e-sdk
freedom-e-sdk % make [clean | metal | software | upload | debug | simulate | standalone | open-docs]
Command Description Options
clean Cleans compiled objects [PROGRAM=<software>] [TARGET=<bsp>] [CONFIGURATION=debug|release]
metal Builds the Metal library [TARGET=<bsp>] [CONFIGURATION=debug|release]
software Builds the example software [PROGRAM=<software>] [TARGET=<bsp>] [CONFIGURATION=debug|release]
upload Loads the executable to the on-board flash [PROGRAM=<software>] [TARGET=<bsp>] [CONFIGURATION=debug|release]
debug Attaches GDB to a running target [PROGRAM=<software>] [TARGET=<bsp>] [CONFIGURATION=debug|release]
simulate Runs the program in the QEMU emulator [PROGRAM=<software>] [TARGET=<bsp>] [CONFIGURATION=debug|release]
standalone Exports a program into a single target STANDALONE_DEST=<path> [PROGRAM=<software>] [TARGET=<bsp>]
open-docs Opens the Freedom E SDK documentation
Command line environment
COPYRIGHT 2020 SIFIVE. ALL RIGHTS RESERVED.191919
Startup and initialization of CPU core complex and SoC subsystem
Hardware abstraction layer - provides a portable interface to all standardand custom SiFive RISC-V core IP and peripherals targeting silicon developmentboards, FPGA development boards or simulation (RTL, QEMU)
Metal library
Freedom E SDK
IP Delivery Dev Board FPGA
drivers libgloss
Metal library
stack ptr data init main()
entry.S crt0.S
RISC-V core IP
● CPU, PMP● Caches, ITIM● Interrupts
Startup and Initialization
● entry.S● crt0.S● libgloss syscalls
Peripherals
● UART● I2C● SPI
● Clocks● Timer● RTC
● PWM● GPIO● Watchdog
COPYRIGHT 2020 SIFIVE. ALL RIGHTS RESERVED.202020
Exploring the Metal library
freedom-metal % tree
.
├── doc
├── dts
├── gloss
├── m4
├── metal
├── scripts
├── src
├── test
├── Doxyfile
├── LICENSE
├── LICENSE.Apache2
├── LICENSE.MIT
├── Makefile.am
├── Makefile.in
├── README.md
├── aclocal.m4
├── ar-lib
├── build.wake
├── compile
├── configure
├── configure.ac
├── depcomp
├── install-git-hooks
├── install-sh
├── missing
└── riscv__menv__metal.specs.in
8 directories, 18 files
freedom-metal %
metal % tree -FL 1 | grep -v /$
.
├── button.h
├── cache.h
├── clock.h
├── compiler.h
├── cpu.h
├── gpio.h
├── interrupt.h
├── io.h
├── itim.h
├── led.h
├── lock.h
├── memory.h
├── pmp.h
├── privilege.h
├── rtc.h
├── shutdown.h
├── spi.h
├── switch.h
├── time.h
├── timer.h
├── tty.h
├── uart.h
└── watchdog.h
1 directory, 23 files
metal %
Implementation for drivers
syscalls
COPYRIGHT 2020 SIFIVE. ALL RIGHTS RESERVED.212121
Place functions in instruction tightly integrated memory (ITIM)
METAL_PLACE_IN_ITIM
void my_itim_func() {
/* This code will run out of the ITIM */
}
Creating your own program in the make based workflow
freedom-e-sdk % cp -rf software/empty software/my-program
freedom-e-sdk % sed -i '' 's/empty/my-program/g' ./software/my-program/Makefile
freedom-e-sdk % make software PROGRAM=my-program
Automatically call functions user functions at startup (before main)
static void my_specific_startup_routine(void) __attribute__((constructor));
static void my_specific_startup_routine(void) {
static int a = b = c = d = 0xffffffff;
}
Freedom E SDK tips and tricks
COPYRIGHT 2020 SIFIVE. ALL RIGHTS RESERVED.2222
DEMO !!!