• Stars
    star
    275
  • Rank 149,796 (Top 3 %)
  • Language BitBake
  • Created over 8 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Freedom U Software Development Kit (FUSDK)

freedom-u-sdk

SiFive Freedom Unleashed SDK layer for OpenEmbedded/Yocto

Description

The experimental Freedom Unleashed (FU) SDK is based on OpenEmbedded/Yocto framework, allowing to build custom Linux distributions:

  • build predefined disk images for QEMU, SiFive HiFive Unleashed development board and SiFive HiFive Unmatched
  • build custom disk images with additional software packages from various third-party OE layers;
  • quickly launch QEMU VM instance with your built disk image;
  • build bootloader binaries (OpenSBI, U-Boot, U-Boot SPL);
  • build Device Tree Binary (DTB);
  • build Linux kernel images;
  • easily modify disk partition layout.

For more information on particular release see ReleaseNotes directory in freedom-u-sdk repository on GitHub.

For advanced OE usage we advice to look into Yocto Project Documentation and A practical guide to BitBake.

Dependencies

This layer depends on:

Prerequisites for the build host

Create the build environment

mkdir dist && cd dist
git clone https://github.com/sifive/freedom-u-sdk

Available machines

This layer doesn't define new machines. It uses machine provides by the meta-sifive layer, as well as the Qemu RISC-V provided by the oe-core layer.

Available distribution

This layer provides a distribution, named freedom-u-sdk for the following machines:

  • freedom-u540: The SiFive HiFive Unleashed board,
  • unmatched: The Sifive Unmatched board,
  • qemuriscv64: The Qemu RISC-V 64bits.

It also provides two disk images:

  • demo-coreip-cli: basic command line image (recommended);
  • demo-coreip-xfce4: basic graphical disk image with Xfce 4 desktop environment.

Build images

Building disk images is CPU intensive, could require <10GB of sources downloaded over the Internet and <200GB of local storage.

This layer provides Kas scripts configured to download and to configure the build environment to build demo-coreip images for supported targets:

kas build --update ./freedom-u-sdk/scripts/kas/freedom-u540.yml
kas build --update ./freedom-u-sdk/scripts/kas/qemuriscv64.yml
kas build --update ./freedom-u-sdk/scripts/kas/unmatched.yml

Moreover, it is also possible to build other images, or SDK, or also packages, for example:

kas build --update ./freedom-u-sdk/scripts/kas/unmatched.yml --target core-image-weston
kas build --update ./freedom-u-sdk/scripts/kas/unmatched.yml --target buildtools-extended-tarball
kas build --update ./freedom-u-sdk/scripts/kas/unmatched.yml --target busybox
kas shell --update ./freedom-u-sdk/scripts/kas/unmatched.yml -c "bitbake core-image-minimal -c populate_sdk"
kas shell --update ./freedom-u-sdk/scripts/kas/unmatched.yml -c "bitbake core-image-minimal -c populate_sdk_ext"

Running in QEMU

The OpenEmbedded/Yocto framework provides a wrapper for QEMU, named runqemu in order to use it easily.

Below examples to use this Qemu over a Kas shell:

kas shell ./freedom-u-sdk/scripts/kas/qemuriscv64.yml -c "runqemu slirp nographic demo-coreip-cli"
kas shell ./freedom-u-sdk/scripts/kas/qemuriscv64.yml -c "runqemu slirp serialstdio demo-coreip-xfce4"

Execute runtime tests

The OpenEmbedded/Yocto framework provides also provides tools to implement and to run tests.

These tests can be executed on all supported targets, using the following commands:

kas build --update ./freedom-u-sdk/scripts/kas/qemuriscv64.yml:./freedom-u-sdk/scripts/kas/include/test.yml
kas shell --update ./freedom-u-sdk/scripts/kas/qemuriscv64.yml:./freedom-u-sdk/scripts/kas/include/test.yml -c "bitbake demo-coreip-cli -c populate_sdk && bitbake demo-coreip-cli -c testsdk"
kas shell --update ./freedom-u-sdk/scripts/kas/qemuriscv64.yml:./freedom-u-sdk/scripts/kas/include/test.yml -c "bitbake demo-coreip-cli -c populate_sdk_ext && bitbake demo-coreip-cli -c testsdkext"
kas shell --update ./freedom-u-sdk/scripts/kas/qemuriscv64.yml:./freedom-u-sdk/scripts/kas/include/test.yml -c "resulttool report  ./tmp/log/oeqa"

