linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Testing the recent RISC-V DT patchsets
@ 2019-04-23  0:17 Paul Walmsley
  2019-05-28  8:32 ` Paul Walmsley
  0 siblings, 1 reply; 14+ messages in thread
From: Paul Walmsley @ 2019-04-23  0:17 UTC (permalink / raw)
  To: linux-riscv, linux-serial, linux-kernel; +Cc: khilman


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 https://github.com/sifive/freedom-u540-c000-bootloader

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
fi
if [ ! -x ${CROSS_COMPILE}gcc ]; then
    echo Path to cross-compiler must be set in the CROSS_COMPILE 
environment variable
fi

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

CORES=$(getconf _NPROCESSORS_ONLN)

#
#

cd ${BASE}
git clone -b dev/paulw/reduce-dt-load-v1 
https://github.com/sifive/riscv-pk
git clone -b dev/paulw/dts-v5.1-rc6-experimental 
https://github.com/sifive/riscv-linux

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

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

rm -rf ${BASE}/work/riscv-pk
mkdir -p ${BASE}/work/riscv-pk
cd ${BASE}/work/riscv-pk
ln -sf 
${BASE}/riscv-linux/arch/riscv/boot/dts/sifive/hifive-unleashed-a00-fu540.dtb 
${BASE}/riscv-pk/linux.dtb
${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.



^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2019-06-04  6:12 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-23  0:17 Testing the recent RISC-V DT patchsets Paul Walmsley
2019-05-28  8:32 ` Paul Walmsley
2019-05-28 15:10   ` Loys Ollivier
2019-05-28 15:35     ` Karsten Merker
2019-05-29  7:50       ` Atish Patra
2019-05-29 10:04         ` Loys Ollivier
2019-05-29 17:09           ` Atish Patra
2019-05-29 17:25           ` Troy Benjegerdes
2019-06-03  9:49             ` Loys Ollivier
2019-06-03 15:40               ` Troy Benjegerdes
2019-06-03 20:17               ` Troy Benjegerdes
2019-06-04  6:12                 ` Anup Patel
2019-05-29  9:41       ` Loys Ollivier
2019-05-28 19:38   ` Atish Patra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).