roc-pc-rk3399: Enable redundant SPI flash environment
Subsystems (3)
PATCH v2 1/5 roc-pc-rk3399: Enable redundant SPI flash environment
From: Fabio Estevam <[email protected]>
Enable redundant environment storage in the SPI NOR flash by enabling CONFIG_ENV_REDUNDANT and defining CONFIG_ENV_OFFSET_REDUND.
Move the primary environment to 0x3f0000 and place the redundant copy at 0x3f8000, matching the existing SPI NOR layout.
Having two copies of the environment improves robustness against power loss or interrupted writes and is useful for software update frameworks such as SWUpdate that modify the U-Boot environment during system updates.
---
Changes since v1:
- Use CONFIG_ENV_OFFSET=0x3F0000 and CONFIG_ENV_OFFSET_REDUND=0x3F8000.
configs/roc-pc-rk3399_defconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
configs/roc-pc-rk3399_defconfig +3 -1
@@ -7,6 +7,6 @@ CONFIG_NR_DRAM_BANKS=1 CONFIG_SF_DEFAULT_SPEED=30000000 CONFIG_ENV_SIZE=0x8000 -CONFIG_ENV_OFFSET=0x3F8000 +CONFIG_ENV_OFFSET=0x3F0000 CONFIG_ENV_SECT_SIZE=0x1000 CONFIG_DEFAULT_DEVICE_TREE="rockchip/rk3399-roc-pc" CONFIG_DM_RESET=y
@@ -17,6 +17,7 @@ CONFIG_SYS_LOAD_ADDR=0x800800 CONFIG_SF_DEFAULT_BUS=1 CONFIG_DEBUG_UART_BASE=0xFF1A0000 CONFIG_DEBUG_UART_CLOCK=24000000 +CONFIG_ENV_OFFSET_REDUND=0x3F8000 CONFIG_SPL_SPI_FLASH_SUPPORT=y CONFIG_SPL_SPI=y CONFIG_DEBUG_UART=y
@@ -39,6 +40,7 @@ CONFIG_CMD_TIME=y CONFIG_SPL_OF_CONTROL=y CONFIG_OF_SPL_REMOVE_PROPS="clock-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents" CONFIG_ENV_IS_IN_SPI_FLASH=y +CONFIG_ENV_REDUNDANT=y CONFIG_ENV_RELOC_GD_ENV_ADDR=y CONFIG_ROCKCHIP_GPIO=y CONFIG_SYS_I2C_ROCKCHIP=y
Signature · 1 line
2.43.0
PATCH v2 2/5 roc-pc-rk3399: Introduce a common defconfig
From: Fabio Estevam <[email protected]>
Introduce a common roc-pc-rk3399_common.config file to make it easier to introduce new roc-pc-rk3399 board variants.
No functional change.
---
Changes since v1:
- None.
configs/roc-pc-rk3399_common.config | 89 ++++++++++++++++++++++++++++ configs/roc-pc-rk3399_defconfig | 90 +---------------------------- 2 files changed, 90 insertions(+), 89 deletions(-) create mode 100644 configs/roc-pc-rk3399_common.config
configs/roc-pc-rk3399_common.config new file +89 -0
@@ -0,0 +1,89 @@ +CONFIG_ARM=y +CONFIG_SKIP_LOWLEVEL_INIT=y +CONFIG_COUNTER_FREQUENCY=24000000 +CONFIG_ARCH_ROCKCHIP=y +CONFIG_SPL_GPIO=y +CONFIG_NR_DRAM_BANKS=1 +CONFIG_SF_DEFAULT_SPEED=30000000 +CONFIG_ENV_SIZE=0x8000 +CONFIG_ENV_OFFSET=0x3F8000 +CONFIG_ENV_SECT_SIZE=0x1000 +CONFIG_DM_RESET=y +CONFIG_ROCKCHIP_RK3399=y +CONFIG_ROCKCHIP_SPI_IMAGE=y +CONFIG_TARGET_ROC_PC_RK3399=y +CONFIG_SYS_LOAD_ADDR=0x800800 +CONFIG_SF_DEFAULT_BUS=1 +CONFIG_DEBUG_UART_BASE=0xFF1A0000 +CONFIG_DEBUG_UART_CLOCK=24000000 +CONFIG_ENV_OFFSET_REDUND=0x3F8000 +CONFIG_SPL_SPI_FLASH_SUPPORT=y +CONFIG_SPL_SPI=y +CONFIG_DEBUG_UART=y +# CONFIG_ANDROID_BOOT_IMAGE is not set +CONFIG_DISPLAY_BOARDINFO_LATE=y +CONFIG_SPL_MAX_SIZE=0x40000 +# CONFIG_SPL_RAW_IMAGE_SUPPORT is not set +CONFIG_SPL_ENV_SUPPORT=y +CONFIG_SPL_SPI_LOAD=y +CONFIG_SYS_SPI_U_BOOT_OFFS=0xE0000 +CONFIG_SPL_ATF_NO_PLATFORM_PARAM=y +CONFIG_TPL=y +CONFIG_CMD_BOOTZ=y +CONFIG_CMD_GPT=y +CONFIG_CMD_MMC=y +CONFIG_CMD_USB=y +# CONFIG_CMD_SETEXPR is not set +CONFIG_CMD_TIME=y +CONFIG_SPL_OF_CONTROL=y +CONFIG_OF_SPL_REMOVE_PROPS="clock-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents" +CONFIG_ENV_IS_IN_SPI_FLASH=y +CONFIG_ENV_REDUNDANT=y +CONFIG_ENV_RELOC_GD_ENV_ADDR=y +CONFIG_ROCKCHIP_GPIO=y +CONFIG_SYS_I2C_ROCKCHIP=y +CONFIG_MMC_DW=y +CONFIG_MMC_DW_ROCKCHIP=y +CONFIG_MMC_SDHCI=y +CONFIG_MMC_SDHCI_SDMA=y +CONFIG_MMC_SDHCI_ROCKCHIP=y +CONFIG_SPI_FLASH_SFDP_SUPPORT=y +CONFIG_DM_ETH_PHY=y +CONFIG_ETH_DESIGNWARE=y +CONFIG_GMAC_ROCKCHIP=y +CONFIG_PHY_REALTEK=y +CONFIG_PHY_ROCKCHIP_INNO_USB2=y +CONFIG_PHY_ROCKCHIP_TYPEC=y +CONFIG_PMIC_RK8XX=y +CONFIG_REGULATOR_PWM=y +CONFIG_SPL_DM_REGULATOR_FIXED=y +CONFIG_REGULATOR_RK8XX=y +CONFIG_PWM_ROCKCHIP=y +# CONFIG_RAM_ROCKCHIP_DEBUG is not set +CONFIG_RAM_ROCKCHIP_LPDDR4=y +CONFIG_BAUDRATE=1500000 +CONFIG_DEBUG_UART_SHIFT=2 +CONFIG_SYS_NS16550_MEM32=y +CONFIG_ROCKCHIP_SPI=y +CONFIG_SYSRESET=y +CONFIG_USB=y +CONFIG_USB_XHCI_HCD=y +CONFIG_USB_EHCI_HCD=y +CONFIG_USB_EHCI_GENERIC=y +CONFIG_USB_OHCI_HCD=y +CONFIG_USB_OHCI_GENERIC=y +CONFIG_USB_DWC3=y +CONFIG_USB_DWC3_GENERIC=y +CONFIG_USB_KEYBOARD=y +CONFIG_USB_HOST_ETHER=y +CONFIG_USB_ETHER_ASIX=y +CONFIG_USB_ETHER_ASIX88179=y +CONFIG_USB_ETHER_MCS7830=y +CONFIG_USB_ETHER_RTL8152=y +CONFIG_USB_ETHER_SMSC95XX=y +CONFIG_USB_GADGET=y +CONFIG_VIDEO=y +CONFIG_DISPLAY=y +CONFIG_VIDEO_ROCKCHIP=y +CONFIG_DISPLAY_ROCKCHIP_HDMI=y +CONFIG_ERRNO_STR=y
configs/roc-pc-rk3399_defconfig +1 -89
93 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v2 3/5 mtd: spi-nor-ids: Add XMC XM25QH128C
In reply to Fabio EstevamFrom: Fabio Estevam <[email protected]>
Add the JEDEC ID for the XMC XM25QH128C SPI NOR flash.
This is a 128Mbit device using 64KiB sectors and supporting 4KiB erase, dual read and quad read, matching the other XM25QH128 variants.
---
Changes since v1:
- None.
drivers/mtd/spi/spi-nor-ids.c | 1 + 1 file changed, 1 insertion(+)
drivers/mtd/spi/spi-nor-ids.c +1 -0
@@ -669,6 +669,7 @@ const struct flash_info spi_nor_ids[] = { { INFO("XM25QH64A", 0x207017, 0, 64 * 1024, 128, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, { INFO("XM25QH64C", 0x204017, 0, 64 * 1024, 128, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, { INFO("XM25QH128A", 0x207018, 0, 64 * 1024, 256, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, + { INFO("XM25QH128C", 0x204018, 0, 64 * 1024, 256, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, { INFO("XM25QU128C", 0x204118, 0, 64 * 1024, 256, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, { INFO("XM25QH256C", 0x204019, 0, 64 * 1024, 512, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) }, { INFO("XM25QU256C", 0x204119, 0, 64 * 1024, 512, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
Signature · 1 line
2.43.0
PATCH v2 4/5 roc-pc-plus-rk3399: Introduce new variant
In reply to Fabio EstevamFrom: Fabio Estevam <[email protected]>
The roc-pc-plus-rk3399 board shares a lot of features with the existing supported roc-pc-rk3399 board.
Its devicetree is also supported in the upstream kernel.
The plus variant has only a 12V supply. It contains a XMC XM25QH128C SPI NOR flash.
Add support for the plus variant.
---
Changes since v1:
- None.
arch/arm/dts/rk3399-roc-pc-plus-u-boot.dtsi | 9 +++++++++ board/firefly/roc-pc-rk3399/MAINTAINERS | 1 + configs/roc-pc-plus-rk3399_defconfig | 4 ++++ doc/board/rockchip/rockchip.rst | 3 ++- 4 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 arch/arm/dts/rk3399-roc-pc-plus-u-boot.dtsi create mode 100644 configs/roc-pc-plus-rk3399_defconfig
arch/arm/dts/rk3399-roc-pc-plus-u-boot.dtsi new file +9 -0
@@ -0,0 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include "rk3399-roc-pc-u-boot.dtsi" + +/delete-node/ &vcc_hub_en; + +&dc_12v { + /delete-property/ vin-supply; +};
board/firefly/roc-pc-rk3399/MAINTAINERS +1 -0
@@ -5,5 +5,6 @@ S: Maintained F: board/firefly/roc-pc-rk3399 F: include/configs/roc-pc-rk3399.h F: configs/roc-pc-rk3399_defconfig +F: configs/roc-pc-plus-rk3399_defconfig F: configs/roc-pc-mezzanine-rk3399_defconfig F: arch/arm/dts/rk3399-roc-pc*
configs/roc-pc-plus-rk3399_defconfig new file +4 -0
@@ -0,0 +1,4 @@ +#include <configs/roc-pc-rk3399_common.config> +CONFIG_DEFAULT_DEVICE_TREE="rockchip/rk3399-roc-pc-plus" +CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-roc-pc-plus.dtb" +CONFIG_SPI_FLASH_XMC=y
doc/board/rockchip/rockchip.rst +2 -1
@@ -81,7 +81,8 @@ List of mainline supported Rockchip boards: - 96boards RK3399 Ficus (ficus-rk3399) - 96boards Rock960 (rock960-rk3399) - Firefly-RK3399 (firefly_rk3399) - - Firefly ROC-RK3399-PC + - Firefly ROC-RK3399-PC (roc-pc-rk3399) + - Firefly ROC-RK3399-PC Plus (roc-pc-plus-rk3399) - FriendlyElec NanoPC-T4 (nanopc-t4-rk3399) - FriendlyElec NanoPi M4 (nanopi-m4-rk3399) - FriendlyElec NanoPi M4B (nanopi-m4b-rk3399)
Signature · 1 line
2.43.0
PATCH v2 5/5 roc-pc-plus-rk3399: Enable USB Mass Storage support
In reply to Fabio EstevamFrom: Fabio Estevam <[email protected]>
Configure the USB0 DWC3 controller for peripheral mode and enable the required USB gadget options to support the U-Boot 'ums' command on the ROC-RK3399-PC Plus.
The 'ums' command provides a convenient way to expose the on-board eMMC as a USB Mass Storage device to a host computer, simplifying development, image installation and recovery without requiring removable media or network access.
Limit the controller to High-Speed operation by using the USB2 OTG PHY.
---
Changes since v1:
- None.
arch/arm/dts/rk3399-roc-pc-plus-u-boot.dtsi | 7 +++++++ configs/roc-pc-plus-rk3399_defconfig | 3 +++ 2 files changed, 10 insertions(+)
arch/arm/dts/rk3399-roc-pc-plus-u-boot.dtsi +7 -0
@@ -7,3 +7,10 @@ &dc_12v { /delete-property/ vin-supply; }; + +&usbdrd_dwc3_0 { + dr_mode = "peripheral"; + maximum-speed = "high-speed"; + phys = <&u2phy0_otg>; + phy-names = "usb2-phy"; +};
configs/roc-pc-plus-rk3399_defconfig +3 -0
@@ -2,3 +2,6 @@ CONFIG_DEFAULT_DEVICE_TREE="rockchip/rk3399-roc-pc-plus" CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-roc-pc-plus.dtb" CONFIG_SPI_FLASH_XMC=y +CONFIG_CMD_USB_MASS_STORAGE=y +# CONFIG_USB_FUNCTION_FASTBOOT is not set +CONFIG_USB_GADGET_DOWNLOAD=y
Signature · 1 line
2.43.0
Hi Fabio,
Quoted 8 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
Enable redundant environment storage in the SPI NOR flash by enabling
CONFIG_ENV_REDUNDANTand definingCONFIG_ENV_OFFSET_REDUND.Move the primary environment to
0x3f0000and place the redundant copy at0x3f8000, matching the existing SPI NOR layout.
Where is this layout defined?
Considering the env size is 0x1000, the same as the erase block size of the SPI NOR flash you add support for in patch 3... I would have imagined to simply use 0x3f7000 (or 0x3f9000) (or have them aligned with the ones you are trying to use for the ROC-PC-RK3588S, which is 0x40000).
Looks good to me otherwise.
Cheers,
Quentin
Re: [PATCH v2 4/5] roc-pc-plus-rk3399: Introduce new variant
In reply to Fabio EstevamHi Fabio,
Quoted 31 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
The roc-pc-plus-rk3399 board shares a lot of features with the existing supported roc-pc-rk3399 board.
Its devicetree is also supported in the upstream kernel.
The plus variant has only a 12V supply. It contains a XMC XM25QH128C SPI NOR flash.
Add support for the plus variant.
Signed-off-by Fabio Estevam <[email protected]>---
Changes since v1:
- None.arch/arm/dts/rk3399-roc-pc-plus-u-boot.dtsi | 9 +++++++++ board/firefly/roc-pc-rk3399/MAINTAINERS | 1 + configs/roc-pc-plus-rk3399_defconfig | 4 ++++ doc/board/rockchip/rockchip.rst | 3 ++- 4 files changed, 16 insertions(+), 1 deletion(-)create mode 100644
arch/arm/dts/rk3399-roc-pc-plus-u-boot.dtsicreate mode 100644 configs/roc-pc-plus-rk3399_defconfigarch/arm/dts/rk3399-roc-pc-plus-u-boot.dtsi new file +0
-0
arch/arm/dts/rk3399-roc-pc-plus-u-boot.dtsi line 9
Quoted 9 lines
arch/arm/dts/rk3399-roc-pc-plus-u-boot.dtsi new file +9
-0@@ -0,0 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include "rk3399-roc-pc-u-boot.dtsi" + +/delete-node/ &vcc_hub_en; + +&dc_12v { + /delete-property/ vin-supply; +};
Mmmmmm... I'm wondering if we cannot remove &dc_12v and /vcc_hub_en-regulator from arch/arm/dts/rk3399-roc-pc-u-boot.dtsi instead? dc_12v is already an mps,mp8859 in the upstream DTS so I'm not sure the override does anything (I don't think the compatible property would be actually used). For /vcc_hub_en-regulator, the upstream DTS seems to be using something.... questionable (a pinconf with forced GPIO output high via &hub_rst that is then used in /regulator-vcc5v0-host). So I **think** we should be able to remove this and not have to care about deleting properties or nodes in arch/arm/dts/rk3399-roc-pc-plus-u-boot.dtsi.
Quoted 17 lines
board/firefly/roc-pc-rk3399/MAINTAINERS +1
-0@@ -5,5 +5,6 @@ S: Maintained F: board/firefly/roc-pc-rk3399 F: include/configs/roc-pc-rk3399.h F: configs/roc-pc-rk3399_defconfig +F: configs/roc-pc-plus-rk3399_defconfig F: configs/roc-pc-mezzanine-rk3399_defconfig F: arch/arm/dts/rk3399-roc-pc*configs/roc-pc-plus-rk3399_defconfig new file +0
-0
configs/roc-pc-plus-rk3399_defconfig line 4
Quoted 4 lines
configs/roc-pc-plus-rk3399_defconfig new file +4
-0@@ -0,0 +1,4 @@ +#include <configs/roc-pc-rk3399_common.config> +CONFIG_DEFAULT_DEVICE_TREE="rockchip/rk3399-roc-pc-plus" +CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-roc-pc-plus.dtb" +CONFIG_SPI_FLASH_XMC=y
Is there any way to detect which of ROC-PC-RK3399 or ROC-PC-PLUS-RK3399 is currently running U-Boot? I'm thinking it'd be nice to NOT have a second defconfig for just essentially using a different device tree (and SPI_FLASH_XMC but this could be enabled for ROC-PC-RK3399 as well). See board/radxa/rock5b-rk3588/rock5b-rk3588.c how we handle both Rock 5B/5B+/5T with the same defconfig (configs/rock5b-rk3588_defconfig, specifically CONFIG_OF_LIST).
Cheers,
Quentin
Re: [PATCH v2 5/5] roc-pc-plus-rk3399: Enable USB Mass Storage support
In reply to Fabio EstevamHi Fabio,
Quoted 3 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
Configure the USB0 DWC3 controller for peripheral mode and enable the
Is this really required? I would have imagined "otg" to be enough. Considering there are setups U-Boot DTS is passed to the Linux kernel, the fewer changes we have compared to Linux kernel DTS, the better. I wouldn't take too much inspiration from the generic Device Trees for Rockchip SoCs if that's where you took it from, a lot is trying to support as many devices as possible without necessarily doing things the proper way.
Quoted 8 lines
required USB gadget options to support the U-Boot 'ums' command on the ROC-RK3399-PC Plus.
The 'ums' command provides a convenient way to expose the on-board eMMC as a USB Mass Storage device to a host computer, simplifying development, image installation and recovery without requiring removable media or network access.
Sounds good.
Quoted 2 lines
Limit the controller to High-Speed operation by using the USB2 OTG PHY.
Why?
Cheers,
Quentin
Hi Quentin,
Quoted 6 lines · Quentin Schulz
Where is this layout defined?
Considering the env size is
0x1000, the same as the erase block size of the SPI NOR flash you add support for in patch 3... I would have imagined to simply use0x3f7000(or0x3f9000) (or have them aligned with the ones you are trying to use for the ROC-PC-RK3588S, which is0x40000).
There is no separately defined SPI NOR layout; my commit message was misleading in that regard.
CONFIG_ENV_SECT_SIZE is 0x1000, but CONFIG_ENV_SIZE is 0x8000.
Therefore, each environment copy occupies 32 KiB rather than 4 KiB. The existing environment starts at 0x3f8000 and occupies 0x3f8000–0x3fffff.
To preserve the existing environment location as the redundant copy, I placed the primary copy immediately before it at 0x3f0000. This gives two adjacent, non-overlapping 32 KiB regions, both aligned to the 4 KiB erase-sector size.
I will reword the commit message to describe this explicitly and remove the reference to an “existing SPI NOR layout.”