[PATCH v2 5/9] ixp4xx: Resurrect IXP4xx support using device tree

Tomasz Maciej Nowak tmn505 at gmail.com
Wed Oct 4 11:31:03 PDT 2023


Hi,
some comments inline.

W dniu 28.09.2023 o 15:28, Linus Walleij pisze:
> This resurrects the support for IXP4xx using device tree
> rather than the old (deleted) board files. The final pieces
> of IXP4xx board files were deleted in Linux v5.19.
> 
> Ext4 root filesystems on CF and USB are supported by the
> default config.
> 
> We support these three initial targets:
> 
> - The Gateworks Avila GW2348 reference design has 64MB of RAM
>   and 32MB of flash and also supports USB and CompactFlash.
> 
> - The Gateworks Cambria GW2358 reference design has 128MB of
>   RAM and 32MB of flash and also supports USB and CompactFlash.
> 
> - The old and stable Linksys NSLU2 works fine as well, albeit
>   it only has 32MB of RAM so it has been marked as non-default.
>   The 8MB of flash can only fit the kernel, so it has been
>   patched to boot from exteral media on USB. I have used
>   it successfully as a NAS with ksmbd and LUCI web API, see:
>   https://dflund.se/~triad/krad/ixp4xx/

What I'm lacking is sysupgrade image. Currently, as I see it, if kernel grows
beyond what's stored in FIS table, user will need to go back to bootloader console
to update whole system. That's not very convenient. We have devices with RedBoot
which support sysupgrade, alas only for devices which have FIS table and RedBoot
config on separate erase block, if that's the case for ones in this target,
check how we create sysupgrade image for adtran_bsap1880 in ath79 target.
The paths of interest would be:
target/linux/ath79/image/generic.mk
target/linux/ath79/generic/base-files/lib/upgrade/platform.sh
target/linux/ath79/generic/base-files/lib/upgrade/redboot-fis.sh

The "slug" seems to be different one, but it has access to the flash from running
OpenWrt, so definitely sysupgrade path could be created for it.

> 
> Signed-off-by: Howard Harte <hharte at magicandroidapps.com>
> Signed-off-by: Linus Walleij <linus.walleij at linaro.org>
> ---
> ChangeLog v1->v2:
> - Have NSLU2 select the apex boot loader instead of having
>   it default built for all targets.
> - SPDX header for the microcode package.
> - Set microcode package version back to 1.
> - Split the microcode firmware package in two, one for
>   just regular ethernet, one for WAN/HSS and select the
>   right package for each device, ridding us one useless
>   firmware file per device.
> - Cleanup Kconfig using make kernel_oldconfig.
> - Remove several surplus kernel Kconfig options, some
>   pointless 8250 extensions for example.
> - Drop all the RTCs from the Kconfig and use the corresponding
>   kernel modules for each device instead, saving space.
> - Drop all the HWMON drivers from the Kconfig and use the
>   corresponding kernel modules for each device instead.
> - Use a kernel module for EEPROM access on Gateworks devices.
> - Fold in an ethernet numbering fix from Howard Harte
> - Activate Marvell MV88E6060 DSA switch as used by
>   USRobotics USR8200.
> ---
>  package/firmware/ixp4xx-microcode/Makefile         |  77 +++++++
>  .../firmware/ixp4xx-microcode/src/IxNpeMicrocode.h | 148 ++++++++++++
>  package/firmware/ixp4xx-microcode/src/LICENSE.IPL  |  27 +++
>  target/linux/ixp4xx/Makefile                       |  27 +++
>  .../linux/ixp4xx/base-files/etc/board.d/02_network |  21 ++
>  .../base-files/lib/preinit/05_set_ether_mac_ixp4xx |  45 ++++
>  target/linux/ixp4xx/config-6.1                     | 252 +++++++++++++++++++++
>  target/linux/ixp4xx/image/Makefile                 |  76 +++++++
>  ...01-mtd-cfi_cmdset_0001-Byte-swap-OTP-info.patch |  74 ++++++
>  ...-ARM-dts-ixp4xx-Boot-NSLU2-from-harddrive.patch |  24 ++
>  10 files changed, 771 insertions(+)
> 

[...]

> diff --git a/target/linux/ixp4xx/base-files/lib/preinit/05_set_ether_mac_ixp4xx b/target/linux/ixp4xx/base-files/lib/preinit/05_set_ether_mac_ixp4xx
> new file mode 100644
> index 000000000000..2feacbfe313e
> --- /dev/null
> +++ b/target/linux/ixp4xx/base-files/lib/preinit/05_set_ether_mac_ixp4xx
> @@ -0,0 +1,45 @@
> +#!/bin/sh
> +. /lib/functions.sh
> +. /lib/functions/system.sh
> +
> +set_from_redboot () {
> +	for npe in eth0 eth1 eth2
> +	do
> +		if ifconfig $npe > /dev/null 2>&1; then

Small nitpick, here "ifconfig" but later "ip", I know it's just an applet
but some consistency would be nice.

> +			ip link set dev $npe address $(fconfig -s -r -d /dev/$1 -n npe_"$npe"_esa)
> +		fi
> +	done
> +
> +	# -- Fixup for the WG302v1, need someone with a WAG302v1 to fix that, too

Patch doesn't introduce support for this board, so remove cases for boards which
are not included in this patch.

> +
> +	if [ "$(ifconfig eth0 2>/dev/null | grep -c 00:00:00:00:00:00)" = "1" ]; then
> +		ip link set dev $npe address $(fconfig -s -r -d /dev/$1 -n zcom_npe_esa)
> +	fi
> +
> +	# Others (*cough*, Tonze) are not handling mac addresses at all
> +
> +	if [ "$(ifconfig eth0 2>/dev/null | grep -c 00:00:00:00:00:00)" = "1" ]; then
> +		ip link set dev eth0 address 00:11:22:33:44:55
> +	fi
> +	if [ "$(ifconfig eth1 2>/dev/null | grep -c 00:00:00:00:00:00)" = "1" ]; then
> +		ip link set dev eth0 address 00:11:22:33:44:56
> +	fi
> +}
> +
> +set_from_sysconf () {
> +	ip link set dev eth0 address $(mtd_get_mac_ascii SysConf hw_addr)
> +}
> +
> +set_ether_mac () {
> +	RBC="$(grep "RedBoot config" /proc/mtd | cut -d: -f1)"
> +	if [ ! -z $RBC ] ; then
> +		set_from_redboot $RBC
> +	else
> +		SYSC="$(grep "SysConf" /proc/mtd | cut -d: -f1)"
> +		if [ ! -z $SYSC ] ; then
> +			set_from_sysconf
> +		fi
> +	fi
> +}
> +

