DEV Community

Luca Barbato
Luca Barbato

Posted on • Updated on

Bringing up BPI-F3 - Part 2

This is part2, in part1 I shown how to get a Gentoo system on the nvme taking some shortcuts. Here are the notes from the second day with some improvements.

Setting up the eMMC

stintel already documented how to build uboot and install it, I'm summarizing it as well here.

Dependencies

We need dtc to compile the device-tree and mkimage and git if we want to clone the trees.

emerge dtc u-boot-tools dev-vcs/git
Enter fullscreen mode Exit fullscreen mode

Bootloader

This board boot process relies on opensbi + u-boot

  • First build opensbi
git clone https://github.com/BPI-SINOVOIP/pi-opensbi -b v1.3-k1
cd pi-opensbi
make PLATFORM=generic menuconfig
make -j 8
Enter fullscreen mode Exit fullscreen mode

As stintel already reported, the default configuration is wrong, so we have to make sure that the build/platform/generic/kconfig/.config has the support for K1x:

# CONFIG_PLATFORM_SPACEMIT_K1PRO is not set
CONFIG_PLATFORM_SPACEMIT_K1X=y
Enter fullscreen mode Exit fullscreen mode

If everything goes well build/platform/generic/firmware/fw_dynamic.bin will exist.

  • Then build u-boot
export OPENSBI=../pi-opensbi/build/platform/generic/firmware/fw_dynamic.bin
git clone https://github.com/BPI-SINOVOIP/pi-u-boot -b v2022.10-k1
cd pi-u-boot
make k1_defconfig
make -j8
Enter fullscreen mode Exit fullscreen mode

If everything goes well it will produce the following files

FSBL.bin  
bootinfo_emmc.bin  
bootinfo_sd.bin  
bootinfo_spinand.bin  
bootinfo_spinor.bin 
u-boot.bin
Enter fullscreen mode Exit fullscreen mode

Partitions

The upstream instructions suggest to copy over the layout, so the uboot, bootfs, rootfs partitions stay the same, but now the eMMC fsbl and opensbi are to live in their dedicated /dev/mmcblk2boot0. So it is up to you to do what you prefer with them.
Surely you have to setup /dev/mmcblk2boot0:

echo 0 > /sys/block/mmcblk2boot0/force_ro
dd if=bootinfo_emmc.bin of=/dev/mmcblk2boot0
dd if=FSBL.bin of=/dev/mmcblk2boot0 bs=512 seek=1
Enter fullscreen mode Exit fullscreen mode

As stintel tested, all that's need is that a partition labeled uboot exists and contains u-boot.bin and a bootfs partition that contains env_k1-x.txt. It is a good idea to have env and rootfs as well.

Kernel

Building the kernel is straightforward enough:

git clone https://github.com/BPI-SINOVOIP/pi-linux -b linux-6.1.15-k1
ln -s pi-linux/ linux
cd linux
zcat /proc/config.gz > .config
make oldconfig # (or menuconfig)
make -j 10 && make modules_install
mount /boot # make sure it picks the right partition
make install
Enter fullscreen mode Exit fullscreen mode

Make sure to enable HWMON and HWMON_NVME so you'll have the thermal sensors available.

Edit boot/env_k1-x.txt accordingly and your new kernel is ready.

Coming next

  • Do not use at all an initrd (right now if you are following along you'd be using the initrd from the starting distro)
  • Other u-boot tweaks

Top comments (0)