[Buildroot] [PATCH] board/broadcom: add support for Northstar platform devices
Thomas Petazzoni
thomas.petazzoni at bootlin.com
Thu Aug 19 21:39:48 UTC 2021
Hello Rafał,
Thanks for this proposal!
On Tue, 10 Aug 2021 15:12:36 +0200
Rafał Miłecki <zajec5 at gmail.com> wrote:
> From: Rafał Miłecki <rafal at milecki.pl>
>
> Broadcom Northstar family of SoCs is most commonly used for home
> routers. It's an ARM platform with Cortex-A9 CPU(s).
>
> All known Northstar devices come with CFE bootloader which almost always
> expects a TRX firmware format (with exception for the D-Link). Some
> vendors (like Luxul and Netgear) wrap TRX in their own containers.
>
> For above reason a plain kernel and rootfs are useless for flashing
> purposes. CFE requires TRX(-like) format and there isn't any CFE
> replacement. Another issue is lack for DTS support in CFE.
> That's why for this board there is post-image script building device
> specific images. It takes care of appending DTB to the kernel and
> putting everything in a TRX image.
Is this also the reason why an initramfs is used, instead of a separated
rootfs?
> board/broadcom/ns/linux.config | 115 ++++++++++++++++++
> board/broadcom/ns/post-image.sh | 43 +++++++
> .../ns/rootfs_overlay/etc/init.d/S39network | 6 +
> .../etc/network/interfaces.luxul,xap-1610-v1 | 24 ++++
> .../etc/network/interfaces.luxul,xwr-3150-v1 | 49 ++++++++
> .../etc/network/interfaces.smartrg,sr400ac | 49 ++++++++
> configs/broadcom_ns_defconfig | 22 ++++
> 7 files changed, 308 insertions(+)
We also need board/broadcom/ns/readme.txt that explains how to use this
defconfig (see other readme.txt files in board/). And we also need an
update to the DEVELOPERS file to associate you with this defconfig and
board/broadcom/ns/ folder.
> diff --git a/board/broadcom/ns/linux.config b/board/broadcom/ns/linux.config
> new file mode 100644
> index 0000000000..1737e1d81a
> --- /dev/null
> +++ b/board/broadcom/ns/linux.config
> @@ -0,0 +1,115 @@
> +CONFIG_KERNEL_XZ=y
> +CONFIG_BLK_DEV_INITRD=y
> +CONFIG_INITRAMFS_SOURCE="${BR_BINARIES_DIR}/rootfs.cpio"
This should not be needed, as it's added by Buildroot.
> diff --git a/board/broadcom/ns/post-image.sh b/board/broadcom/ns/post-image.sh
> new file mode 100755
> index 0000000000..34856991a6
> --- /dev/null
> +++ b/board/broadcom/ns/post-image.sh
> @@ -0,0 +1,43 @@
> +#!/bin/sh
> +
> +# $1: images directory path
> +# $2: device dts filename
> +# $3: board id
> +build_lxl() {
> + local images="$1"
> + local device="$2"
> + local board="$3"
> +
> + lzma-alone e $images/zImage.$device $images/zImage.$device.lzma -d16
I don't have lzma-alone on my system, so it means that this tool should
probably be built by a Buildroot host package, as it's not necessarily
installed on the developer machine.
> + rm -f $images/zImage.$device
> + $HOST_DIR/bin/otrx create $images/$device.trx -f $images/zImage.$device.lzma
> + rm -f $images/zImage.$device.lzma
> + $HOST_DIR/bin/lxlfw create $images/$device.lxl -i $images/$device.trx -b "$board"
> +}
> +
> +# $1: images directory path
> +# $2: device dts filename
> +build_trx() {
> + local images="$1"
> + local device="$2"
> +
> + lzma-alone e $images/zImage.$device $images/zImage.$device.lzma -d16
> + rm -f $images/zImage.$device
> + $HOST_DIR/bin/otrx create $images/$device.trx -f $images/zImage.$device.lzma
> + rm -f $images/zImage.$device.lzma
> +}
> +
> +devices="$(sed -n 's/^BR2_LINUX_KERNEL_INTREE_DTS_NAME="\([a-z0-9 \-]*\)"$/\1/p' ${BR2_CONFIG})"
> +for device in $devices; do
> + case "$device" in
> + "bcm4708-smartrg-sr400ac")
> + build_trx "$1" "$device"
> + ;;
> + "bcm47094-luxul-xap-1610")
> + build_lxl "$1" "$device" "XAP-1610"
> + ;;
> + "bcm47094-luxul-xwr-3150-v1")
> + build_lxl "$1" "$device" "XWR-3150"
> + ;;
> + esac
> +done
Hm, so this defconfig in fact targets a family of devices. Buildroot
defconfigs normally target a single device. But I see the point here,
so perhaps we should leave it as you propose.
> diff --git a/board/broadcom/ns/rootfs_overlay/etc/init.d/S39network b/board/broadcom/ns/rootfs_overlay/etc/init.d/S39network
> new file mode 100755
> index 0000000000..a8098d2ab4
> --- /dev/null
> +++ b/board/broadcom/ns/rootfs_overlay/etc/init.d/S39network
> @@ -0,0 +1,6 @@
> +#!/bin/sh
> +
> +machine="$(cat /proc/device-tree/compatible | tr '\0' '\t' | cut -f 1)"
> +
> +interfaces="/usr/local/etc/network/interfaces.$machine"
> +[ -f "$interfaces" ] && cp "$interfaces" /etc/network/interfaces
> diff --git a/board/broadcom/ns/rootfs_overlay/usr/local/etc/network/interfaces.luxul,xap-1610-v1 b/board/broadcom/ns/rootfs_overlay/usr/local/etc/network/interfaces.luxul,xap-1610-v1
> new file mode 100644
> index 0000000000..bf766044b4
> --- /dev/null
> +++ b/board/broadcom/ns/rootfs_overlay/usr/local/etc/network/interfaces.luxul,xap-1610-v1
[...]
> diff --git a/board/broadcom/ns/rootfs_overlay/usr/local/etc/network/interfaces.luxul,xwr-3150-v1 b/board/broadcom/ns/rootfs_overlay/usr/local/etc/network/interfaces.luxul,xwr-3150-v1
[...]
> diff --git a/board/broadcom/ns/rootfs_overlay/usr/local/etc/network/interfaces.smartrg,sr400ac b/board/broadcom/ns/rootfs_overlay/usr/local/etc/network/interfaces.smartrg,sr400ac
I am not sure how much we want those quite specific network
configuration files in Buildroot itself. Shouldn't we leave that up to
the user? Those example files use 0.0.0.0 as a static IP address for
all interfaces, which isn't going to be very useful in practice I guess.
> diff --git a/configs/broadcom_ns_defconfig b/configs/broadcom_ns_defconfig
> new file mode 100644
> index 0000000000..b68de2e093
> --- /dev/null
> +++ b/configs/broadcom_ns_defconfig
> @@ -0,0 +1,22 @@
> +BR2_arm=y
> +BR2_cortex_a9=y
> +BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_5_10=y
> +BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV=y
Needed for ?
> +BR2_ROOTFS_OVERLAY="board/broadcom/ns/rootfs_overlay"
> +BR2_ROOTFS_POST_IMAGE_SCRIPT="board/broadcom/ns/post-image.sh"
> +BR2_LINUX_KERNEL=y
> +BR2_LINUX_KERNEL_CUSTOM_VERSION=y
> +BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="5.10.57"
> +BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
> +BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/broadcom/ns/linux.config"
> +BR2_LINUX_KERNEL_APPENDED_ZIMAGE=y
> +BR2_LINUX_KERNEL_XZ=y
> +BR2_LINUX_KERNEL_INTREE_DTS_NAME="bcm4708-smartrg-sr400ac bcm47094-luxul-xap-1610 bcm47094-luxul-xwr-3150-v1"
> +BR2_PACKAGE_MTD=y
Not needed.
> +BR2_PACKAGE_LINUX_FIRMWARE=y
> +BR2_PACKAGE_LINUX_FIRMWARE_BRCM_BCM4366C0=y
> +BR2_PACKAGE_BRIDGE_UTILS=y
Most likely not needed if we drop the network configuration files.
> +BR2_PACKAGE_DROPBEAR=y
Not needed (we want defconfigs to be minimal)
> +BR2_TARGET_ROOTFS_INITRAMFS=y
> +# BR2_TARGET_ROOTFS_TAR is not set
> +BR2_PACKAGE_HOST_FIRMWARE_UTILS=y
Thanks!
Thomas
--
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
More information about the buildroot
mailing list