From: Daniel Golle Date: Sun, 19 Nov 2023 22:01:47 +0000 (+0000) Subject: mvebu: add support for Synology DS213j X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=3f7637b05047badc15a58b1581c071892bc6e340;p=openwrt%2Fstaging%2Fblogic.git mvebu: add support for Synology DS213j The Synology DS213j is a rather dated dual-bay SATA NAS based on on the Marvell Armada-370 SoC. It has long been supported in vanilla Linux, however, flash partitioning there didn't match with reality (ie. the bootloaders expectations) and nobody cared to wrap up OpenWrt support for the device. CPU: Marvell Armada-370 ARMv7 SoC @ 1200 MHz RAM: 512 MB DDR3 Flash: 8 MB (Micron Technology N25Q064) Network: 1x 1000M/100M/10M Ethernet (Marvell 88E1510) SATA: 2x 3.0Gbps USB: 2x USB 2.0 As OS options are becoming limited on that still quite useful hardware, patch the flash partitions to be able to get the most out of it when using OpenWrt. The vendor firmware loads kernel and initrd from fixed addresses in the flash, not making use of a modifyable environment stored in flash which is stored at a location right in the middle of the vendor's zImage partition (at 0x100000). Stock firmware flash layout: 0x000000 ~ 0x0c0000 : "RedBoot" (actually U-Boot) 0x0c0000 ~ 0x390000 : "zImage" 0x390000 ~ 0x7d0000 : "rd.gz" 0x7d0000 ~ 0x7e0000 : "vendor" (contains MAC address, serial no) 0x7e0000 ~ 0x7f0000 : "RedBoot Config" (unused? legacy left-over) 0x7f0000 ~ 0x800000 : "FIS directory" (unused? legacy left-over) OpenWrt flash layout: 0x000000 ~ 0x0c0000 : "u-boot" 0x0c0000 ~ 0x100000 : "gap" 0x100000 ~ 0x110000 : "u-boot-env" 0x110000 ~ 0x7d0000 : "kernel" 0x7d0000 ~ 0x7e0000 : "vendor" (contains MAC address, serial no) 0x7e0000 ~ 0x800000 : "gap2" "kernel", "gap" and "gap2" are concatenated using the mtd-concat virtual MTD driver, resulting in a partition "firmware" used by OpenWrt for kernel, rootfs and rootfs-overlay, 0x720000 (7296kiB) in total. Installation: 1. Connect to internal serial console port and Ethernet port, providing a TFTP server at a static IPv4 address, e.g. 192.168.1.254/24. 2. Interrupt bootloader using CTRL+C 3. Configure bootloader to load OpenWrt on future boot: setenv bootcmd "bootm f4110000" saveenv 4. Load and boot initramfs image via TFTP: setenv ipaddr 192.168.1.1 setenv serverip 192.168.1.254 tftpboot openwrt-mvebu-cortexa9-synology_ds213j-initramfs-kernel.bin bootm 5. Use sysupgrade to load final image. Signed-off-by: Daniel Golle --- 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 5c176d4963d5..b9ac2bb1ae04 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 @@ -12,7 +12,8 @@ mvebu_setup_interfaces() local board="$1" case "$board" in - ctera,c200-v2) + ctera,c200-v2|\ + synology,ds213j) ucidef_set_interface_lan "eth0" "dhcp" ;; cznic,turris-omnia) diff --git a/target/linux/mvebu/cortexa9/config-5.15 b/target/linux/mvebu/cortexa9/config-5.15 index e666dd486fb1..266596d6384e 100644 --- a/target/linux/mvebu/cortexa9/config-5.15 +++ b/target/linux/mvebu/cortexa9/config-5.15 @@ -1,4 +1,7 @@ CONFIG_LED_TRIGGER_PHY=y CONFIG_MTD_SPLIT_SEIL_FW=y +CONFIG_MTD_SPLIT_UIMAGE_FW=y +CONFIG_MTD_VIRT_CONCAT=y CONFIG_PHY_MVEBU_A38X_COMPHY=y +CONFIG_POWER_RESET_QNAP=y CONFIG_RTC_DRV_MV=y diff --git a/target/linux/mvebu/cortexa9/config-6.1 b/target/linux/mvebu/cortexa9/config-6.1 index b2625c3b32ee..7f825a806b1e 100644 --- a/target/linux/mvebu/cortexa9/config-6.1 +++ b/target/linux/mvebu/cortexa9/config-6.1 @@ -4,6 +4,9 @@ CONFIG_CURRENT_POINTER_IN_TPIDRURO=y CONFIG_IRQSTACKS=y CONFIG_LED_TRIGGER_PHY=y CONFIG_MTD_SPLIT_SEIL_FW=y +CONFIG_MTD_SPLIT_UIMAGE_FW=y +CONFIG_MTD_VIRT_CONCAT=y CONFIG_PHY_MVEBU_A38X_COMPHY=y +CONFIG_POWER_RESET_QNAP=y CONFIG_RTC_DRV_MV=y CONFIG_THREAD_INFO_IN_TASK=y diff --git a/target/linux/mvebu/image/cortexa9.mk b/target/linux/mvebu/image/cortexa9.mk index 3234d62cd99d..a49401d904c6 100644 --- a/target/linux/mvebu/image/cortexa9.mk +++ b/target/linux/mvebu/image/cortexa9.mk @@ -388,3 +388,22 @@ define Device/solidrun_clearfog-pro-a1 SUPPORTED_DEVICES += armada-388-clearfog armada-388-clearfog-pro endef TARGET_DEVICES += solidrun_clearfog-pro-a1 + +define Device/synology_ds213j + DEVICE_VENDOR := Synology + DEVICE_MODEL := DS213j + KERNEL_SIZE := 6912k + IMAGE_SIZE := 7168k + FILESYSTEMS := squashfs ubifs + KERNEL := kernel-bin | append-dtb | uImage none + KERNEL_INITRAMFS := kernel-bin | append-dtb | uImage none + DEVICE_DTS := armada-370-synology-ds213j + IMAGES := sysupgrade.bin + IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | \ + check-size | append-metadata + DEVICE_PACKAGES := \ + kmod-rtc-s35390a kmod-hwmon-gpiofan kmod-hwmon-drivetemp \ + kmod-md-raid0 kmod-md-raid1 kmod-md-mod e2fsprogs mdadm \ + -ppp -kmod-nft-offload -firewall4 -dnsmasq -odhcpd-ipv6only +endef +TARGET_DEVICES += synology_ds213j diff --git a/target/linux/mvebu/patches-5.15/320-arm-dts-armada-370-synology-ds213j-mtd-parts.patch b/target/linux/mvebu/patches-5.15/320-arm-dts-armada-370-synology-ds213j-mtd-parts.patch new file mode 100644 index 000000000000..280fc5957e49 --- /dev/null +++ b/target/linux/mvebu/patches-5.15/320-arm-dts-armada-370-synology-ds213j-mtd-parts.patch @@ -0,0 +1,134 @@ +--- a/arch/arm/boot/dts/armada-370-synology-ds213j.dts ++++ b/arch/arm/boot/dts/armada-370-synology-ds213j.dts +@@ -31,6 +31,7 @@ + + chosen { + stdout-path = "serial0:115200n8"; ++ append-rootblock = "nullparameter="; /* override the bootloader args */ + }; + + memory@0 { +@@ -94,6 +95,8 @@ + status = "okay"; + phy = <&phy1>; + phy-mode = "sgmii"; ++ nvmem-cells = <&macaddr_vendor_0>; ++ nvmem-cell-names = "mac-address"; + }; + + sata@a0000 { +@@ -175,6 +178,24 @@ + gpio = <&gpio1 30 GPIO_ACTIVE_HIGH>; + }; + }; ++ ++ virtual_flash { ++ compatible = "mtd-concat"; ++ ++ devices = <&mtd_kernel &mtd_gap &mtd_gap2>; ++ ++ partitions { ++ compatible = "fixed-partitions"; ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ++ partition@0 { ++ compatible = "openwrt,uimage", "denx,uimage"; ++ label = "firmware"; ++ reg = <0x0 0x0>; ++ }; ++ }; ++ }; + }; + + &mdio { +@@ -265,48 +286,52 @@ + reg = <0>; /* Chip select 0 */ + spi-max-frequency = <20000000>; + +- /* +- * Warning! +- * +- * Synology u-boot uses its compiled-in environment +- * and it seems Synology did not care to change u-boot +- * default configuration in order to allow saving a +- * modified environment at a sensible location. So, +- * if you do a 'saveenv' under u-boot, your modified +- * environment will be saved at 1MB after the start +- * of the flash, i.e. in the middle of the uImage. +- * For that reason, it is strongly advised not to +- * change the default environment, unless you know +- * what you are doing. +- */ +- partition@0 { /* u-boot */ +- label = "RedBoot"; +- reg = <0x00000000 0x000c0000>; /* 768KB */ +- }; ++ partitions { ++ compatible = "fixed-partitions"; + +- partition@c0000 { /* uImage */ +- label = "zImage"; +- reg = <0x000c0000 0x002d0000>; /* 2880KB */ +- }; ++ partition@0 { /* u-boot */ ++ label = "u-boot"; ++ reg = <0x00000000 0x000c0000>; /* 768KB */ ++ read-only; ++ }; + +- partition@390000 { /* uInitramfs */ +- label = "rd.gz"; +- reg = <0x00390000 0x00440000>; /* 4250KB */ +- }; ++ mtd_gap: partition@c0000 { /* gap */ ++ label = "gap"; ++ reg = <0x000c0000 0x00040000>; /* 256KB */ ++ }; + +- partition@7d0000 { /* MAC address and serial number */ +- label = "vendor"; +- reg = <0x007d0000 0x00010000>; /* 64KB */ +- }; ++ partition@100000 { /* u-boot-env */ ++ label = "u-boot-env"; ++ reg = <0x00100000 0x00010000>; /* 64KB */ ++ }; + +- partition@7e0000 { +- label = "RedBoot config"; +- reg = <0x007e0000 0x00010000>; /* 64KB */ +- }; ++ mtd_kernel: partition@110000 { ++ label = "kernel"; ++ reg = <0x00110000 0x006c0000>; /* 6912KB */ ++ }; + +- partition@7f0000 { +- label = "FIS directory"; +- reg = <0x007f0000 0x00010000>; /* 64KB */ ++ partition@7d0000 { /* MAC address and serial number */ ++ reg = <0x007d0000 0x00010000>; /* 64KB */ ++ label = "vendor"; ++ read-only; ++ ++ compatible = "nvmem-cells"; ++ ++ nvmem-layout { ++ compatible = "fixed-layout"; ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ++ macaddr_vendor_0: macaddr@0 { ++ reg = <0x0 0x6>; ++ }; ++ }; ++ }; ++ ++ mtd_gap2: partition@7e0000 { ++ label = "gap2"; ++ reg = <0x007e0000 0x00020000>; /* 128KB */ ++ }; + }; + }; + }; diff --git a/target/linux/mvebu/patches-6.1/320-arm-dts-armada-370-synology-ds213j-mtd-parts.patch b/target/linux/mvebu/patches-6.1/320-arm-dts-armada-370-synology-ds213j-mtd-parts.patch new file mode 100644 index 000000000000..280fc5957e49 --- /dev/null +++ b/target/linux/mvebu/patches-6.1/320-arm-dts-armada-370-synology-ds213j-mtd-parts.patch @@ -0,0 +1,134 @@ +--- a/arch/arm/boot/dts/armada-370-synology-ds213j.dts ++++ b/arch/arm/boot/dts/armada-370-synology-ds213j.dts +@@ -31,6 +31,7 @@ + + chosen { + stdout-path = "serial0:115200n8"; ++ append-rootblock = "nullparameter="; /* override the bootloader args */ + }; + + memory@0 { +@@ -94,6 +95,8 @@ + status = "okay"; + phy = <&phy1>; + phy-mode = "sgmii"; ++ nvmem-cells = <&macaddr_vendor_0>; ++ nvmem-cell-names = "mac-address"; + }; + + sata@a0000 { +@@ -175,6 +178,24 @@ + gpio = <&gpio1 30 GPIO_ACTIVE_HIGH>; + }; + }; ++ ++ virtual_flash { ++ compatible = "mtd-concat"; ++ ++ devices = <&mtd_kernel &mtd_gap &mtd_gap2>; ++ ++ partitions { ++ compatible = "fixed-partitions"; ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ++ partition@0 { ++ compatible = "openwrt,uimage", "denx,uimage"; ++ label = "firmware"; ++ reg = <0x0 0x0>; ++ }; ++ }; ++ }; + }; + + &mdio { +@@ -265,48 +286,52 @@ + reg = <0>; /* Chip select 0 */ + spi-max-frequency = <20000000>; + +- /* +- * Warning! +- * +- * Synology u-boot uses its compiled-in environment +- * and it seems Synology did not care to change u-boot +- * default configuration in order to allow saving a +- * modified environment at a sensible location. So, +- * if you do a 'saveenv' under u-boot, your modified +- * environment will be saved at 1MB after the start +- * of the flash, i.e. in the middle of the uImage. +- * For that reason, it is strongly advised not to +- * change the default environment, unless you know +- * what you are doing. +- */ +- partition@0 { /* u-boot */ +- label = "RedBoot"; +- reg = <0x00000000 0x000c0000>; /* 768KB */ +- }; ++ partitions { ++ compatible = "fixed-partitions"; + +- partition@c0000 { /* uImage */ +- label = "zImage"; +- reg = <0x000c0000 0x002d0000>; /* 2880KB */ +- }; ++ partition@0 { /* u-boot */ ++ label = "u-boot"; ++ reg = <0x00000000 0x000c0000>; /* 768KB */ ++ read-only; ++ }; + +- partition@390000 { /* uInitramfs */ +- label = "rd.gz"; +- reg = <0x00390000 0x00440000>; /* 4250KB */ +- }; ++ mtd_gap: partition@c0000 { /* gap */ ++ label = "gap"; ++ reg = <0x000c0000 0x00040000>; /* 256KB */ ++ }; + +- partition@7d0000 { /* MAC address and serial number */ +- label = "vendor"; +- reg = <0x007d0000 0x00010000>; /* 64KB */ +- }; ++ partition@100000 { /* u-boot-env */ ++ label = "u-boot-env"; ++ reg = <0x00100000 0x00010000>; /* 64KB */ ++ }; + +- partition@7e0000 { +- label = "RedBoot config"; +- reg = <0x007e0000 0x00010000>; /* 64KB */ +- }; ++ mtd_kernel: partition@110000 { ++ label = "kernel"; ++ reg = <0x00110000 0x006c0000>; /* 6912KB */ ++ }; + +- partition@7f0000 { +- label = "FIS directory"; +- reg = <0x007f0000 0x00010000>; /* 64KB */ ++ partition@7d0000 { /* MAC address and serial number */ ++ reg = <0x007d0000 0x00010000>; /* 64KB */ ++ label = "vendor"; ++ read-only; ++ ++ compatible = "nvmem-cells"; ++ ++ nvmem-layout { ++ compatible = "fixed-layout"; ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ++ macaddr_vendor_0: macaddr@0 { ++ reg = <0x0 0x6>; ++ }; ++ }; ++ }; ++ ++ mtd_gap2: partition@7e0000 { ++ label = "gap2"; ++ reg = <0x007e0000 0x00020000>; /* 128KB */ ++ }; + }; + }; + };