[...]

> +boot_hook_add preinit_main set_ether_mac
> diff --git a/target/linux/ixp4xx/image/Makefile b/target/linux/ixp4xx/image/Makefile
> new file mode 100644
> index 000000000000..d61189d09b24
> --- /dev/null
> +++ b/target/linux/ixp4xx/image/Makefile
> @@ -0,0 +1,76 @@
> +# SPDX-License-Identifier: GPL-2.0-only
> +#
> +# Copyright (C) 2006-2021 OpenWrt.org
> +
> +include $(TOPDIR)/rules.mk
> +include $(INCLUDE_DIR)/image.mk
> +
> +# Cook a Linksys NSLU2 etc image
> +define Build/linksys-ixp425-image
> +	touch $@.null-initrd
> +	$(TOPDIR)/scripts/slugimage.pl -L $(STAGING_DIR_IMAGE)/apex-$(1)-armeb.bin -k $@ -r $@.null-initrd -p -o $@.new
> +	mv $@.new $@
> +endef
> +
> +# Build sysupgrade image
> +define BuildFirmware/Generic
> +	dd if=$(KDIR)/zImage of=$(KDIR)/zImage.pad bs=64k conv=sync; \
> +	dd if=$(KDIR)/root.$(1) of=$(KDIR)/root.$(1).pad bs=128k conv=sync; \
> +	sh $(TOPDIR)/scripts/combined-image.sh \
> +		$(KDIR)/zImage.pad \
> +		$(KDIR)/root.$(1).pad \
> +		$(BIN_DIR)/$(IMG_PREFIX)-$(patsubst jffs2-%,jffs2,$(patsubst squashfs-%,squashfs,$(1)))-sysupgrade.bin
> +endef
> +
> +define Image/Build
> +	$(call Image/Build/$(1),$(1))
> +	$(call BuildFirmware/Generic,$(1))
> +endef
> +
> +define Device/Default
> +	PROFILES := Default
> +	KERNEL_DEPENDS = $$(wildcard $(DTS_DIR)/$$(DEVICE_DTS).dts)
> +	KERNEL_NAME := zImage
> +	KERNEL := kernel-bin | append-dtb
> +	BLOCKSIZE := 128k
> +endef
> +
> +define Device/avila

Prefered is <vendor_model> instead of only <model>. This will end up in image
file name, more descriptive the better. Please change it for all others and in
patch adding usr8200.

> +	DEVICE_VENDOR := Gateway

Gateworks

> +	DEVICE_MODEL := Avila GW2348-4
> +	DEVICE_PACKAGES := ixp4xx-microcode-ethernet kmod-rtc-ds1672 kmod-eeprom-at24 kmod-hwmon-ad7418
> +	DEVICE_DTS := intel-ixp42x-gateworks-gw2348
> +	KERNEL := kernel-bin | append-dtb
> +	IMAGES := kernel.bin rootfs.bin
> +	IMAGE/kernel.bin := append-kernel
> +	IMAGE/rootfs.bin := append-rootfs | pad-rootfs | pad-to 128k
> +endef
> +TARGET_DEVICES += avila
> +
> +define Device/cambria

> +	DEVICE_VENDOR := Gateway

Gateworks

> +	DEVICE_MODEL := Cambria GW2358-4
> +	DEVICE_PACKAGES := ixp4xx-microcode-ethernet kmod-rtc-ds1672 kmod-eeprom-at24 kmod-hwmon-ad7418
> +	DEVICE_DTS := intel-ixp43x-gateworks-gw2358
> +	KERNEL := kernel-bin | append-dtb
> +	IMAGES := kernel.bin rootfs.bin
> +	IMAGE/kernel.bin := append-kernel
> +	IMAGE/rootfs.bin := append-rootfs | pad-rootfs | pad-to 128k
> +endef
> +TARGET_DEVICES += cambria
> +
> +define Device/nslu2
> +	DEVICE_VENDOR := Linksys
> +	DEVICE_MODEL := NSLU2
> +	DEVICE_PACKAGES := apex ixp4xx-microcode-ethernet kmod-rtc-x1205
> +	# Only 32 MB of RAM so not building by default
> +	DEFAULT := n
> +	DEVICE_DTS := intel-ixp42x-linksys-nslu2
> +	KERNEL := kernel-bin | append-dtb
> +	IMAGES := factory.bin
> +	# This has to boot from harddisk so just append the kernel
> +	IMAGE/factory.bin := append-kernel | linksys-ixp425-image "nslu2"
> +endef
> +TARGET_DEVICES += nslu2
> +
> +$(eval $(call BuildImage))

[...]

Regards

-- 
TMN




More information about the openwrt-devel mailing list