User:Minou/RiscV/BeagleV-Fire
From Gentoo Wiki
< User:Minou | RiscV
Jump to:navigation
Jump to:search
Preface
All done except flashing and test
Create gentoo rootfs
We will be using an already created rootfs
root #
emerge --ask dev-embedded/u-boot-tools
root #
mkdir /usr/src/riscv64
root #
cd /usr/src/riscv64
root #
mkdir rootfs-beaglev-fire
root #
cd rootfs-beaglev-fire
root #
tar xvf ../rootfs-riscv64-20250123.tar.gz --strip-components 1
chroot in rootfs directory
root #
arch-chroot /usr/src/riscv64/rootfs-beaglev-fire
root #
env-update
root #
export PS1="(chroot) $PS1"
root #
source /etc/profile
root #
emerge --sync
update system
Create a root password Just in case the original rootfs is a few days or weeks old it would be a good idea to do a system update If glibc or ncurses are reemerged this could take a while
root #
emerge -avuDN @world
Update fstab
{{RootCmd |echo '/dev/mmcblk0p2 /boot/firmware/ vfat user,uid=1000,gid=1000,defaults 0 2' >> /etc/fstab |echo '/dev/mmcblk0p3 / auto errors=remount-ro 0 1' >> /etc/fstab |echo 'debugfs /sys/kernel/debug debugfs mode=755,uid=root,gid=gpio,defaults 0 0' >> /etc/fstab
Create Linux Kernel
root #
cd /usr/src
root #
git clone https://github.com/SuzieLinux/linux-beaglev-fire.git
root #
ln -s linux-beaglev-fire linux
root #
cd linux
root #
cp arch/riscv/configs/beaglev_fire_defconfig .config
root #
eselect kernel list
[1] linux-beaglev-fire *
If yours doesn't have a default
or if you have an other kernel as default
select linux-beaglev-fire using the number in []
root #
eselect kernel set 1
If you don't intend to change anything do not run "make menuconfig"
This is going to take a few hours
root #
make menuconfig
root #
make Image modules dtbs
root #
make install
root #
make modules_install
root #
mkdir /boot/deploy
root #
mkdir /boot/deploy/input
root #
cp -v arch/riscv/boot/Image /boot/deploy/input/
root #
cp -v arch/riscv/boot/dts/microchip/mpfs-beaglev-fire.dtb /boot/deploy/input/
Leave chroot
root #
exit
Build HSS and u-boot
Create directories
user $
cd ~
user $
mkdir travail
user $
mkdir travail/beaglev-fire
user $
cd travail/beaglev-fire
user $
tar xvf beaglev-fire-deploy-files.tar.gz
user $
mkdir deploy/input
user $
mkdir riscv-toolchain
Build u-boot
user $
wget -c --directory-prefix=./mirror/ https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/11.4.0/x86_64-gcc-11.4.0-nolibc-riscv64-linux.tar.xz
user $
tar xvf mirror/x86_64-gcc-11.4.0-nolibc-riscv64-linux.tar.xz --strip-components=2 -C riscv-toolchain
#!/bin/bash
UBOOT_BRANCH="v2023.02-BeagleV-Fire"
UBOOT_REPO="https://openbeagle.org/beaglev-fire/beaglev-fire-u-boot.git"
echo "git clone -b ${UBOOT_BRANCH} ${UBOOT_REPO} ./u-boot-beaglev-fire --depth=${GIT_DEPTH}"
git clone -b ${UBOOT_BRANCH} ${UBOOT_REPO} ./u-boot-beaglev-fire --depth=${GIT_DEPTH}
#!/bin/bash
CORES=$(getconf _NPROCESSORS_ONLN)
wdir=`pwd`
CC=${CC:-"${wdir}/riscv-toolchain/bin/riscv64-linux-"}
make -C u-boot-beaglev-fire ARCH=riscv CROSS_COMPILE=${CC} distclean
make -C u-boot-beaglev-fire ARCH=riscv CROSS_COMPILE=${CC} microchip_mpfs_icicle_defconfig
make -C u-boot-beaglev-fire ARCH=riscv CROSS_COMPILE=${CC} olddefconfig
make -C u-boot-beaglev-fire ARCH=riscv CROSS_COMPILE=${CC} savedefconfig
cp -v ./u-boot-beaglev-fire/defconfig ./u-boot/configs/microchip_mpfs_icicle_defconfig
echo "make -C u-boot-beaglev-fire -j${CORES} ARCH=riscv CROSS_COMPILE=${CC} all"
make -C u-boot-beaglev-fire -j${CORES} ARCH=riscv CROSS_COMPILE=${CC} all
cp -v ./u-boot-beaglev-fire/u-boot.bin ./deploy/
cp -v ./u-boot-beaglev-fire/u-boot.bin ./deploy/src.bin
user $
chmod a+x get_u-boot.sh
user $
chmod a+x build_uboot.sh
user $
./get_u-boot.sh
user $
./build_uboot.sh
Build HSS
#!/bin/bash
git clone -b v2023.02 https://github.com/polarfire-soc/hart-software-services.git --depth=20
make -C hart-software-services/tools/hss-payload-generator/ clean
echo "make -C hart-software-services/tools/hss-payload-generator/"
make -C hart-software-services/tools/hss-payload-generator/
cp -v ./hart-software-services/tools/hss-payload-generator/hss-payload-generator ./deploy/
user $
chmod a+x build_hss.sh
user $
./build_hss.sh
Build payload
user $
cd deploy
user $
./hss-payload-generator -vv -c config.yaml ./input/payload.bin
user $
cp /usr/src/riscv64/rootfs-beaglev-fire/boot/deploy/input/Image ./input
user $
cp /usr/src/riscv64/rootfs-beaglev-fire/boot/deploy/input/mpfs-beaglev-fire.dtb ./input
user $
cd ./input/
user $
gzip -9 Image -c > Image.gz
user $
cp ../beaglev_fire.its ./
user $
mkimage -f beaglev_fire.its beaglev_fire.itb
cd ../../
Create SD Card image
user $
sudo rm -f /usr/src/riscv64/rootfs-beaglev-fire/var/cache/distfiles/*
user $
sudo cp -Rp /usr/src/riscv64/rootfs-beaglev-fire .root
user $
echo "label Linux eMMC" > ./deploy/input/extlinux.conf
user $
echo " kernel /Image" >> ./deploy/input/extlinux.conf
user $
echo " fdtdir /" >> ./deploy/input/extlinux.conf
user $
echo " fdt /mpfs-beaglev-fire.dtb" >> ./deploy/input/extlinux.conf
user $
echo " #fdtoverlays /overlays/<file>.dtbo" >> ./deploy/input/extlinux.conf
user $
sudo mkdir ./ignore/.root/boot/firmware
user $
sudo cp ./deploy/input/beaglev_fire.itb ./ignore/.root/boot/firmware
The command mkdosfs used by genimage doesn't exist. It must be a debian thing. I created a link earlier to satisfy genimage "ln -s mkfs.vfat mkdosfs" on /usr/bin
user $
dd if=/dev/zero of=./deploy/input/root.ext4 bs=1 count=0 seek=10400M
user $
sudo mkfs.ext4 -F ./deploy/input/root.ext4 -d ./ignore/.root
user $
cp boot.scr ./input
user $
mkdir boot
user $
mkdir root
user $
genimage --config genimage.cfg
The files boot.vfat and sdcard.img are created on images
134217728 28 jan 09:23 boot.vfat
11040145408 28 jan 09:23 sdcard.img