Alternate to official instruction small BSP building.
The current official guide seems very uncomfortable :
so we ended up with alternate one.
Thanks to Samuel Holland samuel@sholland.org to make this thing easy.
I've disabled emac and spi-nand in separate dts currently, they are no harm but still useless for LicheeRV RV Dock and pure LicheeRV, for 86 Panel a modification is also required, so we use sun20i-d1-nezha-lichee.dts instead of sun20i-d1-nezha.dts for now.
Install the prerequisites for the riscv-gnu-toolchain:
You don't have to do any other steps except the prerequisites.
Install additional prerequisites (may be required for fresh Ubuntu installation, thanks to Alexander Fomichev for sharing this):
apt install python3-distutils swig python3-dev libssl-dev python3-pkg-resources cpio
Fetch all submodules:
$ git submodule update --init --recursive
Bundled toochain:
$ make
Either provide TARGET_CROSS_PREFIX:
$ TARGET_CROSS_PREFIX=riscv64-unknown-linux-gnu make
Or simply nail it down in Makefile before ifndef TARGET_CROSS_PREFIX
:
TARGET_CROSS_PREFIX=riscv64-unknown-linux-gnu
ifndef TARGET_CROSS_PREFIX
TARGET_CROSS_PREFIX = ${TOOLCHAIN_PREFIX}/bin/${TARGET_CROSS}
EXTERNAL_CROSS = 0
else
TARGET_CROSS_PATH := $(shell dirname $$(which $${TARGET_CROSS_PREFIX}-gcc))
TARGET_CROSS_PREFIX := ${TARGET_CROSS_PATH}/${TARGET_CROSS_PREFIX}
EXTERNAL_CROSS = 1
endif
$ make
After make we will need the following files:
I use dtb for Lichee RV Dock currently if you require something different edit toc1/toc1.cfg accordingly.
Example of making a card (assuming card is /dev/sdd and empty) :
# parted /dev/sdd --script mklabel gpt
# parted /dev/sdd --script mkpart primary ext2 40MiB 100MiB
# parted /dev/sdd --script mkpart primary ext4 100MiB 100%
# mkfs.ext2 /dev/sdd1 # partion with kernel, dtb, initramfs
# mkfs.ext4 /dev/sdd2 # partition for rootfs
# mount /dev/sdd1 /mnt/sdcard/
# cp build-linux/arch/riscv/boot/Image.gz /mnt/sdcard/
# cp initramfs.img.gz /mnt/sdcard/
# umount /mnt/sdcard
# dd if=sun20i_d1_spl/nboot/boot0_sdcard_sun20iw1p1.bin of=/dev/sdd bs=8192 seek=16
# dd if=u-boot.toc1 of=/dev/sdd bs=512 seek=32800 # large offset thats why we make first partion on 40 MiB
We are not using dtb from u-boot or linux kernel, as boot0 patches dtb with DRAM size and location, so we should use dtb patched - located at fdtcontroladdr.
U-boot commands (i haven't put a u-boot env yet - have to decide what i really need) :
> load mmc 0:1 ${kernel_addr_r} Image.gz
> load mmc 0:1 ${ramdisk_addr_r} initramfs.img.gz
> setenv bootargs "earlycon=sbi console=ttyS0,115200n8 root=/dev/ram0 rw rdinit=/init"
> booti ${kernel_addr_r} ${ramdisk_addr_r} ${fdtcontroladdr}
> load mmc 0:1 ${kernel_addr_r} Image.gz
> setenv bootargs "earlycon=sbi console=ttyS0,115200n8 root=/dev/mmcblk0p2"
> booti ${kernel_addr_r} - ${fdtcontroladdr}
Enjoy!