Running on Hardware

You will find all available build fragments (incl. disk images) in $BUILDDIR/tmp/deploy/images/$MACHINE where MACHINE can be:

  • freedom-u540
  • qemuriscv64
  • unmatched

Disk images files use <image>-<machine>.<output_format> format, for example,

demo-coreip-cli-unmatched.wic.xz. We are interested in .wic.xz disk images for writing to uSD card.

Be very careful while picking /dev/sdX device! Look at dmesg, lsblk, blkid, GNOME Disks, etc. before and after plugging in your uSD card to find a proper device. Double check it to avoid overwriting any of system disks/partitions!

Unmount any mounted partitions from uSD card before writing!

Flash the image on SDCard

Images built can be flashed with bmaptool (faster), for example:

sudo bmaptool copy ../build/tmp/deploy/images/unmatched/demo-coreip-xfce4-unmatched.wic.xz /dev/mmcblk0

Otherwise, you can also use the dd command, for example:

xzcat ../build/tmp/deploy/images/unmatched/demo-coreip-xfce4-unmatched.wic.xz | sudo dd of=/dev/mmcblk0 bs=512K iflag=fullblock oflag=direct conv=fsync status=progress

MSEL for Unleashed

You will need to modify MSEL to allow using U-Boot SPL, OpenSBI, U-Boot proper bootloaders from uSD card instead of SPI-NOR Flash chip:

      USB   LED    Mode Select                  Ethernet
 +===|___|==****==+-+-+-+-+-+-+=================|******|===+
 |                | | | | |X| |                 |      |   |
 |                | | | | | | |                 |      |   |
 |        HFXSEL->|X|X|X|X| |X|                 |______|   |
 |                +-+-+-+-+-+-+                            |
 |        RTCSEL-----/ 0 1 2 3 <--MSEL                     |
 |                                                         |

MSEL for Unmatched

By default MSEL on Unmatched is set to use uSD instead of SPI-NOR Flash chip to load U-Boot SPL, OpenSBI and U-Boot proper. Below is the default configuration for DIP switches (located next to Assembly Number and RTC battery):

  +----------> CHIPIDSEL
  | +--------> MSEL3
  | | +------> MSEL2
  | | | +----> MSEL1
  | | | | +--> MSEL0
  | | | | |
 +-+-+-+-+-+
 | |X| |X|X| ON(1)
 | | | | | |
 |X| |X| | | OFF(0)
 +-+-+-+-+-+
BOOT MODE SEL

Connecting Using Serial Console

Connect your HiFive Unleashed or HiFive Unmatched to your PC using microUSB-USB cable to access serial console.

For macOS, run: screen -L /dev/tty.usbserial-*01 115200

For Linux, run: screen -L /dev/serial/by-id/usb-FTDI_Dual_RS232-HS-if01-port0 115200

The above commands might vary depending on your exact setup.

-L command will log all output to screenlog.0 in your current working directory.

To quit screen, hit Ctrl - A followed by \ symbol. Finally agree to terminate all windows by typing y.

You can login with root account. The password is sifive. We strongly recommend to change the default password for the root account on the first boot before you connect it to the Internet.

Connecting Using SSH

Before you connect your board to the Internet we strongly recommend to change the default password for the root account and configure your network equipment (for example, routers and firewalls) appropriately.

SSH daemon is enabled by default, in order to be able to execute remotely runtime tests. To disable SSH daemon connect to the board using serial console method described above. Once connected execute the following commands:

systemctl disable sshd.socket
systemctl stop sshd.socket

The HiFive Unleashed and Unmatched behave like any other network capable device (such as PC, laptop, and Single Board Computers like Raspberry Pi). Connect the board to your network (for example, a router), and it will acquire IPv4 + DNS configuration using DHCP protocol. You can use your router management panel to get assigned IPv4 address or use the serial console to acquire it directly from the board (use ip addr command to print active network information). Finally you can SSH to the board:

ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no -o StrictHostKeyChecking=no -o "UserKnownHostsFile /dev/null" root@<IPv4>

