Skip to content

Commit

Permalink
bpi_f3: add support for the banana pi f3 riscv64 sbc - wip
Browse files Browse the repository at this point in the history
this looks like some nice hardware with rvv 1.0 vector extensions, 8
cores etc. and it feels a bit snappier than the starfive visionfive2

this is just some initial bringup of support for it:
- legacy bpi v6.1.15-k1 kernel used
- boot blocks, opensbi and u-boot taken from the bpi f3 armbian image
- no gpu support as just quite broken legacy driver
- xorg is running in framebuffer mode, but quite useable this way
- booting is done via some hacks based on the legacy boot setup, but
  adjusted so that regular kernel can be booted
- boot setup is reusing the uEnv.ini idea from amlogic_m8
- lots of stuff missing and not perfect yet
- it boots and runs and provides a clean debian sid image
  • Loading branch information
hexdump0815 committed May 20, 2024
1 parent eba07e9 commit 59ccc27
Show file tree
Hide file tree
Showing 12 changed files with 155 additions and 0 deletions.
1 change: 1 addition & 0 deletions systems/bpi_f3/arch.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
riscv64
28 changes: 28 additions & 0 deletions systems/bpi_f3/extra-files/boot/env_k1-x.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
bootdelay=5
baudrate=115200
stderr=serial
stdin=serial,usbkbd
stdout=serial
# we can easily use the initrd load addr here as the mem is not used after
# the uEnv.ini import anymore and that happens before the inird load
uenv_ini_addr=0x20000000
kernel_addr=0x10000000
initrd_addr=0x20000000
dtb_addr=0x1F000000

# import the uEnv.ini file with all the changable values
# filesize is set automatically after the load it seems
import_uenv_ini=echo "importing uEnv.ini ...";\
load mmc 0:1 ${uenv_ini_addr} uEnv.ini;\
env import -t ${uenv_ini_addr} ${filesize};

bootcmd=run import_uenv_ini;\
echo "loading kernel ...";\
load mmc 0:1 ${kernel_addr} Image-${kver};\
echo "loading dtb ...";\
load mmc 0:1 ${dtb_addr} dtb-${kver}/${dtb_name};\
echo "loading ramdisk ...";\
load mmc 0:1 ${initrd_addr} initrd.img-${kver};\
setenv initrd_info ${initrd_addr}:${filesize};\
echo "booting ...";\
booti ${kernel_addr} ${initrd_info} ${dtb_addr};
7 changes: 7 additions & 0 deletions systems/bpi_f3/extra-files/boot/uEnv.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# this file gets imported into env_k1-x.txt which is getting imported by the bootloader
# kernel version
kver=KERNEL_VERSION
# tested to be working on a bpi f3 4gb ram and 16gb emmc
dtb_name=k1-x_deb1.dtb
# kernel cmdline
bootargs=earlycon=sbi earlyprintk console=tty1 console=ttyS0,115200 loglevel=8 clk_ignore_unused swiotlb=65536 board=bpi-f3 rdinit=/init root=/dev/mmcblk0p2 rootwait ro fsck.fix=yes fsck.repair=yes net.ifnames=0 ipv6.disable=1 selinux=0 apparmor=0
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
COMPRESS=xz
XZ_OPT='-9 --check=crc32 -memlimit-compress=25%'
22 changes: 22 additions & 0 deletions systems/bpi_f3/extra-files/etc/initramfs-tools/hooks/firmware
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh

set -e

PREREQ=""

prereqs()
{
echo "${PREREQ}"
}

case "${1}" in
prereqs)
prereqs
exit 0
;;
esac

. /usr/share/initramfs-tools/hook-functions

mkdir -p ${DESTDIR}/lib/firmware
cp -a /lib/firmware/esos.elf ${DESTDIR}/lib/firmware
5 changes: 5 additions & 0 deletions systems/bpi_f3/finalize-chroot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

