diff mbox series

[1/1] configs/bananapi_f3: new defconfig

Message ID 20240815130312.526791-1-kilian.zinnecker@mail.de
State New
Headers show
Series [1/1] configs/bananapi_f3: new defconfig | expand

Commit Message

Kilian Zinnecker Aug. 15, 2024, 1:03 p.m. UTC
This patch adds board support for the Banana Pi BPI-F3.

This board features the Spacemit K1 RISC-V SoC. The board support
creates a bootable sd card image. It uses a custom kernel, custom
OpenSBI and custom u-boot. Due to issues with the custom kernel,
the sound is disabled.

Signed-off-by: Kilian Zinnecker <kilian.zinnecker@mail.de>
---
 DEVELOPERS                                 |  2 +
 board/bananapi/bananapi-f3/bananapi-f3.dts | 15 +++++
 board/bananapi/bananapi-f3/bananapi_f3.env |  7 ++
 board/bananapi/bananapi-f3/genimage.cfg    | 59 +++++++++++++++++
 board/bananapi/bananapi-f3/linux.fragment  |  3 +
 board/bananapi/bananapi-f3/post-build.sh   | 17 +++++
 board/bananapi/bananapi-f3/readme.txt      | 75 ++++++++++++++++++++++
 configs/bananapi_f3_defconfig              | 59 +++++++++++++++++
 8 files changed, 237 insertions(+)
 create mode 100644 board/bananapi/bananapi-f3/bananapi-f3.dts
 create mode 100644 board/bananapi/bananapi-f3/bananapi_f3.env
 create mode 100644 board/bananapi/bananapi-f3/genimage.cfg
 create mode 100644 board/bananapi/bananapi-f3/linux.fragment
 create mode 100755 board/bananapi/bananapi-f3/post-build.sh
 create mode 100644 board/bananapi/bananapi-f3/readme.txt
 create mode 100644 configs/bananapi_f3_defconfig

Comments

Kilian Zinnecker Aug. 15, 2024, 1:20 p.m. UTC | #1
Hello all,

the board support still has some flaws. Maybe someone can help me a bit with 
it:

[--SNIP--]
> --- /dev/null
> +++ b/board/bananapi/bananapi-f3/bananapi-f3.dts
> @@ -0,0 +1,15 @@
> +/dts-v1/;
> +
> +#include "spacemit/k1-x_mingo.dts"

Maybe someone knows where to find a more suitable dts for the Banana Pi BPI-F3?

[--SNIP--]
> --- /dev/null
> +++ b/board/bananapi/bananapi-f3/post-build.sh
> @@ -0,0 +1,17 @@
> +#!/bin/bash
> +set -e
> +
> +MKIMAGE="${HOST_DIR}"/bin/mkimage
> +MKENVIMAGE="${HOST_DIR}"/bin/mkenvimage
> +BOARD_DIR="$(pwd)"/"${0%/*}"
> +
> +"${MKENVIMAGE}" -s 16384 -o "${BINARIES_DIR}"/u-boot-env.bin

I guess I should rather be using BR2_PACKAGE_HOST_UBOOT_TOOLS_ENVIMAGE here?

> "${BOARD_DIR}"/bananapi_f3.env +
> +pushd "${BINARIES_DIR}"
> +cp "${BUILD_DIR}"/uboot-*/bootinfo_sd.bin "${BINARIES_DIR}"/
> +cp "${BUILD_DIR}"/uboot-*/u-boot.itb "${BINARIES_DIR}"/
> +cp "${BUILD_DIR}"/uboot-*/FSBL.bin "${BINARIES_DIR}"/
> +cp "${BUILD_DIR}"/opensbi-*/build/platform/generic/firmware/fw_dynamic.itb

I don't like using wildcards here. Does anyone have a hint for me, how this 
could be done better here?

Thanks and best regards,
Kilian
diff mbox series

Patch