Supported GPUs

Various GPUs from AMD were successfully tested with the boards. In particular Radeon HD 6450 is the most widely used. Other GPUs from the same family might also work, for instance, THD64xxM, HD7450, HD8450, R5 230, R5 235, R5 235X. The newest tested GPUs from AMD are RX 550, RX 570, RX 580 with no issues.

Online Resizing of rootfs (Root File Partition)

It is highly advised to resize partitions offline (i.e. before booting the system). If you already booted the system and cannot do offline resizing then the following instructions should resize rootfs (root file partition) to full uSD capacity:

sgdisk -v /dev/mmcblk0
sgdisk -e /dev/mmcblk0
parted /dev/mmcblk0 resizepart 4 100%
resize2fs /dev/mmcblk0p4
sync

NBD (Network Block Device) rootfs

This is an experimantal feature currently only available on SiFive HiFive Unmatched board. This allow sharing a block device over the network. This is not an extensive guide into NBD, but a quick start.

If you want to use this feature open extlinux.conf in /boot partition and modify the append line to:

append ip=dhcp root=/dev/nbd0 rw nbdroot=<server_ip_address>:<export_name> nbdport=10809 console=ttySIF0,115200 earlycon

If you are booting directly from U-Boot prompt, you would need to set bootargs variable instead.

Note that <export_name> value might be ignored by the NBD server (depends on the implementation and configuration).

nbdkit is a recommended NBD server for it's flexibility.

Here is an example command for nbdkit:

sudo nbdkit -f --verbose --threads 128 --filter=cow --filter=partition --filter=xz file demo-coreip-xfce4-unmatched-<..>.rootfs.wic.xz partition=4

This would expose the ext4 filesystem on the 4th partition from XZ compressed disk image. By default it's read-only thus we also add a COW (Copy-on-Write) layer. Note that COW layer is not saved by default and will be lost if nbdkit process is terminated. See nbdkit-cow-filter NOTES on how to save disk image with all the modifications for further use.

Using XZ compressed disk image is convenient, but doesn't deliver high performance. For higher performance uncompress disk image before sharing it via NBD.

Here is another example:

sudo mkdir rootfs
sudo tar -xJ --numeric-owner -C rootfs -f demo-coreip-xfce4-unmatched-<..>.rootfs.tar.xz
sudo nbdkit -f --verbose --threads 128 --filter=partition --filter=cow linuxdisk $PWD/rootfs size=+2G partition=1

In this particular case we uncompress rootfs into a directory. We ask nbdkit to take the directory, generate linux disk image from it, add some additional free space, add a COW layer to make it writable and send "naked" filesystem (i.e. no partition table) as before.

nbdkit has a number of plugins and filters allowing various ways how to share disk images over the network.

Run Tensorflow Lite demo

cd /usr/share/tensorflow/lite/examples/python/
python3 python3 mnist.py

Contributions & Feedback

If you want to file issues, send patches and make feature/enhancement requests use freedom-u-sdk repository on GitHub. So that the maintainer can process your request.

You are also welcome to join SiFive Forums where we have HiFive Unleashed and HiFive Unmatched categories for discussions.

More Repositories

1

freedom

Source files for SiFive's Freedom platforms
Scala
1,058
star
2

freedom-e-sdk

Open Source Software for Developing on the Freedom E Platform
C
567
star
3

freedom-tools

Tools for SiFive's Freedom Platform
Makefile
197
star
4

Kami

Kami - a DSL for designing Hardware in Coq, and the associated semantics and theorems for proving its correctness. Kami is inspired by Bluespec. It is actually a complete rewrite of an older version from MIT
Coq
188
star
5

sifive-blocks

Common RTL blocks used in SiFive's projects
Scala
179
star
6

freedom-metal

Bare Metal Compatibility Library for the Freedom Platform
C
153
star
7

fpga-shells

Scala
126
star
8

wake

The SiFive wake build tool
C++
86
star
9

elf2hex

