Skip to contentSkip to conversation

Fixes for SPI boot on SanCloud BBE Lite

PATCH In review Paul Barker 3 participants 13 messages Nov 14, 2022 – Dec 2, 2022 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

v2 cover Fixes for SPI boot on SanCloud BBE Lite

These changes fix SPI boot on the SanCloud BBE Lite and other AM335x boards.

They also put us in a good place to enable SPL_OF_CONTROL for eMMC/SD card boot on AM335x boards. Note that if SPL_OF_CONTROL is enabled, some SPL features need to be dropped due to the limited amount of sram available. In my testing I dropped NAND, NET & USB support.

This series has been build tested for all targets using buildman and no errors were observed. It has been boot tested on the SanCloud BBE Lite with the following configurations:

1) SD card boot using am335x_evm_defconfig with no config changes.

2) SD card boot using am335x_evm_defconfig with the following config changes:

CONFIG_SPL_OF_CONTROL=y
CONFIG_SPL_OF_TRANSLATE=y
CONFIG_SPL_MUSB_NEW=n
CONFIG_SPL_NAND_DRIVERS=n
CONFIG_SPL_NAND_ECC=n
CONFIG_SPL_NAND_BASE=n
CONFIG_SPL_NET=n
CONFIG_SPL_USB_GADGET=n

3) SPI boot using am335x_evm_spiboot_defconfig with the following config changes:

CONFIG_DEFAULT_DEVICE_TREE="am335x-sancloud-bbe-lite" CONFIG_OF_LIST="am335x-sancloud-bbe-lite"

As discussed in my previous message [1], I can't see how to construct a test case to accompany the first patch which fixes an SPL crash during the pre-relocation lists_bind_drivers() call due to exhaustion of the available memory. We can discuss this further though if anyone has any ideas on how to write an appropriate test case.

[1]: https://lore.kernel.org/u-boot/[email protected]/

Paul Barker (9):
dm: core: Fix iteration over driver_info records
bus: TI sysc driver requires DM
bus: Optionally include TI sysc driver in SPL/TPL
am335x-evm: Enable required dtb nodes in SPL
am335x-evm: Fix spiboot configuration
am335x-evm: Support STMicro/Micron SPI flash
am335x-sancloud-bbe-lite: SPI flash is JEDEC compatible
am335x-sancloud-bbe: Add -u-boot.dtsi files
MAINTAINERS: Adopt SanCloud boards

 MAINTAINERS                                   |  6 +++
 arch/arm/dts/am335x-evm-u-boot.dtsi           | 30 ++++++++++++-
 .../dts/am335x-sancloud-bbe-lite-u-boot.dtsi  | 44 +++++++++++++++++++
 arch/arm/dts/am335x-sancloud-bbe-lite.dts     |  2 +-
 arch/arm/dts/am335x-sancloud-bbe-u-boot.dtsi  |  6 +++
 configs/am335x_evm_defconfig                  |  1 +
 configs/am335x_evm_spiboot_defconfig          |  5 +++
 drivers/Makefile                              |  2 +-
 drivers/bus/Kconfig                           |  9 +++-
 drivers/bus/Makefile                          |  5 ++-
 drivers/core/lists.c                          |  6 +--
 11 files changed, 107 insertions(+), 9 deletions(-)
 create mode 100644 arch/arm/dts/am335x-sancloud-bbe-lite-u-boot.dtsi
 create mode 100644 arch/arm/dts/am335x-sancloud-bbe-u-boot.dtsi

base-commit: 0cbeed4f6648e0e4966475e3544280a69ecb59d3

Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 1/9 dm: core: Fix iteration over driver_info records

We should only perform additional iteration steps when needed to initialize the parent of a device. Other binding errors (such as a missing driver) should not lead to additional iteration steps.

Unnecessary iteration steps can cause issues when memory is tightly constrained (such as in the TPL/SPL) since device_bind_by_name() unconditionally allocates memory for a struct udevice. On the SanCloud BBE this led to boot failure caused by memory exhaustion in the SPL when booting from SPI flash.

---
 drivers/core/lists.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/core/lists.c +3 -3
index 3878957c9ef4..8034a8f48d99 100644
@@ -120,10 +120,10 @@ int lists_bind_drivers(struct udevice *parent, bool pre_reloc_only)
 		int ret;
 
 		ret = bind_drivers_pass(parent, pre_reloc_only);
