Skip to contentSkip to conversation

spacemit mmc driver

PATCH Superseded Eric Chung 3 participants 33 messages Jul 27 – Jul 31

Subsystems (4)

v6 of 13 Superseded Latest is v13 →

lore
Share & tools
lore

Eric Chung

author
#0 lore raw

v6 cover spacemit mmc driver

This series adds MMC support for the SpacemiT K1: an SDHCI platform driver, the SD card device-tree overlay, defconfig options, and SPL boot-device selection from the SoC strap/config registers. The SDHCI driver is usable in both SPL and U-Boot proper.

A flashing guide (doc/board/spacemit/k1-flash.rst) describes how to write images to eMMC.

---
Changes in v6:
- pinctrl: Fix drive strength configuration.
- pinctrl: Fix pull-up/pull-down configuration.
- pinctrl: Use dev_read_phandle_with_args() to fetch "spacemit,syscon" instead.
- spacemit: rebase on latest upstream branch.
- Link to v5: https://patch.msgid.link/[email protected]

Changes in v5:
- mmc: Split CMD23 support out.
- mmc: Use read_poll_timeout().
- mmc: Set pinctrl state based on selected timing mode.
- mmc: Remove the condition based on quirks.
- pinctrl: Fix power source argument.
- dts: Add missing power source on mmc pins.
- Link to v4: https://patch.msgid.link/[email protected]

Changes in v4:
- mmc: Add CMD23 for write.
- mmc: Fix CMD23 only for CMD18.
- mmc: Update bulk release operations on reset and clocks for spacemit platform driver.
- MAINTAINER: update the maintainer of Spacemit K1.
- Link to v3: https://patch.msgid.link/[email protected]

Changes in v3:
- pinctrl: Fix "fast" by "uhs".
- pinctrl: Add syscon dependency.
- mmc: Fix quick by capability.
- doc: Add SD boot support.
- Link to v2: https://lore.kernel.org/u-boot/[email protected]/T/#m2aba875a2696a7bb9b704618d22ae2fd7f7f5acc

Changes in v2:
- cmd: drop patches on eminfo & tlv_eeprom.
- configs: Enable ADMA and SYSCON support.
- dts: Use vmmc-supply as vqmmc-supply on the SD card node.
- mmc: k1: Enable ADMA mode support, use CMD23 for multi-block
read/write, correct pinctrl state from "fast" to "uhs".
- mmc: sdhci: Add new quirk patch to enable CMD23 for multi-block
transfers.
- pinctrl: k1: Add new IO power domain configuration support for
dual-voltage GPIO banks.
- spacemit: k1: Use FIELD_GET() to parse boot strap mode.
- Link to v1: https://lore.kernel.org/u-boot/[email protected]/

To: [email protected]
To: [email protected]
To: [email protected]

Cc Huan Zhou <[email protected]>
Cc Tom Rini <[email protected]>
Cc Tim Ouyang <[email protected]>
Cc Leo Liang <[email protected]>
Cc Raymond Mao <[email protected]>
Cc Peng Fan <[email protected]>
Cc Jaehoon Chung <[email protected]>
Cc Bhimeswararao Matsa <[email protected]>
Cc Tanmay Kathpalia <[email protected]>
Cc Kaustabh Chakraborty <[email protected]>
Cc Han Xu <[email protected]>
Cc Yanir Levin <[email protected]>
Cc Christoph Stoidner <[email protected]>
Cc Balsundar Ponnusamy <[email protected]>
Cc Daniel Palmer <[email protected]>
Cc Anshul Dalal <[email protected]>
Cc Bastien Curutchet <[email protected]>
Cc Angelo Dureghello <[email protected]>
Cc Johan Jonker <[email protected]>
Cc Sam Protsenko <[email protected]>
Cc Guodong Xu <[email protected]>
Cc Yao Zi <[email protected]>
Cc Rick Chen <[email protected]>

---
Eric Chung (11):
spacemit: k1: select boot device via config registers
pinctrl: k1: fix drive strength configuration
pinctrl: k1: fix pull-up/pull-down configuration
pinctrl: k1: add IO power domain configuration support
mmc: k1: add sdhci platform driver
dts: k1: add SD card support in u-boot overlay
configs: k1: enable SD and eMMC support
MAINTAINER: update Spacemit K1 entry
doc: spacemit: flash on K1 SoC based boards
config: k1: enable ENV support for eMMC
spacemit: k1: load product name from environment variable

 arch/riscv/dts/k1-bananapi-f3-u-boot.dtsi |  91 +++-
 arch/riscv/dts/k1-musepi-pro-u-boot.dtsi  |  86 +++-
 board/spacemit/k1/MAINTAINERS             |   5 +-
 board/spacemit/k1/spl.c                   | 160 ++++---
 configs/spacemit_k1_defconfig             |  27 +-
 doc/board/spacemit/index.rst              |   1 +
 doc/board/spacemit/k1-mmc.rst             | 320 ++++++++++++++
 drivers/mmc/Kconfig                       |   7 +
 drivers/mmc/Makefile                      |   1 +
 drivers/mmc/spacemit_sdhci.c              | 673 ++++++++++++++++++++++++++++++
 drivers/pinctrl/spacemit/Kconfig          |   2 +-
 drivers/pinctrl/spacemit/pinctrl-k1.c     | 118 +++++-
 12 files changed, 1422 insertions(+), 69 deletions(-)

---
base-commit: b635d43bca429500cb8ef20aa151cb5773b9a8a5
change-id: 20260629-m4-98e01659fefb

Best regards,

Signature · 1 line
Eric Chung <[email protected]>
author
#1 lore raw

PATCH v6 1/11 spacemit: k1: select boot device via config registers

Add logic to determine the current boot device by reading the SoC's configuration registers, rather than using a hardcoded default.

---
v5:
- Add blank lines around the switch statement.
v2:
- Use FIELD_GET() to parse boot strap mode.
- Remove comments on hacking. Since the sequence between eMMC and SD device is exchanged in the upstream DTS. So it isn't a hacking any more.

---
 board/spacemit/k1/spl.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 70 insertions(+), 1 deletion(-)
board/spacemit/k1/spl.c +70 -1
index d749e21a2d5..613e8c4cf02 100644
@@ -13,6 +13,7 @@
 #include <dm/device.h>
 #include <dm/uclass.h>
 #include <i2c.h>
+#include <linux/bitfield.h>
 #include <linux/ctype.h>
 #include <linux/delay.h>
 #include <log.h>
@@ -22,6 +23,17 @@
 #include <tlv_eeprom.h>
 #include "tlv_codes.h"
 
+/* boot mode configs */
+#define BOOT_DEV_FLAG_REG	0xd4282d10
+#define BOOT_PIN_SEL_REG	0xd4282c20
+
+#define BOOT_STRAP_MODE_OFFSET	9
+#define BOOT_STRAP_MODE_MASK	3
+#define BOOT_STRAP_MODE_EMMC	0
+#define BOOT_STRAP_MODE_SPI	1
+#define BOOT_STRAP_MODE_NAND	2
+#define BOOT_STRAP_MODE_SD	3
+
 #define MUX_MODE4		4
 #define EDGE_NONE		BIT(6)
 #define PULL_UP			(6 << 13)       /* bit[15:13] 110 */
@@ -46,6 +58,17 @@ typedef void (*puts_func_t)(const char *s);
 typedef int (*ddr_init_func_t)(u64 ddr_base, u32 cs_num, u32 data_rate,
 			       puts_func_t puts);
 
