Synology DS414 integration mini-review
cover Synology DS414 integration mini-review
Board-specific code lacked a Kconfig file defining CONFIG_SYS_BOARD, CONFIG_SYS_VENDOR, etc - patch 1 fixes that.
I was very pleased to notice the recent changes in PCI/USB code fixed xhci-pci functionality on DS414, so patch 2 enables XHCI support in defconfig.
Adjusting DS109 atags code for DS414 allowed to successfully boot vendor Linux, so I went ahead and generalized the code to support both boards in patch 3.
Patch 4 introduces a misc_init_r() routine populating environment from Synology's special flash partition if appropriate - less manual work for users and no need for random MAC address fallback anymore.
Patch 6 extends the default environment by a command to update u-boot via tftp.
Phil Sutter (5):
ds414: Add a Kconfig defining some strings
configs: ds414: Enable XHCI_PCI by default
board/Synology: Unify legacy kernel support
ds414: Auto-populate env if appropriate
ds414: Add sample u-boot update command
board/Synology/common/Makefile | 5 +++ board/Synology/common/legacy.c | 75 +++++++++++++++++++++++++++++++++ board/Synology/common/legacy.h | 33 +++++++++++++++ board/Synology/ds109/ds109.c | 32 -------------- board/Synology/ds109/ds109.h | 17 -------- board/Synology/ds414/Kconfig | 12 ++++++ board/Synology/ds414/cmd_syno.c | 2 +- board/Synology/ds414/ds414.c | 13 ++++++ configs/ds414_defconfig | 7 ++- include/configs/ds109.h | 3 +- include/configs/ds414.h | 20 ++++++++- 11 files changed, 163 insertions(+), 56 deletions(-) create mode 100644 board/Synology/common/Makefile create mode 100644 board/Synology/common/legacy.c create mode 100644 board/Synology/common/legacy.h create mode 100644 board/Synology/ds414/Kconfig
Signature · 1 line
2.30.1
PATCH 1/5 ds414: Add a Kconfig defining some strings
A rather cosmetic change to conform with other board definitions.
--- board/Synology/ds414/Kconfig | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 board/Synology/ds414/Kconfig
board/Synology/ds414/Kconfig new file +12 -0
@@ -0,0 +1,12 @@ +if TARGET_DS414 + +config SYS_BOARD + default "ds414" + +config SYS_VENDOR + default "Synology" + +config SYS_CONFIG_NAME + default "ds414" + +endif
Signature · 1 line
2.30.1
PATCH 1/5 ds414: Add a Kconfig defining some strings
Quoted 3 lines · Phil Sutter
A rather cosmetic change to conform with other board definitions.
Signed-off-by Phil Sutter <[email protected]>
Thanks,
Stefan
PATCH 2/5 configs: ds414: Enable XHCI_PCI by default
In reply to Phil SutterWith the recent fixes in pci_mvebu and xhci-pci drivers, the two rear USB3 ports are finally usable and accessing them no longer hangs the system.
--- configs/ds414_defconfig | 1 + 1 file changed, 1 insertion(+)
configs/ds414_defconfig +1 -0
@@ -65,5 +65,6 @@ CONFIG_SYS_NS16550=y CONFIG_KIRKWOOD_SPI=y CONFIG_USB=y CONFIG_DM_USB=y +CONFIG_USB_XHCI_PCI=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_STORAGE=y
Signature · 1 line
2.30.1
PATCH 2/5 configs: ds414: Enable XHCI_PCI by default
Quoted 5 lines · Phil Sutter
With the recent fixes in
pci_mvebuand xhci-pci drivers, the two rear USB3 ports are finally usable and accessing them no longer hangs the system.Signed-off-by Phil Sutter <[email protected]>
Thanks,
Stefan
PATCH 2/5 configs: ds414: Enable XHCI_PCI by default
Quoted 8 lines · Stefan Roese
Quoted 5 lines · Phil Sutter
With the recent fixes in
pci_mvebuand xhci-pci drivers, the two rear USB3 ports are finally usable and accessing them no longer hangs the system.Signed-off-by Phil Sutter <[email protected]>Reviewed-by Stefan Roese <[email protected]>
Please hold back on this one, I noticed it needs CONFIG_XHCI_HCD as well. Will send a v2 later.
Sorry for the mess!
Phil
PATCH v2 2/5 configs: ds414: Enable XHCI_PCI by default
In reply to Phil SutterWith the recent fixes in pci_mvebu and xhci-pci drivers, the two rear USB3 ports are finally usable and accessing them no longer hangs the system. Moreover, if Linux is booted without a prior call to 'pci enum' and 'usb start', the HCD is detected but attached devices are not usable:
| xhci_hcd 0000:02:00.0: xHCI Host Controller | xhci_hcd 0000:02:00.0: new USB bus registered, assigned bus number 2 | xhci_hcd 0000:02:00.0: hcc params 0x040040a5 hci version 0x100 quirks 0x0000000000080490 | usb usb2: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.04 | usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1 | usb usb2: Product: xHCI Host Controller | usb usb2: Manufacturer: Linux 5.4.92-1 xhci-hcd | usb usb2: SerialNumber: 0000:02:00.0 | hub 2-0:1.0: USB hub found | ata1: SATA link down (SStatus 0 SControl 300) | hub 2-0:1.0: 2 ports detected | xhci_hcd 0000:02:00.0: xHCI Host Controller | xhci_hcd 0000:02:00.0: new USB bus registered, assigned bus number 3 | xhci_hcd 0000:02:00.0: Host supports USB 3.0 SuperSpeed | usb usb3: We don't know the algorithms for LPM for this host, disabling LPM. | usb usb3: New USB device found, idVendor=1d6b, idProduct=0003, bcdDevice= 5.04 | usb usb3: New USB device strings: Mfr=3, Product=2, SerialNumber=1 | usb usb3: Product: xHCI Host Controller | usb usb3: Manufacturer: Linux 5.4.92-1 xhci-hcd | usb usb3: SerialNumber: 0000:02:00.0 | hub 3-0:1.0: USB hub found | hub 3-0:1.0: 2 ports detected [...] | xhci_hcd 0000:02:00.0: Error while assigning device slot ID | xhci_hcd 0000:02:00.0: Max number of devices this xHCI host supports is 64. | usb usb2-port2: couldn't allocate usb_device
To avoid this problem, enumerate PCI (and USB) from PREBOOT.
---
Changes since v1:
- Have to enable XHCI_HCD as well to fulfill Kconfig dependency.
- Explicitly disable XHCI_MARVELL which defaults to enabled.
- Prefix PREBOOT with 'pci enum'.
- Update commit message accordingly.
--- configs/ds414_defconfig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
configs/ds414_defconfig +4 -1
@@ -22,7 +22,7 @@ CONFIG_BOOTDELAY=3 CONFIG_USE_BOOTARGS=y CONFIG_BOOTARGS="console=ttyS0,115200" CONFIG_USE_PREBOOT=y -CONFIG_PREBOOT="usb start; sf probe" +CONFIG_PREBOOT="pci enum; usb start; sf probe" # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_SPL_I2C_SUPPORT=y
@@ -65,5 +65,8 @@ CONFIG_SYS_NS16550=y CONFIG_KIRKWOOD_SPI=y CONFIG_USB=y CONFIG_DM_USB=y +CONFIG_USB_XHCI_HCD=y +# CONFIG_USB_XHCI_MVEBU is not set +CONFIG_USB_XHCI_PCI=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_STORAGE=y
Signature · 1 line
2.30.1
PATCH v2 2/5 configs: ds414: Enable XHCI_PCI by default
Quoted 35 lines · Phil Sutter
With the recent fixes in
pci_mvebuand xhci-pci drivers, the two rear USB3 ports are finally usable and accessing them no longer hangs the system. Moreover, if Linux is booted without a prior call to 'pci enum' and 'usb start', the HCD is detected but attached devices are not usable:| xhci_hcd 0000:02:00.0: xHCI Host Controller | xhci_hcd 0000:02:00.0: new USB bus registered, assigned bus number 2 | xhci_hcd 0000:02:00.0: hcc params 0x040040a5 hci version 0x100 quirks 0x0000000000080490 | usb usb2: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.04 | usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1 | usb usb2: Product: xHCI Host Controller | usb usb2: Manufacturer: Linux 5.4.92-1 xhci-hcd | usb usb2: SerialNumber: 0000:02:00.0 | hub 2-0:1.0: USB hub found | ata1: SATA link down (SStatus 0 SControl 300) | hub 2-0:1.0: 2 ports detected | xhci_hcd 0000:02:00.0: xHCI Host Controller | xhci_hcd 0000:02:00.0: new USB bus registered, assigned bus number 3 | xhci_hcd 0000:02:00.0: Host supports USB 3.0 SuperSpeed | usb usb3: We don't know the algorithms for LPM for this host, disabling LPM. | usb usb3: New USB device found, idVendor=1d6b, idProduct=0003, bcdDevice= 5.04 | usb usb3: New USB device strings: Mfr=3, Product=2, SerialNumber=1 | usb usb3: Product: xHCI Host Controller | usb usb3: Manufacturer: Linux 5.4.92-1 xhci-hcd | usb usb3: SerialNumber: 0000:02:00.0 | hub 3-0:1.0: USB hub found | hub 3-0:1.0: 2 ports detected [...] | xhci_hcd 0000:02:00.0: Error while assigning device slot ID | xhci_hcd 0000:02:00.0: Max number of devices this xHCI host supports is 64. | usb usb2-port2: couldn't allocate usb_deviceTo avoid this problem, enumerate PCI (and USB) from PREBOOT.
Quoted 7 lines
Signed-off-by Phil Sutter <[email protected]>---
Changes since v1:
- Have to enableXHCI_HCDas well to fulfillKconfigdependency.
- Explicitly disableXHCI_MARVELLwhich defaults to enabled.
- Prefix PREBOOT with 'pci enum'.
- Update commit message accordingly.
Hmmm, in general is should not be necessary to configure / setup any of the devices in the bootloader so that it works correctly in Linux. It's best practice, that Linux does not rely on any bootloader setup. If a device, like PCI and/or USB does not work in Linux without this U-Boot setup, then it should be fixed in Linux instead.
Especially calling "usb start" adds a quite big delay to the bootup time. I would really like to not add such changes. Perhaps you could check with the maintainer(s) of the Linux PCI driver and/or the USB PCI controller driver about this issue instead?
Thanks,
Stefan
Quoted 19 lines
--- configs/ds414_defconfig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)configs/ds414_defconfig +1
-1@@ -22,7 +22,7 @@ CONFIG_BOOTDELAY=3 CONFIG_USE_BOOTARGS=y CONFIG_BOOTARGS="console=ttyS0,115200" CONFIG_USE_PREBOOT=y -CONFIG_PREBOOT="usb start; sf probe" +CONFIG_PREBOOT="pci enum; usb start; sf probe" # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_SPL_I2C_SUPPORT=y
configs/ds414_defconfig CONFIG_SYS_NS16550=y · line 72
Quoted 8 lines
configs/ds414_defconfig +3
-0@@ -65,5 +65,8 @@ CONFIG_SYS_NS16550=y CONFIG_KIRKWOOD_SPI=y CONFIG_USB=y CONFIG_DM_USB=y +CONFIG_USB_XHCI_HCD=y +# CONFIG_USB_XHCI_MVEBU is not set +CONFIG_USB_XHCI_PCI=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_STORAGE=y
Viele Gr??e,
Stefan
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr at denx.de
PATCH v2 2/5 configs: ds414: Enable XHCI_PCI by default
Quoted 50 lines · Stefan Roese
Quoted 35 lines · Phil Sutter
With the recent fixes in
pci_mvebuand xhci-pci drivers, the two rear USB3 ports are finally usable and accessing them no longer hangs the system. Moreover, if Linux is booted without a prior call to 'pci enum' and 'usb start', the HCD is detected but attached devices are not usable:| xhci_hcd 0000:02:00.0: xHCI Host Controller | xhci_hcd 0000:02:00.0: new USB bus registered, assigned bus number 2 | xhci_hcd 0000:02:00.0: hcc params 0x040040a5 hci version 0x100 quirks 0x0000000000080490 | usb usb2: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.04 | usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1 | usb usb2: Product: xHCI Host Controller | usb usb2: Manufacturer: Linux 5.4.92-1 xhci-hcd | usb usb2: SerialNumber: 0000:02:00.0 | hub 2-0:1.0: USB hub found | ata1: SATA link down (SStatus 0 SControl 300) | hub 2-0:1.0: 2 ports detected | xhci_hcd 0000:02:00.0: xHCI Host Controller | xhci_hcd 0000:02:00.0: new USB bus registered, assigned bus number 3 | xhci_hcd 0000:02:00.0: Host supports USB 3.0 SuperSpeed | usb usb3: We don't know the algorithms for LPM for this host, disabling LPM. | usb usb3: New USB device found, idVendor=1d6b, idProduct=0003, bcdDevice= 5.04 | usb usb3: New USB device strings: Mfr=3, Product=2, SerialNumber=1 | usb usb3: Product: xHCI Host Controller | usb usb3: Manufacturer: Linux 5.4.92-1 xhci-hcd | usb usb3: SerialNumber: 0000:02:00.0 | hub 3-0:1.0: USB hub found | hub 3-0:1.0: 2 ports detected [...] | xhci_hcd 0000:02:00.0: Error while assigning device slot ID | xhci_hcd 0000:02:00.0: Max number of devices this xHCI host supports is 64. | usb usb2-port2: couldn't allocate usb_deviceTo avoid this problem, enumerate PCI (and USB) from PREBOOT.
Quoted 7 lines
Signed-off-by Phil Sutter <[email protected]>---
Changes since v1:
- Have to enableXHCI_HCDas well to fulfillKconfigdependency.
- Explicitly disableXHCI_MARVELLwhich defaults to enabled.
- Prefix PREBOOT with 'pci enum'.
- Update commit message accordingly.Hmmm, in general is should not be necessary to configure / setup any of the devices in the bootloader so that it works correctly in Linux. It's best practice, that Linux does not rely on any bootloader setup. If a device, like PCI and/or USB does not work in Linux without this U-Boot setup, then it should be fixed in Linux instead.
Quoted 4 lines
Especially calling "usb start" adds a quite big delay to the bootup time. I would really like to not add such changes. Perhaps you could check with the maintainer(s) of the Linux PCI driver and/or the USB PCI controller driver about this issue instead?
Turns out I should have tried a more recent kernel first, the bug I was working around is quite certainly fixed by Linux commit 216f8e95aacc8 ("PCI: mvebu: Setup BAR0 in order to fix MSI").
I'll send a v3 without the fuss but with the Kconfig fix.
Sorry for the noise,
Phil
PATCH v2 2/5 configs: ds414: Enable XHCI_PCI by default
Quoted 51 lines · Phil Sutter
Quoted 50 lines · Stefan Roese
Quoted 35 lines · Phil Sutter
With the recent fixes in
pci_mvebuand xhci-pci drivers, the two rear USB3 ports are finally usable and accessing them no longer hangs the system. Moreover, if Linux is booted without a prior call to 'pci enum' and 'usb start', the HCD is detected but attached devices are not usable:| xhci_hcd 0000:02:00.0: xHCI Host Controller | xhci_hcd 0000:02:00.0: new USB bus registered, assigned bus number 2 | xhci_hcd 0000:02:00.0: hcc params 0x040040a5 hci version 0x100 quirks 0x0000000000080490 | usb usb2: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.04 | usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1 | usb usb2: Product: xHCI Host Controller | usb usb2: Manufacturer: Linux 5.4.92-1 xhci-hcd | usb usb2: SerialNumber: 0000:02:00.0 | hub 2-0:1.0: USB hub found | ata1: SATA link down (SStatus 0 SControl 300) | hub 2-0:1.0: 2 ports detected | xhci_hcd 0000:02:00.0: xHCI Host Controller | xhci_hcd 0000:02:00.0: new USB bus registered, assigned bus number 3 | xhci_hcd 0000:02:00.0: Host supports USB 3.0 SuperSpeed | usb usb3: We don't know the algorithms for LPM for this host, disabling LPM. | usb usb3: New USB device found, idVendor=1d6b, idProduct=0003, bcdDevice= 5.04 | usb usb3: New USB device strings: Mfr=3, Product=2, SerialNumber=1 | usb usb3: Product: xHCI Host Controller | usb usb3: Manufacturer: Linux 5.4.92-1 xhci-hcd | usb usb3: SerialNumber: 0000:02:00.0 | hub 3-0:1.0: USB hub found | hub 3-0:1.0: 2 ports detected [...] | xhci_hcd 0000:02:00.0: Error while assigning device slot ID | xhci_hcd 0000:02:00.0: Max number of devices this xHCI host supports is 64. | usb usb2-port2: couldn't allocate usb_deviceTo avoid this problem, enumerate PCI (and USB) from PREBOOT.
Quoted 7 lines
Signed-off-by Phil Sutter <[email protected]>---
Changes since v1:
- Have to enableXHCI_HCDas well to fulfillKconfigdependency.
- Explicitly disableXHCI_MARVELLwhich defaults to enabled.
- Prefix PREBOOT with 'pci enum'.
- Update commit message accordingly.Hmmm, in general is should not be necessary to configure / setup any of the devices in the bootloader so that it works correctly in Linux. It's best practice, that Linux does not rely on any bootloader setup. If a device, like PCI and/or USB does not work in Linux without this U-Boot setup, then it should be fixed in Linux instead.
Quoted 8 lines
Quoted 4 lines
Especially calling "usb start" adds a quite big delay to the bootup time. I would really like to not add such changes. Perhaps you could check with the maintainer(s) of the Linux PCI driver and/or the USB PCI controller driver about this issue instead?
Turns out I should have tried a more recent kernel first, the bug I was working around is quite certainly fixed by Linux commit
216f8e95aacc8("PCI: mvebu: Setup BAR0 in order to fix MSI").
This is actually good news. Thanks for testing and reporting.
Quoted 3 lines
I'll send a v3 without the fuss but with the
Kconfigfix.Sorry for the noise,
NP. ;)
Thanks,
Stefan
PATCH v3 2/5 configs: ds414: Enable XHCI_PCI by default
In reply to Phil SutterWith the recent fixes in pci_mvebu and xhci-pci drivers, the two rear USB3 ports are finally usable and accessing them no longer hangs the system.
---
Changes since v2:
- Leave PREBOOT alone, with recent kernels XHCI HCD works fine even if not initialized.
- Adjust commit message again.
Changes since v1:
- Have to enable XHCI_HCD as well to fulfill Kconfig dependency.
- Explicitly disable XHCI_MARVELL which defaults to enabled.
- Prefix PREBOOT with 'pci enum'.
- Update commit message accordingly.
--- configs/ds414_defconfig | 3 +++ 1 file changed, 3 insertions(+)
configs/ds414_defconfig +3 -0
@@ -65,5 +65,8 @@ CONFIG_SYS_NS16550=y CONFIG_KIRKWOOD_SPI=y CONFIG_USB=y CONFIG_DM_USB=y +CONFIG_USB_XHCI_HCD=y +# CONFIG_USB_XHCI_MVEBU is not set +CONFIG_USB_XHCI_PCI=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_STORAGE=y
Signature · 1 line
2.30.1
PATCH v3 2/5 configs: ds414: Enable XHCI_PCI by default
Quoted 5 lines · Phil Sutter
With the recent fixes in
pci_mvebuand xhci-pci drivers, the two rear USB3 ports are finally usable and accessing them no longer hangs the system.Signed-off-by Phil Sutter <[email protected]>
Thanks,
Stefan
PATCH 3/5 board/Synology: Unify legacy kernel support
In reply to Phil SutterMove the relevant bits from ds109.{c,h} into common/ and adjust the code to fit both DS109 and DS414. Moreover:
* Introduce syno_board_id() which translates CONFIG_MACH_TYPE into the expected board ID tag value.
* Properly initialize isusbhost, mac and mtu fields from env variables.
* Set the right bootargs/bootcmd to correctly boot legacy kernel out of the (DS414) box. Getting the ramdisk location right is a bit tedious.
--- board/Synology/common/Makefile | 5 +++ board/Synology/common/legacy.c | 75 ++++++++++++++++++++++++++++++++++ board/Synology/common/legacy.h | 33 +++++++++++++++ board/Synology/ds109/ds109.c | 32 --------------- board/Synology/ds109/ds109.h | 17 -------- configs/ds414_defconfig | 2 +- include/configs/ds109.h | 3 +- include/configs/ds414.h | 15 ++++++- 8 files changed, 130 insertions(+), 52 deletions(-) create mode 100644 board/Synology/common/Makefile create mode 100644 board/Synology/common/legacy.c create mode 100644 board/Synology/common/legacy.h
board/Synology/common/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2021 Phil Sutter <[email protected]> + +obj-y += legacy.o
board/Synology/common/legacy.c new file +75 -0
75 lines not on this page · raw message
board/Synology/common/legacy.h new file +33 -0
@@ -0,0 +1,33 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2021 +* Walter Schweizer <[email protected]> +* Phil Sutter <[email protected]> +*/ + +#ifndef __SYNO_LEGACY_H +#define __SYNO_LEGACY_H + +/* Marvell uboot parameters */ +#define ATAG_MV_UBOOT 0x41000403 +#define VER_NUM 0x03040400/* 3.4.4 */ + +#define BOARD_ID_BASE 0x0 +#define SYNO_DS109_ID (BOARD_ID_BASE+0x15) +#define SYNO_AXP_4BAY_2BAY (0xf + 1) + +#define ETHADDR_MAX 4 +#define USBPORT_MAX 3 + +struct tag_mv_uboot { +u32 uboot_version; +u32 tclk; +u32 sysclk; +u32 isusbhost; +u8 macaddr[ETHADDR_MAX ][ETH_ALEN ]; +u16 mtu[ETHADDR_MAX ]; +u32 fw_image_base; +u32 fw_image_size; +}; + +#endif /* __SYNO_LEGACY_H */
board/Synology/ds109/ds109.c +0 -32
@@ -114,38 +114,6 @@ void reset_misc(void) SOFTWARE_REBOOT); } -/* Support old kernels */ -void setup_board_tags (struct tag **in_params) -{ -unsigned int boardId; -struct tag *params; -struct tag_mv_uboot *t; -int i; - -printf ("Synology board tags..." ); - params = *in_params; - t = (struct tag_mv_uboot *)¶ms->u; - - t->uboot_version =VER_NUM ; - - boardId =SYNO_DS109_ID ; - t->uboot_version |= boardId; - - t->tclk =CONFIG_SYS_TCLK ; - t->sysclk =CONFIG_SYS_TCLK *2 ; - - t->isusbhost =1 ; -for (i =0 ; i <4 ; i++) { -memset (t->macaddr[i],0 ,sizeof (t->macaddr[i])); - t->mtu[i] =0 ; - } - - params->hdr.tag =ATAG_MV_UBOOT ; - params->hdr.size =tag_size (tag_mv_uboot); - params =tag_next (params); - *in_params = params; -} -#ifdef CONFIG_RESET_PHY_R /* Configure and enable MV88E1116 PHY */ void reset_phy (void )
board/Synology/ds109/ds109.h +0 -17
@@ -23,21 +23,4 @@#define MV88E1116_RGMII_TXTM_CTRL (1 << 4)#define MV88E1116_RGMII_RXTM_CTRL (1 << 5) -/* Marvell uboot parameters */ -#define ATAG_MV_UBOOT 0x41000403 -#define VER_NUM 0x03040400/* 3.4.4 */ -#define BOARD_ID_BASE 0x0 -#define SYNO_DS109_ID (BOARD_ID_BASE+0x15) - -struct tag_mv_uboot { -u32 uboot_version; -u32 tclk; -u32 sysclk; -u32 isusbhost; -char macaddr[4 ][6 ]; -u16 mtu[4 ]; -u32 fw_image_base; -u32 fw_image_size; -}; -#endif /* __DS109_H */
configs/ds414_defconfig +1 -1
@@ -20,7 +20,7 @@ CONFIG_DEFAULT_DEVICE_TREE="armada-xp-synology-ds414" CONFIG_DEBUG_UART=y CONFIG_BOOTDELAY=3 CONFIG_USE_BOOTARGS=y -CONFIG_BOOTARGS="console=ttyS0,115200" +CONFIG_BOOTARGS="console=ttyS0,115200 ip=off initrd=0x8000040,8M root=/dev/md0 rw syno_hw_version=DS414r1 ihd_num=4 netif_num=2 flash_size=8 SataLedSpecial=1 HddHotplug=1" CONFIG_USE_PREBOOT=y CONFIG_PREBOOT="usb start; sf probe" # CONFIG_DISPLAY_BOARDINFO is not set
include/configs/ds109.h +2 -1
@@ -44,7 +44,8 @@"x_bootcmd_kernel=fatload usb 0 0x6400000 uImage\0" \"x_bootargs=console=ttyS0,115200\0" \"x_bootargs_root=root=/dev/sda2 rootdelay=10\0" \ -"ipaddr=192.168.1.5\0" +"ipaddr=192.168.1.5\0" \ +"usb0Mode=host\0" /* * Ethernet Driver configuration
include/configs/ds414.h +14 -1
@@ -6,6 +6,9 @@#ifndef _CONFIG_SYNOLOGY_DS414_H#define _CONFIG_SYNOLOGY_DS414_H +/* Vendor kernel expects this MACH_TYPE */ +#define CONFIG_MACH_TYPE 3036 +/* * High Level Configuration Options (easy to change) */
@@ -74,8 +77,18 @@#define CONFIG_DDR_32BIT /* Default Environment */ -#define CONFIG_BOOTCOMMAND "sf read ${loadaddr} 0xd0000 0x700000; bootm"#define CONFIG_LOADADDR 0x80000 +#define CONFIG_BOOTCOMMAND \ + "sf probe; " \ + "sf read ${loadaddr} 0xd0000 0x2d0000; " \ + "sf read ${ramdisk_addr_r} 0x3a0000 0x430000; " \ + "bootm ${loadaddr} ${ramdisk_addr_r}" + +#define CONFIG_EXTRA_ENV_SETTINGS \ + "initrd_high=0xffffffff\0" \ + "ramdisk_addr_r=0x8000000\0" \ + "usb0Mode=host\0usb1Mode=host\0usb2Mode=device\0" \ + "ethmtu=1500\0eth1mtu=1500\0"/* increase autoneg timeout, my NIC sucks */ #define PHY_ANEG_TIMEOUT 16000
Signature · 1 line
2.30.1
PATCH 3/5 board/Synology: Unify legacy kernel support
Quoted 44 lines · Phil Sutter
Move the relevant bits from ds109.{c,h} into common/ and adjust the code to fit both DS109 and DS414. Moreover:
* Introduce
syno_board_id()which translatesCONFIG_MACH_TYPEinto the expected board ID tag value.* Properly initialize isusbhost, mac and mtu fields from env variables.
* Set the right bootargs/bootcmd to correctly boot legacy kernel out of the (DS414) box. Getting the ramdisk location right is a bit tedious.
Cc Walter Schweizer <[email protected]>Signed-off-by Phil Sutter <[email protected]>--- board/Synology/common/Makefile | 5 +++ board/Synology/common/legacy.c | 75 ++++++++++++++++++++++++++++++++++ board/Synology/common/legacy.h | 33 +++++++++++++++ board/Synology/ds109/ds109.c | 32 --------------- board/Synology/ds109/ds109.h | 17 -------- configs/ds414_defconfig | 2 +- include/configs/ds109.h | 3 +- include/configs/ds414.h | 15 ++++++- 8 files changed, 130 insertions(+), 52 deletions(-)create mode 100644 board/Synology/common/Makefile create mode 100644
board/Synology/common/legacy.ccreate mode 100644board/Synology/common/legacy.hboard/Synology/common/Makefile new file +5
-0@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2021 Phil Sutter <[email protected]> + +obj-y += legacy.oboard/Synology/common/legacy.c new file +0
-0
board/Synology/common/legacy.c line 8
Quoted 8 lines
board/Synology/common/legacy.c new file +8
-0@@ -0,0 +1,75 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2021 +* Walter Schweizer <[email protected]> +* Phil Sutter <[email protected]> +*/ + +#include <common.h>
Please don't include "common.h" any more. There is ongoing work to depricate this common header.
Other than this:
Thanks,
Stefan
Quoted 227 lines
board/Synology/common/legacy.c new file +67
-0+#include <env.h> +#include <net.h> +#include <asm/setup.h> + +#include "legacy.h" + +static unsigned int syno_board_id (void ) +{ +switch (CONFIG_MACH_TYPE ) { +case 527 : +return SYNO_DS109_ID ; +case 3036 : +return SYNO_AXP_4BAY_2BAY ; +default : +return 0 ; + } +} + +static unsigned int usb_port_modes (void ) +{ +unsigned int i, ret =0 ; +char var[32 ], *val; + +for (i =0 ; i <USBPORT_MAX ; i++) { +snprintf (var,32 ,"usb%dMode" , i); + val =env_get (var); + +if (!val ||strcasecmp (val,"host" )) +continue ; + + ret |=1 << i; + } +return ret; +} + +/* Support old kernels */ +void setup_board_tags (struct tag **in_params) +{ +struct tag_mv_uboot *t; +struct tag *params; +int i; + +debug ("Synology board tags...\n" ); + + params = *in_params; + t = (struct tag_mv_uboot *)¶ms->u; + + t->uboot_version =VER_NUM |syno_board_id (); + t->tclk =CONFIG_SYS_TCLK ; + t->sysclk =CONFIG_SYS_TCLK *2 ; + t->isusbhost =usb_port_modes (); + +for (i =0 ; i <ETHADDR_MAX ; i++) { +char addrvar[16 ], mtuvar[16 ]; + +sprintf (addrvar, i ?"eth%daddr" :"ethaddr" , i); +sprintf (mtuvar, i ?"eth%dmtu" :"ethmtu" , i); + +eth_env_get_enetaddr (addrvar, t->macaddr[i]); + t->mtu[i] =env_get_ulong (mtuvar,10 ,0 ); + } + + params->hdr.tag =ATAG_MV_UBOOT ; + params->hdr.size =tag_size (tag_mv_uboot); + params =tag_next (params); + *in_params = params; +}board/Synology/common/legacy.h new file +33
-0@@ -0,0 +1,33 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2021 +* Walter Schweizer <[email protected]> +* Phil Sutter <[email protected]> +*/ + +#ifndef __SYNO_LEGACY_H +#define __SYNO_LEGACY_H + +/* Marvell uboot parameters */ +#define ATAG_MV_UBOOT 0x41000403 +#define VER_NUM 0x03040400/* 3.4.4 */ + +#define BOARD_ID_BASE 0x0 +#define SYNO_DS109_ID (BOARD_ID_BASE+0x15) +#define SYNO_AXP_4BAY_2BAY (0xf + 1) + +#define ETHADDR_MAX 4 +#define USBPORT_MAX 3 + +struct tag_mv_uboot { +u32 uboot_version; +u32 tclk; +u32 sysclk; +u32 isusbhost; +u8 macaddr[ETHADDR_MAX ][ETH_ALEN ]; +u16 mtu[ETHADDR_MAX ]; +u32 fw_image_base; +u32 fw_image_size; +}; + +#endif /* __SYNO_LEGACY_H */ board/Synology/ds109/ds109.c +0
-32@@ -114,38 +114,6 @@ void reset_misc(void) SOFTWARE_REBOOT); } -/* Support old kernels */ -void setup_board_tags (struct tag **in_params) -{ -unsigned int boardId; -struct tag *params; -struct tag_mv_uboot *t; -int i; - -printf ("Synology board tags..." ); - params = *in_params; - t = (struct tag_mv_uboot *)¶ms->u; - - t->uboot_version =VER_NUM ; - - boardId =SYNO_DS109_ID ; - t->uboot_version |= boardId; - - t->tclk =CONFIG_SYS_TCLK ; - t->sysclk =CONFIG_SYS_TCLK *2 ; - - t->isusbhost =1 ; -for (i =0 ; i <4 ; i++) { -memset (t->macaddr[i],0 ,sizeof (t->macaddr[i])); - t->mtu[i] =0 ; - } - - params->hdr.tag =ATAG_MV_UBOOT ; - params->hdr.size =tag_size (tag_mv_uboot); - params =tag_next (params); - *in_params = params; -} -#ifdef CONFIG_RESET_PHY_R /* Configure and enable MV88E1116 PHY */ void reset_phy (void )board/Synology/ds109/ds109.h +0
-17@@ -23,21 +23,4 @@#define MV88E1116_RGMII_TXTM_CTRL (1 << 4)#define MV88E1116_RGMII_RXTM_CTRL (1 << 5) -/* Marvell uboot parameters */ -#define ATAG_MV_UBOOT 0x41000403 -#define VER_NUM 0x03040400/* 3.4.4 */ -#define BOARD_ID_BASE 0x0 -#define SYNO_DS109_ID (BOARD_ID_BASE+0x15) - -struct tag_mv_uboot { -u32 uboot_version; -u32 tclk; -u32 sysclk; -u32 isusbhost; -char macaddr[4 ][6 ]; -u16 mtu[4 ]; -u32 fw_image_base; -u32 fw_image_size; -}; -#endif /* __DS109_H */ configs/ds414_defconfig +1
-1@@ -20,7 +20,7 @@ CONFIG_DEFAULT_DEVICE_TREE="armada-xp-synology-ds414" CONFIG_DEBUG_UART=y CONFIG_BOOTDELAY=3 CONFIG_USE_BOOTARGS=y -CONFIG_BOOTARGS="console=ttyS0,115200" +CONFIG_BOOTARGS="console=ttyS0,115200 ip=off initrd=0x8000040,8M root=/dev/md0 rw syno_hw_version=DS414r1 ihd_num=4 netif_num=2 flash_size=8 SataLedSpecial=1 HddHotplug=1" CONFIG_USE_PREBOOT=y CONFIG_PREBOOT="usb start; sf probe" # CONFIG_DISPLAY_BOARDINFO is not setinclude/configs/ds109.h +2
-1@@ -44,7 +44,8 @@"x_bootcmd_kernel=fatload usb 0 0x6400000 uImage\0" \"x_bootargs=console=ttyS0,115200\0" \"x_bootargs_root=root=/dev/sda2 rootdelay=10\0" \ -"ipaddr=192.168.1.5\0" +"ipaddr=192.168.1.5\0" \ +"usb0Mode=host\0" /* * Ethernet Driver configuration include/configs/ds414.h +7
-1@@ -6,6 +6,9 @@#ifndef _CONFIG_SYNOLOGY_DS414_H#define _CONFIG_SYNOLOGY_DS414_H +/* Vendor kernel expects this MACH_TYPE */ +#define CONFIG_MACH_TYPE 3036 +/* * High Level Configuration Options (easy to change) */ @@ -74,8 +77,18 @@#define CONFIG_DDR_32BIT /* Default Environment */ -#define CONFIG_BOOTCOMMAND "sf read ${loadaddr} 0xd0000 0x700000; bootm"#define CONFIG_LOADADDR 0x80000 +#define CONFIG_BOOTCOMMAND \ + "sf probe; " \ + "sf read ${loadaddr} 0xd0000 0x2d0000; " \ + "sf read ${ramdisk_addr_r} 0x3a0000 0x430000; " \
include/configs/ds414.h line 94
Quoted 10 lines
include/configs/ds414.h +7
-0+ "bootm ${loadaddr} ${ramdisk_addr_r}" + +#define CONFIG_EXTRA_ENV_SETTINGS \ + "initrd_high=0xffffffff\0" \ + "ramdisk_addr_r=0x8000000\0" \ + "usb0Mode=host\0usb1Mode=host\0usb2Mode=device\0" \ + "ethmtu=1500\0eth1mtu=1500\0"/* increase autoneg timeout, my NIC sucks */ #define PHY_ANEG_TIMEOUT 16000
Viele Gr??e,
Stefan
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr at denx.de
PATCH 3/5 board/Synology: Unify legacy kernel support
Quoted 48 lines · Stefan Roese
Quoted 47 lines · Phil Sutter
Move the relevant bits from ds109.{c,h} into common/ and adjust the code to fit both DS109 and DS414. Moreover:
* Introduce
syno_board_id()which translatesCONFIG_MACH_TYPEinto the expected board ID tag value.* Properly initialize isusbhost, mac and mtu fields from env variables.
* Set the right bootargs/bootcmd to correctly boot legacy kernel out of the (DS414) box. Getting the ramdisk location right is a bit tedious.
Cc Walter Schweizer <[email protected]>Signed-off-by Phil Sutter <[email protected]>--- board/Synology/common/Makefile | 5 +++ board/Synology/common/legacy.c | 75 ++++++++++++++++++++++++++++++++++ board/Synology/common/legacy.h | 33 +++++++++++++++ board/Synology/ds109/ds109.c | 32 --------------- board/Synology/ds109/ds109.h | 17 -------- configs/ds414_defconfig | 2 +- include/configs/ds109.h | 3 +- include/configs/ds414.h | 15 ++++++- 8 files changed, 130 insertions(+), 52 deletions(-)create mode 100644 board/Synology/common/Makefile create mode 100644
board/Synology/common/legacy.ccreate mode 100644board/Synology/common/legacy.hboard/Synology/common/Makefile new file +5
-0@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2021 Phil Sutter <[email protected]> + +obj-y += legacy.oboard/Synology/common/legacy.c new file +3
-0@@ -0,0 +1,75 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2021
Quoted 8 lines
board/Synology/common/legacy.c line 8
Quoted 5 lines
board/Synology/common/legacy.c new file +5
-0+* Walter Schweizer <[email protected]> +* Phil Sutter <[email protected]> +*/ + +#include <common.h> Please don't include "
common.h" any more. There is ongoing work to depricate this common header.
OK, I'll respin. Thanks for the heads-up!
Phil
PATCH v2 3/5 board/Synology: Unify legacy kernel support
In reply to Phil SutterMove the relevant bits from ds109.{c,h} into common/ and adjust the code to fit both DS109 and DS414. Moreover:
* Introduce syno_board_id() which translates CONFIG_MACH_TYPE into the expected board ID tag value.
* Properly initialize isusbhost, mac and mtu fields from env variables.
* Set the right bootargs/bootcmd to correctly boot legacy kernel out of the (DS414) box. Getting the ramdisk location right is a bit tedious.
--
Changes since v1:
- Avoid deprecated common.h header include.
- Remove 'sf probe' call from DS414 PREBOOT, bootcmd contains it now.
- Use proper comment-style for SPDX tag in introduced legacy.h.
--- board/Synology/common/Makefile | 5 +++ board/Synology/common/legacy.c | 76 ++++++++++++++++++++++++++++++++++ board/Synology/common/legacy.h | 33 +++++++++++++++ board/Synology/ds109/ds109.c | 32 -------------- board/Synology/ds109/ds109.h | 17 -------- configs/ds414_defconfig | 4 +- include/configs/ds109.h | 3 +- include/configs/ds414.h | 15 ++++++- 8 files changed, 132 insertions(+), 53 deletions(-) create mode 100644 board/Synology/common/Makefile create mode 100644 board/Synology/common/legacy.c create mode 100644 board/Synology/common/legacy.h
board/Synology/common/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2021 Phil Sutter <[email protected]> + +obj-y += legacy.o
board/Synology/common/legacy.c new file +76 -0
76 lines not on this page · raw message
board/Synology/common/legacy.h new file +33 -0
@@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2021 +* Walter Schweizer <[email protected]> +* Phil Sutter <[email protected]> +*/ + +#ifndef __SYNO_LEGACY_H +#define __SYNO_LEGACY_H + +/* Marvell uboot parameters */ +#define ATAG_MV_UBOOT 0x41000403 +#define VER_NUM 0x03040400/* 3.4.4 */ + +#define BOARD_ID_BASE 0x0 +#define SYNO_DS109_ID (BOARD_ID_BASE + 0x15) +#define SYNO_AXP_4BAY_2BAY (0xf + 1) + +#define ETHADDR_MAX 4 +#define USBPORT_MAX 3 + +struct tag_mv_uboot { +u32 uboot_version; +u32 tclk; +u32 sysclk; +u32 isusbhost; +u8 macaddr[ETHADDR_MAX ][ETH_ALEN ]; +u16 mtu[ETHADDR_MAX ]; +u32 fw_image_base; +u32 fw_image_size; +}; + +#endif /* __SYNO_LEGACY_H */
board/Synology/ds109/ds109.c +0 -32
@@ -114,38 +114,6 @@ void reset_misc(void) SOFTWARE_REBOOT); } -/* Support old kernels */ -void setup_board_tags (struct tag **in_params) -{ -unsigned int boardId; -struct tag *params; -struct tag_mv_uboot *t; -int i; - -printf ("Synology board tags..." ); - params = *in_params; - t = (struct tag_mv_uboot *)¶ms->u; - - t->uboot_version =VER_NUM ; - - boardId =SYNO_DS109_ID ; - t->uboot_version |= boardId; - - t->tclk =CONFIG_SYS_TCLK ; - t->sysclk =CONFIG_SYS_TCLK *2 ; - - t->isusbhost =1 ; -for (i =0 ; i <4 ; i++) { -memset (t->macaddr[i],0 ,sizeof (t->macaddr[i])); - t->mtu[i] =0 ; - } - - params->hdr.tag =ATAG_MV_UBOOT ; - params->hdr.size =tag_size (tag_mv_uboot); - params =tag_next (params); - *in_params = params; -} -#ifdef CONFIG_RESET_PHY_R /* Configure and enable MV88E1116 PHY */ void reset_phy (void )
board/Synology/ds109/ds109.h +0 -17
@@ -23,21 +23,4 @@#define MV88E1116_RGMII_TXTM_CTRL (1 << 4)#define MV88E1116_RGMII_RXTM_CTRL (1 << 5) -/* Marvell uboot parameters */ -#define ATAG_MV_UBOOT 0x41000403 -#define VER_NUM 0x03040400/* 3.4.4 */ -#define BOARD_ID_BASE 0x0 -#define SYNO_DS109_ID (BOARD_ID_BASE+0x15) - -struct tag_mv_uboot { -u32 uboot_version; -u32 tclk; -u32 sysclk; -u32 isusbhost; -char macaddr[4 ][6 ]; -u16 mtu[4 ]; -u32 fw_image_base; -u32 fw_image_size; -}; -#endif /* __DS109_H */
configs/ds414_defconfig +2 -2
@@ -20,9 +20,9 @@ CONFIG_DEFAULT_DEVICE_TREE="armada-xp-synology-ds414" CONFIG_DEBUG_UART=y CONFIG_BOOTDELAY=3 CONFIG_USE_BOOTARGS=y -CONFIG_BOOTARGS="console=ttyS0,115200" +CONFIG_BOOTARGS="console=ttyS0,115200 ip=off initrd=0x8000040,8M root=/dev/md0 rw syno_hw_version=DS414r1 ihd_num=4 netif_num=2 flash_size=8 SataLedSpecial=1 HddHotplug=1" CONFIG_USE_PREBOOT=y -CONFIG_PREBOOT="pci enum; usb start; sf probe" +CONFIG_PREBOOT="pci enum; usb start" # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_SPL_I2C_SUPPORT=y
include/configs/ds109.h +2 -1
@@ -44,7 +44,8 @@"x_bootcmd_kernel=fatload usb 0 0x6400000 uImage\0" \"x_bootargs=console=ttyS0,115200\0" \"x_bootargs_root=root=/dev/sda2 rootdelay=10\0" \ -"ipaddr=192.168.1.5\0" +"ipaddr=192.168.1.5\0" \ +"usb0Mode=host\0" /* * Ethernet Driver configuration
include/configs/ds414.h +14 -1
@@ -6,6 +6,9 @@#ifndef _CONFIG_SYNOLOGY_DS414_H#define _CONFIG_SYNOLOGY_DS414_H +/* Vendor kernel expects this MACH_TYPE */ +#define CONFIG_MACH_TYPE 3036 +/* * High Level Configuration Options (easy to change) */
@@ -74,8 +77,18 @@#define CONFIG_DDR_32BIT /* Default Environment */ -#define CONFIG_BOOTCOMMAND "sf read ${loadaddr} 0xd0000 0x700000; bootm"#define CONFIG_LOADADDR 0x80000 +#define CONFIG_BOOTCOMMAND \ + "sf probe; " \ + "sf read ${loadaddr} 0xd0000 0x2d0000; " \ + "sf read ${ramdisk_addr_r} 0x3a0000 0x430000; " \ + "bootm ${loadaddr} ${ramdisk_addr_r}" + +#define CONFIG_EXTRA_ENV_SETTINGS \ + "initrd_high=0xffffffff\0" \ + "ramdisk_addr_r=0x8000000\0" \ + "usb0Mode=host\0usb1Mode=host\0usb2Mode=device\0" \ + "ethmtu=1500\0eth1mtu=1500\0"/* increase autoneg timeout, my NIC sucks */ #define PHY_ANEG_TIMEOUT 16000
Signature · 1 line
2.30.1
PATCH v3 3/5 board/Synology: Unify legacy kernel support
Move the relevant bits from ds109.{c,h} into common/ and adjust the code to fit both DS109 and DS414. Moreover:
* Introduce syno_board_id() which translates CONFIG_MACH_TYPE into the expected board ID tag value.
* Properly initialize isusbhost, mac and mtu fields from env variables.
* Set the right bootargs/bootcmd to correctly boot legacy kernel out of the (DS414) box. Getting the ramdisk location right is a bit tedious.
--
Changes since v2:
- Drop PREBOOT entirely, 'usb init' is not needed.
Changes since v1:
- Avoid deprecated common.h header include.
- Remove 'sf probe' call from DS414 PREBOOT, bootcmd contains it now.
--- board/Synology/common/Makefile | 5 +++ board/Synology/common/legacy.c | 76 ++++++++++++++++++++++++++++++++++ board/Synology/common/legacy.h | 33 +++++++++++++++ board/Synology/ds109/ds109.c | 32 -------------- board/Synology/ds109/ds109.h | 17 -------- configs/ds414_defconfig | 5 +-- include/configs/ds109.h | 3 +- include/configs/ds414.h | 15 ++++++- 8 files changed, 132 insertions(+), 54 deletions(-) create mode 100644 board/Synology/common/Makefile create mode 100644 board/Synology/common/legacy.c create mode 100644 board/Synology/common/legacy.h
board/Synology/common/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2021 Phil Sutter <[email protected]> + +obj-y += legacy.o
board/Synology/common/legacy.c new file +76 -0
76 lines not on this page · raw message
board/Synology/common/legacy.h new file +33 -0
@@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2021 +* Walter Schweizer <[email protected]> +* Phil Sutter <[email protected]> +*/ + +#ifndef __SYNO_LEGACY_H +#define __SYNO_LEGACY_H + +/* Marvell uboot parameters */ +#define ATAG_MV_UBOOT 0x41000403 +#define VER_NUM 0x03040400/* 3.4.4 */ + +#define BOARD_ID_BASE 0x0 +#define SYNO_DS109_ID (BOARD_ID_BASE + 0x15) +#define SYNO_AXP_4BAY_2BAY (0xf + 1) + +#define ETHADDR_MAX 4 +#define USBPORT_MAX 3 + +struct tag_mv_uboot { +u32 uboot_version; +u32 tclk; +u32 sysclk; +u32 isusbhost; +u8 macaddr[ETHADDR_MAX ][ETH_ALEN ]; +u16 mtu[ETHADDR_MAX ]; +u32 fw_image_base; +u32 fw_image_size; +}; + +#endif /* __SYNO_LEGACY_H */
board/Synology/ds109/ds109.c +0 -32
@@ -114,38 +114,6 @@ void reset_misc(void) SOFTWARE_REBOOT); } -/* Support old kernels */ -void setup_board_tags (struct tag **in_params) -{ -unsigned int boardId; -struct tag *params; -struct tag_mv_uboot *t; -int i; - -printf ("Synology board tags..." ); - params = *in_params; - t = (struct tag_mv_uboot *)¶ms->u; - - t->uboot_version =VER_NUM ; - - boardId =SYNO_DS109_ID ; - t->uboot_version |= boardId; - - t->tclk =CONFIG_SYS_TCLK ; - t->sysclk =CONFIG_SYS_TCLK *2 ; - - t->isusbhost =1 ; -for (i =0 ; i <4 ; i++) { -memset (t->macaddr[i],0 ,sizeof (t->macaddr[i])); - t->mtu[i] =0 ; - } - - params->hdr.tag =ATAG_MV_UBOOT ; - params->hdr.size =tag_size (tag_mv_uboot); - params =tag_next (params); - *in_params = params; -} -#ifdef CONFIG_RESET_PHY_R /* Configure and enable MV88E1116 PHY */ void reset_phy (void )
board/Synology/ds109/ds109.h +0 -17
@@ -23,21 +23,4 @@#define MV88E1116_RGMII_TXTM_CTRL (1 << 4)#define MV88E1116_RGMII_RXTM_CTRL (1 << 5) -/* Marvell uboot parameters */ -#define ATAG_MV_UBOOT 0x41000403 -#define VER_NUM 0x03040400/* 3.4.4 */ -#define BOARD_ID_BASE 0x0 -#define SYNO_DS109_ID (BOARD_ID_BASE+0x15) - -struct tag_mv_uboot { -u32 uboot_version; -u32 tclk; -u32 sysclk; -u32 isusbhost; -char macaddr[4 ][6 ]; -u16 mtu[4 ]; -u32 fw_image_base; -u32 fw_image_size; -}; -#endif /* __DS109_H */
configs/ds414_defconfig +2 -3
@@ -20,9 +20,8 @@ CONFIG_DEFAULT_DEVICE_TREE="armada-xp-synology-ds414" CONFIG_DEBUG_UART=y CONFIG_BOOTDELAY=3 CONFIG_USE_BOOTARGS=y -CONFIG_BOOTARGS="console=ttyS0,115200" -CONFIG_USE_PREBOOT=y -CONFIG_PREBOOT="usb start; sf probe" +CONFIG_BOOTARGS="console=ttyS0,115200 ip=off initrd=0x8000040,8M root=/dev/md0 rw syno_hw_version=DS414r1 ihd_num=4 netif_num=2 flash_size=8 SataLedSpecial=1 HddHotplug=1" +# CONFIG_USE_PREBOOT is not set # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_SPL_I2C_SUPPORT=y
include/configs/ds109.h +2 -1
@@ -44,7 +44,8 @@"x_bootcmd_kernel=fatload usb 0 0x6400000 uImage\0" \"x_bootargs=console=ttyS0,115200\0" \"x_bootargs_root=root=/dev/sda2 rootdelay=10\0" \ -"ipaddr=192.168.1.5\0" +"ipaddr=192.168.1.5\0" \ +"usb0Mode=host\0" /* * Ethernet Driver configuration
include/configs/ds414.h +14 -1
@@ -6,6 +6,9 @@#ifndef _CONFIG_SYNOLOGY_DS414_H#define _CONFIG_SYNOLOGY_DS414_H +/* Vendor kernel expects this MACH_TYPE */ +#define CONFIG_MACH_TYPE 3036 +/* * High Level Configuration Options (easy to change) */
@@ -74,8 +77,18 @@#define CONFIG_DDR_32BIT /* Default Environment */ -#define CONFIG_BOOTCOMMAND "sf read ${loadaddr} 0xd0000 0x700000; bootm"#define CONFIG_LOADADDR 0x80000 +#define CONFIG_BOOTCOMMAND \ + "sf probe; " \ + "sf read ${loadaddr} 0xd0000 0x2d0000; " \ + "sf read ${ramdisk_addr_r} 0x3a0000 0x430000; " \ + "bootm ${loadaddr} ${ramdisk_addr_r}" + +#define CONFIG_EXTRA_ENV_SETTINGS \ + "initrd_high=0xffffffff\0" \ + "ramdisk_addr_r=0x8000000\0" \ + "usb0Mode=host\0usb1Mode=host\0usb2Mode=device\0" \ + "ethmtu=1500\0eth1mtu=1500\0"/* increase autoneg timeout, my NIC sucks */ #define PHY_ANEG_TIMEOUT 16000
Signature · 1 line
2.30.1
PATCH v3 3/5 board/Synology: Unify legacy kernel support
Quoted 6 lines · Phil Sutter
Move the relevant bits from ds109.{c,h} into common/ and adjust the code to fit both DS109 and DS414. Moreover:
* Introduce
syno_board_id()which translatesCONFIG_MACH_TYPEinto the expected board ID tag value.
Quoted 7 lines
* Properly initialize isusbhost, mac and mtu fields from env variables.
* Set the right bootargs/bootcmd to correctly boot legacy kernel out of the (DS414) box. Getting the ramdisk location right is a bit tedious.
Cc Walter Schweizer <[email protected]>Signed-off-by Phil Sutter <[email protected]>
Thanks,
Stefan
Quoted 277 lines
--
Changes since v2:
- Drop PREBOOT entirely, 'usb init' is not needed.Changes since v1:
- Avoid deprecatedcommon.hheader include.
- Remove 'sf probe' call from DS414 PREBOOT, bootcmd contains it now.--- board/Synology/common/Makefile | 5 +++ board/Synology/common/legacy.c | 76 ++++++++++++++++++++++++++++++++++ board/Synology/common/legacy.h | 33 +++++++++++++++ board/Synology/ds109/ds109.c | 32 -------------- board/Synology/ds109/ds109.h | 17 -------- configs/ds414_defconfig | 5 +-- include/configs/ds109.h | 3 +- include/configs/ds414.h | 15 ++++++- 8 files changed, 132 insertions(+), 54 deletions(-)create mode 100644 board/Synology/common/Makefile create mode 100644
board/Synology/common/legacy.ccreate mode 100644board/Synology/common/legacy.hboard/Synology/common/Makefile new file +5
-0@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2021 Phil Sutter <[email protected]> + +obj-y += legacy.oboard/Synology/common/legacy.c new file +76
-0@@ -0,0 +1,76 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2021 +* Walter Schweizer <[email protected]> +* Phil Sutter <[email protected]> +*/ + +#include <config.h> +#include <vsprintf.h> +#include <env.h> +#include <net.h> +#include <asm/setup.h> + +#include "legacy.h" + +static unsigned int syno_board_id (void ) +{ +switch (CONFIG_MACH_TYPE ) { +case 527 : +return SYNO_DS109_ID ; +case 3036 : +return SYNO_AXP_4BAY_2BAY ; +default : +return 0 ; + } +} + +static unsigned int usb_port_modes (void ) +{ +unsigned int i, ret =0 ; +char var[32 ], *val; + +for (i =0 ; i <USBPORT_MAX ; i++) { +snprintf (var,32 ,"usb%dMode" , i); + val =env_get (var); + +if (!val ||strcasecmp (val,"host" )) +continue ; + + ret |=1 << i; + } +return ret; +} + +/* Support old kernels */ +void setup_board_tags (struct tag **in_params) +{ +struct tag_mv_uboot *t; +struct tag *params; +int i; + +debug ("Synology board tags...\n" ); + + params = *in_params; + t = (struct tag_mv_uboot *)¶ms->u; + + t->uboot_version =VER_NUM |syno_board_id (); + t->tclk =CONFIG_SYS_TCLK ; + t->sysclk =CONFIG_SYS_TCLK *2 ; + t->isusbhost =usb_port_modes (); + +for (i =0 ; i <ETHADDR_MAX ; i++) { +char addrvar[16 ], mtuvar[16 ]; + +sprintf (addrvar, i ?"eth%daddr" :"ethaddr" , i); +sprintf (mtuvar, i ?"eth%dmtu" :"ethmtu" , i); + +eth_env_get_enetaddr (addrvar, t->macaddr[i]); + t->mtu[i] =env_get_ulong (mtuvar,10 ,0 ); + } + + params->hdr.tag =ATAG_MV_UBOOT ; + params->hdr.size =tag_size (tag_mv_uboot); + params =tag_next (params); + *in_params = params; +}board/Synology/common/legacy.h new file +33
-0@@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2021 +* Walter Schweizer <[email protected]> +* Phil Sutter <[email protected]> +*/ + +#ifndef __SYNO_LEGACY_H +#define __SYNO_LEGACY_H + +/* Marvell uboot parameters */ +#define ATAG_MV_UBOOT 0x41000403 +#define VER_NUM 0x03040400/* 3.4.4 */ + +#define BOARD_ID_BASE 0x0 +#define SYNO_DS109_ID (BOARD_ID_BASE + 0x15) +#define SYNO_AXP_4BAY_2BAY (0xf + 1) + +#define ETHADDR_MAX 4 +#define USBPORT_MAX 3 + +struct tag_mv_uboot { +u32 uboot_version; +u32 tclk; +u32 sysclk; +u32 isusbhost; +u8 macaddr[ETHADDR_MAX ][ETH_ALEN ]; +u16 mtu[ETHADDR_MAX ]; +u32 fw_image_base; +u32 fw_image_size; +}; + +#endif /* __SYNO_LEGACY_H */ board/Synology/ds109/ds109.c +0
-32@@ -114,38 +114,6 @@ void reset_misc(void) SOFTWARE_REBOOT); } -/* Support old kernels */ -void setup_board_tags (struct tag **in_params) -{ -unsigned int boardId; -struct tag *params; -struct tag_mv_uboot *t; -int i; - -printf ("Synology board tags..." ); - params = *in_params; - t = (struct tag_mv_uboot *)¶ms->u; - - t->uboot_version =VER_NUM ; - - boardId =SYNO_DS109_ID ; - t->uboot_version |= boardId; - - t->tclk =CONFIG_SYS_TCLK ; - t->sysclk =CONFIG_SYS_TCLK *2 ; - - t->isusbhost =1 ; -for (i =0 ; i <4 ; i++) { -memset (t->macaddr[i],0 ,sizeof (t->macaddr[i])); - t->mtu[i] =0 ; - } - - params->hdr.tag =ATAG_MV_UBOOT ; - params->hdr.size =tag_size (tag_mv_uboot); - params =tag_next (params); - *in_params = params; -} -#ifdef CONFIG_RESET_PHY_R /* Configure and enable MV88E1116 PHY */ void reset_phy (void )board/Synology/ds109/ds109.h +0
-17@@ -23,21 +23,4 @@#define MV88E1116_RGMII_TXTM_CTRL (1 << 4)#define MV88E1116_RGMII_RXTM_CTRL (1 << 5) -/* Marvell uboot parameters */ -#define ATAG_MV_UBOOT 0x41000403 -#define VER_NUM 0x03040400/* 3.4.4 */ -#define BOARD_ID_BASE 0x0 -#define SYNO_DS109_ID (BOARD_ID_BASE+0x15) - -struct tag_mv_uboot { -u32 uboot_version; -u32 tclk; -u32 sysclk; -u32 isusbhost; -char macaddr[4 ][6 ]; -u16 mtu[4 ]; -u32 fw_image_base; -u32 fw_image_size; -}; -#endif /* __DS109_H */ configs/ds414_defconfig +2
-3@@ -20,9 +20,8 @@ CONFIG_DEFAULT_DEVICE_TREE="armada-xp-synology-ds414" CONFIG_DEBUG_UART=y CONFIG_BOOTDELAY=3 CONFIG_USE_BOOTARGS=y -CONFIG_BOOTARGS="console=ttyS0,115200" -CONFIG_USE_PREBOOT=y -CONFIG_PREBOOT="usb start; sf probe" +CONFIG_BOOTARGS="console=ttyS0,115200 ip=off initrd=0x8000040,8M root=/dev/md0 rw syno_hw_version=DS414r1 ihd_num=4 netif_num=2 flash_size=8 SataLedSpecial=1 HddHotplug=1" +# CONFIG_USE_PREBOOT is not set # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_SPL_I2C_SUPPORT=yinclude/configs/ds109.h +2
-1@@ -44,7 +44,8 @@"x_bootcmd_kernel=fatload usb 0 0x6400000 uImage\0" \"x_bootargs=console=ttyS0,115200\0" \"x_bootargs_root=root=/dev/sda2 rootdelay=10\0" \ -"ipaddr=192.168.1.5\0" +"ipaddr=192.168.1.5\0" \ +"usb0Mode=host\0" /* * Ethernet Driver configuration include/configs/ds414.h +7
-1@@ -6,6 +6,9 @@#ifndef _CONFIG_SYNOLOGY_DS414_H#define _CONFIG_SYNOLOGY_DS414_H +/* Vendor kernel expects this MACH_TYPE */ +#define CONFIG_MACH_TYPE 3036 +/* * High Level Configuration Options (easy to change) */ @@ -74,8 +77,18 @@#define CONFIG_DDR_32BIT /* Default Environment */ -#define CONFIG_BOOTCOMMAND "sf read ${loadaddr} 0xd0000 0x700000; bootm"#define CONFIG_LOADADDR 0x80000 +#define CONFIG_BOOTCOMMAND \ + "sf probe; " \ + "sf read ${loadaddr} 0xd0000 0x2d0000; " \ + "sf read ${ramdisk_addr_r} 0x3a0000 0x430000; " \
include/configs/ds414.h line 94
Quoted 10 lines
include/configs/ds414.h +7
-0+ "bootm ${loadaddr} ${ramdisk_addr_r}" + +#define CONFIG_EXTRA_ENV_SETTINGS \ + "initrd_high=0xffffffff\0" \ + "ramdisk_addr_r=0x8000000\0" \ + "usb0Mode=host\0usb1Mode=host\0usb2Mode=device\0" \ + "ethmtu=1500\0eth1mtu=1500\0"/* increase autoneg timeout, my NIC sucks */ #define PHY_ANEG_TIMEOUT 16000
Viele Gr??e,
Stefan
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr at denx.de
PATCH 4/5 ds414: Auto-populate env if appropriate
In reply to Phil SutterDefine a misc_init_r() which calls "syno populate_env" if the environment seems incomplete (or default), indicated by missing "ethaddr" variable. With this in place, no random MAC address fallback is needed anymore.
--- board/Synology/ds414/cmd_syno.c | 2 +- board/Synology/ds414/ds414.c | 13 +++++++++++++ configs/ds414_defconfig | 4 +--- 3 files changed, 15 insertions(+), 4 deletions(-)
board/Synology/ds414/cmd_syno.c +1 -1
@@ -22,7 +22,7 @@#define SYNO_CHKSUM_TAG "CHK=" -static int do_syno_populate (int argc,char *const argv[]) +int do_syno_populate (int argc,char *const argv[]) {unsigned int bus =CONFIG_SF_DEFAULT_BUS ;unsigned int cs =CONFIG_SF_DEFAULT_CS ;
board/Synology/ds414/ds414.c +13 -0
@@ -179,6 +179,19 @@ int board_init(void)return 0 ; } +#ifndef CONFIG_SPL_BUILD +int do_syno_populate (int argc,char *const argv[]); + +int misc_init_r (void ) +{ +if (!env_get ("ethaddr" )) { +puts ("Incomplete environment, populating from SPI flash\n" ); +do_syno_populate (0 ,NULL ); + } +return 0 ; +} +#endif +int checkboard (void ) {puts ("Board: DS414\n" );
configs/ds414_defconfig +1 -3
@@ -21,10 +21,9 @@ CONFIG_DEBUG_UART=y CONFIG_BOOTDELAY=3 CONFIG_USE_BOOTARGS=y CONFIG_BOOTARGS="console=ttyS0,115200 ip=off initrd=0x8000040,8M root=/dev/md0 rw syno_hw_version=DS414r1 ihd_num=4 netif_num=2 flash_size=8 SataLedSpecial=1 HddHotplug=1" -CONFIG_USE_PREBOOT=y -CONFIG_PREBOOT="usb start; sf probe" # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_DISPLAY_BOARDINFO_LATE=y +CONFIG_MISC_INIT_R=y CONFIG_SPL_I2C_SUPPORT=y # CONFIG_CMD_FLASH is not set CONFIG_CMD_I2C=y
@@ -47,7 +46,6 @@ CONFIG_ENV_OVERWRITE=y CONFIG_USE_ENV_SPI_MAX_HZ=y CONFIG_ENV_SPI_MAX_HZ=50000000 CONFIG_SYS_RELOC_GD_ENV_ADDR=y -CONFIG_NET_RANDOM_ETHADDR=y CONFIG_SPL_OF_TRANSLATE=y CONFIG_BLK=y # CONFIG_MMC is not set
Signature · 1 line
2.30.1
PATCH 4/5 ds414: Auto-populate env if appropriate
Quoted 30 lines · Phil Sutter
Define a
misc_init_r()which calls "synopopulate_env" if the environment seems incomplete (or default), indicated by missing "ethaddr" variable. With this in place, no random MAC address fallback is needed anymore.Signed-off-by Phil Sutter <[email protected]>--- board/Synology/ds414/cmd_syno.c | 2 +- board/Synology/ds414/ds414.c | 13 +++++++++++++ configs/ds414_defconfig | 4 +--- 3 files changed, 15 insertions(+), 4 deletions(-)board/Synology/ds414/cmd_syno.c +1
-1@@ -22,7 +22,7 @@#define SYNO_CHKSUM_TAG "CHK=" -static int do_syno_populate (int argc,char *const argv[]) +int do_syno_populate (int argc,char *const argv[]) {unsigned int bus =CONFIG_SF_DEFAULT_BUS ;unsigned int cs =CONFIG_SF_DEFAULT_CS ;board/Synology/ds414/ds414.c +0
-0
board/Synology/ds414/ds414.c int board_init(void) · line 183
Quoted 5 lines
board/Synology/ds414/ds414.c +2
-0@@ -179,6 +179,19 @@ int board_init(void)return 0 ; } +#ifndef CONFIG_SPL_BUILD +int do_syno_populate (int argc,char *const argv[]);
I suspect that this prototype in a C file will trigger at least a checkpatch warning?
Other than that:
Thanks,
Stefan
Quoted 32 lines
board/Synology/ds414/ds414.c +11
-0+ +int misc_init_r (void ) +{ +if (!env_get ("ethaddr" )) { +puts ("Incomplete environment, populating from SPI flash\n" ); +do_syno_populate (0 ,NULL ); + } +return 0 ; +} +#endif +int checkboard (void ) {puts ("Board: DS414\n" );configs/ds414_defconfig +1
-2@@ -21,10 +21,9 @@ CONFIG_DEBUG_UART=y CONFIG_BOOTDELAY=3 CONFIG_USE_BOOTARGS=y CONFIG_BOOTARGS="console=ttyS0,115200 ip=off initrd=0x8000040,8M root=/dev/md0 rw syno_hw_version=DS414r1 ihd_num=4 netif_num=2 flash_size=8 SataLedSpecial=1 HddHotplug=1" -CONFIG_USE_PREBOOT=y -CONFIG_PREBOOT="usb start; sf probe" # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_DISPLAY_BOARDINFO_LATE=y +CONFIG_MISC_INIT_R=y CONFIG_SPL_I2C_SUPPORT=y # CONFIG_CMD_FLASH is not set CONFIG_CMD_I2C=y
configs/ds414_defconfig CONFIG_ENV_OVERWRITE=y · line 51
Quoted 7 lines
configs/ds414_defconfig +0
-1@@ -47,7 +46,6 @@ CONFIG_ENV_OVERWRITE=y CONFIG_USE_ENV_SPI_MAX_HZ=y CONFIG_ENV_SPI_MAX_HZ=50000000 CONFIG_SYS_RELOC_GD_ENV_ADDR=y -CONFIG_NET_RANDOM_ETHADDR=y CONFIG_SPL_OF_TRANSLATE=y CONFIG_BLK=y # CONFIG_MMC is not set
Viele Gr??e,
Stefan
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr at denx.de
PATCH 4/5 ds414: Auto-populate env if appropriate
Quoted 34 lines · Stefan Roese
Quoted 33 lines · Phil Sutter
Define a
misc_init_r()which calls "synopopulate_env" if the environment seems incomplete (or default), indicated by missing "ethaddr" variable. With this in place, no random MAC address fallback is needed anymore.Signed-off-by Phil Sutter <[email protected]>--- board/Synology/ds414/cmd_syno.c | 2 +- board/Synology/ds414/ds414.c | 13 +++++++++++++ configs/ds414_defconfig | 4 +--- 3 files changed, 15 insertions(+), 4 deletions(-)board/Synology/ds414/cmd_syno.c +1
-1@@ -22,7 +22,7 @@#define SYNO_CHKSUM_TAG "CHK=" -static int do_syno_populate (int argc,char *const argv[]) +int do_syno_populate (int argc,char *const argv[]) {unsigned int bus =CONFIG_SF_DEFAULT_BUS ;unsigned int cs =CONFIG_SF_DEFAULT_CS ;board/Synology/ds414/ds414.c +0
-0@@ -179,6 +179,19 @@ int board_init(void)return 0 ; }
Quoted 5 lines
board/Synology/ds414/ds414.c int board_init(void) · line 183
Quoted 2 lines
board/Synology/ds414/ds414.c +2
-0+#ifndef CONFIG_SPL_BUILD +int do_syno_populate (int argc,char *const argv[]);I suspect that this prototype in a C file will trigger at least a checkpatch warning?
What is checkpatch? ;)
Mea culpa, sometimes past me's dirty hacks slip my review. I'll go find a checkpatch-compliant way.
Thanks, Phil
PATCH 4/5 ds414: Auto-populate env if appropriate
Quoted 35 lines · Phil Sutter
Quoted 34 lines · Stefan Roese
Quoted 33 lines · Phil Sutter
Define a
misc_init_r()which calls "synopopulate_env" if the environment seems incomplete (or default), indicated by missing "ethaddr" variable. With this in place, no random MAC address fallback is needed anymore.Signed-off-by Phil Sutter <[email protected]>--- board/Synology/ds414/cmd_syno.c | 2 +- board/Synology/ds414/ds414.c | 13 +++++++++++++ configs/ds414_defconfig | 4 +--- 3 files changed, 15 insertions(+), 4 deletions(-)board/Synology/ds414/cmd_syno.c +1
-1@@ -22,7 +22,7 @@#define SYNO_CHKSUM_TAG "CHK=" -static int do_syno_populate (int argc,char *const argv[]) +int do_syno_populate (int argc,char *const argv[]) {unsigned int bus =CONFIG_SF_DEFAULT_BUS ;unsigned int cs =CONFIG_SF_DEFAULT_CS ;board/Synology/ds414/ds414.c +0
-0@@ -179,6 +179,19 @@ int board_init(void)return 0 ; }
Quoted 7 lines
Quoted 5 lines
board/Synology/ds414/ds414.c int board_init(void) · line 183
Quoted 2 lines
board/Synology/ds414/ds414.c +2
-0+#ifndef CONFIG_SPL_BUILD +int do_syno_populate (int argc,char *const argv[]);I suspect that this prototype in a C file will trigger at least a checkpatch warning?
What is checkpatch? ;)
Provided with Linux and your favorite bootloader: ;)
./scripts/checkpatch.pl
Quoted 2 lines
Mea culpa, sometimes past me's dirty hacks slip my review. I'll go find a checkpatch-compliant way.
NP. Thanks for working on this.
Thanks,
Stefan
PATCH v2 4/5 ds414: Auto-populate env if appropriate
In reply to Phil SutterDefine a misc_init_r() which calls "syno populate_env" if the environment seems incomplete (or default), indicated by missing "ethaddr" variable. With this in place, no random MAC address fallback is needed anymore.
---
Changes since v1:
- Don't drop PREBOOT, it is needed for XHCI functionality
- Introduce cmd_syno.h holding function prototype and defines
- No need to define misc_init_r() conditionally, get rid of surrounding #ifdef.
--- board/Synology/ds414/cmd_syno.c | 9 +++------ board/Synology/ds414/cmd_syno.h | 17 +++++++++++++++++ board/Synology/ds414/ds414.c | 11 +++++++++++ configs/ds414_defconfig | 2 +- 4 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 board/Synology/ds414/cmd_syno.h
board/Synology/ds414/cmd_syno.c +3 -6
@@ -17,12 +17,9 @@#include <asm/io.h> #include "../drivers/ddr/marvell/axp/ddr3_init.h" -#define ETHADDR_MAX 4 -#define SYNO_SN_TAG "SN=" -#define SYNO_CHKSUM_TAG "CHK=" +#include "cmd_syno.h" - -static int do_syno_populate (int argc,char *const argv[]) +int do_syno_populate (int argc,char *const argv[]) {unsigned int bus =CONFIG_SF_DEFAULT_BUS ;unsigned int cs =CONFIG_SF_DEFAULT_CS ;
@@ -57,7 +54,7 @@ static int do_syno_populate(int argc, char *const argv[]) goto out_unmap; } -for (n =0 ; n <ETHADDR_MAX ; n++) { +for (n =0 ; n <SYNO_ETHADDR_MAX ; n++) {char ethaddr[ETH_ALEN ];int i, sum =0 ;unsigned char csum =0 ;
board/Synology/ds414/cmd_syno.h new file +17 -0
@@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Commands to deal with Synology specifics. +* +* Copyright (C) 2021 Phil Sutter <[email protected]> +*/ + +#ifndef _CMD_SYNO_H +#define _CMD_SYNO_H + +#define SYNO_ETHADDR_MAX 4 +#define SYNO_SN_TAG "SN=" +#define SYNO_CHKSUM_TAG "CHK=" + +int do_syno_populate (int argc,char *const argv[]); + +#endif /* _CMD_SYNO_H */
board/Synology/ds414/ds414.c +11 -0
@@ -18,6 +18,8 @@#include "../arch/arm/mach-mvebu/serdes/axp/high_speed_env_spec.h" #include "../arch/arm/mach-mvebu/serdes/axp/board_env_spec.h" +#include "cmd_syno.h" +DECLARE_GLOBAL_DATA_PTR ;/* GPP and MPP settings as found in mvBoardEnvSpec.c of Synology's U-Boot */
@@ -179,6 +181,15 @@ int board_init(void)return 0 ; } +int misc_init_r (void ) +{ +if (!env_get ("ethaddr" )) { +puts ("Incomplete environment, populating from SPI flash\n" ); +do_syno_populate (0 ,NULL ); + } +return 0 ; +} +int checkboard (void ) {puts ("Board: DS414\n" );
configs/ds414_defconfig +1 -1
@@ -25,6 +25,7 @@ CONFIG_USE_PREBOOT=y CONFIG_PREBOOT="pci enum; usb start" # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_DISPLAY_BOARDINFO_LATE=y +CONFIG_MISC_INIT_R=y CONFIG_SPL_I2C_SUPPORT=y # CONFIG_CMD_FLASH is not set CONFIG_CMD_I2C=y
@@ -47,7 +48,6 @@ CONFIG_ENV_OVERWRITE=y CONFIG_USE_ENV_SPI_MAX_HZ=y CONFIG_ENV_SPI_MAX_HZ=50000000 CONFIG_SYS_RELOC_GD_ENV_ADDR=y -CONFIG_NET_RANDOM_ETHADDR=y CONFIG_SPL_OF_TRANSLATE=y CONFIG_BLK=y # CONFIG_MMC is not set
Signature · 1 line
2.30.1
PATCH 5/5 ds414: Add sample u-boot update command
In reply to Phil Sutter--- include/configs/ds414.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
include/configs/ds414.h +6 -1
@@ -88,7 +88,12 @@"initrd_high=0xffffffff\0" \"ramdisk_addr_r=0x8000000\0" \"usb0Mode=host\0usb1Mode=host\0usb2Mode=device\0" \ -"ethmtu=1500\0eth1mtu=1500\0" +"ethmtu=1500\0eth1mtu=1500\0" \ +"update_uboot=sf probe; dhcp; " \ +"mw.b ${loadaddr} 0x0 0xd0000; " \ +"tftpboot ${loadaddr} u-boot-spl.kwb; " \ +"sf update ${loadaddr} 0x0 0xd0000\0" + /* increase autoneg timeout, my NIC sucks */#define PHY_ANEG_TIMEOUT 16000
Signature · 1 line
2.30.1
PATCH 5/5 ds414: Add sample u-boot update command
Quoted 1 line · Phil Sutter
Signed-off-by Phil Sutter <[email protected]>
It's common practice to add some minimal text in the commit text, even for simple patches.
One short question below...
Quoted 9 lines
--- include/configs/ds414.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)include/configs/ds414.h +0
-0
include/configs/ds414.h line 96
Quoted 10 lines
include/configs/ds414.h +6
-1@@ -88,7 +88,12 @@"initrd_high=0xffffffff\0" \"ramdisk_addr_r=0x8000000\0" \"usb0Mode=host\0usb1Mode=host\0usb2Mode=device\0" \ -"ethmtu=1500\0eth1mtu=1500\0" +"ethmtu=1500\0eth1mtu=1500\0" \ +"update_uboot=sf probe; dhcp; " \ +"mw.b ${loadaddr} 0x0 0xd0000; " \ +"tftpboot ${loadaddr} u-boot-spl.kwb; " \ +"sf update ${loadaddr} 0x0 0xd0000\0" +
Wouldn't it be better to use ${filesize} instead of 0xd0000 here?
Other than that:
Thanks,
Stefan
PATCH 5/5 ds414: Add sample u-boot update command
Quoted 5 lines · Stefan Roese
Quoted 1 line · Phil Sutter
Signed-off-by Phil Sutter <[email protected]>It's common practice to add some minimal text in the commit text, even for simple patches.
I should learn to put less meaningful subjects in those cases so I have an easier time finding something to write about in the description. Then again, your question indicates I just didn't think hard enough.
[...]
Quoted 9 lines
Quoted 9 lines
include/configs/ds414.h +0
-1@@ -88,7 +88,12 @@"initrd_high=0xffffffff\0" \"ramdisk_addr_r=0x8000000\0" \"usb0Mode=host\0usb1Mode=host\0usb2Mode=device\0" \ -"ethmtu=1500\0eth1mtu=1500\0"
Quoted 8 lines
include/configs/ds414.h line 96
Quoted 6 lines
include/configs/ds414.h +6
-0+"ethmtu=1500\0eth1mtu=1500\0" \ +"update_uboot=sf probe; dhcp; " \ +"mw.b ${loadaddr} 0x0 0xd0000; " \ +"tftpboot ${loadaddr} u-boot-spl.kwb; " \ +"sf update ${loadaddr} 0x0 0xd0000\0" +Wouldn't it be better to use ${filesize} instead of
0xd0000here?
U-Boot's "partition" size is fixed and hard-coded in the DTB at least. Putting the destination size as a limit at least avoids the unlikely chance of overwriting data past that partition.
BTW: I spent a while trying to make the DTB-defined partitions available in sf command, but eventually gave up. Seems I need to have this SPI->MTD mapping and still define partitions in environment. Not worth spending cycles on though, I was just curious because 'help sf' mentions partitions as offset alternatives.
Cheers, Phil
PATCH 5/5 ds414: Add sample u-boot update command
Quoted 9 lines · Phil Sutter
Quoted 5 lines · Stefan Roese
Quoted 1 line · Phil Sutter
Signed-off-by Phil Sutter <[email protected]>It's common practice to add some minimal text in the commit text, even for simple patches.
I should learn to put less meaningful subjects in those cases so I have an easier time finding something to write about in the description.
;)
Quoted 2 lines
Then
again, your question indicates I just didn't think hard enough.
I agree that this "rule" is sometimes hard to understand. I myself am sometimes finding it stupid to write the same sentence twice.
Quoted 19 lines
[...]
Quoted 9 lines
Quoted 9 lines
include/configs/ds414.h +0
-1@@ -88,7 +88,12 @@"initrd_high=0xffffffff\0" \"ramdisk_addr_r=0x8000000\0" \"usb0Mode=host\0usb1Mode=host\0usb2Mode=device\0" \ -"ethmtu=1500\0eth1mtu=1500\0" Quoted 8 lines
include/configs/ds414.h line 96
Quoted 6 lines
include/configs/ds414.h +6
-0+"ethmtu=1500\0eth1mtu=1500\0" \ +"update_uboot=sf probe; dhcp; " \ +"mw.b ${loadaddr} 0x0 0xd0000; " \ +"tftpboot ${loadaddr} u-boot-spl.kwb; " \ +"sf update ${loadaddr} 0x0 0xd0000\0" +Wouldn't it be better to use ${filesize} instead of
0xd0000here?
Quoted 3 lines
U-Boot's "partition" size is fixed and hard-coded in the DTB at least. Putting the destination size as a limit at least avoids the unlikely chance of overwriting data past that partition.
Ok, understood.
Quoted 5 lines
BTW: I spent a while trying to make the DTB-defined partitions available in sf command, but eventually gave up. Seems I need to have this
SPI->MTDmapping and still define partitions in environment. Not worth spending cycles on though, I was just curious because 'help sf' mentions partitions as offset alternatives.
Not looking to hard into your issue here, but did you take a look at the "mtd" command? It's newer than the other flash related commands and can manage all kind of flash types (SPI NOR, NAND etc) in one place. And also integrated better into the MTD partitions IIRC.
Thanks,
Stefan
PATCH 5/5 ds414: Add sample u-boot update command
Quoted 11 lines · Stefan Roese
Quoted 9 lines · Phil Sutter
Quoted 5 lines · Stefan Roese
Quoted 1 line · Phil Sutter
Signed-off-by Phil Sutter <[email protected]>It's common practice to add some minimal text in the commit text, even for simple patches.
I should learn to put less meaningful subjects in those cases so I have an easier time finding something to write about in the description.
Quoted 7 lines
;)
Quoted 2 lines
Then
again, your question indicates I just didn't think hard enough.I agree that this "rule" is sometimes hard to understand. I myself am sometimes finding it stupid to write the same sentence twice.
I've seen enough projects where one-liners are absolutely acceptable, I'd rather write redundant texts than accepting that coding "style". Nothing worse than confusing code garnished with no description at all. :)
[...]
Quoted 10 lines
Quoted 5 lines
BTW: I spent a while trying to make the DTB-defined partitions available in sf command, but eventually gave up. Seems I need to have this
SPI->MTDmapping and still define partitions in environment. Not worth spending cycles on though, I was just curious because 'help sf' mentions partitions as offset alternatives.Not looking to hard into your issue here, but did you take a look at the "mtd" command? It's newer than the other flash related commands and can manage all kind of flash types (SPI NOR, NAND etc) in one place. And also integrated better into the MTD partitions IIRC.
Hmm, for some reason I assumed 'sf' is the optimal tool for SPI flashes. I'll give it a try, thanks for the hint!
Thanks, Phil
PATCH v2 5/5 ds414: Add sample u-boot update command
In reply to Phil SutterCall 'run update_uboot' to fetch u-boot-spl.kwb via TFTP and write it into the correct SPI flash location. The latter's size is defined in DS414's DTB file, so hard-coding it should be acceptable here.
Take care to not append garbage from RAM to the written image and to stay within assigned flash boundaries even if an oversized image was fetched.
---
Changes since v1:
- Add a proper commit message.
--- include/configs/ds414.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
include/configs/ds414.h +6 -1
@@ -88,7 +88,12 @@"initrd_high=0xffffffff\0" \"ramdisk_addr_r=0x8000000\0" \"usb0Mode=host\0usb1Mode=host\0usb2Mode=device\0" \ -"ethmtu=1500\0eth1mtu=1500\0" +"ethmtu=1500\0eth1mtu=1500\0" \ +"update_uboot=sf probe; dhcp; " \ +"mw.b ${loadaddr} 0x0 0xd0000; " \ +"tftpboot ${loadaddr} u-boot-spl.kwb; " \ +"sf update ${loadaddr} 0x0 0xd0000\0" + /* increase autoneg timeout, my NIC sucks */#define PHY_ANEG_TIMEOUT 16000
Signature · 1 line
2.30.1
cover Synology DS414 integration mini-review
In reply to Phil SutterQuoted 37 lines · Phil Sutter
Board-specific code lacked a
Kconfigfile definingCONFIG_SYS_BOARD,CONFIG_SYS_VENDOR, etc - patch 1 fixes that.I was very pleased to notice the recent changes in PCI/USB code fixed xhci-pci functionality on DS414, so patch 2 enables XHCI support in defconfig.
Adjusting DS109 atags code for DS414 allowed to successfully boot vendor Linux, so I went ahead and generalized the code to support both boards in patch 3.
Patch 4 introduces a
misc_init_r()routine populating environment from Synology's special flash partition if appropriate - less manual work for users and no need for random MAC address fallback anymore.Patch 6 extends the default environment by a command to update u-boot via tftp.
Phil Sutter (5):
ds414: Add aKconfigdefining some strings
configs: ds414: EnableXHCI_PCIby default
board/Synology: Unify legacy kernel support
ds414: Auto-populate env if appropriate
ds414: Add sample u-boot update commandboard/Synology/common/Makefile | 5 +++ board/Synology/common/legacy.c | 75 +++++++++++++++++++++++++++++++++ board/Synology/common/legacy.h | 33 +++++++++++++++ board/Synology/ds109/ds109.c | 32 -------------- board/Synology/ds109/ds109.h | 17 -------- board/Synology/ds414/Kconfig | 12 ++++++ board/Synology/ds414/cmd_syno.c | 2 +- board/Synology/ds414/ds414.c | 13 ++++++ configs/ds414_defconfig | 7 ++- include/configs/ds109.h | 3 +- include/configs/ds414.h | 20 ++++++++- 11 files changed, 163 insertions(+), 56 deletions(-)
Quoted 5 lines
create mode 100644 board/Synology/common/Makefile create mode 100644
board/Synology/common/legacy.ccreate mode 100644board/Synology/common/legacy.hcreate mode 100644 board/Synology/ds414/Kconfig
Applied to u-boot-marvell/master (whole series)
Thanks,
Stefan