# write the special boot header at the beginning of the disk back as
# it seems to get overwritten when creating the partitions with fdisk
dd if=/boot/extra/boot-bpi-f3-armbian.dd of=/dev/loop0 bs=1 count=68 status=progress
21 changes: 21 additions & 0 deletions systems/bpi_f3/get-files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# this file is supposed to be sourced by the get-files shell script

bpi_f3_release_version="6.1.15-bf3-001+"
bpi_f3_boot_version="6.1.15-bf3-001+"
bpi_f3_firmware_version="6.1.15-bf3-001+"

rm -f ${DOWNLOAD_DIR}/kernel-bpi_f3-${2}.tar.gz
wget -v https://github.com/hexdump0815/linux-spacemit-k1-kernel/releases/download/${bpi_f3_release_version}/${bpi_f3_release_version}.tar.gz -O ${DOWNLOAD_DIR}/kernel-bpi_f3-${2}.tar.gz

rm -f ${DOWNLOAD_DIR}/boot-bpi_f3-${2}.dd
wget -v https://github.com/hexdump0815/linux-spacemit-k1-kernel/raw/${bpi_f3_boot_version}/misc.bf3/misc/boot-bpi-f3-armbian.dd.gz -O - | gunzip -c > ${DOWNLOAD_DIR}/boot-bpi_f3-${2}.dd

# the boot blocks
rm -rf ${DOWNLOAD_DIR}/boot-extra-${1}
mkdir -p ${DOWNLOAD_DIR}/boot-extra-${1}
cp ${DOWNLOAD_DIR}/boot-bpi_f3-${2}.dd ${DOWNLOAD_DIR}/boot-extra-${1}/boot-bpi-f3-armbian.dd

# the required remoteproc firmware
rm -rf ${DOWNLOAD_DIR}/postinstall-${1}
mkdir -p ${DOWNLOAD_DIR}/postinstall-${1}
wget -v https://github.com/hexdump0815/linux-spacemit-k1-kernel/raw/${bpi_f3_firmware_version}/misc.bf3/misc/firmware/esos.elf.gz -O - | gunzip -c > ${DOWNLOAD_DIR}/postinstall-${1}/esos.elf
19 changes: 19 additions & 0 deletions systems/bpi_f3/mbr-partitions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
o
n
p
1
204800
+512M
t
ea
n
p
2
1253376

t
2
83
p
w

4 changes: 4 additions & 0 deletions systems/bpi_f3/partition-mapping.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
BOOTFS=fat
ROOTFS=btrfs
BOOTPART=1
ROOTPART=2
11 changes: 11 additions & 0 deletions systems/bpi_f3/postinstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# this is something for later when the gpu is working well
#cp -v etc/X11/xorg.conf.d.samples/11-modesetting-no-glamor.conf etc/X11/xorg.conf.d
#cp -v etc/X11/xorg.conf.d.samples/13-pvr-swapped-dri-nodes.conf etc/X11/xorg.conf.d

# in the meantime lets use the framebuffer for xorg - not fancy, but shoudl work well
cp -v etc/X11/xorg.conf.d.samples/11-fbdev.conf etc/X11/xorg.conf.d

# install the required remoteproc firmware
cp -v postinstall/esos.elf lib/firmware
34 changes: 34 additions & 0 deletions systems/bpi_f3/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# banana pi f3

## bootable sd card images

- none yet

## tested systems - working

- banana pi f3 (4gb ram / 16gb emmc version running from sd card)

## untested systems

- banana pi f3 (2gb ram / 8gb emmc version)

## kernel build notes

- https://github.com/hexdump0815/linux-spacemit-k1-kernel/blob/main/readme.bf3

## u-boot build notes

- none yet as for now the vendor u-boot on the sd card is used

## mesa build notes

- none yet, but will come once its time to look closer at gpu support

## priority

- medium: some first experiments with a useable riscv64 sbc

## special notes

- all this is very much wip and not that useable yet
- more info coming soon
1 change: 1 addition & 0 deletions systems/bpi_f3/todo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- lots of things to be done, but nothing noted down here yet ...

0 comments on commit 59ccc27

Please sign in to comment.