Converts ELF files to HEX files that are suitable for Verilog's readmemh.
Shell
81
star
10

freedom-u540-c000-bootloader

Freedom U540-C000 Bootloader Code
C
77
star
11

benchmark-dhrystone

"DHRYSTONE" Benchmark Program by Reinhold P. Weicker
C
73
star
12

RiscvSpecFormal

The RiscvSpecKami package provides SiFive's RISC-V processor model. Built using Coq, this processor model can be used for simulation, model checking, and semantics analysis. The RISC-V processor model can be output as Verilog and simulated/synthesized using standard Verilog tools.
Haskell
73
star
13

duh

πŸ‘Ύ Design βˆͺ Hardware
JavaScript
72
star
14

block-inclusivecache-sifive

Scala
72
star
15

riscv-llvm

SiFive's LLVM working tree
C++
69
star
16

chisel-circt

Library to compile Chisel circuits using LLVM/MLIR (CIRCT)
Scala
69
star
17

meta-sifive

SiFive OpenEmbedded / Yocto BSP Layer
BitBake
49
star
18

block-nvdla-sifive

Verilog
40
star
19

freedom-devicetree-tools

A linker script generator for SiFive's Freedom platform
C++
32
star
20

cinco

Port of Arduino environment for Freedom E 300 Dev Kit & HiFive Board
C++
31
star
21

last-week-in-risc-v

Weekly RISC-V Newsletter
Shell
28
star
22

ProcKami

Kami based processor implementations and specifications
Coq
24
star
23

pydevicetree

Python Library for Parsing Devicetree Source v1
Python
23
star
24

verilator

