Skip to contentSkip to conversation

board/broadcom: add support for BCM4908 platform devices

PATCH Superseded Rafał Miłecki 2 participants 2 messages Dec 20, 2021 – Jan 13, 2022

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 board/broadcom: add support for BCM4908 platform devices

From: Rafał Miłecki <[email protected]>

BCM4908 is Broadcom's 64-bit platform with Broadcom's own Brahma-B53 CPU(s). It's mostly used for home routers.

Kernel config is a minimal setup required to support on-SoC blocks like NAND controller, Ethernet, switch, USB.

To make kernels 5.12+ boot those boards require a hacky patch modifying hyp-stub.S. That booting problem will hopefully get fixes on day in upstream kernel code.

There are many BCM4908 devices and all of them can be supported with the same kernel & rootfs. For that reason this board compiles DTB files for all 3 upstream supported devices. Compiling DTS files is cheap and it saves duplicating the same board code for every supported board.

BCM4908 devices use Broadcom's own CFE bootloader which isn't properly opensourced. Available CFE sources are very old and cover only some ancient MIPS devices.

---
V2: Add DEVELOPERS entry
Add readme.txt
Describe bootloader
Remove redundant config options

---
 DEVELOPERS                                    |  2 +
 board/broadcom/bcm4908/linux.config           | 41 +++++++++++++++++++
 .../0001-arm64-don-t-issue-HVC-on-boot.patch  | 32 +++++++++++++++
 board/broadcom/bcm4908/readme.txt             | 37 +++++++++++++++++
 configs/broadcom_bcm4908_defconfig            |  9 ++++
 5 files changed, 121 insertions(+)
 create mode 100644 board/broadcom/bcm4908/linux.config
 create mode 100644 board/broadcom/bcm4908/patches/linux/0001-arm64-don-t-issue-HVC-on-boot.patch
 create mode 100644 board/broadcom/bcm4908/readme.txt
 create mode 100644 configs/broadcom_bcm4908_defconfig
DEVELOPERS +2 -0
index 35f3be81b8..4a8d53c672 100644
@@ -2310,6 +2310,8 @@ F:	board/avnet/s6lx9_microboard/
 F:	configs/s6lx9_microboard_defconfig
 
 N:	Rafał Miłecki <[email protected]>
+F:	board/broadcom/bcm4908/
+F:	configs/broadcom_bcm4908_defconfig
 F:	package/firmware-utils/
 
 N:	Rahul Bedarkar <[email protected]>
board/broadcom/bcm4908/linux.config new file +41 -0

41 lines not on this page · raw message