diff --git a/DEVELOPERS b/DEVELOPERS
index 16f63bdc0e..5ec07ea670 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -2007,8 +2007,10 @@  F:	package/libcamera/
 
 N:	Kilian Zinnecker <kilian.zinnecker@mail.de>
 F:	board/avnet/rzboard_v2l/
+F:	board/bananapi/bananapi-f3/
 F:	board/radxa/rock5b/
 F:	configs/avnet_rzboard_v2l_defconfig
+F:	configs/bananapi_f3_defconfig
 F:	configs/rock5b_defconfig
 F:	package/rockchip-rkbin/
 
diff --git a/board/bananapi/bananapi-f3/bananapi-f3.dts b/board/bananapi/bananapi-f3/bananapi-f3.dts
new file mode 100644
index 0000000000..ca2fdd50d5
--- /dev/null
+++ b/board/bananapi/bananapi-f3/bananapi-f3.dts
@@ -0,0 +1,15 @@ 
+/dts-v1/;
+
+#include "spacemit/k1-x_mingo.dts"
+
+&hdmi_sspa {
+	status = "disabled";
+};
+
+&sound_hdmi {
+	status = "disabled";
+};
+
+&sound_codec {
+	status = "disabled";
+};
diff --git a/board/bananapi/bananapi-f3/bananapi_f3.env b/board/bananapi/bananapi-f3/bananapi_f3.env
new file mode 100644
index 0000000000..23d947e428
--- /dev/null
+++ b/board/bananapi/bananapi-f3/bananapi_f3.env
@@ -0,0 +1,7 @@ 
+kernel_name="Image"
+fdt_name="bananapi-f3.dtb"
+kernel_addr_r=0x11000000
+fdt_addr_r=0x31000000
+bootdelay=2
+bootargs=earlyprintk console=ttyS0,115200, loglevel=8 clk_ignore_unused root=/dev/mmcblk0p6 rootwait rw
+bootcmd=load mmc 0:5 ${kernel_addr_r} ${kernel_name}; load mmc 0:5 ${fdt_addr_r} ${fdt_name}; booti ${kernel_addr_r} - ${fdt_addr_r}
diff --git a/board/bananapi/bananapi-f3/genimage.cfg b/board/bananapi/bananapi-f3/genimage.cfg
new file mode 100644
index 0000000000..6e660fef44
--- /dev/null
+++ b/board/bananapi/bananapi-f3/genimage.cfg
@@ -0,0 +1,59 @@ 
+# SD card image for Banana Pi BPI-F3
+
+image boot.vfat {
+	vfat {
+		files = {
+			"Image",
+			"bananapi-f3.dtb",
+		}
+	}
+	size = 60M
+}
+
+image sdcard.img {
+	hdimage {
+		partition-table-type = "hybrid"
+	}
+
+	partition bootinfo {
+		in-partition-table = "no"
+		image = "bootinfo_sd.bin"
+		offset = 0K
+		size = 512
+		holes = {"(80; 512)"}
+	}
+
+	partition fsbl {
+		image = "FSBL.bin"
+		offset = 128K
+		size = 256K
+	}
+
+	partition u-boot-env {
+		image = "u-boot-env.bin"
+		offset = 384K
+		size = 64K
+	}
+
+	partition opensbi {
+		image = "fw_dynamic.itb"
+		offset = 512K
+		size = 256K
+	}
+
+	partition uboot {
+		image = "u-boot.itb"
+		offset = 1M
+		size = 2M
+	}
+
+	partition kernel {
+		bootable = "true"
+		image = "boot.vfat"
+	}
+
+	partition rootfs {
+		partition-type = 0x83
+		image = "rootfs.ext4"
+	}
+}
diff --git a/board/bananapi/bananapi-f3/linux.fragment b/board/bananapi/bananapi-f3/linux.fragment
new file mode 100644
index 0000000000..a989a32df7
--- /dev/null
+++ b/board/bananapi/bananapi-f3/linux.fragment
@@ -0,0 +1,3 @@ 
+# CONFIG_SND_SOC_SPACEMIT is not set
+# CONFIG_SND_SOC_ALL_CODECS is not set
+# CONFIG_SOUND is not set
diff --git a/board/bananapi/bananapi-f3/post-build.sh b/board/bananapi/bananapi-f3/post-build.sh
new file mode 100755
index 0000000000..b12104d734
--- /dev/null
+++ b/board/bananapi/bananapi-f3/post-build.sh
@@ -0,0 +1,17 @@ 
+#!/bin/bash
+set -e
+
+MKIMAGE="${HOST_DIR}"/bin/mkimage
+MKENVIMAGE="${HOST_DIR}"/bin/mkenvimage
+BOARD_DIR="$(pwd)"/"${0%/*}"
+
+"${MKENVIMAGE}" -s 16384 -o "${BINARIES_DIR}"/u-boot-env.bin "${BOARD_DIR}"/bananapi_f3.env
+
+pushd "${BINARIES_DIR}"
+cp "${BUILD_DIR}"/uboot-*/bootinfo_sd.bin "${BINARIES_DIR}"/
+cp "${BUILD_DIR}"/uboot-*/u-boot.itb "${BINARIES_DIR}"/
+cp "${BUILD_DIR}"/uboot-*/FSBL.bin "${BINARIES_DIR}"/
+cp "${BUILD_DIR}"/opensbi-*/build/platform/generic/firmware/fw_dynamic.itb "${BINARIES_DIR}"/
+popd
+
+support/scripts/genimage.sh -c "${BOARD_DIR}"/genimage.cfg
diff --git a/board/bananapi/bananapi-f3/readme.txt b/board/bananapi/bananapi-f3/readme.txt
new file mode 100644
index 0000000000..a63f943cae
--- /dev/null
+++ b/board/bananapi/bananapi-f3/readme.txt
@@ -0,0 +1,75 @@ 
+Banana Pi BPI-F3
+================
+https://docs.banana-pi.org/en/BPI-F3/BananaPi_BPI-F3
+
+Build:
+======
+  $ make bananapi_f3_defconfig
+  $ make
+
+Files created in output directory
+=================================
+
+output/images
+.
+├── bananapi-f3.dtb
+├── bootinfo_sd.bin
+├── boot.vfat
+├── FSBL.bin
+├── fw_dynamic.bin
+├── fw_dynamic.elf
+├── fw_dynamic.itb
+├── fw_jump.bin
+├── fw_jump.elf
+├── Image
+├── rootfs.ext2
+├── rootfs.ext4 -> rootfs.ext2
+├── rootfs.tar
+├── sdcard.img
+├── u-boot.bin
+├── u-boot-env.bin
+├── u-boot.itb
+└── u-boot-spl.bin
+
+Creating bootable SD card:
+==========================
+
+Simply invoke (as root)
+
+sudo dd if=output/images/sdcard.img of=/dev/sdX && sync
+
+Where X is your SD card device.
+
+Booting:
+========
+
+Serial console:
+---------------
+The Banana Pi BPI-F3 has a 3-pin header (J25) labeled with TX, RX and GND for
+UART. Baudrate for this board is 115200.
+
+Login:
+------
+Enter 'root' as login user, and the prompt is ready.
+
+Issues:
+=======
+
+The boot of the custom kernel hangs at 'spacemit_snd_sspa_pdev_probe'. In
+addition there is a bug in the source code of the custom kernel in line 1246
+of sound/soc/codecs/es8326.c. Hence, CONFIG_SND_SOC_SPACEMIT and further
+kernel config parameters are disabled.
+
+Furthermore, as there currently is no device tree source file specificly for
+the Banana Pi BPI-F3, the dts from the mingo board is used.
+
+Links:
+======
+
+wiki link:
+----------
+https://docs.banana-pi.org/en/BPI-F3/BananaPi_BPI-F3
+
+forum link:
+-----------
+https://forum.banana-pi.org/c/risc-v/85
diff --git a/configs/bananapi_f3_defconfig b/configs/bananapi_f3_defconfig
new file mode 100644
index 0000000000..6ef5335c0e
--- /dev/null
+++ b/configs/bananapi_f3_defconfig
@@ -0,0 +1,59 @@ 
+# Architecture
+BR2_riscv=y
+BR2_riscv_custom=y
+BR2_RISCV_ISA_RVM=y
+BR2_RISCV_ISA_RVA=y
+BR2_RISCV_ISA_RVF=y
+BR2_RISCV_ISA_RVD=y
+BR2_RISCV_ISA_RVC=y
+BR2_RISCV_64=y
+BR2_RISCV_ABI_LP64D=y
+
+# System
+BR2_ROOTFS_POST_BUILD_SCRIPT="board/bananapi/bananapi-f3/post-build.sh"
+BR2_ROOTFS_POST_IMAGE_SCRIPT="support/scripts/genimage.sh"
+BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/bananapi/bananapi-f3/genimage.cfg"
+
+# Filesystem
+BR2_TARGET_ROOTFS_EXT2=y
+BR2_TARGET_ROOTFS_EXT2_4=y
+
+# Linux headers same as kernel, a 6.1 series
+BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_6_1=y
+
+# Kernel
+BR2_LINUX_KERNEL=y
+BR2_LINUX_KERNEL_CUSTOM_GIT=y
+BR2_LINUX_KERNEL_CUSTOM_REPO_URL="https://gitee.com/bianbu-linux/linux-6.1.git"
+BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="95d774caeae5409927384a2984e3ad5badf74cf6"
+BR2_LINUX_KERNEL_USE_DEFCONFIG=y
+BR2_LINUX_KERNEL_DEFCONFIG="k1"
+BR2_LINUX_KERNEL_DTS_SUPPORT=y
+BR2_LINUX_KERNEL_CUSTOM_DTS_PATH="board/bananapi/bananapi-f3/bananapi-f3.dts"
+BR2_LINUX_KERNEL_DTB_OVERLAY_SUPPORT=y
+BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
+BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="board/bananapi/bananapi-f3/linux.fragment"
+
+# Bootloader
+BR2_TARGET_OPENSBI=y
+BR2_TARGET_OPENSBI_CUSTOM_GIT=y
+BR2_TARGET_OPENSBI_CUSTOM_REPO_URL="https://gitee.com/bianbu-linux/opensbi.git"
+BR2_TARGET_OPENSBI_CUSTOM_REPO_VERSION="94bf83cc0bd1c86e51f48174fa17e23427903c59"
+BR2_TARGET_OPENSBI_PLAT="generic"
+BR2_TARGET_OPENSBI_ADDITIONAL_VARIABLES="PLATFORM_DEFCONFIG=k1_defconfig"
+BR2_TARGET_UBOOT=y
+BR2_TARGET_UBOOT_CUSTOM_GIT=y
+BR2_TARGET_UBOOT_CUSTOM_REPO_URL="https://gitee.com/bianbu-linux/uboot-2022.10.git"
+BR2_TARGET_UBOOT_CUSTOM_REPO_VERSION="41499876c85f19ff73b4450eca69bf3405a9d4a9"
+BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y
+BR2_TARGET_UBOOT_BOARD_DEFCONFIG="k1"
+BR2_TARGET_UBOOT_NEEDS_DTC=y
+BR2_TARGET_UBOOT_NEEDS_OPENSBI=y
+BR2_TARGET_UBOOT_NEEDS_OPENSSL=y
+BR2_TARGET_UBOOT_SPL=y
+
+# Host tools
+BR2_PACKAGE_HOST_GENIMAGE=y
+BR2_PACKAGE_HOST_MTOOLS=y
+BR2_PACKAGE_HOST_UBOOT_TOOLS=y
+BR2_PACKAGE_HOST_UBOOT_TOOLS_FIT_SUPPORT=y