Fork of Verilator with prebuilt Ubuntu binaries (https://www.veripool.org/wiki/verilator)
C++
22
star
25

wit

Workspace Integration Tool
Python
22
star
26

riscv-vector-intrinsic-fuzzing

A random fuzz generator for the RISC-V vector extension intrinsics
C
17
star
27

freedom-studio

IDE for SiFive's Freedom Platform
16
star
28

FreeRTOS-metal

C
14
star
29

berkeley-hardfloat-chisel3

Hardfloat using chisel3
Scala
12
star
30

block-pio-sifive

An example of on-boarding a PIO block in with duh and wake
Scala
12
star
31

api-generator-sifive

Wake build descriptions of hardware generators
Python
12
star
32

soc-testsocket-sifive

A simple SoC for testing IP blocks
Scala
11
star
33

soc-freedom-sifive

e300 and u500 devkits
Scala
10
star
34

hifive1-revb-pendulum

An LED Ring and Accelerometer Pendulum Demo for HiFive1 Rev B
C
10
star
35

benchmark-mem-latency

simple cache latency test
C
9
star
36

devicetree-overlay-generator

Generates Devicetree overlays which encode the assumptions and/or sane defaults
Python
9
star
37

cmsis-svd-generator

Generates CMSIS-SVD xml files from DTS info and Register templates
Python
9
star
38

chisel-circt-demo

Demonstration of a project using sifive/chisel-circt
Scala
9
star
39

ldscript-generator

Freedom Metal Linker Script Generator
Python
8
star
40

Amazon-FreeRTOS

C
8
star
41

FpuKami

Coq
7
star
42

duh-scala

⛏️ DUH component export to Scala
JavaScript
7
star
43

sifive-libc

Assembly
6
star
44

duh-ipxact

❌ DUH IP-XACT import / export package
JavaScript
6
star
45

duh-schema

πŸ“ DUH Schema
JavaScript
6
star
46

StdLibKami

Standard Library of Kami Modules
Coq
5
star
47

block-ark

πŸŒŠπŸ›³οΈπŸ˜πŸ˜πŸ…πŸˆπŸͺπŸ«πŸ‘πŸπŸ€πŸπŸŒπŸŒ block with all sorts of bus interfaces
5
star
48

example-hpm

Demonstrates usage of the RISC-V hardware performance counter APIs.
C
5
star
49

scl-metal

C
5
star
50

duh-core

🌰 DUH core
JavaScript
4
star
51

debug-mechanism-comparison

Comparison of 2 proposed debug mechanisms.
HTML
4
star
52

example-pmp-baremetal

Example on how to program Physical Memory Protection Regions
C
4
star
53

example-cflush

An example demonstrating how to use cflush (CFLUSH.D.L1) and use FENCE to ensure flush complete
C
4
star
54

example-return-pass

A simple example for RTL run return pass
Makefile
3
star
55

xc3sprog

Imported from svn://svn.code.sf.net/p/xc3sprog/code/trunk
C++
3
star
56

soscl

SiFive Open Source Cryptographic Library
HTML
3
star
57

api-scala-sifive

Package for building Scala projects with wake
Python
3
star
58

example-pmp

C
3
star
59

freedom-gcc-metal

Bare Metal GCC for SiFive's Freedom Platform
Makefile
3
star
60

example-gpio

C
3
star
61

duhportinf

πŸ‰ DUH port inference package
Python
3
star
62

freedom-qemu

QEMU System Emulator for SiFive's Freedom Platform
C
3
star
63

example-return-fail

A simple example for RTL run return fail
Makefile
3
star
64

freedom-elf2hex

Converts ELF files to HEX files that are suitable for Verilog's readmemh.
C
3
star
65

upf

upf tools
JavaScript
3
star
66

zephyr-sifive-freedom-template

Board template for building Zephyr RTOS for SiFive Freedom E-Series products
C
2
star
67

example-buserror

Freedom Metal Example for the SiFive Bus Error Unit
C
2
star
68

openocdcfg-generator

OpenOCD Configuration Generator for Freedom Metal
Python
2
star
69

example-chisel-wake

Example For Wake to run a Chisel design and unit test.
Scala
2
star
70

freedom-metal-docs

HTML
2
star
71

example-freertos-blinky-systemview

C
2
star
72

plic-baremetal

Low level setup for PLIC interrupt controller
C
2
star
73

duh-verilog

πŸ‡»Verilog import / export package
JavaScript
2
star
74

example-l2pm

Example code to demonstrate usage of Sifive L2 performance monitor counters to capture L2 cache event logs.
C
2
star
75

Segger_SystemView-metal

C
2
star
76

example-user-mode

C
2
star
77

trace-decoder-tests

Tests for SiFive trace decoder
Assembly
2
star
78

rocket-chip-wake

Wake build description for rocket-chip
2
star
79

riscv-fsf-gdb

C
2
star
80

example-firrtl-wake

Example Chisel modules and Chisel -> Verilog Wake flow
Scala
2
star
81

environment-blockci-sifive

Docker image and Wake environment for hardware development
Dockerfile
2
star
82

example-freertos-blinky

Standard Blinky freertos example
C
1
star
83

chisel-bootcamp-india

This is a trimmed down version of chisel bootcamp targeted for Indian undergraduate students. The Exercises here are sourced from different public chisel materials
Scala
1
star
84

testenv-metal

Test environment for freedom-metal
C
1
star
85

test-wfi-multicore

C
1
star
86

duh-svd

DUH to SVD converter
JavaScript
1
star
87

example-multicore-hello

C
1
star
88

environment-example-sifive

An example environment package
1
star
89

duh-bus

🚌 Bus definition DUH documents
JavaScript
1
star
90

spdk-multithread

C
1
star
91

prepare-riscv-toolchain-qemu

Shell
1
star
92

example-freertos-minimal

C
1
star
93

duh-mem

Ⓜ️ DUH memory package
JavaScript
1
star
94

soc-iofpga-sifive

An IOFPGA SoC
Scala
1
star
95

firesim-ci-image

CI Image with LLVM and RISC-V utilities
Shell
1
star
96

freedom-gdb-metal

Bare Metal GDB for SiFive's Freedom Platform
Makefile
1
star
97

example-clic-nested-interrupts

A simple example demonstrating how to use CLIC preemptive (level and priority) nested interrupts
C
1
star
98

example-l2pf

Example code to demonstrate usage of Sifive L2 hardware prefetcher.
C
1
star
99

tree-sitter-wake

Wake grammar for tree-sitter
JavaScript
1
star
100

example-gpio-testbench

Exercises a GPIO connected to an RTL Testbench
C
1
star