-		if (!ret)
-			break;
-		if (ret != -EAGAIN && !result)
+		if (!result || result == -EAGAIN)
 			result = ret;
+		if (ret != -EAGAIN)
+			break;
 	}
 
 	return result;
Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH v2 1/9] dm: core: Fix iteration over driver_info records

Quoted 11 lines · Paul Barker

We should only perform additional iteration steps when needed to initialize the parent of a device. Other binding errors (such as a missing driver) should not lead to additional iteration steps.

Unnecessary iteration steps can cause issues when memory is tightly constrained (such as in the TPL/SPL) since device_bind_by_name() unconditionally allocates memory for a struct udevice. On the SanCloud BBE this led to boot failure caused by memory exhaustion in the SPL when booting from SPI flash.

For the series, applied to u-boot/master, thanks!

Signature · 1 line
Tom
#3 lore raw

PATCH v2 2/9 bus: TI sysc driver requires DM

In reply to Paul Barker

This driver does not build if CONFIG_DM is disabled as it uses the function dev_get_priv.

---
 drivers/bus/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/bus/Kconfig +1 -1
index d742ed333b16..c607d24ecf60 100644
@@ -13,7 +13,7 @@ config TI_PWMSS
 
 config TI_SYSC
 	bool "TI sysc interconnect target module driver"
-	depends on ARCH_OMAP2PLUS
+	depends on DM && ARCH_OMAP2PLUS
 	help
 	  Generic driver for Texas Instruments interconnect target module
 	  found on many TI SoCs.
Signature · 1 line
2.25.1
#4 lore raw

PATCH v2 3/9 bus: Optionally include TI sysc driver in SPL/TPL

In reply to Paul Barker

The TI sysc bus driver is required to allow access to the SPI bus on am335x platforms. To support SPI boot this driver needs to be enabled in the SPL/TPL as appropriate.

---
 drivers/Makefile     | 2 +-
 drivers/bus/Kconfig  | 7 +++++++
 drivers/bus/Makefile | 5 ++++-
 3 files changed, 12 insertions(+), 2 deletions(-)
drivers/Makefile +1 -1
index ac2d83af4e3f..6f1de58e0030 100644
@@ -37,6 +37,7 @@ obj-$(CONFIG_$(SPL_)SYSINFO) += sysinfo/
 obj-$(CONFIG_$(SPL_TPL_)TPM) += tpm/
 obj-$(CONFIG_XEN) += xen/
 obj-$(CONFIG_$(SPL_)FPGA) += fpga/
+obj-y += bus/
 
 ifndef CONFIG_TPL_BUILD
 ifndef CONFIG_VPL_BUILD
@@ -77,7 +78,6 @@ ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_TPL_BUILD),)
 
 obj-y += adc/
 obj-y += ata/
-obj-y += bus/
 obj-$(CONFIG_DM_DEMO) += demo/
 obj-$(CONFIG_BIOSEMU) += bios_emulator/
 obj-y += block/
drivers/bus/Kconfig +7 -0
index c607d24ecf60..e60aa722b97f 100644
@@ -18,6 +18,13 @@ config TI_SYSC
 	  Generic driver for Texas Instruments interconnect target module
 	  found on many TI SoCs.
 
+config SPL_TI_SYSC
+	bool "Support TI sysc interconnect in SPL"
+	depends on SPL_DM && TI_SYSC
+	help
+	  Generic driver for Texas Instruments interconnect target module
+	  found on many TI SoCs.
+
 config UNIPHIER_SYSTEM_BUS
 	bool "UniPhier System Bus driver"
 	depends on ARCH_UNIPHIER
drivers/bus/Makefile +4 -1
index a2e71c7b3b52..0802b9666bfc 100644
@@ -3,6 +3,9 @@
 # Makefile for the bus drivers.
 #
 
+ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_TPL_BUILD),)
 obj-$(CONFIG_TI_PWMSS)	+= ti-pwmss.o
-obj-$(CONFIG_TI_SYSC)	+= ti-sysc.o
 obj-$(CONFIG_UNIPHIER_SYSTEM_BUS) += uniphier-system-bus.o
+endif
+
+obj-$(CONFIG_$(SPL_)TI_SYSC)	+= ti-sysc.o
Signature · 1 line
2.25.1
#5 lore raw

PATCH v2 4/9 am335x-evm: Enable required dtb nodes in SPL

In reply to Paul Barker