board/broadcom/bcm4908/patches/linux/0001-arm64-don-t-issue-HVC-on-boot.patch new file +32 -0
new file mode 100644
index 0000000000..32e2b6330b
@@ -0,0 +1,32 @@
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <[email protected]>
+Date: Thu, 12 Aug 2021 11:52:42 +0200
+Subject: [PATCH] arm64: don't issue HVC on boot
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Broadcom's CFE loader seems to miss setting SCR_EL3.HCE which results in
+generating an UNDEF and kernel panic on the first HVC.
+
+HVC gets issued by kernels 5.12+ while booting, by kexec and KVM. Until
+someone finds a workaround we have to avoid all above.
+
+Workarounds: 0c93df9622d4 ("arm64: Initialise as nVHE before switching to VHE")
+Signed-off-by: Rafał Miłecki <[email protected]>
+---
+ arch/arm64/kernel/hyp-stub.S | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/arch/arm64/kernel/hyp-stub.S b/arch/arm64/kernel/hyp-stub.S
+index 43d212618..fc95b103e 100644
+--- a/arch/arm64/kernel/hyp-stub.S
++++ b/arch/arm64/kernel/hyp-stub.S
+@@ -238,7 +238,7 @@ SYM_FUNC_START(switch_to_vhe)
+ 
+ 	// Turn the world upside down
+ 	mov	x0, #HVC_VHE_RESTART
+-	hvc	#0
++//	hvc	#0
+ 1:
+ 	ret
+ SYM_FUNC_END(switch_to_vhe)
board/broadcom/bcm4908/readme.txt new file +37 -0
new file mode 100644
index 0000000000..b918ab8477
@@ -0,0 +1,37 @@
+BCM4908
+
+Intro
+=====
+
+This readme covers BCM4908 family of Broadcom SoCs. It includes:
+  - BCM4906
+  - BCM4908
+  - BCM49408
+
+BCM4908 is commonly used in home routers by multiple vendors.
+
+Booting is handled using closed source CFE bootloader. There is no U-Boot (or
+any other) drop-in replacement. CFE supports booting over TFTP and from flash.
+
+How to build it
+===============
+
+  $ make broadcom_bcm4908_defconfig
+
+  $ make
+
+How to boot using TFTP
+======================
+
+When set into h (host) / c (tftp) mode CFE tries to boot image from a TFTP
+server. That allows booting buildroot built binaries. There are 3 files CFE
+looks for: kernel (Image), rootfs (cpio) and DTB. Exact filenames depend on CFE
+configuration.
+
+Booting from TFTP requires sharing 3 above files in TFTP server root dir.
+
+How to write to flash
+=====================
+
+Writing to flash requires using a custom BCM4908 firmware image format. It isn't
+supported yet.
configs/broadcom_bcm4908_defconfig new file +9 -0
new file mode 100644
index 0000000000..85307af053
@@ -0,0 +1,9 @@
+BR2_aarch64=y
+BR2_LINUX_KERNEL=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="5.13.9"
+BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
+BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/broadcom/bcm4908/linux.config"
+BR2_LINUX_KERNEL_DTS_SUPPORT=y
+BR2_LINUX_KERNEL_INTREE_DTS_NAME="broadcom/bcm4908/bcm4906-netgear-r8000p broadcom/bcm4908/bcm4906-tplink-archer-c2300-v1 broadcom/bcm4908/bcm4908-asus-gt-ac5300"
+BR2_TARGET_ROOTFS_CPIO=y
Signature · 6 lines
2.31.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

Rafał, All,

On 2021-12-20 05:52 +0100, Rafał Miłecki spake thusly:

Quoted 17 lines

From: Rafał Miłecki <[email protected]>

BCM4908 is Broadcom's 64-bit platform with Broadcom's own Brahma-B53 CPU(s). It's mostly used for home routers.

Kernel config is a minimal setup required to support on-SoC blocks like NAND controller, Ethernet, switch, USB.

To make kernels 5.12+ boot those boards require a hacky patch modifying hyp-stub.S. That booting problem will hopefully get fixes on day in upstream kernel code.

There are many BCM4908 devices and all of them can be supported with the same kernel & rootfs. For that reason this board compiles DTB files for all 3 upstream supported devices. Compiling DTS files is cheap and it saves duplicating the same board code for every supported board.

Quoted 6 lines

BCM4908 devices use Broadcom's own CFE bootloader which isn't properly opensourced. Available CFE sources are very old and cover only some ancient MIPS devices.

---

[--SNIP--]

board/broadcom/bcm4908/linux.config line 2

Quoted 8 lines
board/broadcom/bcm4908/linux.config new file +2 -0
new file mode 100644
index 0000000000..446a0bdf83
@@ -0,0 +1,41 @@
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_ARCH_BCM4908=y

The in-tree arm64 defconfig has support for CONFIG_ARCH_BCM4908, so can't we use that in-tree defconfig rather than carry a custom config file?

If it's just because some drivers are missing, maybe provide them as a config fragment with just the symbols for those drivers.

board/broadcom/bcm4908/patches/linux/0001-arm64-don-t-issue-HVC-on-boot.patch line 6

