opensbi
git clone https://github.com/riscv-software-src/opensbi.git
cd opensbi/
sudo apt install gcc-riscv64-linux-gnu
make PLATFORM=generic FW_TEXT_START=0x40000000 FW_OPTIONS=0 CROSS_COMPILE=riscv64-linux-gnu- -j16
uboot
sudo apt install swig
git clone https://github.com/u-boot/u-boot.git
cd u-boot/
starfive_visionfive2_defconfig
添加:
CONFIG_CMD_SYSBOOT=y
CONFIG_BOOTCOMMAND="sysboot mmc 1:3 any b0000000 /extlinux/extlinux.conf"
make starfive_visionfive2_defconfig
make CROSS_COMPILE=riscv64-linux-gnu- OPENSBI=../opensbi/build/platform/generic/firmware/fw_dynamic.bin -j16
linux
git clone https://github.com/starfive-tech/linux.git
cd linux/
git checkout JH7110_VisionFive2_upstream
make starfive_visionfive2_defconfig
make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- -j16
rootfs
sudo apt install mmdebstrap qemu-user-static binfmt-support
mkdir rvrootfs
sudo mmdebstrap --architectures=riscv64 sid rvrootfs "deb https://mirrors.ustc.edu.cn/debian sid main"
sudo chroot rvrootfs
passwd root
...
exit
dd if=/dev/zero of=rootfs.img bs=1G count=1
sudo mkfs.ext4 rootfs.img
mkdir rootfs_mount
sudo mount rootfs.img rootfs_mount
sudo cp -rfp rvrootfs/* rootfs_mount
sudo umount rootfs_mount
rm -r rootfs_mount
sudo e2fsck -f rootfs.img
sudo resize2fs -M rootfs.img # 调整镜像为实际大小
sdcard
sudo sgdisk -z -og /dev/sdc
sudo sgdisk --clear \
--set-alignment=2 \
--new=1:4096:8191 --change-name=1:spl --typecode=1:2E54B353-1271-4842-806F-E436D6AF6985 \
--new=2:8192:16383 --change-name=2:uboot --typecode=2:BC13C2FF-59E6-4262-A352-B275FD6F7172 \
--new=3:16384:1654784 --change-name=3:boot --typecode=3:EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 \
--new=4:1654785: --change-name=4:rootfs \
/dev/sdc
sudo mkfs.ext4 /dev/sdc3
nano extlinux.conf
extlinux.conf:
default hhh
label hhh
kernel /Image.gz
fdt /jh7110-starfive-visionfive-2-v1.3b.dtb
append root=/dev/mmcblk1p4 rw
sudo dd if=u-boot/spl/u-boot-spl.bin.normal.out of=/dev/sdc1 bs=512
sudo dd if=u-boot/u-boot.itb of=/dev/sdc2 bs=512
sudo dd if=rootfs.img of=/dev/sdc4 bs=512
sync
sudo mount /dev/sdc3 /mnt/
sudo mkdir /mnt/extlinux
sudo cp extlinux.conf /mnt/extlinux/
sudo cp linux/arch/riscv/boot/Image.gz /mnt/
sudo cp linux/arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-2-v1.3b.dtb /mnt/
sudo umount /mnt
power on…
使用root
登录
扩展分区大小:
lsblk
df -h
resize2fs /dev/mmcblk1p4