+enum board_boot_mode {
+	BOOT_MODE_NONE = 0,
+	BOOT_MODE_USB = 0x55a,
+	BOOT_MODE_EMMC,
+	BOOT_MODE_NAND,
+	BOOT_MODE_SPI,
+	BOOT_MODE_SD,
+	BOOT_MODE_SHELL = 0x55f,
+	BOOT_MODE_BOOTSTRAP,
+};
+
 struct ddr_cfg {
 	u32     data_rate;
 	u32     cs_num;
@@ -354,7 +377,53 @@ void board_init_f(ulong dummy)
 
 u32 spl_boot_device(void)
 {
-	return BOOT_DEVICE_SPI;
+	void __iomem *boot_dev = (void __iomem *)BOOT_DEV_FLAG_REG;
+	void __iomem *boot_strap = (void __iomem *)BOOT_PIN_SEL_REG;
+	u32 mode, sel, ret = 0;
+
+	mode = readl(boot_dev);
+	if (mode == BOOT_MODE_NONE || mode > BOOT_MODE_SD) {
+		sel = FIELD_GET(BOOT_STRAP_MODE_MASK << BOOT_STRAP_MODE_OFFSET,
+				readl(boot_strap));
+		switch (sel) {
+		case BOOT_STRAP_MODE_EMMC:
+			mode = BOOT_MODE_EMMC;
+			break;
+		case BOOT_STRAP_MODE_NAND:
+			mode = BOOT_MODE_NAND;
+			break;
+		case BOOT_STRAP_MODE_SPI:
+			mode = BOOT_MODE_SPI;
+			break;
+		case BOOT_STRAP_MODE_SD:
+		default:
+			mode = BOOT_MODE_SD;
+			break;
+		}
+	}
+
+	switch (mode) {
+	case BOOT_MODE_EMMC:
+		ret = BOOT_DEVICE_MMC1;
+		break;
+	case BOOT_MODE_NAND:
+		ret = BOOT_DEVICE_NAND;
+		break;
+	case BOOT_MODE_SPI:
+		ret = BOOT_DEVICE_SPI;
+		break;
+	case BOOT_MODE_USB:
+		ret = BOOT_DEVICE_USB;
+		break;
+	case BOOT_MODE_SD:
+		ret = BOOT_DEVICE_MMC2;
+		break;
+	default:
+		ret = BOOT_DEVICE_MMC1;
+		break;
+	}
+
+	return ret;
 }
 
 void spl_board_init(void)
Signature · 1 line
2.51.0
author
#2 lore raw

PATCH v6 2/11 pinctrl: k1: fix drive strength configuration

In reply to Eric Chung

Fix drive strength configuration by:
- Using FIELD_PREP() to properly set the PAD_DRIVE mask bits
- Not overriding io_type with IO_TYPE_EXTERNAL for external pins
- Returning the pin number instead of 0 from pinmux_property_set
- Removing redundant zero-initialization of the mask variable

---
v6:
- Fix drive strength configuration.

---
 drivers/pinctrl/spacemit/pinctrl-k1.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/pinctrl/spacemit/pinctrl-k1.c +8 -4
index a6a22eacac7..6ed511879da 100644
@@ -9,6 +9,7 @@
 #include <dm/device_compat.h>
 #include <dm/pinctrl.h>
 #include <dm/read.h>
+#include <linux/bitfield.h>
 #include <linux/bitops.h>
 #include <linux/errno.h>
 #include <linux/io.h>
@@ -386,10 +387,12 @@ static int spacemit_pinmux_set(struct udevice *dev, unsigned int pin,
 static int spacemit_pinmux_property_set(struct udevice *dev, u32 pinmux_group)
 {
 	u32 pin, mux;
+	int ret;
 
 	pin = spacemit_dt_get_pin(pinmux_group);
 	mux = spacemit_dt_get_pin_mux(pinmux_group);
-	return spacemit_pinmux_set(dev, pin, mux);
+	ret = spacemit_pinmux_set(dev, pin, mux);
+	return ret ? ret : pin;
 }
 
 static const struct pinconf_param spacemit_pinconf_params[] = {
@@ -406,7 +409,7 @@ static int spacemit_pinconf_set(struct udevice *dev, unsigned int pin_selector,
 	struct spacemit_pinctrl_data *data;
 	struct spacemit_pinctrl_priv *priv = dev_get_priv(dev);
 	void __iomem *addr;
-	u32 mask = 0;
+	u32 mask;
 	unsigned int io_type;
 	u8 ds;
 	bool found;
@@ -433,7 +436,8 @@ static int spacemit_pinconf_set(struct udevice *dev, unsigned int pin_selector,
 		for (i = 0; i < priv->nr_io_pins; i++) {
 			if (priv->io_pins[i].pin != pin_selector)
 				continue;
-			io_type = priv->io_pins[i].io_type;
+			if (priv->io_pins[i].io_type != IO_TYPE_EXTERNAL)
+				io_type = priv->io_pins[i].io_type;
 			break;
 		}
 		if (io_type != IO_TYPE_3V3 && io_type != IO_TYPE_1V8) {
@@ -441,7 +445,7 @@ static int spacemit_pinconf_set(struct udevice *dev, unsigned int pin_selector,
 			return -EINVAL;
 		}
 		ds = spacemit_get_drive_strength(io_type, argument);
-		clrsetbits_le32(addr, PAD_DRIVE, ds);
+		clrsetbits_le32(addr, PAD_DRIVE, FIELD_PREP(PAD_DRIVE, ds));
 		break;
 	case PIN_CONFIG_POWER_SOURCE:
 		for (i = 0, found = false; i < priv->nr_io_pins; i++) {
Signature · 1 line
2.51.0
author
#3 lore raw

PATCH v6 3/11 pinctrl: k1: fix pull-up/pull-down configuration

In reply to Eric Chung

Fix pull-up/pull-down configuration to honor the argument parameter:
when argument is non-zero, enable the requested pull direction; when argument is zero, clear all pull bits to disable.

---
v6:
- Fix pull-up/pull-down configuration.

---
 drivers/pinctrl/spacemit/pinctrl-k1.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/pinctrl/spacemit/pinctrl-k1.c +8 -2
index 6ed511879da..454bc307ba3 100644
@@ -425,11 +425,17 @@ static int spacemit_pinconf_set(struct udevice *dev, unsigned int pin_selector,
 		break;
 	case PIN_CONFIG_BIAS_PULL_DOWN:
 		mask = PAD_PULLDOWN | PAD_PULLUP | PAD_PULL_EN;
-		clrsetbits_le32(addr, mask, PAD_PULLDOWN | PAD_PULL_EN);
+		if (argument)
+			clrsetbits_le32(addr, mask, PAD_PULLDOWN | PAD_PULL_EN);
+		else
+			clrbits_le32(addr, PAD_PULLDOWN | PAD_PULL_EN);
 		break;
 	case PIN_CONFIG_BIAS_PULL_UP:
 		mask = PAD_PULLDOWN | PAD_PULLUP | PAD_PULL_EN;
-		clrsetbits_le32(addr, mask, PAD_PULLUP | PAD_PULL_EN);
+		if (argument)
+			clrsetbits_le32(addr, mask, PAD_PULLUP | PAD_PULL_EN);
+		else
+			clrbits_le32(addr, PAD_PULLUP | PAD_PULL_EN);
 		break;
 	case PIN_CONFIG_DRIVE_STRENGTH:
 		io_type = IO_TYPE_1V8;
Signature · 1 line
2.51.0
#4 lore raw

Re: [PATCH v6 03/11] pinctrl: k1: fix pull-up/pull-down configuration

Quoted 3 lines · Eric Chung

Fix pull-up/pull-down configuration to honor the argument parameter:
when argument is non-zero, enable the requested pull direction; when argument is zero, clear all pull bits to disable.

Since this is a bug in a patch that hasn't been merged, please fix it in place and re-spin the pinctrl/GPIO/SPI-NOR series.

Quoted 14 lines

---
v6:
- Fix pull-up/pull-down configuration.

---
 drivers/pinctrl/spacemit/pinctrl-k1.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/pinctrl/spacemit/pinctrl-k1.c +0 -0
index 6ed511879da..454bc307ba3 100644

drivers/pinctrl/spacemit/pinctrl-k1.c static int spacemit_pinconf_set(struct udevice *dev, unsigned int pin_selector, · line 431

Quoted 8 lines
drivers/pinctrl/spacemit/pinctrl-k1.c +4 -1
@@ -425,11 +425,17 @@ static int spacemit_pinconf_set(struct udevice *dev, unsigned int pin_selector,
 		break;
 	case PIN_CONFIG_BIAS_PULL_DOWN:
 		mask = PAD_PULLDOWN | PAD_PULLUP | PAD_PULL_EN;
-		clrsetbits_le32(addr, mask, PAD_PULLDOWN | PAD_PULL_EN);
+		if (argument)
+			clrsetbits_le32(addr, mask, PAD_PULLDOWN | PAD_PULL_EN);
+		else
+			clrbits_le32(addr, PAD_PULLDOWN | PAD_PULL_EN);

This could be simplified as

	clrsetbits_le32(addr, PAD_PULLDOWN | PAD_PULLUP | PAD_PULL_EN,
			      argument ? PAD_PULLDOWN | PAD_PULL_EN : 0);

similar for the pull-up case.

Quoted 15 lines
drivers/pinctrl/spacemit/pinctrl-k1.c +4 -1
 		break;
 	case PIN_CONFIG_BIAS_PULL_UP:
 		mask = PAD_PULLDOWN | PAD_PULLUP | PAD_PULL_EN;
-		clrsetbits_le32(addr, mask, PAD_PULLUP | PAD_PULL_EN);
+		if (argument)
+			clrsetbits_le32(addr, mask, PAD_PULLUP | PAD_PULL_EN);
+		else
+			clrbits_le32(addr, PAD_PULLUP | PAD_PULL_EN);
 		break;
 	case PIN_CONFIG_DRIVE_STRENGTH:
 		io_type = IO_TYPE_1V8;
Signature · 2 lines
-- 
2.51.0

Best regards,
Yao Zi

#5 lore raw

Re: [PATCH v6 03/11] pinctrl: k1: fix pull-up/pull-down configuration

Quoted 7 lines · Yao Zi
Quoted 3 lines · Eric Chung

Fix pull-up/pull-down configuration to honor the argument parameter:
when argument is non-zero, enable the requested pull direction; when argument is zero, clear all pull bits to disable.

Since this is a bug in a patch that hasn't been merged, please fix it in place and re-spin the pinctrl/GPIO/SPI-NOR series.

Oops, I forgot lore is out of synchronization now. Checked U-Boot main again and it seems the pinctrl driver is already here. Please ignore this comment.

Best regards,
Yao Zi

Quoted 1 line
Quoted 1 line
author
#6 lore raw

PATCH v6 4/11 pinctrl: k1: add IO power domain configuration support

In reply to Eric Chung

Dual-voltage GPIO banks default to 3.3V, but when externally supplied with 1.8V the internal logic must be explicitly reconfigured to match.

Add the ability to program IO power domain control registers through the APBC block. These registers require unlocking the AIB Secure Access Register (ASAR) before every read/write, since configuring a 1.8V domain while 3.3V is externally supplied can cause back-powering and pin damage.

---
v6:
- Use dev_read_phandle_with_args() to fetch "spacemit,apbc" instead. v5:
- Use tabs for macro definition alignment.
- Fix the missing power source argument.
v3:
- Add SYSCON dependency in Kconfig.
- Fix not sorted issue in the driver.

---
 drivers/pinctrl/spacemit/Kconfig      |  2 +-
 drivers/pinctrl/spacemit/pinctrl-k1.c | 96 +++++++++++++++++++++++++++++++++--
 2 files changed, 94 insertions(+), 4 deletions(-)
drivers/pinctrl/spacemit/Kconfig +1 -1
index 6aab89e160c..ff754f5839c 100644
@@ -1,6 +1,6 @@
 config PINCTRL_SPACEMIT_K1
 	bool "Spacemit K1 SoC pinctrl driver"
-	depends on PINCTRL_GENERIC && DM
+	depends on PINCTRL_GENERIC && DM && SYSCON
 	help
 	  Supports pin multiplexing control on Spacemit K1 SoCs.
 
drivers/pinctrl/spacemit/pinctrl-k1.c +93 -3

165 lines not on this page · raw message

Signature · 1 line
2.51.0
#7 lore raw

Re: [PATCH v6 04/11] pinctrl: k1: add IO power domain configuration support

Hi Eric,

I wasn't included in the To/Cc list, and lore has not been working properly recently, so I had some difficulty replying to this thread.

drivers/pinctrl/spacemit/Kconfig line 3

Quoted 2 lines
drivers/pinctrl/spacemit/Kconfig +1 -1
-	depends on PINCTRL_GENERIC && DM
+	depends on PINCTRL_GENERIC && DM && SYSCON

Since v6 uses dev_read_phandle_with_args() followed by regmap_init_mem(), the driver no longer uses the syscon uclass or any syscon_* API. Therefore, the SYSCON dependency is unnecessary.

drivers/pinctrl/spacemit/pinctrl-k1.c line 17

Quoted 2 lines
drivers/pinctrl/spacemit/pinctrl-k1.c +2 -0
+#include <regmap.h>
+#include <syscon.h>

This include is unnecessary as well.

Best regards,
Junhui

author
#8 lore raw

PATCH v6 5/11 mmc: k1: add sdhci platform driver

In reply to Eric Chung

Add SDHCI platform driver support for SpacemiT K1 SoC. This driver implements the necessary platform-specific operations for the SDHCI controller, enabling MMC/SD card functionality on K1-based platforms.

---
v6:
- Remove ".data = 0" in spacemit_sdhci_ids[].
v5:
- Remove MMC_CAP_CMD23 as the CMD23 support is now a separate series.
- Use tabs for macro definition alignment.
- Use read_poll_timeout().
- Set pinctrl state based on selected timing mode.
- Add the definition of SDHC_DLL_REG1_HS400_VAL.
- Remove the condition based on quirks.
v4:
- Add bulk release operations on reset and clock.
v3:
- Enable CMD23 in capability.
v2:
- Enable ADMA mode support.
- Use CMD23 for multi-block read/write.
- Move ASR/AIB register into pinctrl driver.
- Correct pinctrl state from "fast" to "uhs".
- Migrate tuning support from the spacemit linux driver.

---
 drivers/mmc/Kconfig          |   7 +
 drivers/mmc/Makefile         |   1 +
 drivers/mmc/spacemit_sdhci.c | 673 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 681 insertions(+)
drivers/mmc/Kconfig +7 -0
index f9f7aa5cf97..b991a5931c0 100644
@@ -722,6 +722,13 @@ config MMC_SDHCI_SNPS
 
 	  If unsure, say N.
 
+config MMC_SDHCI_SPACEMIT
+	bool "Spacemit SDHCI controller"
+	depends on MMC_SDHCI
+	help
+	  Support for Secure Digital Host Controller Interface (SDHCI) on
+	  Spacemit K1 SoC.
+
 config MMC_SDHCI_STI
 	bool "SDHCI support for STMicroelectronics SoC"
 	depends on MMC_SDHCI && OF_CONTROL && ARCH_STI
drivers/mmc/Makefile +1 -0
index a23336d7d8d..aa05cec23be 100644
@@ -71,6 +71,7 @@ obj-$(CONFIG_MMC_SDHCI_ROCKCHIP)	+= rockchip_sdhci.o
 obj-$(CONFIG_MMC_SDHCI_ADI)		+= adi_sdhci.o
 obj-$(CONFIG_MMC_SDHCI_S5P)		+= s5p_sdhci.o
 obj-$(CONFIG_MMC_SDHCI_SNPS)		+= snps_sdhci.o
+obj-$(CONFIG_MMC_SDHCI_SPACEMIT)	+= spacemit_sdhci.o
 obj-$(CONFIG_MMC_SDHCI_STI)		+= sti_sdhci.o
 obj-$(CONFIG_MMC_SDHCI_TANGIER)		+= tangier_sdhci.o
 obj-$(CONFIG_MMC_SDHCI_TEGRA)		+= tegra_mmc.o
drivers/mmc/spacemit_sdhci.c new file +673 -0

673 lines not on this page · raw message

Signature · 1 line
2.51.0
author
#9 lore raw

PATCH v6 6/11 dts: k1: add SD card support in u-boot overlay

In reply to Eric Chung

Add the SDH0 controller node and its pinctrl groups to the u-boot overlay. The upstream DTS only contains the eMMC node; the SD card controller (sdhci@d4280000) and its MMC1 pinctrl configuration are missing. Place the new node inside the storage-bus via path-based merge so it inherits the dma-ranges from the parent bus.

---
v5:
- Append power source field on eMMC/SD pinctrl.
v3:
- Fix SD pinctrl as uhs.
v2:
- Use vmmc-supply as vqmmc-supply on SD node.
- Add alias of mmc0 and mmc1.

---
 arch/riscv/dts/k1-bananapi-f3-u-boot.dtsi | 91 ++++++++++++++++++++++++++++++-
 arch/riscv/dts/k1-musepi-pro-u-boot.dtsi  | 86 ++++++++++++++++++++++++++++-
 2 files changed, 173 insertions(+), 4 deletions(-)
arch/riscv/dts/k1-bananapi-f3-u-boot.dtsi +89 -2
index 7f9443d6951..4823cbc1f33 100644
@@ -6,6 +6,11 @@
 #include "binman.dtsi"
 
 / {
+	aliases {
+		mmc0 = &emmc;
+		mmc1 = &sdhci0;
+	};
+
 	memory@0 {
 		device_type = "memory";
 		reg = <0x00000000 0x00000000 0x00000000 0x80000000>;
@@ -76,12 +81,14 @@
 				bootph-pre-ram;
 			};
 
-			buck3 {
+			buck3_1v8: buck3 {
 				regulator-name = "vdd_1v8";
 				bootph-pre-ram;
 			};
 
-			aldo1 {
+			buck4_3v3: buck4 { };
+
+			aldo1: aldo1 {
 				regulator-name = "vdd_1v8_mmc";
 				bootph-pre-ram;
 			};
@@ -89,6 +96,86 @@
 	};
 };
 
+/ {
+	soc {
+		storage-bus {
+			sdhci0: mmc@d4280000 {
+				bootph-pre-ram;
+				compatible = "spacemit,k1-sdhci";
+				reg = <0x0 0xd4280000 0x0 0x200>;
+				clocks = <&syscon_apmu CLK_SDH_AXI>,
+					 <&syscon_apmu CLK_SDH0>;
+				clock-names = "core", "io";
+				interrupts = <99>;
+				resets = <&syscon_apmu RESET_SDH_AXI>,
+					 <&syscon_apmu RESET_SDH0>;
+				reset-names = "sdh_axi", "sdh0";
+				bus-width = <4>;
+				max-frequency = <204800000>;
+				cd-gpios = <&gpio K1_GPIO(80) GPIO_ACTIVE_LOW>;
+				pinctrl-names = "default", "uhs";
+				pinctrl-0 = <&sdhci0_0_cfg>;
+				pinctrl-1 = <&sdhci0_1_cfg>;
+				status = "okay";
+			};
+		};
+	};
+};
+
+/* SD card pinctrl groups -- not present in upstream k1-pinctrl.dtsi */
+&pinctrl {
+	sdhci0_0_cfg: sdhci0-0-cfg {
+		grp_cmd_data {
+			pinmux = <K1_PADCONF(104, 0)>,  /* MMC1_DAT3 */
+				 <K1_PADCONF(105, 0)>,  /* MMC1_DAT2 */
+				 <K1_PADCONF(106, 0)>,  /* MMC1_DAT1 */
+				 <K1_PADCONF(107, 0)>,  /* MMC1_DAT0 */
+				 <K1_PADCONF(108, 0)>;  /* MMC1_CMD */
+			bias-pull-up = <1>;
+			drive-strength = <19>;
+			power-source = <3300>;
+		};
+		grp_clk {
+			pinmux = <K1_PADCONF(109, 0)>;  /* MMC1_CLK */
+			bias-pull-down = <1>;
+			drive-strength = <19>;
+			power-source = <3300>;
+		};
+	};
+
+	sdhci0_1_cfg: sdhci0-1-cfg {			/* uhs */
+		grp_cmd_data {
+			pinmux = <K1_PADCONF(104, 0)>,  /* MMC1_DAT3 */
+				 <K1_PADCONF(105, 0)>,  /* MMC1_DAT2 */
+				 <K1_PADCONF(106, 0)>,  /* MMC1_DAT1 */
+				 <K1_PADCONF(107, 0)>,  /* MMC1_DAT0 */
+				 <K1_PADCONF(108, 0)>;  /* MMC1_CMD */
+			bias-pull-up = <1>;
+			drive-strength = <42>;
+			power-source = <1800>;
+		};
+		grp_clk {
+			pinmux = <K1_PADCONF(109, 0)>;  /* MMC1_CLK */
+			bias-pull-down = <1>;
+			drive-strength = <42>;
+			power-source = <1800>;
+		};
+	};
+};
+
+&emmc {
+	bootph-pre-ram;
+	resets = <&syscon_apmu RESET_SDH_AXI>, <&syscon_apmu RESET_SDH2>;
+	reset-names = "sdh_axi", "sdh2";
+	vqmmc-supply = <&buck3_1v8>;
+	vmmc-supply = <&aldo1>;
+	max-frequency = <204800000>;
+};
+
+&sdhci0 {
+	vmmc-supply = <&buck4_3v3>;
+};
+
 &binman {
 	u-boot-spl-ddr {
 		type = "section";
arch/riscv/dts/k1-musepi-pro-u-boot.dtsi +84 -2

110 lines not on this page · raw message

Signature · 1 line
2.51.0
#10 lore raw

Re: [PATCH v6 06/11] dts: k1: add SD card support in u-boot overlay

Quoted 7 lines · Eric Chung

Add the SDH0 controller node and its pinctrl groups to the u-boot overlay. The upstream DTS only contains the eMMC node; the SD card controller (sdhci@d4280000) and its MMC1 pinctrl configuration are missing. Place the new node inside the storage-bus via path-based merge so it inherits the dma-ranges from the parent bus.

Please cherry-pick upstream devicetree changes from Linux upstream with tools/update-subtree.sh instead of adding our own copies. Changes for k1-bananapi-f3 and k1-muse-pi-pro have both landed in Linux v7.2.

Best regards,
Yao Zi

Quoted 12 lines

---
v5:
- Append power source field on eMMC/SD pinctrl.
v3:
- Fix SD pinctrl as uhs.
v2:
- Use vmmc-supply as vqmmc-supply on SD node.
- Add alias of mmc0 and mmc1.

---
 arch/riscv/dts/k1-bananapi-f3-u-boot.dtsi | 91 ++++++++++++++++++++++++++++++-
 arch/riscv/dts/k1-musepi-pro-u-boot.dtsi  | 86 ++++++++++++++++++++++++++++-
 2 files changed, 173 insertions(+), 4 deletions(-)
author
#11 lore raw

Re: [PATCH v6 06/11] dts: k1: add SD card support in u-boot overlay

Hi Yao,

I'm not familiar with the policy for syncing DTS files from the Linux upstream. Could you clarify how this script works?

Does it sync all DTS files from Linux upstream at once, or is it possible to sync
only the Spacemit DTS file?

If I choose to sync only the Spacemit DTS file and include it in my patch set, would that cause conflicts later when others try to sync all DTS files?

Best Regards
Eric

Quoted 29 lines · Yao Zi
Quoted 7 lines · Eric Chung

Add the SDH0 controller node and its pinctrl groups to the u-boot overlay. The upstream DTS only contains the eMMC node; the SD card controller (sdhci@d4280000) and its MMC1 pinctrl configuration are missing. Place the new node inside the storage-bus via path-based merge so it inherits the dma-ranges from the parent bus.

Please cherry-pick upstream devicetree changes from Linux upstream with tools/update-subtree.sh instead of adding our own copies. Changes for k1-bananapi-f3 and k1-muse-pi-pro have both landed in Linux v7.2.

Best regards,
Yao Zi

Quoted 12 lines

---
v5:
- Append power source field on eMMC/SD pinctrl.
v3:
- Fix SD pinctrl as uhs.
v2:
- Use vmmc-supply as vqmmc-supply on SD node.
- Add alias of mmc0 and mmc1.

---
 arch/riscv/dts/k1-bananapi-f3-u-boot.dtsi | 91 ++++++++++++++++++++++++++++++-
 arch/riscv/dts/k1-musepi-pro-u-boot.dtsi  | 86 ++++++++++++++++++++++++++++-
 2 files changed, 173 insertions(+), 4 deletions(-)
#12 lore raw

Re: [PATCH v6 06/11] dts: k1: add SD card support in u-boot overlay

Quoted 8 lines · Eric Chung

Hi Yao,

I'm not familiar with the policy for syncing DTS files from the Linux upstream. Could you clarify how this script works?

Does it sync all DTS files from Linux upstream at once, or is it possible to sync
only the Spacemit DTS file?

update-subtree.sh cherry-picks a commit from the upstream, or merge an upstream tag into the subtree. Cherry-picking SD-related commits from Linux upstream suits for your case.

Quoted 2 lines

If I choose to sync only the Spacemit DTS file and include it in my patch set, would that cause conflicts later when others try to sync all DTS files?

Tom synchronizes the dts subtree with Linux upstream irregularly, there should be no conflict or relatively small ones if you cherry-pick the changes, while adding downstream nodes in *-u-boot.dtsi might suffer from duplication, too, during synchronization.

Quoted 2 lines

Best Regards
Eric

By the way, please avoid top-posting if possible.

Thanks,
Yao Zi

Quoted 30 lines · Yao Zi
Quoted 29 lines · Eric Chung
Quoted 7 lines

Add the SDH0 controller node and its pinctrl groups to the u-boot overlay. The upstream DTS only contains the eMMC node; the SD card controller (sdhci@d4280000) and its MMC1 pinctrl configuration are missing. Place the new node inside the storage-bus via path-based merge so it inherits the dma-ranges from the parent bus.

Please cherry-pick upstream devicetree changes from Linux upstream with tools/update-subtree.sh instead of adding our own copies. Changes for k1-bananapi-f3 and k1-muse-pi-pro have both landed in Linux v7.2.

Best regards,
Yao Zi

Quoted 12 lines

---
v5:
- Append power source field on eMMC/SD pinctrl.
v3:
- Fix SD pinctrl as uhs.
v2:
- Use vmmc-supply as vqmmc-supply on SD node.
- Add alias of mmc0 and mmc1.

---
 arch/riscv/dts/k1-bananapi-f3-u-boot.dtsi | 91 ++++++++++++++++++++++++++++++-
 arch/riscv/dts/k1-musepi-pro-u-boot.dtsi  | 86 ++++++++++++++++++++++++++++-
 2 files changed, 173 insertions(+), 4 deletions(-)
author
#13 lore raw

Re: [PATCH v6 06/11] dts: k1: add SD card support in u-boot overlay

Quoted 15 lines · Yao Zi
Quoted 8 lines · Eric Chung

Hi Yao,

I'm not familiar with the policy for syncing DTS files from the Linux upstream. Could you clarify how this script works?

Does it sync all DTS files from Linux upstream at once, or is it possible to sync
only the Spacemit DTS file?

update-subtree.sh cherry-picks a commit from the upstream, or merge an upstream tag into the subtree. Cherry-picking SD-related commits from Linux upstream suits for your case.

Quoted 8 lines
Quoted 2 lines

If I choose to sync only the Spacemit DTS file and include it in my patch set, would that cause conflicts later when others try to sync all DTS files?

Tom synchronizes the dts subtree with Linux upstream irregularly, there should be no conflict or relatively small ones if you cherry-pick the changes, while adding downstream nodes in *-u-boot.dtsi might suffer from duplication, too, during synchronization.

The process is a bit complex. Since my main issue is that the DTS files are out of
date, would it be simpler if I just copy the relevant Spacemit DTS files directly
from the Linux upstream into the dts/upstream folder?

Quoted 38 lines
Quoted 2 lines

Best Regards
Eric

By the way, please avoid top-posting if possible.

Thanks,
Yao Zi

Quoted 30 lines · Yao Zi
Quoted 29 lines · Eric Chung
Quoted 7 lines

Add the SDH0 controller node and its pinctrl groups to the u-boot overlay. The upstream DTS only contains the eMMC node; the SD card controller (sdhci@d4280000) and its MMC1 pinctrl configuration are missing. Place the new node inside the storage-bus via path-based merge so it inherits the dma-ranges from the parent bus.

Please cherry-pick upstream devicetree changes from Linux upstream with tools/update-subtree.sh instead of adding our own copies. Changes for k1-bananapi-f3 and k1-muse-pi-pro have both landed in Linux v7.2.

Best regards,
Yao Zi

Quoted 12 lines

---
v5:
- Append power source field on eMMC/SD pinctrl.
v3:
- Fix SD pinctrl as uhs.
v2:
- Use vmmc-supply as vqmmc-supply on SD node.
- Add alias of mmc0 and mmc1.

---
 arch/riscv/dts/k1-bananapi-f3-u-boot.dtsi | 91 ++++++++++++++++++++++++++++++-
 arch/riscv/dts/k1-musepi-pro-u-boot.dtsi  | 86 ++++++++++++++++++++++++++++-
 2 files changed, 173 insertions(+), 4 deletions(-)
#14 lore raw

Re: [PATCH v6 06/11] dts: k1: add SD card support in u-boot overlay

Quoted 25 lines · Eric Chung
Quoted 15 lines · Yao Zi
Quoted 8 lines · Eric Chung

Hi Yao,

I'm not familiar with the policy for syncing DTS files from the Linux upstream. Could you clarify how this script works?

Does it sync all DTS files from Linux upstream at once, or is it possible to sync
only the Spacemit DTS file?

update-subtree.sh cherry-picks a commit from the upstream, or merge an upstream tag into the subtree. Cherry-picking SD-related commits from Linux upstream suits for your case.

Quoted 8 lines
Quoted 2 lines

If I choose to sync only the Spacemit DTS file and include it in my patch set, would that cause conflicts later when others try to sync all DTS files?

Tom synchronizes the dts subtree with Linux upstream irregularly, there should be no conflict or relatively small ones if you cherry-pick the changes, while adding downstream nodes in *-u-boot.dtsi might suffer from duplication, too, during synchronization.

Quoted 5 lines

The process is a bit complex. Since my main issue is that the DTS files are out of
date, would it be simpler if I just copy the relevant Spacemit DTS files directly
from the Linux upstream into the dts/upstream folder?

The answer is simply no.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Best Regards
Eric

Regards,
Yao Zi

Quoted 35 lines
Quoted 35 lines

By the way, please avoid top-posting if possible.

Thanks,
Yao Zi

Quoted 30 lines · Yao Zi
Quoted 29 lines · Eric Chung
Quoted 7 lines

Add the SDH0 controller node and its pinctrl groups to the u-boot overlay. The upstream DTS only contains the eMMC node; the SD card controller (sdhci@d4280000) and its MMC1 pinctrl configuration are missing. Place the new node inside the storage-bus via path-based merge so it inherits the dma-ranges from the parent bus.

Please cherry-pick upstream devicetree changes from Linux upstream with tools/update-subtree.sh instead of adding our own copies. Changes for k1-bananapi-f3 and k1-muse-pi-pro have both landed in Linux v7.2.

Best regards,
Yao Zi

Quoted 12 lines

---
v5:
- Append power source field on eMMC/SD pinctrl.
v3:
- Fix SD pinctrl as uhs.
v2:
- Use vmmc-supply as vqmmc-supply on SD node.
- Add alias of mmc0 and mmc1.

---
 arch/riscv/dts/k1-bananapi-f3-u-boot.dtsi | 91 ++++++++++++++++++++++++++++++-
 arch/riscv/dts/k1-musepi-pro-u-boot.dtsi  | 86 ++++++++++++++++++++++++++++-
 2 files changed, 173 insertions(+), 4 deletions(-)
author
#15 lore raw

Re: [PATCH v6 06/11] dts: k1: add SD card support in u-boot overlay

Quoted 27 lines · Yao Zi
Quoted 25 lines · Eric Chung
Quoted 23 lines · Yao Zi
Quoted 8 lines · Eric Chung

Hi Yao,

I'm not familiar with the policy for syncing DTS files from the Linux upstream. Could you clarify how this script works?

Does it sync all DTS files from Linux upstream at once, or is it possible to sync
only the Spacemit DTS file?

update-subtree.sh cherry-picks a commit from the upstream, or merge an upstream tag into the subtree. Cherry-picking SD-related commits from Linux upstream suits for your case.

Quoted 2 lines

If I choose to sync only the Spacemit DTS file and include it in my patch set, would that cause conflicts later when others try to sync all DTS files?

Tom synchronizes the dts subtree with Linux upstream irregularly, there should be no conflict or relatively small ones if you cherry-pick the changes, while adding downstream nodes in *-u-boot.dtsi might suffer from duplication, too, during synchronization.

Quoted 8 lines
Quoted 5 lines

The process is a bit complex. Since my main issue is that the DTS files are out of
date, would it be simpler if I just copy the relevant Spacemit DTS files directly
from the Linux upstream into the dts/upstream folder?

The answer is simply no.

OK. I'll keep using my own overlay DTS file.
I tried upstream DTS file. It only gave me more bugs. I could switch to upstream DTS file when Tom syncs it.

Quoted 41 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Best Regards
Eric

Regards,
Yao Zi

Quoted 35 lines
Quoted 35 lines

By the way, please avoid top-posting if possible.

Thanks,
Yao Zi

Quoted 30 lines · Yao Zi
Quoted 29 lines · Eric Chung
Quoted 7 lines

Add the SDH0 controller node and its pinctrl groups to the u-boot overlay. The upstream DTS only contains the eMMC node; the SD card controller (sdhci@d4280000) and its MMC1 pinctrl configuration are missing. Place the new node inside the storage-bus via path-based merge so it inherits the dma-ranges from the parent bus.

Please cherry-pick upstream devicetree changes from Linux upstream with tools/update-subtree.sh instead of adding our own copies. Changes for k1-bananapi-f3 and k1-muse-pi-pro have both landed in Linux v7.2.

Best regards,
Yao Zi

Quoted 12 lines

---
v5:
- Append power source field on eMMC/SD pinctrl.
v3:
- Fix SD pinctrl as uhs.
v2:
- Use vmmc-supply as vqmmc-supply on SD node.
- Add alias of mmc0 and mmc1.

---
 arch/riscv/dts/k1-bananapi-f3-u-boot.dtsi | 91 ++++++++++++++++++++++++++++++-
 arch/riscv/dts/k1-musepi-pro-u-boot.dtsi  | 86 ++++++++++++++++++++++++++++-
 2 files changed, 173 insertions(+), 4 deletions(-)
#16 lore raw

Re: [PATCH v6 06/11] dts: k1: add SD card support in u-boot overlay

Quoted 34 lines · Eric Chung
Quoted 33 lines · Yao Zi
Quoted 30 lines · Eric Chung
Quoted 15 lines · Yao Zi
Quoted 8 lines · Eric Chung

Hi Yao,

I'm not familiar with the policy for syncing DTS files from the Linux upstream. Could you clarify how this script works?

Does it sync all DTS files from Linux upstream at once, or is it possible to sync
only the Spacemit DTS file?

update-subtree.sh cherry-picks a commit from the upstream, or merge an upstream tag into the subtree. Cherry-picking SD-related commits from Linux upstream suits for your case.

Quoted 8 lines
Quoted 2 lines

If I choose to sync only the Spacemit DTS file and include it in my patch set, would that cause conflicts later when others try to sync all DTS files?

Tom synchronizes the dts subtree with Linux upstream irregularly, there should be no conflict or relatively small ones if you cherry-pick the changes, while adding downstream nodes in *-u-boot.dtsi might suffer from duplication, too, during synchronization.

The process is a bit complex. Since my main issue is that the DTS files are out of
date, would it be simpler if I just copy the relevant Spacemit DTS files directly
from the Linux upstream into the dts/upstream folder?

Quoted 6 lines
Quoted 2 lines

The answer is simply no.

OK. I'll keep using my own overlay DTS file.
I tried upstream DTS file. It only gave me more bugs. I could switch to upstream DTS file when Tom syncs it.

So first of all, please note switching to upstream devicetree doesn't mean you must remove all the dts overlays, you could keep small pieces like these adding bootph-pre-ram properties, which are bootloader-specific and might not get upstreamed in a short period.

And I noticed there have been quite a lot code in the overlays, like the PMIC code, thus changes to overlays might be huge when cherry-picking, if it's the case, this patch is then acceptable, but please mention it in the commit message.

But, if switching to the devicetree with cherry-picked patches for MMC leads to bugs, there are likely ABI compatibility issues in your driver, which would persist even after the synchronization with upstream v7.2 tag. Please fix them. From the very start, it's agreed compatibility with Linux devicetree ABI is important[1].

So here's my NAK for this series, including v7 of it.

Thanks,
Yao Zi

[1]: https://lore.kernel.org/all/20260429-glare-anybody-16c98d01184e@spud/

Quoted 41 lines
Quoted 41 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Best Regards
Eric

Regards,
Yao Zi

Quoted 35 lines
Quoted 35 lines

By the way, please avoid top-posting if possible.

Thanks,
Yao Zi

Quoted 30 lines · Yao Zi
Quoted 29 lines · Eric Chung
Quoted 7 lines

Add the SDH0 controller node and its pinctrl groups to the u-boot overlay. The upstream DTS only contains the eMMC node; the SD card controller (sdhci@d4280000) and its MMC1 pinctrl configuration are missing. Place the new node inside the storage-bus via path-based merge so it inherits the dma-ranges from the parent bus.

Please cherry-pick upstream devicetree changes from Linux upstream with tools/update-subtree.sh instead of adding our own copies. Changes for k1-bananapi-f3 and k1-muse-pi-pro have both landed in Linux v7.2.

Best regards,
Yao Zi

Quoted 12 lines

---
v5:
- Append power source field on eMMC/SD pinctrl.
v3:
- Fix SD pinctrl as uhs.
v2:
- Use vmmc-supply as vqmmc-supply on SD node.
- Add alias of mmc0 and mmc1.

---
 arch/riscv/dts/k1-bananapi-f3-u-boot.dtsi | 91 ++++++++++++++++++++++++++++++-
 arch/riscv/dts/k1-musepi-pro-u-boot.dtsi  | 86 ++++++++++++++++++++++++++++-
 2 files changed, 173 insertions(+), 4 deletions(-)
author
#17 lore raw

Re: [PATCH v6 06/11] dts: k1: add SD card support in u-boot overlay

Quoted 48 lines · Yao Zi
Quoted 34 lines · Eric Chung
Quoted 33 lines · Yao Zi
Quoted 30 lines · Eric Chung
Quoted 15 lines · Yao Zi
Quoted 8 lines · Eric Chung

Hi Yao,

I'm not familiar with the policy for syncing DTS files from the Linux upstream. Could you clarify how this script works?

Does it sync all DTS files from Linux upstream at once, or is it possible to sync
only the Spacemit DTS file?

update-subtree.sh cherry-picks a commit from the upstream, or merge an upstream tag into the subtree. Cherry-picking SD-related commits from Linux upstream suits for your case.

Quoted 8 lines
Quoted 2 lines

If I choose to sync only the Spacemit DTS file and include it in my patch set, would that cause conflicts later when others try to sync all DTS files?

Tom synchronizes the dts subtree with Linux upstream irregularly, there should be no conflict or relatively small ones if you cherry-pick the changes, while adding downstream nodes in *-u-boot.dtsi might suffer from duplication, too, during synchronization.

The process is a bit complex. Since my main issue is that the DTS files are out of
date, would it be simpler if I just copy the relevant Spacemit DTS files directly
from the Linux upstream into the dts/upstream folder?

Quoted 6 lines
Quoted 2 lines

The answer is simply no.

OK. I'll keep using my own overlay DTS file.
I tried upstream DTS file. It only gave me more bugs. I could switch to upstream DTS file when Tom syncs it.

So first of all, please note switching to upstream devicetree doesn't mean you must remove all the dts overlays, you could keep small pieces like these adding bootph-pre-ram properties, which are bootloader-specific and might not get upstreamed in a short period.

Quoted 5 lines

And I noticed there have been quite a lot code in the overlays, like the PMIC code, thus changes to overlays might be huge when cherry-picking, if it's the case, this patch is then acceptable, but please mention it in the commit message.

Yes, it's one of the reasons. Too many related commits exist. I prefer to keep the process simple. When someone syncs the whole DTS, the process is much easier and avoids commit conflicts.

Quoted 5 lines

But, if switching to the devicetree with cherry-picked patches for MMC leads to bugs, there are likely ABI compatibility issues in your driver, which would persist even after the synchronization with upstream v7.2 tag. Please fix them. From the very start, it's agreed compatibility with Linux devicetree ABI is important[1].

There are several commits on DTS. Cherry-picking only a few commits is not ideal.
I'm using upstream DTS. I just keep minimal changes in the overlay DTS file.

The cd-gpios property isn't even consistent between bananapi f3 and musepi pro board.

The sequence of mmc nodes is also inconsistent. SD node is declared first, and the
eMMC node is declared second. However, there is an alias that reverses this order.
In order to make it work, I have to enable CONFIG_DM_SEQ_ALIAS.

As I said they could be fixed. And I failed to cherry-pick only a few commits. So I don't
want to import commit conflicts when I synchronizing DTS files. I prefer it could be
handled by maintainers. When it's done, I can continue to submit new patches for fixes.

It should be fixed in Linux. But that doesn't mean I must fix the error in Linux first.
Then I submit this patch set after 6 months, waiting for the fix to merge in Linux.

Quoted 49 lines

So here's my NAK for this series, including v7 of it.

Thanks,
Yao Zi

[1]: https://lore.kernel.org/all/20260429-glare-anybody-16c98d01184e@spud/

Quoted 41 lines
Quoted 41 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Best Regards
Eric

Regards,
Yao Zi

Quoted 35 lines
Quoted 35 lines

By the way, please avoid top-posting if possible.

Thanks,
Yao Zi

Quoted 30 lines · Yao Zi
Quoted 29 lines · Eric Chung
Quoted 7 lines

Add the SDH0 controller node and its pinctrl groups to the u-boot overlay. The upstream DTS only contains the eMMC node; the SD card controller (sdhci@d4280000) and its MMC1 pinctrl configuration are missing. Place the new node inside the storage-bus via path-based merge so it inherits the dma-ranges from the parent bus.

Please cherry-pick upstream devicetree changes from Linux upstream with tools/update-subtree.sh instead of adding our own copies. Changes for k1-bananapi-f3 and k1-muse-pi-pro have both landed in Linux v7.2.

Best regards,
Yao Zi

Quoted 12 lines

---
v5:
- Append power source field on eMMC/SD pinctrl.
v3:
- Fix SD pinctrl as uhs.
v2:
- Use vmmc-supply as vqmmc-supply on SD node.
- Add alias of mmc0 and mmc1.

---
 arch/riscv/dts/k1-bananapi-f3-u-boot.dtsi | 91 ++++++++++++++++++++++++++++++-
 arch/riscv/dts/k1-musepi-pro-u-boot.dtsi  | 86 ++++++++++++++++++++++++++++-
 2 files changed, 173 insertions(+), 4 deletions(-)
author
#18 lore raw

PATCH v6 7/11 configs: k1: enable SD and eMMC support

In reply to Eric Chung

Enable high-speed MMC modes.

---
v5:
- Remove ADMA support since it depends on CMD23 support.
- Enable PINCONF support for related power source setting. v2:
- Enable ADMA support.
- Enable SYSCON support.

---
 board/spacemit/k1/MAINTAINERS |  1 +
 configs/spacemit_k1_defconfig | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+)
board/spacemit/k1/MAINTAINERS +1 -0
index 32d47ecc8f1..ca994e2a1fb 100644
@@ -9,6 +9,7 @@ F:	configs/spacemit_k1_defconfig
 F:	doc/board/spacemit/bananapi-f3.rst
 F:	drivers/gpio/spacemit_gpio.c
 F:	drivers/i2c/k1_i2c.c
+F:	drivers/mmc/spacemit_sdhci.c
 F:	drivers/pinctrl/spacemit/
 F:	drivers/power/pmic/pmic_spacemit_p1.c
 F:	drivers/power/regulator/spacemit_p1_regulator.c
configs/spacemit_k1_defconfig +20 -0
index 0604c2feefc..c0ee3a29f23 100644
@@ -23,6 +23,7 @@ CONFIG_DEBUG_UART_BASE=0xd4017000
 CONFIG_DEBUG_UART_CLOCK=14700000
 CONFIG_TARGET_SPACEMIT_K1=y
 CONFIG_ARCH_RV64I=y
+CONFIG_RISCV_ISA_ZICBOM=y
 CONFIG_RISCV_SMODE=y
 CONFIG_SPL_RISCV_MMODE=y
 # CONFIG_SPL_SMP is not set
@@ -48,6 +49,7 @@ CONFIG_SPL_CMD_TLV_EEPROM=y
 CONFIG_OF_UPSTREAM=y
 CONFIG_ENV_OVERWRITE=y
 CONFIG_SPL_REGMAP=y
+CONFIG_SYSCON=y
 CONFIG_SPL_SYSCON=y
 CONFIG_CLK=y
 CONFIG_CLK_CCF=y
@@ -61,6 +63,7 @@ CONFIG_MISC=y
 CONFIG_I2C_EEPROM=y
 CONFIG_SPL_I2C_EEPROM=y
 CONFIG_PINCTRL=y
+CONFIG_PINCONF=y
 CONFIG_PINCTRL_SPACEMIT_K1=y
 CONFIG_GPIO=y
 CONFIG_DM_GPIO=y
@@ -87,9 +90,26 @@ CONFIG_SPI_FLASH_WINBOND=y
 CONFIG_SPI_MEM=y
 CONFIG_SYS_SPI_U_BOOT_OFFS=0x000a0000
 CONFIG_CMD_SPI=y
+CONFIG_MMC=y
+CONFIG_MMC_SDHCI=y
+CONFIG_MMC_SDHCI_SPACEMIT=y
+CONFIG_MMC_IO_VOLTAGE=y
+CONFIG_MMC_HS200_SUPPORT=y
+CONFIG_MMC_HS400_SUPPORT=y
+CONFIG_MMC_HS400_ES_SUPPORT=y
+CONFIG_SUPPORT_EMMC_BOOT=y
+CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION=y
+CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION=0x4
+CONFIG_CMD_MMC=y
+CONFIG_CMD_MEMINFO=y
+CONFIG_CMD_MEMINFO_MAP=y
+CONFIG_EFI_PARTITION=y
 CONFIG_SPL_SPI=y
 CONFIG_SPL_DM_SPI=y
 CONFIG_SPL_DM_SPI_FLASH=y
 CONFIG_SPL_SPI_LOAD=y
 CONFIG_SPL_SPI_FLASH_TINY=y
 CONFIG_SPL_SPI_FLASH_SUPPORT=y
+CONFIG_SPL_BOARD_INIT=y
+CONFIG_SPL_MMC=y
+CONFIG_SPL_SYS_MMCSD_RAW_MODE=y
Signature · 1 line
2.51.0
#19 lore raw

Re: [PATCH v6 07/11] configs: k1: enable SD and eMMC support

Quoted 11 lines · Eric Chung

Enable high-speed MMC modes.

---
v5:
- Remove ADMA support since it depends on CMD23 support.
- Enable PINCONF support for related power source setting. v2:
- Enable ADMA support.
- Enable SYSCON support.

Quoted 2 lines
---
 board/spacemit/k1/MAINTAINERS |  1 +

This change doesn't seem to match the commit description. Please create a separate commit for the MAINTAINERS file, or at least move the change to the commit adding the driver.

Also, I don't think it's the reasonable place for board MAINTAINERS file to keep the entry for drivers. Please consider creating an entry for your platform in /MAINTAINERS later. You don't need to do so in this series, though.

Quoted 2 lines
 configs/spacemit_k1_defconfig | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+)

Best regards,
Yao Zi

author
#20 lore raw

PATCH v6 8/11 MAINTAINER: update Spacemit K1 entry

In reply to Eric Chung

Update the maintainer for Spacemit K1 from Guodong to Eric.

---
v4:
- Update the maintainer.

---
 board/spacemit/k1/MAINTAINERS | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
board/spacemit/k1/MAINTAINERS +1 -1
index ca994e2a1fb..4b2bc4ecfc1 100644
@@ -1,6 +1,6 @@
 BananaPi F3
 M:	Huan Zhou <[email protected]>
-M:	Guodong Xu <[email protected]>
+M:	Eric Chung <[email protected]>
 L:	[email protected]
 S:	Maintained
 F:	arch/riscv/dts/k1-*-u-boot.dtsi
Signature · 1 line
2.51.0
author
#21 lore raw

PATCH v6 9/11 doc: spacemit: flash on K1 SoC based boards

In reply to Eric Chung

Add document on how to flash images into eMMC of K1 SoC based boards.

---
v3:
- Add document on how to flash images into SD card.

---
 board/spacemit/k1/MAINTAINERS |   2 +-
 doc/board/spacemit/index.rst  |   1 +
 doc/board/spacemit/k1-mmc.rst | 320 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 322 insertions(+), 1 deletion(-)
board/spacemit/k1/MAINTAINERS +1 -1
index 4b2bc4ecfc1..e12288a206e 100644
@@ -6,7 +6,7 @@ S:	Maintained
 F:	arch/riscv/dts/k1-*-u-boot.dtsi
 F:	board/spacemit/k1/
 F:	configs/spacemit_k1_defconfig
-F:	doc/board/spacemit/bananapi-f3.rst
+F:	doc/board/spacemit/
 F:	drivers/gpio/spacemit_gpio.c
 F:	drivers/i2c/k1_i2c.c
 F:	drivers/mmc/spacemit_sdhci.c
doc/board/spacemit/index.rst +1 -0
index a5e35ee12ab..71854e5735b 100644
@@ -6,5 +6,6 @@ SpacemiT
    :maxdepth: 1
 
    bananapi-f3
+   k1-mmc
    k1-spl
 
doc/board/spacemit/k1-mmc.rst new file +320 -0

320 lines not on this page · raw message

Signature · 1 line
2.51.0
#22 lore raw

Re: [PATCH v6 09/11] doc: spacemit: flash on K1 SoC based boards

Quoted 12 lines · Eric Chung

Add document on how to flash images into eMMC of K1 SoC based boards.

---
v3:
- Add document on how to flash images into SD card.

---
 board/spacemit/k1/MAINTAINERS |   2 +-
 doc/board/spacemit/index.rst  |   1 +
 doc/board/spacemit/k1-mmc.rst | 320 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 322 insertions(+), 1 deletion(-)

...

Quoted 6 lines
doc/board/spacemit/k1-mmc.rst new file +0 -0
new file mode 100644
index 00000000000..b0fe78c75ce
@@ -0,0 +1,320 @@

...

Quoted 47 lines
doc/board/spacemit/k1-mmc.rst new file +47 -0
+Chapter 2: SD Card Boot
+=======================
+
+
+SpacemiT K1 Bianbu SD Card Image Flashing and U-Boot Update Guide
+==================================================================
+
+This guide explains how to prepare a bootable SD card with Bianbu OS for
+SpacemiT K1 based boards and how to replace the U-Boot binary on the SD
+card with a custom build.
+
+Prerequisites
+~~~~~~~~~~~~~
+
+- A SpacemiT K1 based development board
+- A microSD card (at least 8 GB capacity recommended)
+- A card reader for your host computer
+- A Linux host system (for ``dd``, ``fdisk``, ``lsblk`` commands)
+- The Bianbu SD card image from
+   <https://spacemit.com/community/resources-download/Images%20Collects/K1/Bianbu>
+- A custom ``u-boot.itb`` file (device tree blob or U-Boot FIT image) to be
+  written to the U-Boot partition
+
+Prepare the SD Card & the image
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+**1. Download the image**
+
+Download the released package from the official SpacemiT website:
+
+<https://archive.spacemit.com/image/k1/version/bianbu/v2.3.5/Bianbu-Minimal-K1-sdcard-V2.3.5-20260601180942.img.zip>
+
+**2. Extract the image**
+
+.. code-block:: console
+
+   $ unzip Bianbu-Minimal-K1-sdcard-V2.3.5-20260601180942.img.zip
+
+**3. Identify the SD card device**
+
+Insert the microSD card into your card reader, then run:
+
+.. code-block:: console
+
+   $ lsblk
+
+Compare the output before and after inserting the card to identify

doc/board/spacemit/k1-mmc.rst line 230

Quoted 10 lines
doc/board/spacemit/k1-mmc.rst new file +10 -0
+the new device. It will typically appear as ``/dev/sdb``, ``/dev/sdc``,
+or ``/dev/mmcblk0``.
+
+**4. Write the image to the SD card**
+
+.. code-block:: console
+
+   $ sudo dd if=./Bianbu-Minimal-K1-sdcard-V2.3.5-20260601180942.img of=/dev/sdb bs=1M status=progress
+
+The SD card is now ready as a bootable Bianbu system disk.

This looks out of scope of describing how to create a bootable SD card with U-Boot. In my opinion, you'd better describe the requirements of parition layout and image position for SD-card booting, to allow readers to create their own images/bootable medium from scratch more easily, instead of sticking to the vendored image.

Best regards,
Yao Zi

author
#23 lore raw

Re: [PATCH v6 09/11] doc: spacemit: flash on K1 SoC based boards

Quoted 81 lines · Yao Zi
Quoted 12 lines · Eric Chung

Add document on how to flash images into eMMC of K1 SoC based boards.

---
v3:
- Add document on how to flash images into SD card.

---
 board/spacemit/k1/MAINTAINERS |   2 +-
 doc/board/spacemit/index.rst  |   1 +
 doc/board/spacemit/k1-mmc.rst | 320 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 322 insertions(+), 1 deletion(-)

...

Quoted 6 lines
doc/board/spacemit/k1-mmc.rst new file +0 -0
new file mode 100644
index 00000000000..b0fe78c75ce
@@ -0,0 +1,320 @@

...

Quoted 55 lines
doc/board/spacemit/k1-mmc.rst new file +55 -0
+Chapter 2: SD Card Boot
+=======================
+
+
+SpacemiT K1 Bianbu SD Card Image Flashing and U-Boot Update Guide
+==================================================================
+
+This guide explains how to prepare a bootable SD card with Bianbu OS for
+SpacemiT K1 based boards and how to replace the U-Boot binary on the SD
+card with a custom build.
+
+Prerequisites
+~~~~~~~~~~~~~
+
+- A SpacemiT K1 based development board
+- A microSD card (at least 8 GB capacity recommended)
+- A card reader for your host computer
+- A Linux host system (for ``dd``, ``fdisk``, ``lsblk`` commands)
+- The Bianbu SD card image from
+   <https://spacemit.com/community/resources-download/Images%20Collects/K1/Bianbu>
+- A custom ``u-boot.itb`` file (device tree blob or U-Boot FIT image) to be
+  written to the U-Boot partition
+
+Prepare the SD Card & the image
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+**1. Download the image**
+
+Download the released package from the official SpacemiT website:
+
+<https://archive.spacemit.com/image/k1/version/bianbu/v2.3.5/Bianbu-Minimal-K1-sdcard-V2.3.5-20260601180942.img.zip>
+
+**2. Extract the image**
+
+.. code-block:: console
+
+   $ unzip Bianbu-Minimal-K1-sdcard-V2.3.5-20260601180942.img.zip
+
+**3. Identify the SD card device**
+
+Insert the microSD card into your card reader, then run:
+
+.. code-block:: console
+
+   $ lsblk
+
+Compare the output before and after inserting the card to identify
+the new device. It will typically appear as ``/dev/sdb``, ``/dev/sdc``,
+or ``/dev/mmcblk0``.
+
+**4. Write the image to the SD card**
+
+.. code-block:: console
+
+   $ sudo dd if=./Bianbu-Minimal-K1-sdcard-V2.3.5-20260601180942.img of=/dev/sdb bs=1M status=progress
Quoted 9 lines

doc/board/spacemit/k1-mmc.rst line 230

Quoted 2 lines
doc/board/spacemit/k1-mmc.rst new file +2 -0
+
+The SD card is now ready as a bootable Bianbu system disk.

This looks out of scope of describing how to create a bootable SD card with U-Boot. In my opinion, you'd better describe the requirements of parition layout and image position for SD-card booting, to allow readers to create their own images/bootable medium from scratch more easily, instead of sticking to the vendored image.

Creating a bootable SD card from scratch would be valuable, but I'll address it later due to time constraints.

#24 lore raw

Re: [PATCH v6 09/11] doc: spacemit: flash on K1 SoC based boards

Quoted 92 lines · Eric Chung
Quoted 81 lines · Yao Zi
Quoted 12 lines · Eric Chung

Add document on how to flash images into eMMC of K1 SoC based boards.

---
v3:
- Add document on how to flash images into SD card.

---
 board/spacemit/k1/MAINTAINERS |   2 +-
 doc/board/spacemit/index.rst  |   1 +
 doc/board/spacemit/k1-mmc.rst | 320 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 322 insertions(+), 1 deletion(-)

...

Quoted 6 lines
doc/board/spacemit/k1-mmc.rst new file +0 -0
new file mode 100644
index 00000000000..b0fe78c75ce
@@ -0,0 +1,320 @@

...

Quoted 55 lines
doc/board/spacemit/k1-mmc.rst new file +55 -0
+Chapter 2: SD Card Boot
+=======================
+
+
+SpacemiT K1 Bianbu SD Card Image Flashing and U-Boot Update Guide
+==================================================================
+
+This guide explains how to prepare a bootable SD card with Bianbu OS for
+SpacemiT K1 based boards and how to replace the U-Boot binary on the SD
+card with a custom build.
+
+Prerequisites
+~~~~~~~~~~~~~
+
+- A SpacemiT K1 based development board
+- A microSD card (at least 8 GB capacity recommended)
+- A card reader for your host computer
+- A Linux host system (for ``dd``, ``fdisk``, ``lsblk`` commands)
+- The Bianbu SD card image from
+   <https://spacemit.com/community/resources-download/Images%20Collects/K1/Bianbu>
+- A custom ``u-boot.itb`` file (device tree blob or U-Boot FIT image) to be
+  written to the U-Boot partition
+
+Prepare the SD Card & the image
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+**1. Download the image**
+
+Download the released package from the official SpacemiT website:
+
+<https://archive.spacemit.com/image/k1/version/bianbu/v2.3.5/Bianbu-Minimal-K1-sdcard-V2.3.5-20260601180942.img.zip>
+
+**2. Extract the image**
+
+.. code-block:: console
+
+   $ unzip Bianbu-Minimal-K1-sdcard-V2.3.5-20260601180942.img.zip
+
+**3. Identify the SD card device**
+
+Insert the microSD card into your card reader, then run:
+
+.. code-block:: console
+
+   $ lsblk
+
+Compare the output before and after inserting the card to identify
+the new device. It will typically appear as ``/dev/sdb``, ``/dev/sdc``,
+or ``/dev/mmcblk0``.
+
+**4. Write the image to the SD card**
+
+.. code-block:: console
+
+   $ sudo dd if=./Bianbu-Minimal-K1-sdcard-V2.3.5-20260601180942.img of=/dev/sdb bs=1M status=progress
Quoted 9 lines

doc/board/spacemit/k1-mmc.rst line 230

Quoted 2 lines
doc/board/spacemit/k1-mmc.rst new file +2 -0
+
+The SD card is now ready as a bootable Bianbu system disk.

This looks out of scope of describing how to create a bootable SD card with U-Boot. In my opinion, you'd better describe the requirements of parition layout and image position for SD-card booting, to allow readers to create their own images/bootable medium from scratch more easily, instead of sticking to the vendored image.

Quoted 2 lines

Creating a bootable SD card from scratch would be valuable, but I'll address it later due to time constraints.

In case I didn't make myself clear enough, the documentation *SHOULD* describe how to create bootable devices from scratch, instead of alternating an existing OS image to use mainline U-Boot. I don't think the current documentation helps much for downstream users/distributions to adapt U-Boot for their own use cases, or at least it could be written in a much more clear, vendor-neutral way.

So here's my NAK for this patch. I'm not sure what you mean by "time constraints", but please keep submitted patches in a good shape.

Thanks,
Yao Zi

author
#25 lore raw

Re: [PATCH v6 09/11] doc: spacemit: flash on K1 SoC based boards

Quoted 104 lines · Yao Zi
Quoted 92 lines · Eric Chung
Quoted 81 lines · Yao Zi
Quoted 12 lines · Eric Chung

Add document on how to flash images into eMMC of K1 SoC based boards.

---
v3:
- Add document on how to flash images into SD card.

---
 board/spacemit/k1/MAINTAINERS |   2 +-
 doc/board/spacemit/index.rst  |   1 +
 doc/board/spacemit/k1-mmc.rst | 320 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 322 insertions(+), 1 deletion(-)

...

Quoted 6 lines
doc/board/spacemit/k1-mmc.rst new file +0 -0
new file mode 100644
index 00000000000..b0fe78c75ce
@@ -0,0 +1,320 @@

...

Quoted 55 lines
doc/board/spacemit/k1-mmc.rst new file +55 -0
+Chapter 2: SD Card Boot
+=======================
+
+
+SpacemiT K1 Bianbu SD Card Image Flashing and U-Boot Update Guide
+==================================================================
+
+This guide explains how to prepare a bootable SD card with Bianbu OS for
+SpacemiT K1 based boards and how to replace the U-Boot binary on the SD
+card with a custom build.
+
+Prerequisites
+~~~~~~~~~~~~~
+
+- A SpacemiT K1 based development board
+- A microSD card (at least 8 GB capacity recommended)
+- A card reader for your host computer
+- A Linux host system (for ``dd``, ``fdisk``, ``lsblk`` commands)
+- The Bianbu SD card image from
+   <https://spacemit.com/community/resources-download/Images%20Collects/K1/Bianbu>
+- A custom ``u-boot.itb`` file (device tree blob or U-Boot FIT image) to be
+  written to the U-Boot partition
+
+Prepare the SD Card & the image
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+**1. Download the image**
+
+Download the released package from the official SpacemiT website:
+
+<https://archive.spacemit.com/image/k1/version/bianbu/v2.3.5/Bianbu-Minimal-K1-sdcard-V2.3.5-20260601180942.img.zip>
+
+**2. Extract the image**
+
+.. code-block:: console
+
+   $ unzip Bianbu-Minimal-K1-sdcard-V2.3.5-20260601180942.img.zip
+
+**3. Identify the SD card device**
+
+Insert the microSD card into your card reader, then run:
+
+.. code-block:: console
+
+   $ lsblk
+
+Compare the output before and after inserting the card to identify
+the new device. It will typically appear as ``/dev/sdb``, ``/dev/sdc``,
+or ``/dev/mmcblk0``.
+
+**4. Write the image to the SD card**
+
+.. code-block:: console
+
+   $ sudo dd if=./Bianbu-Minimal-K1-sdcard-V2.3.5-20260601180942.img of=/dev/sdb bs=1M status=progress
Quoted 9 lines

doc/board/spacemit/k1-mmc.rst line 230

Quoted 2 lines
doc/board/spacemit/k1-mmc.rst new file +2 -0
+
+The SD card is now ready as a bootable Bianbu system disk.

This looks out of scope of describing how to create a bootable SD card with U-Boot. In my opinion, you'd better describe the requirements of parition layout and image position for SD-card booting, to allow readers to create their own images/bootable medium from scratch more easily, instead of sticking to the vendored image.

Quoted 2 lines

Creating a bootable SD card from scratch would be valuable, but I'll address it later due to time constraints.

In case I didn't make myself clear enough, the documentation *SHOULD* describe how to create bootable devices from scratch, instead of alternating an existing OS image to use mainline U-Boot. I don't think the current documentation helps much for downstream users/distributions to adapt U-Boot for their own use cases, or at least it could be written in a much more clear, vendor-neutral way.

Quoted 3 lines

So here's my NAK for this patch. I'm not sure what you mean by "time constraints", but please keep submitted patches in a good shape.

I’m not sure why the documentation insists on walking users through creating a bootable SD card from scratch, especially when, at this stage, it still depends on
the vendor’s tools. In practice, we’re required to use the vendor’s flashing tool for
both eMMC and SD devices, and we must adhere to the provided partition table.

If users prefer to define their own partition layout, nothing prevents them from doing
so on their own. That’s entirely up to them.

The default SD image already includes the vendor’s U-Boot. My instructions simply
explain how to replace it with the upstream version—nothing more.

#26 lore raw

Re: [PATCH v6 09/11] doc: spacemit: flash on K1 SoC based boards

Quoted 105 lines · Eric Chung
Quoted 104 lines · Yao Zi
Quoted 92 lines · Eric Chung
Quoted 81 lines · Yao Zi
Quoted 12 lines · Eric Chung

Add document on how to flash images into eMMC of K1 SoC based boards.

---
v3:
- Add document on how to flash images into SD card.

---
 board/spacemit/k1/MAINTAINERS |   2 +-
 doc/board/spacemit/index.rst  |   1 +
 doc/board/spacemit/k1-mmc.rst | 320 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 322 insertions(+), 1 deletion(-)

...

Quoted 6 lines
doc/board/spacemit/k1-mmc.rst new file +0 -0
new file mode 100644
index 00000000000..b0fe78c75ce
@@ -0,0 +1,320 @@

...

Quoted 55 lines
doc/board/spacemit/k1-mmc.rst new file +55 -0
+Chapter 2: SD Card Boot
+=======================
+
+
+SpacemiT K1 Bianbu SD Card Image Flashing and U-Boot Update Guide
+==================================================================
+
+This guide explains how to prepare a bootable SD card with Bianbu OS for
+SpacemiT K1 based boards and how to replace the U-Boot binary on the SD
+card with a custom build.
+
+Prerequisites
+~~~~~~~~~~~~~
+
+- A SpacemiT K1 based development board
+- A microSD card (at least 8 GB capacity recommended)
+- A card reader for your host computer
+- A Linux host system (for ``dd``, ``fdisk``, ``lsblk`` commands)
+- The Bianbu SD card image from
+   <https://spacemit.com/community/resources-download/Images%20Collects/K1/Bianbu>
+- A custom ``u-boot.itb`` file (device tree blob or U-Boot FIT image) to be
+  written to the U-Boot partition
+
+Prepare the SD Card & the image
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+**1. Download the image**
+
+Download the released package from the official SpacemiT website:
+
+<https://archive.spacemit.com/image/k1/version/bianbu/v2.3.5/Bianbu-Minimal-K1-sdcard-V2.3.5-20260601180942.img.zip>
+
+**2. Extract the image**
+
+.. code-block:: console
+
+   $ unzip Bianbu-Minimal-K1-sdcard-V2.3.5-20260601180942.img.zip
+
+**3. Identify the SD card device**
+
+Insert the microSD card into your card reader, then run:
+
+.. code-block:: console
+
+   $ lsblk
+
+Compare the output before and after inserting the card to identify
+the new device. It will typically appear as ``/dev/sdb``, ``/dev/sdc``,
+or ``/dev/mmcblk0``.
+
+**4. Write the image to the SD card**
+
+.. code-block:: console
+
+   $ sudo dd if=./Bianbu-Minimal-K1-sdcard-V2.3.5-20260601180942.img of=/dev/sdb bs=1M status=progress
Quoted 9 lines

doc/board/spacemit/k1-mmc.rst line 230

Quoted 2 lines
doc/board/spacemit/k1-mmc.rst new file +2 -0
+
+The SD card is now ready as a bootable Bianbu system disk.

This looks out of scope of describing how to create a bootable SD card with U-Boot. In my opinion, you'd better describe the requirements of parition layout and image position for SD-card booting, to allow readers to create their own images/bootable medium from scratch more easily, instead of sticking to the vendored image.

Quoted 2 lines

Creating a bootable SD card from scratch would be valuable, but I'll address it later due to time constraints.

In case I didn't make myself clear enough, the documentation *SHOULD* describe how to create bootable devices from scratch, instead of alternating an existing OS image to use mainline U-Boot. I don't think the current documentation helps much for downstream users/distributions to adapt U-Boot for their own use cases, or at least it could be written in a much more clear, vendor-neutral way.

Quoted 3 lines
Quoted 3 lines

So here's my NAK for this patch. I'm not sure what you mean by "time constraints", but please keep submitted patches in a good shape.

In case that I still didn't make myself clear enough, by "bootable SD card", I mean a minimal medium with only a bootable U-Boot, you could refer to Rockchip or StarFive's documentation.

Quoted 4 lines

I’m not sure why the documentation insists on walking users through creating a bootable SD card from scratch, especially when, at this stage, it still depends on
the vendor’s tools.

Please explain which tools it depends on. Now U-Boot for your platform already has its SPL ported, and according to your instructions of replacing the vendor U-Boot, it seems no extra post-processing is required for the SoC to identify it.

And after re-reading the documentation, it seems you don't make use of the upstream SPL when creating the SD-card image, is this intended, and why?

Quoted 3 lines

In practice, we’re required to use the vendor’s
flashing tool for
both eMMC and SD devices,

Please explain the constraints, it's okay to depend on vendor's tools, but for creating a SD-card image, I couldn't come up with a reason to do so, at least by inferring from the current documentation.

Quoted 1 line

and we must adhere to the provided partition table.

Thus please clearly describe which part of the partition table must be preserved for the SoC to boot.

Quoted 7 lines

If users prefer to define their own partition layout, nothing prevents them from doing
so on their own. That’s entirely up to them.

The default SD image already includes the vendor’s U-Boot. My instructions simply
explain how to replace it with the upstream version—nothing more.

Best regards,
Yao Zi

author
#27 lore raw

Re: [PATCH v6 09/11] doc: spacemit: flash on K1 SoC based boards

Quoted 107 lines · Yao Zi
Quoted 105 lines · Eric Chung
Quoted 104 lines · Yao Zi
Quoted 92 lines · Eric Chung
Quoted 81 lines · Yao Zi
Quoted 12 lines · Eric Chung

Add document on how to flash images into eMMC of K1 SoC based boards.

---
v3:
- Add document on how to flash images into SD card.

---
 board/spacemit/k1/MAINTAINERS |   2 +-
 doc/board/spacemit/index.rst  |   1 +
 doc/board/spacemit/k1-mmc.rst | 320 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 322 insertions(+), 1 deletion(-)

...

Quoted 6 lines
doc/board/spacemit/k1-mmc.rst new file +0 -0
new file mode 100644
index 00000000000..b0fe78c75ce
@@ -0,0 +1,320 @@

...

Quoted 55 lines
doc/board/spacemit/k1-mmc.rst new file +55 -0
+Chapter 2: SD Card Boot
+=======================
+
+
+SpacemiT K1 Bianbu SD Card Image Flashing and U-Boot Update Guide
+==================================================================
+
+This guide explains how to prepare a bootable SD card with Bianbu OS for
+SpacemiT K1 based boards and how to replace the U-Boot binary on the SD
+card with a custom build.
+
+Prerequisites
+~~~~~~~~~~~~~
+
+- A SpacemiT K1 based development board
+- A microSD card (at least 8 GB capacity recommended)
+- A card reader for your host computer
+- A Linux host system (for ``dd``, ``fdisk``, ``lsblk`` commands)
+- The Bianbu SD card image from
+   <https://spacemit.com/community/resources-download/Images%20Collects/K1/Bianbu>
+- A custom ``u-boot.itb`` file (device tree blob or U-Boot FIT image) to be
+  written to the U-Boot partition
+
+Prepare the SD Card & the image
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+**1. Download the image**
+
+Download the released package from the official SpacemiT website:
+
+<https://archive.spacemit.com/image/k1/version/bianbu/v2.3.5/Bianbu-Minimal-K1-sdcard-V2.3.5-20260601180942.img.zip>
+
+**2. Extract the image**
+
+.. code-block:: console
+
+   $ unzip Bianbu-Minimal-K1-sdcard-V2.3.5-20260601180942.img.zip
+
+**3. Identify the SD card device**
+
+Insert the microSD card into your card reader, then run:
+
+.. code-block:: console
+
+   $ lsblk
+
+Compare the output before and after inserting the card to identify
+the new device. It will typically appear as ``/dev/sdb``, ``/dev/sdc``,
+or ``/dev/mmcblk0``.
+
+**4. Write the image to the SD card**
+
+.. code-block:: console
+
+   $ sudo dd if=./Bianbu-Minimal-K1-sdcard-V2.3.5-20260601180942.img of=/dev/sdb bs=1M status=progress
Quoted 9 lines

doc/board/spacemit/k1-mmc.rst line 230

Quoted 2 lines
doc/board/spacemit/k1-mmc.rst new file +2 -0
+
+The SD card is now ready as a bootable Bianbu system disk.

This looks out of scope of describing how to create a bootable SD card with U-Boot. In my opinion, you'd better describe the requirements of parition layout and image position for SD-card booting, to allow readers to create their own images/bootable medium from scratch more easily, instead of sticking to the vendored image.

Quoted 2 lines

Creating a bootable SD card from scratch would be valuable, but I'll address it later due to time constraints.

In case I didn't make myself clear enough, the documentation *SHOULD* describe how to create bootable devices from scratch, instead of alternating an existing OS image to use mainline U-Boot. I don't think the current documentation helps much for downstream users/distributions to adapt U-Boot for their own use cases, or at least it could be written in a much more clear, vendor-neutral way.

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines

So here's my NAK for this patch. I'm not sure what you mean by "time constraints", but please keep submitted patches in a good shape.

In case that I still didn't make myself clear enough, by "bootable SD card", I mean a minimal medium with only a bootable U-Boot, you could refer to Rockchip or StarFive's documentation.

I checked Rockchip or StarFive's documentation. And I can't find any mention of creating a bootable SD card.

Quoted 9 lines
Quoted 4 lines

I’m not sure why the documentation insists on walking users through creating a bootable SD card from scratch, especially when, at this stage, it still depends on
the vendor’s tools.

Please explain which tools it depends on. Now U-Boot for your platform already has its SPL ported, and according to your instructions of replacing the vendor U-Boot, it seems no extra post-processing is required for the SoC to identify it.

The flashing process must begin with a USB transfer. The vendor's proprietary tool is required to download the images to the target device. To maintain compatibility with this tool, I need to use the same partition table that it expects.

Currently, the SPL (Secondary Program Loader) only boots U-Boot; it has no other function in the boot flow.

Quoted 5 lines

And after re-reading the documentation, it seems you don't make use of the upstream SPL when creating the SD-card image, is this intended, and why?

Oh, I missed it. I need to append SPL part.

Quoted 8 lines
Quoted 3 lines

In practice, we’re required to use the vendor’s
flashing tool for
both eMMC and SD devices,

Please explain the constraints, it's okay to depend on vendor's tools, but for creating a SD-card image, I couldn't come up with a reason to do so, at least by inferring from the current documentation.

I’m required to use the vendor’s flashing tool, flashserver, for programming SD card images — mainly because it’s the only way I can properly program the RPMB partition.

The tool supports both eMMC and SD boot modes, and environment variables (ENV) can be stored on either medium. However, it would be unusual to boot from an SD card while loading the ENV from eMMC. Therefore, the simplest and most consistent approach is to keep the same partition layout across all critical components — including FSBL, ENV, and OpenSBI partitions — regardless of the boot medium.

Quoted 5 lines
Quoted 1 line

and we must adhere to the provided partition table.

Thus please clearly describe which part of the partition table must be preserved for the SoC to boot.

Mentioned above.

Quoted 10 lines
Quoted 7 lines

If users prefer to define their own partition layout, nothing prevents them from doing
so on their own. That’s entirely up to them.

The default SD image already includes the vendor’s U-Boot. My instructions simply
explain how to replace it with the upstream version—nothing more.

Best regards,
Yao Zi

#28 lore raw

Re: [PATCH v6 09/11] doc: spacemit: flash on K1 SoC based boards

Quoted 112 lines · Eric Chung
Quoted 111 lines · Yao Zi
Quoted 108 lines · Eric Chung
Quoted 107 lines · Yao Zi
Quoted 92 lines · Eric Chung
Quoted 81 lines · Yao Zi
Quoted 12 lines · Eric Chung

Add document on how to flash images into eMMC of K1 SoC based boards.

---
v3:
- Add document on how to flash images into SD card.

---
 board/spacemit/k1/MAINTAINERS |   2 +-
 doc/board/spacemit/index.rst  |   1 +
 doc/board/spacemit/k1-mmc.rst | 320 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 322 insertions(+), 1 deletion(-)

...

Quoted 6 lines
doc/board/spacemit/k1-mmc.rst new file +0 -0
new file mode 100644
index 00000000000..b0fe78c75ce
@@ -0,0 +1,320 @@

...

Quoted 55 lines
doc/board/spacemit/k1-mmc.rst new file +55 -0
+Chapter 2: SD Card Boot
+=======================
+
+
+SpacemiT K1 Bianbu SD Card Image Flashing and U-Boot Update Guide
+==================================================================
+
+This guide explains how to prepare a bootable SD card with Bianbu OS for
+SpacemiT K1 based boards and how to replace the U-Boot binary on the SD
+card with a custom build.
+
+Prerequisites
+~~~~~~~~~~~~~
+
+- A SpacemiT K1 based development board
+- A microSD card (at least 8 GB capacity recommended)
+- A card reader for your host computer
+- A Linux host system (for ``dd``, ``fdisk``, ``lsblk`` commands)
+- The Bianbu SD card image from
+   <https://spacemit.com/community/resources-download/Images%20Collects/K1/Bianbu>
+- A custom ``u-boot.itb`` file (device tree blob or U-Boot FIT image) to be
+  written to the U-Boot partition
+
+Prepare the SD Card & the image
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+**1. Download the image**
+
+Download the released package from the official SpacemiT website:
+
+<https://archive.spacemit.com/image/k1/version/bianbu/v2.3.5/Bianbu-Minimal-K1-sdcard-V2.3.5-20260601180942.img.zip>
+
+**2. Extract the image**
+
+.. code-block:: console
+
+   $ unzip Bianbu-Minimal-K1-sdcard-V2.3.5-20260601180942.img.zip
+
+**3. Identify the SD card device**
+
+Insert the microSD card into your card reader, then run:
+
+.. code-block:: console
+
+   $ lsblk
+
+Compare the output before and after inserting the card to identify
+the new device. It will typically appear as ``/dev/sdb``, ``/dev/sdc``,
+or ``/dev/mmcblk0``.
+
+**4. Write the image to the SD card**
+
+.. code-block:: console
+
+   $ sudo dd if=./Bianbu-Minimal-K1-sdcard-V2.3.5-20260601180942.img of=/dev/sdb bs=1M status=progress
Quoted 9 lines

doc/board/spacemit/k1-mmc.rst

Quoted 2 lines
doc/board/spacemit/k1-mmc.rst new file +2 -0
+
+The SD card is now ready as a bootable Bianbu system disk.

This looks out of scope of describing how to create a bootable SD card with U-Boot. In my opinion, you'd better describe the requirements of parition layout and image position for SD-card booting, to allow readers to create their own images/bootable medium from scratch more easily, instead of sticking to the vendored image.

Quoted 2 lines

Creating a bootable SD card from scratch would be valuable, but I'll address it later due to time constraints.

In case I didn't make myself clear enough, the documentation *SHOULD* describe how to create bootable devices from scratch, instead of alternating an existing OS image to use mainline U-Boot. I don't think the current documentation helps much for downstream users/distributions to adapt U-Boot for their own use cases, or at least it could be written in a much more clear, vendor-neutral way.

So here's my NAK for this patch. I'm not sure what you mean by "time constraints", but please keep submitted patches in a good shape.

Quoted 7 lines
Quoted 4 lines

In case that I still didn't make myself clear enough, by "bootable SD card", I mean a minimal medium with only a bootable U-Boot, you could refer to Rockchip or StarFive's documentation.

I checked Rockchip or StarFive's documentation. And I can't find any mention of creating a bootable SD card.

Please grep SD in doc/rockchip/rockchip.rst. For StarFive, it seems the process of creating bootable SDcards has been removed a little earlier, but in section "Zero Stage BootLoader" of doc/starfive/jh7110_common.rst, the BROM's behavior is still described.

Quoted 10 lines
Quoted 9 lines
Quoted 4 lines

I’m not sure why the documentation insists on walking users through creating a bootable SD card from scratch, especially when, at this stage, it still depends on
the vendor’s tools.

Please explain which tools it depends on. Now U-Boot for your platform already has its SPL ported, and according to your instructions of replacing the vendor U-Boot, it seems no extra post-processing is required for the SoC to identify it.

Quoted 4 lines

The flashing process must begin with a USB transfer. The vendor's proprietary tool is required to download the images to the target device. To maintain compatibility with this tool, I need to use the same partition table that it expects.

So please make it clear whether the proprietary tool is required for creating SD-card images, or it's only required for downloading the image to the SD card. The latter seems impossible since you described how to flash an image to SD with dd in this documentation.

I'm really confused with your description.

Quoted 15 lines

Currently, the SPL (Secondary Program Loader) only boots U-Boot; it has no other function in the boot flow.

Quoted 5 lines

And after re-reading the documentation, it seems you don't make use of the upstream SPL when creating the SD-card image, is this intended, and why?

Oh, I missed it. I need to append SPL part.

Quoted 4 lines
Quoted 3 lines

In practice, we’re required to use the vendor’s
flashing tool for
both eMMC and SD devices,

Quoted 8 lines
Quoted 4 lines

Please explain the constraints, it's okay to depend on vendor's tools, but for creating a SD-card image, I couldn't come up with a reason to do so, at least by inferring from the current documentation.

I’m required to use the vendor’s flashing tool, flashserver, for programming SD card images — mainly because it’s the only way I can properly program the RPMB partition.

But you don't do so in the documentation, dd is used. This wouldn't program the RPMB partition AFAIK. And does it mean that K1 requires a SDcard with RPMB support to boot? This doesn't match my experience with the platform.

Quoted 7 lines

The tool supports both eMMC and SD boot modes, and environment variables (ENV) can be stored on either medium. However, it would be unusual to boot from an SD card while loading the ENV from eMMC. Therefore, the simplest and most consistent approach is to keep the same partition layout across all critical components — including FSBL, ENV, and OpenSBI partitions — regardless of the boot medium.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

and we must adhere to the provided partition table.

Thus please clearly describe which part of the partition table must be preserved for the SoC to boot.

Mentioned above.

Please quote the text, you do provide an example partition table, but there's no note describing which partitions are mandatory, and whether their offsets could be changed.

If a user could only create their own SDcard images by trial and error, this documentation loses its purpose. Please describe what is mandatory, or only describe the mandatory parts like Rockchip's documentation.

Quoted 10 lines
Quoted 10 lines
Quoted 7 lines

If users prefer to define their own partition layout, nothing prevents them from doing
so on their own. That’s entirely up to them.

The default SD image already includes the vendor’s U-Boot. My instructions simply
explain how to replace it with the upstream version—nothing more.

Best regards,
Yao Zi

Frankly, I'm really tired of this discussion, I don't think you understand much of my questions, even though I tried to explain myself once and once again. And your replies are self-contradictory.

Please make sure you understand my questions and reply with reasonable answers. I wouldn't continue to review your patches before you resolve questions in this thread.

Best regards,
Yao Zi

author
#29 lore raw

Re: [PATCH v6 09/11] doc: spacemit: flash on K1 SoC based boards

Quoted 212 lines · Yao Zi
Quoted 112 lines · Eric Chung
Quoted 111 lines · Yao Zi
Quoted 108 lines · Eric Chung
Quoted 107 lines · Yao Zi
Quoted 92 lines · Eric Chung
Quoted 81 lines · Yao Zi
Quoted 12 lines · Eric Chung

Add document on how to flash images into eMMC of K1 SoC based boards.

---
v3:
- Add document on how to flash images into SD card.

---
 board/spacemit/k1/MAINTAINERS |   2 +-
 doc/board/spacemit/index.rst  |   1 +
 doc/board/spacemit/k1-mmc.rst | 320 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 322 insertions(+), 1 deletion(-)

...

Quoted 6 lines
doc/board/spacemit/k1-mmc.rst new file +0 -0
new file mode 100644
index 00000000000..b0fe78c75ce
@@ -0,0 +1,320 @@

...

Quoted 55 lines
doc/board/spacemit/k1-mmc.rst new file +55 -0
+Chapter 2: SD Card Boot
+=======================
+
+
+SpacemiT K1 Bianbu SD Card Image Flashing and U-Boot Update Guide
+==================================================================
+
+This guide explains how to prepare a bootable SD card with Bianbu OS for
+SpacemiT K1 based boards and how to replace the U-Boot binary on the SD
+card with a custom build.
+
+Prerequisites
+~~~~~~~~~~~~~
+
+- A SpacemiT K1 based development board
+- A microSD card (at least 8 GB capacity recommended)
+- A card reader for your host computer
+- A Linux host system (for ``dd``, ``fdisk``, ``lsblk`` commands)
+- The Bianbu SD card image from
+   <https://spacemit.com/community/resources-download/Images%20Collects/K1/Bianbu>
+- A custom ``u-boot.itb`` file (device tree blob or U-Boot FIT image) to be
+  written to the U-Boot partition
+
+Prepare the SD Card & the image
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+**1. Download the image**
+
+Download the released package from the official SpacemiT website:
+
+<https://archive.spacemit.com/image/k1/version/bianbu/v2.3.5/Bianbu-Minimal-K1-sdcard-V2.3.5-20260601180942.img.zip>
+
+**2. Extract the image**
+
+.. code-block:: console
+
+   $ unzip Bianbu-Minimal-K1-sdcard-V2.3.5-20260601180942.img.zip
+
+**3. Identify the SD card device**
+
+Insert the microSD card into your card reader, then run:
+
+.. code-block:: console
+
+   $ lsblk
+
+Compare the output before and after inserting the card to identify
+the new device. It will typically appear as ``/dev/sdb``, ``/dev/sdc``,
+or ``/dev/mmcblk0``.
+
+**4. Write the image to the SD card**
+
+.. code-block:: console
+
+   $ sudo dd if=./Bianbu-Minimal-K1-sdcard-V2.3.5-20260601180942.img of=/dev/sdb bs=1M status=progress
Quoted 9 lines

doc/board/spacemit/k1-mmc.rst

Quoted 2 lines
doc/board/spacemit/k1-mmc.rst new file +2 -0
+
+The SD card is now ready as a bootable Bianbu system disk.

This looks out of scope of describing how to create a bootable SD card with U-Boot. In my opinion, you'd better describe the requirements of parition layout and image position for SD-card booting, to allow readers to create their own images/bootable medium from scratch more easily, instead of sticking to the vendored image.

Quoted 2 lines

Creating a bootable SD card from scratch would be valuable, but I'll address it later due to time constraints.

In case I didn't make myself clear enough, the documentation *SHOULD* describe how to create bootable devices from scratch, instead of alternating an existing OS image to use mainline U-Boot. I don't think the current documentation helps much for downstream users/distributions to adapt U-Boot for their own use cases, or at least it could be written in a much more clear, vendor-neutral way.

So here's my NAK for this patch. I'm not sure what you mean by "time constraints", but please keep submitted patches in a good shape.

Quoted 7 lines
Quoted 4 lines

In case that I still didn't make myself clear enough, by "bootable SD card", I mean a minimal medium with only a bootable U-Boot, you could refer to Rockchip or StarFive's documentation.

I checked Rockchip or StarFive's documentation. And I can't find any mention of creating a bootable SD card.

Please grep SD in doc/rockchip/rockchip.rst. For StarFive, it seems the process of creating bootable SDcards has been removed a little earlier, but in section "Zero Stage BootLoader" of doc/starfive/jh7110_common.rst, the BROM's behavior is still described.

Quoted 10 lines
Quoted 9 lines
Quoted 4 lines

I’m not sure why the documentation insists on walking users through creating a bootable SD card from scratch, especially when, at this stage, it still depends on
the vendor’s tools.

Please explain which tools it depends on. Now U-Boot for your platform already has its SPL ported, and according to your instructions of replacing the vendor U-Boot, it seems no extra post-processing is required for the SoC to identify it.

Quoted 4 lines

The flashing process must begin with a USB transfer. The vendor's proprietary tool is required to download the images to the target device. To maintain compatibility with this tool, I need to use the same partition table that it expects.

So please make it clear whether the proprietary tool is required for creating SD-card images, or it's only required for downloading the image to the SD card. The latter seems impossible since you described how to flash an image to SD with dd in this documentation.

I'm really confused with your description.

Quoted 15 lines

Currently, the SPL (Secondary Program Loader) only boots U-Boot; it has no other function in the boot flow.

Quoted 5 lines

And after re-reading the documentation, it seems you don't make use of the upstream SPL when creating the SD-card image, is this intended, and why?

Oh, I missed it. I need to append SPL part.

Quoted 4 lines
Quoted 3 lines

In practice, we’re required to use the vendor’s
flashing tool for
both eMMC and SD devices,

Quoted 8 lines
Quoted 4 lines

Please explain the constraints, it's okay to depend on vendor's tools, but for creating a SD-card image, I couldn't come up with a reason to do so, at least by inferring from the current documentation.

I’m required to use the vendor’s flashing tool, flashserver, for programming SD card images — mainly because it’s the only way I can properly program the RPMB partition.

But you don't do so in the documentation, dd is used. This wouldn't program the RPMB partition AFAIK. And does it mean that K1 requires a SDcard with RPMB support to boot? This doesn't match my experience with the platform.

Quoted 7 lines

The tool supports both eMMC and SD boot modes, and environment variables (ENV) can be stored on either medium. However, it would be unusual to boot from an SD card while loading the ENV from eMMC. Therefore, the simplest and most consistent approach is to keep the same partition layout across all critical components — including FSBL, ENV, and OpenSBI partitions — regardless of the boot medium.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

and we must adhere to the provided partition table.

Thus please clearly describe which part of the partition table must be preserved for the SoC to boot.

Mentioned above.

Please quote the text, you do provide an example partition table, but there's no note describing which partitions are mandatory, and whether their offsets could be changed.

If a user could only create their own SDcard images by trial and error, this documentation loses its purpose. Please describe what is mandatory, or only describe the mandatory parts like Rockchip's documentation.

Quoted 10 lines
Quoted 10 lines
Quoted 7 lines

If users prefer to define their own partition layout, nothing prevents them from doing
so on their own. That’s entirely up to them.

The default SD image already includes the vendor’s U-Boot. My instructions simply
explain how to replace it with the upstream version—nothing more.

Best regards,
Yao Zi

Quoted 7 lines

Frankly, I'm really tired of this discussion, I don't think you understand much of my questions, even though I tried to explain myself once and once again. And your replies are self-contradictory.

Please make sure you understand my questions and reply with reasonable answers. I wouldn't continue to review your patches before you resolve questions in this thread.

So let it be simple. I'll remove the SD card part from this document in the next round. Then we don't need to discuss it any more.

Any new comments on this series? If no, I'll send the next round in this week.

author
#30 lore raw

PATCH v6 10/11 config: k1: enable ENV support for eMMC

In reply to Eric Chung

Enable environment variable support on the eMMC storage device for both SPL and U-Boot stages.

---
 configs/spacemit_k1_defconfig | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
configs/spacemit_k1_defconfig +6 -1
index c0ee3a29f23..7caba18ddcd 100644
@@ -14,7 +14,7 @@ CONFIG_SPL_BSS_MAX_SIZE=0x400
 CONFIG_SPL_STACK_R=y
 CONFIG_SPL_STACK_R_ADDR=0xc00000
 CONFIG_SPL_SYS_MALLOC_SIMPLE=y
-CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x100000
+CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x400000
 CONFIG_SYS_BOOTM_LEN=0xa000000
 CONFIG_SYS_LOAD_ADDR=0x200000
 CONFIG_SPL_SIZE_LIMIT=0x31000
@@ -48,6 +48,10 @@ CONFIG_CMD_TLV_EEPROM=y
 CONFIG_SPL_CMD_TLV_EEPROM=y
 CONFIG_OF_UPSTREAM=y
 CONFIG_ENV_OVERWRITE=y
+CONFIG_ENV_SIZE=0x4000
+CONFIG_ENV_OFFSET=0x60000
+CONFIG_ENV_SECT_SIZE=0x10000
+CONFIG_ENV_IS_IN_MMC=y
 CONFIG_SPL_REGMAP=y
 CONFIG_SYSCON=y
 CONFIG_SPL_SYSCON=y
@@ -111,5 +115,6 @@ CONFIG_SPL_SPI_LOAD=y
 CONFIG_SPL_SPI_FLASH_TINY=y
 CONFIG_SPL_SPI_FLASH_SUPPORT=y
 CONFIG_SPL_BOARD_INIT=y
+CONFIG_SPL_ENV_SUPPORT=y
 CONFIG_SPL_MMC=y
 CONFIG_SPL_SYS_MMCSD_RAW_MODE=y
Signature · 1 line
2.51.0
author
#31 lore raw

PATCH v6 11/11 spacemit: k1: load product name from environment variable

In reply to Eric Chung

Read the product name from the environment instead of EEPROM, as the EEPROM may not be programmed and the environment always contains this information.

---
v6:
- Rebased onto latest upstream. Cleaned up board_fit_config_name_match() to maintain consistentcy with v5.

---
 board/spacemit/k1/spl.c | 89 +++++++++++++++++++++----------------------------
 1 file changed, 38 insertions(+), 51 deletions(-)
board/spacemit/k1/spl.c +38 -51
index 613e8c4cf02..69c992ea57a 100644
@@ -12,9 +12,9 @@
 #include <configs/k1.h>
 #include <dm/device.h>
 #include <dm/uclass.h>
+#include <env.h>
 #include <i2c.h>
 #include <linux/bitfield.h>
-#include <linux/ctype.h>
 #include <linux/delay.h>
 #include <log.h>
 #include <power/regulator.h>
@@ -97,37 +97,41 @@ static void i2c_early_init(void)
 	}
 }
 
-int read_product_name(char *name, int size)
+static const struct {
+	const char *eeprom_name;
+	const char *fit_name;
+} k1_board_map[] = {
+	{ "k1-x_MUSE-Pi-Pro",   "spacemit/k1-musepi-pro"    },
+	{ "k1-x_deb1",          "spacemit/k1-bananapi-f3"   },
+	{ "k1-x_milkv-jupiter", "spacemit/k1-milkv-jupiter" },
+};
+
+static void fixup_product_name(void)
 {
-	u8 eeprom_data[TLV_TOTAL_LEN_MAX], *p;
-	struct tlvinfo_header *tlv_hdr;
-	struct tlvinfo_tlv *tlv_entry;
-	int ret, i = 0;
-	u32 entry_size;
+	char fdt_name[I2C_BUF_SIZE], *name;
+	int i;
 
-	if (!name || size <= 0)
-		return -EINVAL;
-	ret = read_tlvinfo_tlv_eeprom(eeprom_data, &tlv_hdr,
-				      &tlv_entry, i);
-	if (ret)
-		return ret;
-	p = (u8 *)tlv_entry;
-	for (i = 0; i < tlv_hdr->totallen; ) {
-		if (tlv_entry->type == TLV_CODE_PRODUCT_NAME) {
-			if (tlv_entry->length < size)
-				size = tlv_entry->length;
-			memset(name, 0, size);
-			memcpy(name, &tlv_entry->value[0], size);
-			return 0;
+	memset(product_name, 0, I2C_BUF_SIZE);
+	env_init();
+	env_load();
+	name = env_get("product_name");
+	if (name)
+		snprintf(product_name, I2C_BUF_SIZE, "%s", name);
+	memset(fdt_name, 0, I2C_BUF_SIZE);
+	for (i = 0; i < ARRAY_SIZE(k1_board_map); i++) {
+		if (!strncmp(product_name, k1_board_map[i].eeprom_name,
+			     strlen(k1_board_map[i].eeprom_name))) {
+			snprintf(fdt_name, I2C_BUF_SIZE, "%s",
+				 k1_board_map[i].fit_name);
+			break;
 		}
-		if (tlv_entry->type == TLV_CODE_CRC_32)
-			return -ENOENT;
-		entry_size = tlv_entry->length + sizeof(struct tlvinfo_tlv);
-		i += entry_size;
-		p += entry_size;
-		tlv_entry = (struct tlvinfo_tlv *)p;
 	}
-	return -ENOENT;
+	if (fdt_name[0] == '\0') {
+		/* set default board name */
+		sprintf(fdt_name, CONFIG_DEFAULT_DEVICE_TREE);
+	}
+	memset(product_name, 0, I2C_BUF_SIZE);
+	memcpy(product_name, fdt_name, I2C_BUF_SIZE);
 }
 
 static void clk_early_init(void)
@@ -364,11 +368,6 @@ void board_init_f(ulong dummy)
 	preloader_console_init();
 
 	i2c_early_init();
-	ret = read_product_name(product_name, I2C_BUF_SIZE);
-	if (ret)
-		log_info("Fail to detect board:%d\n", ret);
-	else
-		log_info("Get board name:%s\n", product_name);
 	pmic_init();
 
 	ddr_early_init();
@@ -430,26 +429,14 @@ void spl_board_init(void)
 {
 }
 
-int board_fit_config_name_match(const char *name)
+void spl_perform_board_fixups(struct spl_image_info *spl_image)
 {
-	char fdt_name[I2C_BUF_SIZE];
-	int i;
+	fixup_product_name();
+}
 
-	memset(fdt_name, 0, I2C_BUF_SIZE);
-	if (!strncmp(product_name, "k1-x_", 5)) {
-		snprintf(fdt_name, I2C_BUF_SIZE, "%s-%s", "k1",
-			 &product_name[5]);
-	}
-	if (fdt_name[0] == '\0') {
-		/* set default board name */
-		sprintf(fdt_name, "k1-musepi-pro");
-	}
-	for (i = 0; i < I2C_BUF_SIZE; i++) {
-		if (fdt_name[i] == '\0')
-			break;
-		fdt_name[i] = tolower(fdt_name[i]);
-	}
-	if (!strcmp(name, fdt_name))
+int board_fit_config_name_match(const char *name)
+{
+	if (!strcmp(name, product_name))
 		return 0;
 	return -ENOENT;
 }
Signature · 1 line
2.51.0
#32 lore raw

Re: [PATCH v6 11/11] spacemit: k1: load product name from environment variable

Quoted 3 lines · Eric Chung

Read the product name from the environment instead of EEPROM, as the EEPROM may not be programmed and the environment always contains this information.

Please explain why the environment "always contains this information". This sounds strange since the environment variable is placed on MMC, and there should be no "product_name" environment variable in the environment partition if U-Boot is flashed to a completely new and empty MMC.

The EEPROM should be the most robost way to distinguish board types. If you do have devices with unprogrammed EEPROMs, please provide a guide to program it correctly.

Furthremore, this doesn't seem to fit the subject of the series, "spacemit mmc driver", since I don't think these changes are required for MMC to work. So I think this patch should be split out even if you do want to change the board detection logic.

Quoted 1 line

Best regards,
Yao Zi