Quoted 12 lines
board/broadcom/bcm4908/patches/linux/0001-arm64-don-t-issue-HVC-on-boot.patch new file +6 -0
new file mode 100644
index 0000000000..32e2b6330b
@@ -0,0 +1,32 @@
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <[email protected]>
+Date: Thu, 12 Aug 2021 11:52:42 +0200
+Subject: [PATCH] arm64: don't issue HVC on boot
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit

Please use a git-formated patch, which you get with:

    git format-patch --no-numbered

[--SNIP--]

Quoted 10 lines
board/broadcom/bcm4908/readme.txt new file +4 -0
new file mode 100644
index 0000000000..b918ab8477
@@ -0,0 +1,37 @@
+BCM4908
+
+Intro
+=====

board/broadcom/bcm4908/readme.txt line 14

Quoted 10 lines
board/broadcom/bcm4908/readme.txt new file +10 -0
+
+This readme covers BCM4908 family of Broadcom SoCs. It includes:
+  - BCM4906
+  - BCM4908
+  - BCM49408
+
+BCM4908 is commonly used in home routers by multiple vendors.
+
+Booting is handled using closed source CFE bootloader. There is no U-Boot (or
+any other) drop-in replacement. CFE supports booting over TFTP and from flash.

Out of curiosity, and definitely not needed for that patch: is there no way to chain-boot? I.e. have CFE load a U-Boot, adn then that U-Boot load kernel and so on.

board/broadcom/bcm4908/readme.txt line 26

Quoted 11 lines
board/broadcom/bcm4908/readme.txt new file +11 -0
+How to build it
+===============
+
+  $ make broadcom_bcm4908_defconfig
+
+  $ make
+
+How to boot using TFTP
+======================
+
+When set into h (host) / c (tftp) mode CFE tries to boot image from a TFTP

I am not sure I grasped what this "h (host) / c (tftp) mode" means. Can we expect users who have such a board to understand that?

board/broadcom/bcm4908/readme.txt line 29

Quoted 3 lines
board/broadcom/bcm4908/readme.txt new file +3 -0
+server. That allows booting buildroot built binaries. There are 3 files CFE
+looks for: kernel (Image), rootfs (cpio) and DTB. Exact filenames depend on CFE
+configuration.

I would maybe add something like:

Inspect the logs of your TFTP server to see what files are requested.

Otherwise I think this readme is good.

Quoted 13 lines
board/broadcom/bcm4908/readme.txt new file +7 -0
+Booting from TFTP requires sharing 3 above files in TFTP server root dir.
+
+How to write to flash
+=====================
+
+Writing to flash requires using a custom BCM4908 firmware image format. It isn't
+supported yet.
configs/broadcom_bcm4908_defconfig new file +0 -0
new file mode 100644
index 0000000000..85307af053

configs/broadcom_bcm4908_defconfig line 4

Quoted 4 lines
configs/broadcom_bcm4908_defconfig new file +4 -0
@@ -0,0 +1,9 @@
+BR2_aarch64=y
+BR2_LINUX_KERNEL=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="5.13.9"

You will need to pin the linux-headers to that version too:

    BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_5_13=y

However, why do you want to stick to 5.13.x? Can't we use a more recent version (5.15, or even the brand new 5.16)?

Regards,
Yann E. MORIN.

Quoted 12 lines
configs/broadcom_bcm4908_defconfig new file +5 -0
+BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
+BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/broadcom/bcm4908/linux.config"
+BR2_LINUX_KERNEL_DTS_SUPPORT=y
+BR2_LINUX_KERNEL_INTREE_DTS_NAME="broadcom/bcm4908/bcm4906-netgear-r8000p broadcom/bcm4908/bcm4906-tplink-archer-c2300-v1 broadcom/bcm4908/bcm4908-asus-gt-ac5300"
+BR2_TARGET_ROOTFS_CPIO=y
Signature · 6 lines
2.31.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot