[lkml]   [2019]   [Apr]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectTesting the recent RISC-V DT patchsets

I've heard from two separate people who have had trouble getting started
with BBL & open-source FSBL test flows with arbitrary DT files on the
Freedom Unleashed board. The following instructions should help get
people started.

The core issue, aside from general unfamiliarity, is that multiple parts
of the pre-kernel software stack try to parse and/or modify the kernel DT.
We wish to avoid this as much as possible.

Testing with U-boot and OpenSBI is currently left as an exercise for the
reader, for a similar reason and because those ports are still quite new.

The following instructions are provided with no warranty whatsoever, and
assume knowledge of the shell and Linux. If implemented carelessly, may
trash your filesystems or do other horrible things.

- Paul

These instructions assume that bare metal and Linux RV64 cross-toolchains
are installed. If not, consider using crosstool-ng with the
"riscv64-unknown-elf" and "riscv64-unknown-linux-gnu" experimental sample
configurations. You will need both.

1. Put the location of the temporary build tree into the BASE
environment variable, and set up some initial directories:
export BASE=~/riscv-test; mkdir -p ${BASE}/work

2. Partition a microSD card with (at least) two GPT partitions.
Here is a sample sfdisk dump:

label: gpt
label-id: 074689DB-0440-411C-91DB-440DFE5BA0B6
device: /dev/sda
unit: sectors
first-lba: 34
last-lba: 62333918

/dev/sda1 : start= 2048, size= 2048, type=5B193300-FC78-40CD-8002-E86C45580B47, uuid=DEAD9378-45FF-44FB-B2E3-F3FEA45ADC9E, name="fsbl"
/dev/sda2 : start= 4096, size= 65536, type=2E54B353-1271-4842-806F-E436D6AF6985, uuid=1B48DE68-8004-444D-BA47-AAA8DBEBFA60, name="bbl"
/dev/sda3 : start= 69632, size= 62264287, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=D672F1FC-3E45-4CC1-835A-E6384A26C395, name="rootfs"

3. Download the open-source FSBL:
cd ${BASE}
git clone

4. Build the open-source FSBL:
cd freedom-u540-c000-bootloader
CROSSCOMPILE=/opt/rv64gc-mmu-elf/bin/riscv64-unknown-elf- make

5. Write the open-source FSBL to the first partition of the SD card with
something like:
sudo dd if=fsbl.bin of=/dev/SD-CARD-DEVICE1 conv=nocreat

6. Copy an initramfs sysroot into ${BASE}/work/buildroot_initramfs_sysroot.
A reasonable one to start with is the sysroot built by
freedom-u-sdk, in work/buildroot_initramfs_sysroot.

7. Set the CROSS_COMPILE environment variable to point to your
cross-compiler, in the Linux kernel form:
export CROSS_COMPILE=/opt/rv64gc-mmu-linux-8.2.0/bin/riscv64-unknown-linux-gnu-

8. Put something like this into a script and run it:

if [ ! -d ${BASE} ]; then
echo Base build directory must be set in the BASE environment variable
if [ ! -x ${CROSS_COMPILE}gcc ]; then
echo Path to cross-compiler must be set in the CROSS_COMPILE
environment variable

export ARCH=riscv
export OBJCOPY=${CROSS_COMPILE}objcopy
export CC=${CROSS_COMPILE}gcc



cd ${BASE}
git clone -b dev/paulw/reduce-dt-load-v1
git clone -b dev/paulw/dts-v5.1-rc6-experimental

cd riscv-linux
make -j${CORES} defconfig dtbs vmlinux

${CROSS_COMPILE}strip -o ${BASE}/work/vmlinux-stripped

rm -rf ${BASE}/work/riscv-pk
mkdir -p ${BASE}/work/riscv-pk
cd ${BASE}/work/riscv-pk
ln -sf
${BASE}/riscv-pk/configure \
--host=riscv64-unknown-linux-gnu \
--enable-print-device-tree --with-payload=../vmlinux-stripped
CFLAGS="-mabi=lp64d -march=rv64imafdc" make

$OBJCOPY -S -O binary --change-addresses -0x80000000 bbl ../bbl.bin

9. Write ${BASE}/work/bbl.bin to the second partition of your microSD
card with something like:
sudo dd if=${BASE}/work/bbl.bin of=/dev/SD-CARD-DEVICE2 bs=64k conv=nocreat

10. Boot the microSD card on your Unleashed board.

 \ /
  Last update: 2019-04-23 02:19    [W:0.103 / U:0.096 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site