I compiled again the firmware: openwrt-ls220de-test.zip
Parts to check:
- FAN cooler
- poweroff and restart.
- ethernet LED: should blink on activity, and should be on when the ethernet cable is connected
I also included devmem. Since your ethernet phy is only 1.8V capable, you should adjust the voltage with the command:
devmem 0xd00184e0 32 0xa8a
devmem can't be installed with the default Openwrt fimware, therefore for a permanent solution an Uboot modification should be done. Before using this command Double check your ethernet phy is indeed a Marvell 88E1318
I'm still looking for a way to simplify a bit more the sysupgrade process without nand-utils. I'll check if nandwrite can be replaced with mtd write. Even with mtd erase looks like the NAND isn't erased as it should.
The current patch:
diff --git a/package/boot/uboot-envtools/files/mvebu b/package/boot/uboot-envtools/files/mvebu
index cffd396ae1..e07e797858 100644
--- a/package/boot/uboot-envtools/files/mvebu
+++ b/package/boot/uboot-envtools/files/mvebu
@@ -13,6 +13,7 @@ touch /etc/config/ubootenv
board=$(board_name)
case "$board" in
+buffalo,ls220de|\
buffalo,ls421de)
ubootenv_add_uci_config "/dev/mtd3" "0x0" "0x10000"
;;
diff --git a/target/linux/mvebu/cortexa9/base-files/etc/board.d/02_network b/target/linux/mvebu/cortexa9/base-files/etc/board.d/02_network
index c613a3cd60..d2229fe6bf 100644
--- a/target/linux/mvebu/cortexa9/base-files/etc/board.d/02_network
+++ b/target/linux/mvebu/cortexa9/base-files/etc/board.d/02_network
@@ -61,6 +61,7 @@ mvebu_setup_macs()
local label_mac=""
case "$board" in
+ buffalo,ls220de|\
buffalo,ls421de)
lan_mac=$(mtd_get_mac_ascii u-boot-env eth1addr)
;;
diff --git a/target/linux/mvebu/cortexa9/base-files/lib/upgrade/platform.sh b/target/linux/mvebu/cortexa9/base-files/lib/upgrade/platform.sh
index 18b978d437..b879296e3b 100755
--- a/target/linux/mvebu/cortexa9/base-files/lib/upgrade/platform.sh
+++ b/target/linux/mvebu/cortexa9/base-files/lib/upgrade/platform.sh
@@ -23,8 +23,29 @@ platform_check_image() {
esac
}
+platform_do_upgrade_buffalo_nand() {
+ CI_KERNPART=none
+
+ local fw_mtd=$(find_mtd_part kernel)
+ fw_mtd="${fw_mtd/block/}"
+ [ -n "$fw_mtd" ] || return
+
+ local board_dir=$(tar tf "$1" | grep -m 1 '^sysupgrade-.*/$')
+ board_dir=${board_dir%/}
+ [ -n "$board_dir" ] || return
+
+ mtd erase kernel
+ tar xf "$1" ${board_dir}/kernel
+ nandwrite "$fw_mtd" ${board_dir}/kernel
+
+ nand_do_upgrade "$1"
+}
+
platform_do_upgrade() {
case "$(board_name)" in
+ buffalo,ls220de)
+ platform_do_upgrade_buffalo_nand "$1"
+ ;;
buffalo,ls421de)
nand_do_upgrade "$1"
;;
diff --git a/target/linux/mvebu/files/arch/arm/boot/dts/armada-370-buffalo-ls220de.dts b/target/linux/mvebu/files/arch/arm/boot/dts/armada-370-buffalo-ls220de.dts
new file mode 100644
index 0000000000..d82a3f23bb
--- /dev/null
+++ b/target/linux/mvebu/files/arch/arm/boot/dts/armada-370-buffalo-ls220de.dts
@@ -0,0 +1,361 @@
+// SPDX-License-Identifier: (GPL-2.0-or-later OR MIT)
+/*
+ * Device Tree file for Buffalo LinkStation LS220DE
+ *
+ * Copyright (C) 2020 Daniel González Cabanelas <dgcbueu@gmail.com>
+ */
+
+/dts-v1/;
+
+#include "armada-370.dtsi"
+#include "mvebu-linkstation-fan.dtsi"
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/thermal/thermal.h>
+
+/ {
+ model = "Buffalo LinkStation LS220DE";
+ compatible = "buffalo,ls220de", "marvell,armada370", "marvell,armada-370-xp";
+
+ aliases {
+ led-boot = &led_boot;
+ led-failsafe = &led_failsafe;
+ led-running = &led_power;
+ led-upgrade = &led_upgrade;
+ };
+
+ chosen {
+ bootargs = "earlycon";
+ stdout-path = "serial0:115200n8";
+ append-rootblock = "nullparameter="; /* override the bootloader args */
+ };
+
+ memory {
+ device_type = "memory";
+ reg = <0x00000000 0x10000000>; /* 256 MB */
+ };
+
+ soc {
+ ranges = <MBUS_ID(0xf0, 0x01) 0 0xd0000000 0x100000
+ MBUS_ID(0x01, 0xe0) 0 0xfff00000 0x100000
+ MBUS_ID(0x09, 0x01) 0 0xf1100000 0x10000>;
+ };
+
+ system_fan: gpio_fan {
+ gpios = <&gpio0 13 GPIO_ACTIVE_HIGH
+ &gpio0 14 GPIO_ACTIVE_HIGH>;
+ alarm-gpios = <&gpio0 10 GPIO_ACTIVE_HIGH>;
+
+ #cooling-cells = <2>;
+ };
+
+ thermal-zones {
+ hdd-thermal {
+ polling-delay = <20000>;
+ polling-delay-passive = <2000>;
+
+ thermal-sensors = <&hdd0_temp>; /* only one drivetemp sensor is supported */
+
+ trips {
+ hdd_alert1: trip1 {
+ temperature = <36000>;
+ hysteresis = <2000>;
+ type = "active";
+ };
+ hdd_alert2: trip2 {
+ temperature = <44000>;
+ hysteresis = <2000>;
+ type = "active";
+ };
+ hdd_alert3: trip3 {
+ temperature = <52000>;
+ hysteresis = <2000>;
+ type = "passive";
+ };
+ hdd_crit: trip4 {
+ temperature = <60000>;
+ hysteresis = <2000>;
+ type = "critical";
+ };
+ };
+
+ cooling-maps {
+ map1 {
+ trip = <&hdd_alert1>;
+ cooling-device = <&system_fan THERMAL_NO_LIMIT 1>;
+ };
+ map2 {
+ trip = <&hdd_alert2>;
+ cooling-device = <&system_fan 2 2>;
+ };
+ map3 {
+ trip = <&hdd_alert3>;
+ cooling-device = <&system_fan 3 THERMAL_NO_LIMIT>;
+ };
+ };
+ };
+ };
+
+ gpio_keys {
+ compatible = "gpio-keys";
+ pinctrl-0 = <&pmx_buttons>;
+ pinctrl-names = "default";
+
+ power {
+ label = "Power Switch";
+ linux,code = <KEY_POWER>;
+ linux,input-type = <EV_SW>;
+ gpios = <&gpio0 15 GPIO_ACTIVE_LOW>;
+ };
+
+ function {
+ label = "Function Button";
+ linux,code = <KEY_CONFIG>;
+ gpios = <&gpio0 16 GPIO_ACTIVE_LOW>;
+ };
+ };
+
+ gpio_leds {
+ compatible = "gpio-leds";
+ pinctrl-names = "default";
+ pinctrl-0 = <&pmx_leds1 &pmx_leds2>;
+
+ system_red {
+ label = "ls421de:red:system";
+ gpios = <&gpio0 7 GPIO_ACTIVE_HIGH>;
+ };
+
+ led_power: power_white {
+ label = "ls421de:white:power";
+ gpios = <&gpio1 22 GPIO_ACTIVE_HIGH>;
+ default-state = "on";
+ };
+
+ led_failsafe: power_red {
+ label = "ls421de:red:power";
+ gpios = <&gpio1 23 GPIO_ACTIVE_HIGH>;
+ };
+
+ led_upgrade: power_orange {
+ label = "ls421de:orange:power";
+ gpios = <&gpio1 25 GPIO_ACTIVE_HIGH>;
+ };
+
+ led_boot: system_white {
+ label = "ls421de:white:system";
+ gpios = <&gpio1 27 GPIO_ACTIVE_HIGH>;
+ };
+
+ hdd1_red {
+ label = "ls421de:red:hdd1";
+ gpios = <&gpio1 29 GPIO_ACTIVE_HIGH>;
+ linux,default-trigger = "ata1";
+ };
+
+ hdd2_red {
+ label = "ls421de:red:hdd2";
+ gpios = <&gpio1 30 GPIO_ACTIVE_HIGH>;
+ linux,default-trigger = "ata2";
+ };
+ };
+
+ regulators {
+ compatible = "simple-bus";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ pinctrl-0 = <&pmx_power_hdd1 &pmx_power_hdd2>;
+ pinctrl-names = "default";
+
+ sata1_power: regulator@1 {
+ compatible = "regulator-fixed";
+ reg = <1>;
+ regulator-name = "HDD1";
+ regulator-min-microvolt = <12000000>;
+ regulator-max-microvolt = <12000000>;
+ startup-delay-us = <2000000>;
+ enable-active-high;
+ regulator-always-on;
+ regulator-boot-on;
+ gpio = <&gpio0 8 GPIO_ACTIVE_HIGH>;
+ };
+
+ sata2_power: regulator@2 {
+ compatible = "regulator-fixed";
+ reg = <2>;
+ regulator-name = "HDD2";
+ regulator-min-microvolt = <12000000>;
+ regulator-max-microvolt = <12000000>;
+ startup-delay-us = <4000000>;
+ enable-active-high;
+ regulator-always-on;
+ regulator-boot-on;
+ gpio = <&gpio0 2 GPIO_ACTIVE_HIGH>;
+ };
+ };
+};
+
+&coherencyfab {
+ broken-idle;
+};
+
+ð1 {
+ pinctrl-0 = <&ge1_rgmii_pins>;
+ pinctrl-names = "default";
+ status = "okay";
+ phy-handle = <ðphy0>;
+ phy-connection-type = "rgmii-id";
+};
+
+&mdio {
+ pinctrl-0 = <&mdio_pins>;
+ pinctrl-names = "default";
+
+ ethphy0: ethernet-phy@0 { /* Marvell 88E1318 */
+ reg = <0>;
+ marvell,reg-init = <0x2 0x10 0xffff 0x0006>, /* disable CLK125 */
+ <0x3 0x10 0xf000 0x0918>, /* LED function */
+ <0x3 0x11 0x0000 0x4401>, /* LED polarity */
+ <0x3 0x12 0x0000 0x4905>; /* LED timer */
+ #thermal-sensor-cells = <0>;
+ };
+};
+
+&pmsu {
+ pinctrl-0 = <&pmx_power_cpu>;
+ pinctrl-names = "default";
+};
+
+&sata {
+ nr-ports = <2>;
+ status = "okay";
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ hdd0_temp: sata-port@0 {
+ reg = <0>;
+ #thermal-sensor-cells = <0>;
+ };
+
+ hdd1_temp: sata-port@1 {
+ reg = <1>;
+ #thermal-sensor-cells = <0>;
+ };
+};
+
+&uart0 {
+ status = "okay";
+};
+
+&usb0 {
+ status = "okay";
+};
+
+&nand_controller {
+ status = "okay";
+
+ nand@0 {
+ reg = <0>;
+ label = "pxa3xx_nand-0";
+ nand-rb = <0>;
+ marvell,nand-keep-config;
+ nand-on-flash-bbt;
+ nand-ecc-strength = <4>;
+ nand-ecc-step-size = <512>;
+
+ partitions {
+ compatible = "fixed-partitions";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ partition@0 {
+ label = "kernel";
+ reg = <0x00000000 0x02000000>; /* 32 MiB */
+ };
+
+ partition@2000000 {
+ label = "ubi";
+ reg = <0x02000000 0x1e000000>; /* 480 MiB */
+ };
+ };
+ };
+};
+
+&spi0 {
+ status = "okay";
+ pinctrl-0 = <&spi0_pins2>;
+ pinctrl-names = "default";
+
+ spi-flash@0 {
+ compatible = "mxicy,mx25l8005", "jedec,spi-nor";
+ reg = <0>; /* Chip select 0 */
+ spi-max-frequency = <50000000>;
+
+ partitions {
+ compatible = "fixed-partitions";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ partition@0 {
+ reg = <0x00000 0xf0000>; /* 960 KiB*/
+ label = "u-boot";
+ read-only;
+ };
+ partition@f0000 {
+ reg = <0xf0000 0x10000>; /* 64 KiB */
+ label = "u-boot-env";
+ };
+ };
+ };
+};
+
+&pinctrl {
+ pmx_power_cpu: pmx-power-cpu {
+ marvell,pins = "mpp4";
+ marvell,function = "vdd";
+ };
+
+ pmx_power_hdd1: pmx-power-hdd1 {
+ marvell,pins = "mpp8";
+ marvell,function = "gpio";
+ };
+
+ pmx_power_hdd2: pmx-power-hdd2 {
+ marvell,pins = "mpp2";
+ marvell,function = "gpo";
+ };
+
+ pmx_fan_lock: pmx-fan-lock {
+ marvell,pins = "mpp10";
+ marvell,function = "gpio";
+ };
+
+ pmx_hdd_present: pmx-hdd-present {
+ marvell,pins = "mpp11", "mpp12";
+ marvell,function = "gpio";
+ };
+
+ pmx_fan_high: pmx-fan-high {
+ marvell,pins = "mpp13";
+ marvell,function = "gpio";
+ };
+
+ pmx_fan_low: pmx-fan-low {
+ marvell,pins = "mpp14";
+ marvell,function = "gpio";
+ };
+
+ pmx_buttons: pmx-buttons {
+ marvell,pins = "mpp15", "mpp16";
+ marvell,function = "gpio";
+ };
+
+ pmx_leds1: pmx-leds {
+ marvell,pins = "mpp7", "mpp54", "mpp59", "mpp61";
+ marvell,function = "gpo";
+ };
+
+ pmx_leds2: pmx-leds {
+ marvell,pins = "mpp55", "mpp57", "mpp62";
+ marvell,function = "gpio";
+ };
+};
diff --git a/target/linux/mvebu/image/Makefile b/target/linux/mvebu/image/Makefile
index 44e66a5f87..a13b61c1eb 100644
--- a/target/linux/mvebu/image/Makefile
+++ b/target/linux/mvebu/image/Makefile
@@ -51,6 +51,20 @@ define Build/buffalo-kernel-jffs2
rm -rf $(KDIR)/kernel_jffs2 $@.fakerd
endef
+define Build/buffalo-kernel-ubifs
+ rm -rf $@-ubidir $@.ubi
+ mkdir -p $@-ubidir
+ mv $@ $@-ubidir/uImage.buffalo
+ touch $@
+ $(call Build/append-uImage-fakehdr, ramdisk)
+ mv $@ $@-ubidir/initrd.buffalo
+ $(STAGING_DIR_HOST)/bin/mkfs.ubifs \
+ $(KERNEL_UBIFS_OPTS) -r $@-ubidir $@.ubi
+ sh $(TOPDIR)/scripts/ubinize-image.sh \
+ --part boot=$@.ubi=20 $@ -p $(BLOCKSIZE:%k=%KiB) -m $(PAGESIZE) \
+ -s $(SUBPAGESIZE) -O $(VID_HDR_OFFSET) $(UBINIZE_OPTS)
+endef
+
# Some info about Ctera firmware:
# 1. It's simple tar file (GNU standard), but it must have ".firm" suffix.
# 2. It contains two images: kernel and romdisk. Both are required.
diff --git a/target/linux/mvebu/image/cortexa9.mk b/target/linux/mvebu/image/cortexa9.mk
index 6715a41c9e..1c96ae47d6 100644
--- a/target/linux/mvebu/image/cortexa9.mk
+++ b/target/linux/mvebu/image/cortexa9.mk
@@ -14,14 +14,30 @@ define Device/kernel-size-migration
Upgrade via sysupgrade mechanism is not possible, so new installation via factory style image is required.
endef
+define Device/buffalo_ls220de
+ $(Device/NAND-128K)
+ DEVICE_VENDOR := Buffalo
+ DEVICE_MODEL := LinkStation LS220DE
+ KERNEL_UBIFS_OPTS = -m $$(PAGESIZE) -e 124KiB -c $$(PAGESIZE) -x none
+ KERNEL_SIZE := 33554432
+ FILESYSTEMS := squashfs ubifs
+ KERNEL := kernel-bin | append-dtb | uImage none | buffalo-kernel-ubifs
+ KERNEL_INITRAMFS := kernel-bin | append-dtb | uImage none
+ DEVICE_DTS := armada-370-buffalo-ls220de
+ DEVICE_PACKAGES := \
+ kmod-hwmon-gpiofan kmod-hwmon-drivetemp kmod-linkstation-poweroff \
+ kmod-md-raid0 kmod-md-raid1 kmod-md-mod \
+ kmod-fs-xfs mkf2fs e2fsprogs partx-utils
+endef
+TARGET_DEVICES += buffalo_ls220de
define Device/buffalo_ls421de
$(Device/NAND-128K)
DEVICE_VENDOR := Buffalo
DEVICE_MODEL := LinkStation LS421DE
- SUBPAGESIZE :=
+ KERNEL_UBIFS_OPTS = -m $$(PAGESIZE) -e 124KiB -c $$(PAGESIZE) -x none
KERNEL_SIZE := 33554432
FILESYSTEMS := squashfs ubifs
- KERNEL := kernel-bin | append-dtb | uImage none | buffalo-kernel-jffs2
+ KERNEL := kernel-bin | append-dtb | uImage none | buffalo-kernel-ubifs
KERNEL_INITRAMFS := kernel-bin | append-dtb | uImage none
DEVICE_DTS := armada-370-buffalo-ls421de
DEVICE_PACKAGES := \
diff --git a/target/linux/mvebu/patches-5.10/linkstation-poweroff.patch b/target/linux/mvebu/patches-5.10/linkstation-poweroff.patch
new file mode 100644
index 0000000000..e23ba81812
--- /dev/null
+++ b/target/linux/mvebu/patches-5.10/linkstation-poweroff.patch
@@ -0,0 +1,15 @@
+--- a/drivers/power/reset/linkstation-poweroff.c
++++ b/drivers/power/reset/linkstation-poweroff.c
+@@ -86,10 +86,12 @@
+
+ kernel_restart("Power off");
+ }
+
+ static const struct of_device_id ls_poweroff_of_match[] = {
++ { .compatible = "buffalo,ls220d" },
++ { .compatible = "buffalo,ls220de" },
+ { .compatible = "buffalo,ls421d" },
+ { .compatible = "buffalo,ls421de" },
+ { },
+ };
+