For successful boot when CONFIG_SPL_OF_CONTROL=y, we need to ensure that the board EEPROM on i2c0, the uart0 serial port and the relevant boot device (mmc1 or mmc2) can be accessed in the SPL. We also need to preserve the parent nodes for each required dtb node.

---
 arch/arm/dts/am335x-evm-u-boot.dtsi | 30 +++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)
arch/arm/dts/am335x-evm-u-boot.dtsi +28 -2
index 4cf5f9928d58..8fc65df2ef9b 100644
@@ -6,9 +6,9 @@
 #include "am33xx-u-boot.dtsi"
 
 &l4_per {
-
+	u-boot,dm-pre-reloc;
 	segment@300000 {
-
+		u-boot,dm-pre-reloc;
 		target-module@e000 {
 			u-boot,dm-pre-reloc;
 
@@ -26,3 +26,29 @@
 &usb0 {
 	dr_mode = "peripheral";
 };
+
+&i2c0 {
+	u-boot,dm-pre-reloc;
+};
+
+&l4_wkup {
+	u-boot,dm-pre-reloc;
+	segment@200000 {
+		u-boot,dm-pre-reloc;
+		target-module@9000 {
+			u-boot,dm-pre-reloc;
+		};
+	};
+};
+
+&uart0 {
+	u-boot,dm-pre-reloc;
+};
+
+&mmc1 {
+	u-boot,dm-pre-reloc;
+};
+
+&mmc2 {
+	u-boot,dm-pre-reloc;
+};
Signature · 1 line
2.25.1
#6 lore raw

PATCH v2 5/9 am335x-evm: Fix spiboot configuration

In reply to Paul Barker

The advanced address translation provided by CONFIG_SPL_OF_TRANSLATE is needed to determine the base address of the uart0 peripheral on am335x platforms when CONFIG_SPL_OF_CONTROL is enabled.

If CONFIG_SPL_OF_CONTROL is enabled in the base (non-spiboot) am335x_evm_defconfig, then CONFIG_SPL_OF_TRANSLATE will also need to be enabled there. Unfortunately this cannot be done pre-emptively due to the kconfig dependencies.

The TI clk-ctrl & TI sysc drivers are also required to bring up the SPI bus on am335x platforms.

---
 configs/am335x_evm_spiboot_defconfig | 4 ++++
 1 file changed, 4 insertions(+)
configs/am335x_evm_spiboot_defconfig +4 -0
index 3d04e6fa934a..2bc911cfd022 100644
@@ -53,10 +53,14 @@ CONFIG_SPL_ENV_IS_NOWHERE=y
 CONFIG_VERSION_VARIABLE=y
 CONFIG_NET_RETRY_COUNT=10
 CONFIG_BOOTP_SEND_HOSTNAME=y
+CONFIG_SPL_OF_TRANSLATE=y
+CONFIG_SPL_TI_SYSC=y
 CONFIG_BOOTCOUNT_LIMIT=y
 CONFIG_SYS_BOOTCOUNT_BE=y
 CONFIG_CLK=y
+CONFIG_SPL_CLK=y
 CONFIG_CLK_CDCE9XX=y
+CONFIG_CLK_TI_CTRL=y
 CONFIG_DFU_TFTP=y
 CONFIG_DFU_MMC=y
 CONFIG_DFU_NAND=y
Signature · 1 line
2.25.1
#7 lore raw

PATCH v2 6/9 am335x-evm: Support STMicro/Micron SPI flash

In reply to Paul Barker

This change enables access to the SPI flash on the SanCloud BBE Lite board.

---
 configs/am335x_evm_defconfig         | 1 +
 configs/am335x_evm_spiboot_defconfig | 1 +
 2 files changed, 2 insertions(+)
configs/am335x_evm_defconfig +1 -0
index f0fbe475b394..f73123e0b71d 100644
@@ -92,6 +92,7 @@ CONFIG_SYS_NAND_U_BOOT_LOCATIONS=y
 CONFIG_SYS_NAND_U_BOOT_OFFS=0xc0000
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SF_DEFAULT_SPEED=24000000
+CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_SPI_FLASH_WINBOND=y
 CONFIG_PHY_ATHEROS=y
 CONFIG_PHY_SMSC=y
configs/am335x_evm_spiboot_defconfig +1 -0
index 2bc911cfd022..7f422010c1c7 100644
@@ -84,6 +84,7 @@ CONFIG_SYS_NAND_U_BOOT_LOCATIONS=y
 CONFIG_SYS_NAND_U_BOOT_OFFS=0xc0000
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SF_DEFAULT_SPEED=24000000
+CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_SPI_FLASH_WINBOND=y
 CONFIG_PHY_ATHEROS=y
 CONFIG_PHY_SMSC=y
Signature · 1 line
2.25.1
#8 lore raw

PATCH v2 7/9 am335x-sancloud-bbe-lite: SPI flash is JEDEC compatible

In reply to Paul Barker
---
 arch/arm/dts/am335x-sancloud-bbe-lite.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/dts/am335x-sancloud-bbe-lite.dts +1 -1
index d6ef19311a91..8ffbc72dc57e 100644
@@ -41,7 +41,7 @@
 		#address-cells = <1>;
 		#size-cells = <0>;
 
-		compatible = "micron,spi-authenta";
+		compatible = "micron,spi-authenta", "jedec,spi-nor";
 
 		reg = <0>;
 		spi-max-frequency = <16000000>;
Signature · 1 line
2.25.1
#9 lore raw

Re: [PATCH v2 7/9] am335x-sancloud-bbe-lite: SPI flash is JEDEC compatible

Hi Paul,

Quoted 1 line · Paul Barker

It is my humble opinion that you add some commit message here and not leave the body blank with just a sign off.

Quoted 17 lines
---
  arch/arm/dts/am335x-sancloud-bbe-lite.dts | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/dts/am335x-sancloud-bbe-lite.dts +1 -1
index d6ef19311a91..8ffbc72dc57e 100644
@@ -41,7 +41,7 @@
  		#address-cells = <1>;
  		#size-cells = <0>;
 
-		compatible = "micron,spi-authenta";
+		compatible = "micron,spi-authenta", "jedec,spi-nor";
 
  		reg = <0>;
  		spi-max-frequency = <16000000>;
Signature · 2 lines
Thanks and Regards,
Dhruva Gole
#10 lore raw

PATCH v2 8/9 am335x-sancloud-bbe: Add -u-boot.dtsi files

In reply to Paul Barker

The SanCloud BBE requires the same dtb nodes to be present in the SPL as the AM335x EVM.

The SanCloud BBE Lite also requires the SPI flash node and all dependencies to be present in the SPL to support SPI boot.

---
 .../dts/am335x-sancloud-bbe-lite-u-boot.dtsi  | 44 +++++++++++++++++++
 arch/arm/dts/am335x-sancloud-bbe-u-boot.dtsi  |  6 +++
 2 files changed, 50 insertions(+)
 create mode 100644 arch/arm/dts/am335x-sancloud-bbe-lite-u-boot.dtsi
 create mode 100644 arch/arm/dts/am335x-sancloud-bbe-u-boot.dtsi
arch/arm/dts/am335x-sancloud-bbe-lite-u-boot.dtsi new file +44 -0
new file mode 100644
index 000000000000..01c105ebb383
@@ -0,0 +1,44 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
+ * Copyright (C) 2021 SanCloud Ltd
+ */
+
+#include "am335x-sancloud-bbe-u-boot.dtsi"
+
+&l4_wkup {
+	segment@200000 {
+		target-module@0 {
+			u-boot,dm-pre-reloc;
+		};
+	};
+};
+
+&prcm {
+	u-boot,dm-pre-reloc;
+};
+
+&per_cm {
+	u-boot,dm-pre-reloc;
+};
+
+&l4ls_clkctrl {
+	u-boot,dm-pre-reloc;
+};
+
+&l4_per {
+	u-boot,dm-pre-reloc;
+	segment@0 {
+		u-boot,dm-pre-reloc;
+		target-module@30000 {
+			u-boot,dm-pre-reloc;
+		};
+	};
+};
+
+&spi0 {
+	u-boot,dm-pre-reloc;
+	channel@0 {
+		u-boot,dm-pre-reloc;
+	};
+};
arch/arm/dts/am335x-sancloud-bbe-u-boot.dtsi new file +6 -0
new file mode 100644
index 000000000000..06e7554a63c8
@@ -0,0 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2022 SanCloud Ltd
+ */
+
+#include "am335x-evm-u-boot.dtsi"
Signature · 1 line
2.25.1
#11 lore raw

PATCH v2 9/9 MAINTAINERS: Adopt SanCloud boards

In reply to Paul Barker
---
 MAINTAINERS | 6 ++++++
 1 file changed, 6 insertions(+)
MAINTAINERS +6 -0
index 8d3d528650a7..3ab1dca33a4a 100644
@@ -485,6 +485,12 @@ F:	arch/arm/mach-exynos/
 F:	arch/arm/mach-s5pc1xx/
 F:	arch/arm/cpu/armv7/s5p-common/
 
+ARM SANCLOUD
+M:	Paul Barker <[email protected]>
+R:	Marc Murphy <[email protected]>
+S:	Supported
+F:	arch/arm/dts/am335x-sancloud*
+
 ARM SNAPDRAGON
 M:	Ramon Fried <[email protected]>
 S:	Maintained
Signature · 1 line
2.25.1
#12 lore raw
In reply to Paul Barker
Quoted 67 lines · Paul Barker

These changes fix SPI boot on the SanCloud BBE Lite and other AM335x boards.

They also put us in a good place to enable SPL_OF_CONTROL for eMMC/SD card boot on AM335x boards. Note that if SPL_OF_CONTROL is enabled, some SPL features need to be dropped due to the limited amount of sram available. In my testing I dropped NAND, NET & USB support.

This series has been build tested for all targets using buildman and no errors were observed. It has been boot tested on the SanCloud BBE Lite with the following configurations:

1) SD card boot using am335x_evm_defconfig with no config changes.

2) SD card boot using am335x_evm_defconfig with the following config changes:

CONFIG_SPL_OF_CONTROL=y
CONFIG_SPL_OF_TRANSLATE=y
CONFIG_SPL_MUSB_NEW=n
CONFIG_SPL_NAND_DRIVERS=n
CONFIG_SPL_NAND_ECC=n
CONFIG_SPL_NAND_BASE=n
CONFIG_SPL_NET=n
CONFIG_SPL_USB_GADGET=n

3) SPI boot using am335x_evm_spiboot_defconfig with the following config changes:

