riscv: Add support for the BeagleBoard.org BeagleV-Ahead
cover riscv: Add support for the BeagleBoard.org BeagleV-Ahead
This series adds support for the BeagleBoard.org BeagleV-Ahead, a single board computer built around the T-Head TH1520 SoC (4x Xuantie C910) with 4 GB of LPDDR4X and 16 GB of eMMC.
Most of the work is already upstream: the TH1520 SoC support added for the Lichee Pi 4A (SPL, DDR controller, clock and pinctrl drivers, binman FIT generation) and the BeagleV-Ahead devicetree, which is available through OF_UPSTREAM. The board therefore only needs a small board directory, a U-Boot specific devicetree include and a defconfig.
The one missing piece is in the DDR controller driver, which only accepts the dual rank firmware and fails with -EINVAL on the BeagleV-Ahead. The first patch makes it program the rank configuration and the address map from the number of ranks described by the firmware.
As on the Lichee Pi 4A, u-boot-with-spl.bin contains the SPL, the DDR firmware, OpenSBI and U-Boot proper, and is loaded into SRAM through fastboot.
The BeagleV-Ahead has a single rank of LPDDR4X, so the DDR firmware has to be generated from lpddr4x-3733-singlerank.lua, which is already provided by
https://github.com/ziyao233/th1520-firmware, instead of the dual rank configuration used by the Lichee Pi 4A. This is described in the documentation added by the third patch.
Testing: the series builds with the Bootlin riscv64 glibc toolchain (2026.08-1) together with OpenSBI v1.9, and produces a u-boot-with-spl.bin holding the SPL, the DDR firmware and the FIT image.
The image was loaded into SRAM through the BROM fastboot interface on a BeagleV-Ahead. Without the first patch the SPL stops with "failed to initialize DDR controller: -22". With it, the DDR is initialized with the single rank firmware, OpenSBI and U-Boot proper start, and the console reports "Model: BeagleV Ahead", "DRAM: 4 GiB", both MMC controllers and the Ethernet device. The Ethernet link, the eMMC and microSD accesses and writing U-Boot to the eMMC were not tested. The dual rank behavior is unchanged by the first patch, but I could not test it on a Lichee Pi 4A.
Quoted 1 line
---
Thomas Perrot (3):
ram: thead: th1520: Add single rank support
board: beagle: Add BeagleV-Ahead board support
doc: board: beagle: Add BeagleV-Ahead documentation
arch/riscv/Kconfig | 9 ++ arch/riscv/dts/th1520-beaglev-ahead-u-boot.dtsi | 32 +++++++ board/beagle/beaglev_ahead/Kconfig | 43 +++++++++ board/beagle/beaglev_ahead/MAINTAINERS | 8 ++ board/beagle/beaglev_ahead/Makefile | 7 ++ board/beagle/beaglev_ahead/board.c | 14 +++ board/beagle/beaglev_ahead/spl.c | 51 +++++++++++ configs/beaglev_ahead_defconfig | 110 ++++++++++++++++++++++++ doc/board/beagle/beaglev_ahead.rst | 102 ++++++++++++++++++++++ doc/board/beagle/index.rst | 9 ++ drivers/ram/thead/th1520_ddr.c | 13 ++- include/configs/beaglev_ahead.h | 20 +++++ 12 files changed, 415 insertions(+), 3 deletions(-)
---
base-commit: ece349ade2973e220f524ce59e59711cc919263f
change-id: 20261014-dev-tprrt-beaglev-ahead-spl-7dc2a4fc0a28
Best regards,
Signature · 1 line
Thomas Perrot <[email protected]>
PATCH RESEND 1/3 ram: thead: th1520: Add single rank support
The controller initialization only handles the dual rank configuration and fails with -EINVAL when the firmware describes a single rank, as it is the case for the BeagleV-Ahead.
Select the rank configuration in MSTR and the matching address mapping in ADDRMAP0 from the number of ranks described by the firmware, with the values used for 64-bit LPDDR4X by the vendor DDR initialization code.
--- drivers/ram/thead/th1520_ddr.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/ram/thead/th1520_ddr.c +10 -3
@@ -309,10 +309,16 @@ static int th1520_ddr_ctrl_init(void __iomem *ctrlreg, struct th1520_ddr_fw *fw)if (ret)return ret; -if (fw->ranknum ==2 ) +switch (fw->ranknum) { +case 1 : +writel (0x01080020 , ctrlreg +TH1520_CTRL_MSTR ); +break ; +case 2 :writel (0x03080020 , ctrlreg +TH1520_CTRL_MSTR ); -else +break ; +default :return -EINVAL ; + }writel (0x00003030 , ctrlreg +TH1520_CTRL_MRCTRL0 );writel (0x0002d90f , ctrlreg +TH1520_CTRL_MRCTRL1 );
@@ -479,7 +485,8 @@ static int th1520_ddr_ctrl_init(void __iomem *ctrlreg, struct th1520_ddr_fw *fw)switch (fw->bitwidth) {case 64 : -writel (0x00040018 , ctrlreg +TH1520_CTRL_ADDRMAP0 ); +writel (fw->ranknum ==2 ?0x00040018 :0x0004001f , + ctrlreg +TH1520_CTRL_ADDRMAP0 );writel (0x00090909 , ctrlreg +TH1520_CTRL_ADDRMAP1 );writel (0x00000000 , ctrlreg +TH1520_CTRL_ADDRMAP2 );writel (0x01010101 , ctrlreg +TH1520_CTRL_ADDRMAP3 );
Signature · 1 line
2.56.0
PATCH RESEND 2/3 board: beagle: Add BeagleV-Ahead board support
In reply to Thomas PerrotAdd support for the BeagleBoard.org BeagleV-Ahead, based on the T-Head TH1520 SoC with 4 GB of LPDDR4X.
The TH1520 SoC support and the devicetree are already upstream, so only a board directory, a U-Boot devicetree include and a defconfig are needed. As on the Lichee Pi 4A, the SPL is loaded into SRAM through fastboot and starts OpenSBI and U-Boot from a FIT generated by binman.
The board has a single rank of memory, so the DDR firmware must be built from lpddr4x-3733-singlerank.lua instead of the dual rank configuration used by the Lichee Pi 4A.
--- arch/riscv/Kconfig | 9 ++ arch/riscv/dts/th1520-beaglev-ahead-u-boot.dtsi | 32 +++++++ board/beagle/beaglev_ahead/Kconfig | 43 +++++++++ board/beagle/beaglev_ahead/MAINTAINERS | 8 ++ board/beagle/beaglev_ahead/Makefile | 7 ++ board/beagle/beaglev_ahead/board.c | 14 +++ board/beagle/beaglev_ahead/spl.c | 51 +++++++++++ configs/beaglev_ahead_defconfig | 110 ++++++++++++++++++++++++ include/configs/beaglev_ahead.h | 20 +++++ 9 files changed, 294 insertions(+)
arch/riscv/Kconfig +9 -0
@@ -20,6 +20,14 @@ config TARGET_BANANAPI_F3 config TARGET_BEAGLEBOARD_BEAGLEVFIRE bool "Support BeagleBoard BeagleV-Fire Board (based on Microchip MPFS)" +config TARGET_BEAGLEV_AHEAD + bool "Support BeagleBoard BeagleV-Ahead Board (based on T-Head TH1520)" + select SYS_CACHE_SHIFT_6 + help + The BeagleBoard.org BeagleV-Ahead is a single board computer based on + the T-Head TH1520 SoC (4x Xuantie C910), with 4 GB of LPDDR4X and + 16 GB of eMMC. + config TARGET_K230_CANMV bool "Support K230 CanMV Board"
@@ -109,6 +117,7 @@ config SPL_ZERO_MEM_BEFORE_USE source "board/andestech/ae350/Kconfig" source "board/andestech/voyager/Kconfig" source "board/aspeed/ibex_ast2700/Kconfig" +source "board/beagle/beaglev_ahead/Kconfig" source "board/beagle/beaglev_fire/Kconfig" source "board/canaan/k230_canmv/Kconfig" source "board/emulation/qemu-riscv/Kconfig"
arch/riscv/dts/th1520-beaglev-ahead-u-boot.dtsi new file +32 -0
@@ -0,0 +1,32 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2025 Yao Zi <[email protected]> + * Copyright (C) 2026 Thomas Perrot <[email protected]> + */ + +#include "th1520-u-boot.dtsi" +#include "thead-th1520-binman.dtsi" + +&{/memory@0} { + bootph-pre-ram; +}; + +&clk { + bootph-some-ram; +}; + +&padctrl0_apsys { + bootph-some-ram; +}; + +&uart0_pins { + bootph-some-ram; + + tx-pins { + bootph-some-ram; + }; + + rx-pins { + bootph-some-ram; + }; +};
board/beagle/beaglev_ahead/Kconfig new file +43 -0
43 lines not on this page · raw message
board/beagle/beaglev_ahead/MAINTAINERS new file +8 -0
@@ -0,0 +1,8 @@ +BeagleBoard BeagleV-Ahead +M: Thomas Perrot <[email protected]> +S: Maintained +F: arch/riscv/dts/th1520-beaglev-ahead-u-boot.dtsi +F: board/beagle/beaglev_ahead/ +F: configs/beaglev_ahead_defconfig +F: doc/board/beagle/beaglev_ahead.rst +F: include/configs/beaglev_ahead.h
board/beagle/beaglev_ahead/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (c) 2023, Yixun Lan <[email protected]> +# Copyright (c) 2026, Thomas Perrot <[email protected]> + +obj-y += board.o +obj-$(CONFIG_XPL_BUILD) += spl.o
board/beagle/beaglev_ahead/board.c new file +14 -0
@@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (c) 2023, Yixun Lan <[email protected]> +* Copyright (c) 2026, Thomas Perrot <[email protected]> +*/ + +#include <cpu_func.h> + +int board_init (void ) +{ +enable_caches (); + +return 0 ; +}
board/beagle/beaglev_ahead/spl.c new file +51 -0
51 lines not on this page · raw message
configs/beaglev_ahead_defconfig new file +110 -0
110 lines not on this page · raw message
include/configs/beaglev_ahead.h new file +20 -0
@@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (c) 2023 Yixun Lan <[email protected]> +* Copyright (c) 2026 Thomas Perrot <[email protected]> +*/ + +#ifndef __BEAGLEV_AHEAD_H +#define __BEAGLEV_AHEAD_H + +#include <linux/sizes.h> + +#define CFG_SYS_NS16550_CLK 100000000 +#define CFG_SYS_SDRAM_BASE 0x00000000 + +/* Environment options */ + +#define CFG_EXTRA_ENV_SETTINGS \ + "PS1=[BeagleV-Ahead]# \0" + +#endif /* __BEAGLEV_AHEAD_H */
Signature · 1 line
2.56.0
PATCH RESEND 3/3 doc: board: beagle: Add BeagleV-Ahead documentation
In reply to Thomas PerrotDescribe how to generate the DDR firmware, build OpenSBI and U-Boot, and load the resulting u-boot-with-spl.bin on the BeagleV-Ahead through fastboot.
--- doc/board/beagle/beaglev_ahead.rst | 102 +++++++++++++++++++++++++++++++++++++ doc/board/beagle/index.rst | 9 ++++ 2 files changed, 111 insertions(+)
doc/board/beagle/beaglev_ahead.rst new file +102 -0
@@ -0,0 +1,102 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +BeagleBoard.org BeagleV-Ahead +============================= + +BeagleV-Ahead is an open-source single board computer based on the T-Head +TH1520 SoC (4x Xuantie C910 @ 1.85GHz), featuring 4 GB of LPDDR4X and 16 GB of +eMMC flash. + + - SoC T-Head TH1520 + - System Memory 4 GB LPDDR4X (single rank, 3733 MT/s) + - Storage 16 GB eMMC flash + - external microSD slot + - Networking Gigabit Ethernet + - WiFi + BT + - Display HDMI 2.0, 4-lane MIPI DSI + - USB 4x USB 3.0 Type-A, 1x USB 2.0 Type-C + - Expansion BeagleBone-compatible P8/P9 headers + +Mainline support +---------------- + +The following features are currently supported: + +1. ns16550 UART driver +2. eMMC and microSD card +3. Gigabit Ethernet (DesignWare GMAC with Realtek PHY) +4. LPDDR4X controller and PHY initialization in SPL + +Building +~~~~~~~~ + +1. Add the RISC-V toolchain to your PATH. +2. Setup ARCH & cross compilation environment variable: + +.. code-block:: none + + export CROSS_COMPILE=<riscv64 toolchain prefix> + +3. Build DDR firmware + +The DDR driver requires a firmware blob to initialize the controller and the +PHY. BeagleV-Ahead has a single rank of LPDDR4X, which needs the single-rank +variant of the configuration: + +.. code-block:: bash + + git clone --depth 1 https://github.com/ziyao233/th1520-firmware + cd th1520-firmware + lua5.4 ddr-generate.lua src/lpddr4x-3733-singlerank.lua th1520-ddr-firmware.bin + +4. Build OpenSBI firmware + +The proper U-Boot runs in S mode, thus OpenSBI is required as SBI firmware. +TH1520 support in OpenSBI requires v1.2 or a more recent version: + +.. code-block:: bash + + git clone https://github.com/riscv-software-src/opensbi.git + cd opensbi + make PLATFORM=generic + +5. Build U-Boot images + +The DDR firmware must be found by binman. The simplest way is to copy it to +the U-Boot source directory before building: + +.. code-block:: bash + + cd <U-Boot-dir> + cp <path-to-ddr-firmware> th1520-ddr-firmware.bin + make beaglev_ahead_defconfig + make OPENSBI=<opensbi_dir>/build/platform/generic/firmware/fw_dynamic.bin + +Alternatively, binman can be pointed to the directory holding the firmware +with BINMAN_INDIRS, which keeps the source tree clean and works with +out-of-tree builds: + +.. code-block:: bash + + cd <U-Boot-dir> + make O=<build-dir> beaglev_ahead_defconfig + make O=<build-dir> \ + BINMAN_INDIRS=<dir-containing-th1520-ddr-firmware.bin> \ + OPENSBI=<opensbi_dir>/build/platform/generic/firmware/fw_dynamic.bin + +This generates u-boot-with-spl.bin, which contains SPL, the DDR firmware, the +OpenSBI firmware and the proper U-Boot. + +Booting +~~~~~~~ + +u-boot-with-spl.bin is loaded to SRAM through fastboot. Hold the USB button +while connecting the board to the host through the Type-C port, then release +the button and run: + +.. code-block:: bash + + fastboot flash ram u-boot-with-spl.bin + fastboot reboot + +The serial console is available on the debug UART header at 115200 8n1.
doc/board/beagle/index.rst +9 -0
@@ -13,3 +13,12 @@ ARM based boards am62x_beagleplay am67a_beagley_ai.rst j721e_beagleboneai64 + + +RISC-V based boards +------------------- + +.. toctree:: + :maxdepth: 2 + + beaglev_ahead
Signature · 1 line
2.56.0