CONFIG_DEFAULT_DEVICE_TREE="am335x-sancloud-bbe-lite" CONFIG_OF_LIST="am335x-sancloud-bbe-lite"

As discussed in my previous message [1], I can't see how to construct a test case to accompany the first patch which fixes an SPL crash during the pre-relocation lists_bind_drivers() call due to exhaustion of the available memory. We can discuss this further though if anyone has any ideas on how to write an appropriate test case.

[1]: https://lore.kernel.org/u-boot/[email protected]/

Paul Barker (9):
dm: core: Fix iteration over driver_info records
bus: TI sysc driver requires DM
bus: Optionally include TI sysc driver in SPL/TPL
am335x-evm: Enable required dtb nodes in SPL
am335x-evm: Fix spiboot configuration
am335x-evm: Support STMicro/Micron SPI flash
am335x-sancloud-bbe-lite: SPI flash is JEDEC compatible
am335x-sancloud-bbe: Add -u-boot.dtsi files
MAINTAINERS: Adopt SanCloud boards

 MAINTAINERS                                   |  6 +++
 arch/arm/dts/am335x-evm-u-boot.dtsi           | 30 ++++++++++++-
 .../dts/am335x-sancloud-bbe-lite-u-boot.dtsi  | 44 +++++++++++++++++++
 arch/arm/dts/am335x-sancloud-bbe-lite.dts     |  2 +-
 arch/arm/dts/am335x-sancloud-bbe-u-boot.dtsi  |  6 +++
 configs/am335x_evm_defconfig                  |  1 +
 configs/am335x_evm_spiboot_defconfig          |  5 +++
 drivers/Makefile                              |  2 +-
 drivers/bus/Kconfig                           |  9 +++-
 drivers/bus/Makefile                          |  5 ++-
 drivers/core/lists.c                          |  6 +--
 11 files changed, 107 insertions(+), 9 deletions(-)
 create mode 100644 arch/arm/dts/am335x-sancloud-bbe-lite-u-boot.dtsi
 create mode 100644 arch/arm/dts/am335x-sancloud-bbe-u-boot.dtsi
Quoted 1 line

base-commit: 0cbeed4f6648e0e4966475e3544280a69ecb59d3

A gentle ping on this patch series.

Signature · 6 lines
Paul Barker
Principal Software Engineer
SanCloud Ltd

e: [email protected]
w: https://sancloud.com/