* [PATCH v2 0/2] board: sophgo: add support for Milk-V Duo 256M
@ 2026-07-23 14:44 Hiago De Franco
2026-07-23 14:44 ` [PATCH v2 1/2] board: sophgo: move ethernet driver to common directory Hiago De Franco
` (3 more replies)
0 siblings, 4 replies; 14+ messages in thread
From: Hiago De Franco @ 2026-07-23 14:44 UTC (permalink / raw)
To: u-boot
Cc: Kongyang Liu, Tom Rini, Peter Robinson, Ilias Apalodimas,
Quentin Schulz, Rick Chen, Leo, Jamie Gibbons, Conor Dooley,
Randolph Sheng-Kai Lin, Yao Zi, Andreas Schwab, Michal Simek,
Martin Herren, Peng Fan, Sam Protsenko, u-boot
Milk-V Duo 256M is a small development board based on the Sophgo SG2002
SoC.
U-Boot runs as the S-mode payload on top of the vendor FSBL and OpenSBI,
packaged together into a FIP image on the SD card.
The vendor FIP tool prepends a 32-byte loader header to u-boot.bin and
loads the result at 0x80200000, so TEXT_BASE is set to 0x80200020 to
match the address the U-Boot code actually runs.
The following peripherals are supported:
- ns16550 serial console (UART0)
- SD/MMC
- Ethernet with the SoC internal PHY
This patch was tested on Milk-V Duo 256MB using an SD card and the Duo
USB & Ethernet IOB (base board) [0].
This series uses the CV1800B SYS_CPU target since SG2002 shares common
IPs with CV1800B. Other SG2002 as LicheeRV Nano does the same.
Note: Linux device tree is not yet merged [1], therefore I am adding a
device tree here and it can be later changed to use the kernel upstream
one.
[0] https://milkv.io/docs/duo/io-board/usb-ethernet-iob
[1] https://lore.kernel.org/lkml/20260710075917.159969-1-chenyou910331@gmail.com/
Link: https://milkv.io/docs/duo/getting-started/duo256m
Signed-off-by: Hiago De Franco <hfranco@baylibre.com>
---
Changes in v2:
- Makefile: changed to use 'milkv_duo/board.c' instead of
'milkv_duo_256m/board.c', since they share the exact same code.
- board.c: deleted, because of the above.
- doc: updated to add Ethernet support.
- Link to v1: https://lore.kernel.org/r/20260710-add-milkv-duo256m-v1-0-0f761100361d@baylibre.com
---
Hiago De Franco (2):
board: sophgo: move ethernet driver to common directory
board: sophgo: add support for Milk-V Duo 256M
arch/riscv/Kconfig | 4 ++
arch/riscv/dts/Makefile | 1 +
arch/riscv/dts/sg2002-milkv-duo256m.dts | 46 ++++++++++++++
board/sophgo/{milkv_duo => common}/ethernet.c | 0
board/sophgo/{milkv_duo => common}/ethernet.h | 0
board/sophgo/milkv_duo/MAINTAINERS | 1 +
board/sophgo/milkv_duo/Makefile | 2 +-
board/sophgo/milkv_duo/board.c | 2 +-
board/sophgo/milkv_duo_256m/Kconfig | 30 +++++++++
board/sophgo/milkv_duo_256m/MAINTAINERS | 5 ++
board/sophgo/milkv_duo_256m/Makefile | 6 ++
board/sophgo/milkv_duo_256m/milkv_duo_256m.env | 8 +++
configs/milkv_duo_256m_defconfig | 42 +++++++++++++
doc/board/sophgo/index.rst | 1 +
doc/board/sophgo/milkv_duo_256m.rst | 84 ++++++++++++++++++++++++++
include/configs/milkv_duo_256m.h | 12 ++++
16 files changed, 242 insertions(+), 2 deletions(-)
---
base-commit: ece349ade2973e220f524ce59e59711cc919263f
change-id: 20260710-add-milkv-duo256m-1662c5cafb35
Best regards,
--
Hiago De Franco <hfranco@baylibre.com>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v2 1/2] board: sophgo: move ethernet driver to common directory
2026-07-23 14:44 [PATCH v2 0/2] board: sophgo: add support for Milk-V Duo 256M Hiago De Franco
@ 2026-07-23 14:44 ` Hiago De Franco
2026-08-05 15:29 ` Leo Liang via U-Boot
2026-07-23 14:44 ` [PATCH v2 2/2] board: sophgo: add support for Milk-V Duo 256M Hiago De Franco
` (2 subsequent siblings)
3 siblings, 1 reply; 14+ messages in thread
From: Hiago De Franco @ 2026-07-23 14:44 UTC (permalink / raw)
To: u-boot
Cc: Kongyang Liu, Tom Rini, Peter Robinson, Ilias Apalodimas,
Quentin Schulz, Rick Chen, Leo, Jamie Gibbons, Conor Dooley,
Randolph Sheng-Kai Lin, Yao Zi, Andreas Schwab, Michal Simek,
Martin Herren, Peng Fan, Sam Protsenko, u-boot
This will make easier for future boards to reuse the same driver (e.g.
Milk-V Duo 256MB).
Signed-off-by: Hiago De Franco <hfranco@baylibre.com>
---
board/sophgo/{milkv_duo => common}/ethernet.c | 0
board/sophgo/{milkv_duo => common}/ethernet.h | 0
board/sophgo/milkv_duo/MAINTAINERS | 1 +
board/sophgo/milkv_duo/Makefile | 2 +-
board/sophgo/milkv_duo/board.c | 2 +-
5 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/board/sophgo/milkv_duo/ethernet.c b/board/sophgo/common/ethernet.c
similarity index 100%
rename from board/sophgo/milkv_duo/ethernet.c
rename to board/sophgo/common/ethernet.c
diff --git a/board/sophgo/milkv_duo/ethernet.h b/board/sophgo/common/ethernet.h
similarity index 100%
rename from board/sophgo/milkv_duo/ethernet.h
rename to board/sophgo/common/ethernet.h
diff --git a/board/sophgo/milkv_duo/MAINTAINERS b/board/sophgo/milkv_duo/MAINTAINERS
index 651a0592f7a..6941dc5b376 100644
--- a/board/sophgo/milkv_duo/MAINTAINERS
+++ b/board/sophgo/milkv_duo/MAINTAINERS
@@ -2,5 +2,6 @@ Milk-V Duo
M: Kongyang Liu <seashell11234455@gmail.com>
S: Maintained
F: board/sophgo/milkv_duo/
+F: board/sophgo/common/
F: configs/milkv_duo_defconfig
F: doc/board/sophgo/milkv_duo.rst
diff --git a/board/sophgo/milkv_duo/Makefile b/board/sophgo/milkv_duo/Makefile
index 18ada7d72ff..aa321d15687 100644
--- a/board/sophgo/milkv_duo/Makefile
+++ b/board/sophgo/milkv_duo/Makefile
@@ -3,4 +3,4 @@
# Copyright (c) 2024, Kongyang Liu <seashell11234455@gmail.com>
obj-y += board.o
-obj-$(CONFIG_NET_LEGACY) += ethernet.o
+obj-$(CONFIG_NET_LEGACY) += ../common/ethernet.o
diff --git a/board/sophgo/milkv_duo/board.c b/board/sophgo/milkv_duo/board.c
index f0944859b58..34339c42925 100644
--- a/board/sophgo/milkv_duo/board.c
+++ b/board/sophgo/milkv_duo/board.c
@@ -5,7 +5,7 @@
#include <dm/lists.h>
-#include "ethernet.h"
+#include "../common/ethernet.h"
int board_init(void)
{
--
2.53.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v2 2/2] board: sophgo: add support for Milk-V Duo 256M
2026-07-23 14:44 [PATCH v2 0/2] board: sophgo: add support for Milk-V Duo 256M Hiago De Franco
2026-07-23 14:44 ` [PATCH v2 1/2] board: sophgo: move ethernet driver to common directory Hiago De Franco
@ 2026-07-23 14:44 ` Hiago De Franco
2026-08-05 15:31 ` Leo Liang via U-Boot
2026-08-05 15:50 ` [PATCH v2 0/2] " Leo Liang via U-Boot
2026-08-22 9:15 ` Andrei Lalaev
3 siblings, 1 reply; 14+ messages in thread
From: Hiago De Franco @ 2026-07-23 14:44 UTC (permalink / raw)
To: u-boot
Cc: Kongyang Liu, Tom Rini, Peter Robinson, Ilias Apalodimas,
Quentin Schulz, Rick Chen, Leo, Jamie Gibbons, Conor Dooley,
Randolph Sheng-Kai Lin, Yao Zi, Andreas Schwab, Michal Simek,
Martin Herren, Peng Fan, Sam Protsenko, u-boot
Add U-Boot support for Milk-V Duo 256M.
This board has a different SoC compared to the Milk-V Duo 64M, it uses
the Sophgo SG2002 instead of the Sophgo CV1800B. Both SoCs share many
common IP blocks, so this board reuses the existing cv1800b CPU support.
The board shares the same 'board.c' with Milk-V Duo 64MB (CV1800B), so
use the same file for now.
Link: https://milkv.io/docs/duo/getting-started/duo256m
Signed-off-by: Hiago De Franco <hfranco@baylibre.com>
---
arch/riscv/Kconfig | 4 ++
arch/riscv/dts/Makefile | 1 +
arch/riscv/dts/sg2002-milkv-duo256m.dts | 46 ++++++++++++++
board/sophgo/milkv_duo_256m/Kconfig | 30 +++++++++
board/sophgo/milkv_duo_256m/MAINTAINERS | 5 ++
board/sophgo/milkv_duo_256m/Makefile | 6 ++
board/sophgo/milkv_duo_256m/milkv_duo_256m.env | 8 +++
configs/milkv_duo_256m_defconfig | 42 +++++++++++++
doc/board/sophgo/index.rst | 1 +
doc/board/sophgo/milkv_duo_256m.rst | 84 ++++++++++++++++++++++++++
include/configs/milkv_duo_256m.h | 12 ++++
11 files changed, 239 insertions(+)
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index ad7589123c6..8a285c32072 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -32,6 +32,9 @@ config TARGET_MICROCHIP_GENERIC
config TARGET_MILKV_DUO
bool "Support Milk-v Duo Board"
+config TARGET_MILKV_DUO_256M
+ bool "Support Milk-V Duo 256M Board"
+
config TARGET_OPENPITON_RISCV64
bool "Support RISC-V cores on OpenPiton SoC"
@@ -118,6 +121,7 @@ source "board/sifive/unleashed/Kconfig"
source "board/sifive/unmatched/Kconfig"
source "board/sipeed/maix/Kconfig"
source "board/sophgo/milkv_duo/Kconfig"
+source "board/sophgo/milkv_duo_256m/Kconfig"
source "board/sophgo/licheerv_nano/Kconfig"
source "board/spacemit/bananapi-f3/Kconfig"
source "board/starfive/visionfive2/Kconfig"
diff --git a/arch/riscv/dts/Makefile b/arch/riscv/dts/Makefile
index 8e591cb7aa9..c20b980b3af 100644
--- a/arch/riscv/dts/Makefile
+++ b/arch/riscv/dts/Makefile
@@ -6,6 +6,7 @@ dtb-$(CONFIG_TARGET_BANANAPI_F3) += k1-bananapi-f3.dtb
dtb-$(CONFIG_TARGET_K230_CANMV) += k230-canmv.dtb
dtb-$(CONFIG_TARGET_MICROCHIP_ICICLE) += mpfs-icicle-kit.dtb
dtb-$(CONFIG_TARGET_MILKV_DUO) += cv1800b-milkv-duo.dtb
+dtb-$(CONFIG_TARGET_MILKV_DUO_256M) += sg2002-milkv-duo256m.dtb
dtb-$(CONFIG_TARGET_LICHEERV_NANO) += sg2002-licheerv-nano-b.dtb
dtb-$(CONFIG_TARGET_QEMU_VIRT) += qemu-virt32.dtb qemu-virt64.dtb
dtb-$(CONFIG_TARGET_OPENPITON_RISCV64) += openpiton-riscv64.dtb
diff --git a/arch/riscv/dts/sg2002-milkv-duo256m.dts b/arch/riscv/dts/sg2002-milkv-duo256m.dts
new file mode 100644
index 00000000000..4ad86ce39ec
--- /dev/null
+++ b/arch/riscv/dts/sg2002-milkv-duo256m.dts
@@ -0,0 +1,46 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/*
+ * Copyright (C) 2026 Hiago De Franco <hfranco@baylibre.com>
+ */
+
+/dts-v1/;
+
+#include "sg2002.dtsi"
+
+/ {
+ model = "Milk-V Duo 256M";
+ compatible = "milkv,duo256m", "sophgo,sg2002";
+
+ aliases {
+ serial0 = &uart0;
+ serial1 = &uart1;
+ serial2 = &uart2;
+ serial3 = &uart3;
+ serial4 = &uart4;
+ };
+
+ chosen {
+ stdout-path = "serial0:115200n8";
+ };
+};
+
+ðernet0 {
+ status = "okay";
+ phy-mode = "rmii";
+};
+
+&osc {
+ clock-frequency = <25000000>;
+};
+
+&sdhci0 {
+ status = "okay";
+ bus-width = <4>;
+ no-1-8-v;
+ no-mmc;
+ no-sdio;
+};
+
+&uart0 {
+ status = "okay";
+};
diff --git a/board/sophgo/milkv_duo_256m/Kconfig b/board/sophgo/milkv_duo_256m/Kconfig
new file mode 100644
index 00000000000..a443207f65e
--- /dev/null
+++ b/board/sophgo/milkv_duo_256m/Kconfig
@@ -0,0 +1,30 @@
+if TARGET_MILKV_DUO_256M
+
+config SYS_BOARD
+ default "milkv_duo_256m"
+
+config SYS_VENDOR
+ default "sophgo"
+
+config SYS_CPU
+ default "cv1800b"
+
+config SYS_CONFIG_NAME
+ default "milkv_duo_256m"
+
+# The vendor FIP tool prepends a 32-byte loader header to u-boot.bin and loads
+# the result at 0x80200000, so the U-Boot code runs 0x20 bytes above that.
+config TEXT_BASE
+ default 0x80200020
+
+config ENV_SIZE
+ default 0x20000
+
+config ENV_SECT_SIZE
+ default 0x40000
+
+config BOARD_SPECIFIC_OPTIONS
+ def_bool y
+ select SOPHGO_CV1800B
+
+endif
diff --git a/board/sophgo/milkv_duo_256m/MAINTAINERS b/board/sophgo/milkv_duo_256m/MAINTAINERS
new file mode 100644
index 00000000000..929960e7251
--- /dev/null
+++ b/board/sophgo/milkv_duo_256m/MAINTAINERS
@@ -0,0 +1,5 @@
+Milk-V Duo 256M
+M: Hiago De Franco <hfranco@baylibre.com>
+S: Maintained
+F: board/sophgo/milkv_duo_256m/
+F: configs/milkv_duo_256m_defconfig
diff --git a/board/sophgo/milkv_duo_256m/Makefile b/board/sophgo/milkv_duo_256m/Makefile
new file mode 100644
index 00000000000..c3068e56bf4
--- /dev/null
+++ b/board/sophgo/milkv_duo_256m/Makefile
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (c) 2026, Hiago De Franco <hfranco@baylibre.com>
+
+obj-y += ../milkv_duo/board.o
+obj-$(CONFIG_NET_LEGACY) += ../common/ethernet.o
diff --git a/board/sophgo/milkv_duo_256m/milkv_duo_256m.env b/board/sophgo/milkv_duo_256m/milkv_duo_256m.env
new file mode 100644
index 00000000000..4c1e17b53ca
--- /dev/null
+++ b/board/sophgo/milkv_duo_256m/milkv_duo_256m.env
@@ -0,0 +1,8 @@
+fdt_addr_r=0x84000000
+fdtfile=CONFIG_DEFAULT_DEVICE_TREE.dtb
+kernel_addr_r=0x80200000
+kernel_comp_addr_r=0x88000000
+kernel_comp_size=0x4000000
+pxefile_addr_r=0x84300000
+ramdisk_addr_r=0x84400000
+scriptaddr=0x84200000
diff --git a/configs/milkv_duo_256m_defconfig b/configs/milkv_duo_256m_defconfig
new file mode 100644
index 00000000000..9d92eec6394
--- /dev/null
+++ b/configs/milkv_duo_256m_defconfig
@@ -0,0 +1,42 @@
+CONFIG_RISCV=y
+CONFIG_SYS_MALLOC_LEN=0x820000
+CONFIG_SYS_MALLOC_F_LEN=0x8000
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
+CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x82300000
+CONFIG_DEFAULT_DEVICE_TREE="sg2002-milkv-duo256m"
+CONFIG_SYS_LOAD_ADDR=0x80080000
+CONFIG_IDENT_STRING="milkv_duo_256m"
+CONFIG_TARGET_MILKV_DUO_256M=y
+CONFIG_ARCH_RV64I=y
+CONFIG_RISCV_SMODE=y
+CONFIG_FIT=y
+CONFIG_BOOTSTD_FULL=y
+# CONFIG_BOOTMETH_EFI_BOOTMGR is not set
+CONFIG_SD_BOOT=y
+CONFIG_SYS_CBSIZE=512
+CONFIG_SYS_PBSIZE=544
+CONFIG_SYS_PROMPT="milkv_duo_256m# "
+# CONFIG_CMD_BOOTDEV is not set
+CONFIG_CMD_MBR=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_POWEROFF=y
+# CONFIG_CMD_MII is not set
+CONFIG_CMD_EXT4_WRITE=y
+# CONFIG_ISO_PARTITION is not set
+# CONFIG_EFI_PARTITION is not set
+CONFIG_ENV_OVERWRITE=y
+CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_CLK_SOPHGO_CV1800B=y
+CONFIG_MMC=y
+CONFIG_MMC_IO_VOLTAGE=y
+CONFIG_MMC_UHS_SUPPORT=y
+CONFIG_MMC_SDHCI=y
+CONFIG_MMC_SDHCI_ADMA=y
+CONFIG_MMC_SDHCI_CV1800B=y
+CONFIG_ETH_DESIGNWARE=y
+CONFIG_SYS_NS16550=y
+CONFIG_SYS_NS16550_MEM32=y
+CONFIG_SPI=y
+CONFIG_SYSRESET=y
+CONFIG_SYSRESET_CV1800B=y
diff --git a/doc/board/sophgo/index.rst b/doc/board/sophgo/index.rst
index 26dba4a4851..19c9a19b1d4 100644
--- a/doc/board/sophgo/index.rst
+++ b/doc/board/sophgo/index.rst
@@ -6,4 +6,5 @@ Sophgo
:maxdepth: 1
milkv_duo
+ milkv_duo_256m
licheerv_nano
diff --git a/doc/board/sophgo/milkv_duo_256m.rst b/doc/board/sophgo/milkv_duo_256m.rst
new file mode 100644
index 00000000000..9e2cbddf4db
--- /dev/null
+++ b/doc/board/sophgo/milkv_duo_256m.rst
@@ -0,0 +1,84 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+Milk-V Duo 256M
+===============
+
+SG2002 RISC-V SoC
+------------------
+The SG2002 is a high-performance, low-power 64-bit RISC-V/ARM SoC from Sophgo.
+
+Mainline support
+----------------
+The support for following drivers are already enabled:
+
+1. ns16550 UART Driver.
+2. Synopsys Designware MSHC Driver.
+3. Synopsys Designware Ethernet Controller.
+
+Building
+~~~~~~~~
+1. Add the RISC-V toolchain to your PATH.
+2. Setup ARCH & cross compilation environment variable:
+
+.. code-block:: console
+
+ export CROSS_COMPILE=<riscv64 toolchain prefix>
+ cd <U-Boot-dir>
+ make milkv_duo_256m_defconfig
+ make
+
+This will generate u-boot.bin
+
+Booting
+~~~~~~~
+Currently, we rely on vendor FSBL (First Stage Boot Loader) to initialize the
+clock and load OpenSBI and the u-boot image, then bootup from it.
+
+To run u-boot.bin on top of FSBL, follow these steps:
+
+1. Generate a compatible u-boot.bin using U-Boot with the Milk-V Duo 256M
+ default configuration.
+
+2. Use mainline OpenSBI with a newer version than 1.5 to generate fw_dynamic.
+ Use FDT_FW_PATH to point to sg2002-milkv-duo256m.dtb device tree file while
+ compiling fw_dynamic. Example:
+
+.. code-block:: console
+
+ cd open-sbi
+ PLATFORM=generic FW_FDT_PATH=../u-boot/arch/riscv/dts/sg2002-milkv-duo256m.dtb make
+
+This will generate build/platform/generic/firmware/fw_dynamic.bin.
+
+3. Use the vendor-provided tool [1] to create a unified fip.bin file containing
+ FSBL, OpenSBI, and U-Boot.
+ Note that you will have to use the file cv181x.bin as the FSBL.
+
+4. Place the generated fip.bin file into the FAT partition of the SD card.
+
+5. Insert the SD card into the board and power it on.
+
+The board will automatically execute the FSBL from the fip.bin file.
+Subsequently, it will transition to OpenSBI, and finally, OpenSBI will invoke
+U-Boot.
+
+[1]: https://github.com/sophgo/fiptool
+
+Sample boot log from Milk-V 256M Duo board
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.. code-block:: none
+
+ U-Boot 2026.07-00002-g0b690770386f-dirty (Jul 07 2026 - 13:33:36 -0300)milkv_duo_256m
+
+ DRAM: 256 MiB
+ Core: 20 devices, 13 uclasses, devicetree: separate
+ MMC: mmc@4310000: 0
+ Loading Environment from nowhere... OK
+ In: serial@4140000
+ Out: serial@4140000
+ Err: serial@4140000
+ Net:
+ Warning: ethernet@4070000 (eth0) using random MAC address - 0a:f3:23:40:7e:55
+ eth0: ethernet@4070000
+ Hit any key to stop autoboot: 0
+ milkv_duo_256m#
diff --git a/include/configs/milkv_duo_256m.h b/include/configs/milkv_duo_256m.h
new file mode 100644
index 00000000000..4d6678b9c84
--- /dev/null
+++ b/include/configs/milkv_duo_256m.h
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2026, Hiago De Franco <hfranco@baylibre.com>
+ *
+ */
+
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+#define CFG_SYS_SDRAM_BASE 0x80000000
+
+#endif /* __CONFIG_H */
--
2.53.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH v2 1/2] board: sophgo: move ethernet driver to common directory
2026-07-23 14:44 ` [PATCH v2 1/2] board: sophgo: move ethernet driver to common directory Hiago De Franco
@ 2026-08-05 15:29 ` Leo Liang via U-Boot
0 siblings, 0 replies; 14+ messages in thread
From: Leo Liang via U-Boot @ 2026-08-05 15:29 UTC (permalink / raw)
To: Hiago De Franco
Cc: u-boot, Kongyang Liu, Tom Rini, Peter Robinson, Ilias Apalodimas,
Quentin Schulz, Rick Chen, Leo, Jamie Gibbons, Conor Dooley,
Randolph Sheng-Kai Lin, Yao Zi, Andreas Schwab, Michal Simek,
Martin Herren, Peng Fan, Sam Protsenko, u-boot
On Thu, Jul 23, 2026 at 11:44:34AM -0300, Hiago De Franco wrote:
> This will make easier for future boards to reuse the same driver (e.g.
> Milk-V Duo 256MB).
>
> Signed-off-by: Hiago De Franco <hfranco@baylibre.com>
> ---
> board/sophgo/{milkv_duo => common}/ethernet.c | 0
> board/sophgo/{milkv_duo => common}/ethernet.h | 0
> board/sophgo/milkv_duo/MAINTAINERS | 1 +
> board/sophgo/milkv_duo/Makefile | 2 +-
> board/sophgo/milkv_duo/board.c | 2 +-
> 5 files changed, 3 insertions(+), 2 deletions(-)
Acked-by: Leo Yu-Chi Liang <leo.liang@sifive.com>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 2/2] board: sophgo: add support for Milk-V Duo 256M
2026-07-23 14:44 ` [PATCH v2 2/2] board: sophgo: add support for Milk-V Duo 256M Hiago De Franco
@ 2026-08-05 15:31 ` Leo Liang via U-Boot
0 siblings, 0 replies; 14+ messages in thread
From: Leo Liang via U-Boot @ 2026-08-05 15:31 UTC (permalink / raw)
To: Hiago De Franco
Cc: u-boot, Kongyang Liu, Tom Rini, Peter Robinson, Ilias Apalodimas,
Quentin Schulz, Rick Chen, Leo, Jamie Gibbons, Conor Dooley,
Randolph Sheng-Kai Lin, Yao Zi, Andreas Schwab, Michal Simek,
Martin Herren, Peng Fan, Sam Protsenko, u-boot
On Thu, Jul 23, 2026 at 11:44:35AM -0300, Hiago De Franco wrote:
> Add U-Boot support for Milk-V Duo 256M.
>
> This board has a different SoC compared to the Milk-V Duo 64M, it uses
> the Sophgo SG2002 instead of the Sophgo CV1800B. Both SoCs share many
> common IP blocks, so this board reuses the existing cv1800b CPU support.
>
> The board shares the same 'board.c' with Milk-V Duo 64MB (CV1800B), so
> use the same file for now.
>
> Link: https://milkv.io/docs/duo/getting-started/duo256m
> Signed-off-by: Hiago De Franco <hfranco@baylibre.com>
> ---
> arch/riscv/Kconfig | 4 ++
> arch/riscv/dts/Makefile | 1 +
> arch/riscv/dts/sg2002-milkv-duo256m.dts | 46 ++++++++++++++
> board/sophgo/milkv_duo_256m/Kconfig | 30 +++++++++
> board/sophgo/milkv_duo_256m/MAINTAINERS | 5 ++
> board/sophgo/milkv_duo_256m/Makefile | 6 ++
> board/sophgo/milkv_duo_256m/milkv_duo_256m.env | 8 +++
> configs/milkv_duo_256m_defconfig | 42 +++++++++++++
> doc/board/sophgo/index.rst | 1 +
> doc/board/sophgo/milkv_duo_256m.rst | 84 ++++++++++++++++++++++++++
> include/configs/milkv_duo_256m.h | 12 ++++
> 11 files changed, 239 insertions(+)
Acked-by: Leo Yu-Chi Liang <leo.liang@sifive.com>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 0/2] board: sophgo: add support for Milk-V Duo 256M
2026-07-23 14:44 [PATCH v2 0/2] board: sophgo: add support for Milk-V Duo 256M Hiago De Franco
2026-07-23 14:44 ` [PATCH v2 1/2] board: sophgo: move ethernet driver to common directory Hiago De Franco
2026-07-23 14:44 ` [PATCH v2 2/2] board: sophgo: add support for Milk-V Duo 256M Hiago De Franco
@ 2026-08-05 15:50 ` Leo Liang via U-Boot
2026-08-22 9:15 ` Andrei Lalaev
3 siblings, 0 replies; 14+ messages in thread
From: Leo Liang via U-Boot @ 2026-08-05 15:50 UTC (permalink / raw)
To: Hiago De Franco
Cc: u-boot, Kongyang Liu, Tom Rini, Peter Robinson, Ilias Apalodimas,
Quentin Schulz, Rick Chen, Leo, Jamie Gibbons, Conor Dooley,
Randolph Sheng-Kai Lin, Yao Zi, Andreas Schwab, Michal Simek,
Martin Herren, Peng Fan, Sam Protsenko, u-boot
Hi Hiago,
On Thu, Jul 23, 2026 at 11:44:33AM -0300, Hiago De Franco wrote:
> Milk-V Duo 256M is a small development board based on the Sophgo SG2002
> SoC.
>
> U-Boot runs as the S-mode payload on top of the vendor FSBL and OpenSBI,
> packaged together into a FIP image on the SD card.
>
> The vendor FIP tool prepends a 32-byte loader header to u-boot.bin and
> loads the result at 0x80200000, so TEXT_BASE is set to 0x80200020 to
> match the address the U-Boot code actually runs.
>
> The following peripherals are supported:
> - ns16550 serial console (UART0)
> - SD/MMC
> - Ethernet with the SoC internal PHY
>
> This patch was tested on Milk-V Duo 256MB using an SD card and the Duo
> USB & Ethernet IOB (base board) [0].
>
> This series uses the CV1800B SYS_CPU target since SG2002 shares common
> IPs with CV1800B. Other SG2002 as LicheeRV Nano does the same.
>
> Note: Linux device tree is not yet merged [1], therefore I am adding a
> device tree here and it can be later changed to use the kernel upstream
> one.
>
> [0] https://milkv.io/docs/duo/io-board/usb-ethernet-iob
> [1] https://lore.kernel.org/lkml/20260710075917.159969-1-chenyou910331@gmail.com/
>
> Link: https://milkv.io/docs/duo/getting-started/duo256m
> Signed-off-by: Hiago De Franco <hfranco@baylibre.com>
> ---
> Changes in v2:
> - Makefile: changed to use 'milkv_duo/board.c' instead of
> 'milkv_duo_256m/board.c', since they share the exact same code.
> - board.c: deleted, because of the above.
> - doc: updated to add Ethernet support.
> - Link to v1: https://lore.kernel.org/r/20260710-add-milkv-duo256m-v1-0-0f761100361d@baylibre.com
>
> ---
> Hiago De Franco (2):
> board: sophgo: move ethernet driver to common directory
> board: sophgo: add support for Milk-V Duo 256M
>
> arch/riscv/Kconfig | 4 ++
> arch/riscv/dts/Makefile | 1 +
> arch/riscv/dts/sg2002-milkv-duo256m.dts | 46 ++++++++++++++
> board/sophgo/{milkv_duo => common}/ethernet.c | 0
> board/sophgo/{milkv_duo => common}/ethernet.h | 0
> board/sophgo/milkv_duo/MAINTAINERS | 1 +
> board/sophgo/milkv_duo/Makefile | 2 +-
> board/sophgo/milkv_duo/board.c | 2 +-
> board/sophgo/milkv_duo_256m/Kconfig | 30 +++++++++
> board/sophgo/milkv_duo_256m/MAINTAINERS | 5 ++
> board/sophgo/milkv_duo_256m/Makefile | 6 ++
> board/sophgo/milkv_duo_256m/milkv_duo_256m.env | 8 +++
> configs/milkv_duo_256m_defconfig | 42 +++++++++++++
> doc/board/sophgo/index.rst | 1 +
> doc/board/sophgo/milkv_duo_256m.rst | 84 ++++++++++++++++++++++++++
> include/configs/milkv_duo_256m.h | 12 ++++
> 16 files changed, 242 insertions(+), 2 deletions(-)
> ---
> base-commit: ece349ade2973e220f524ce59e59711cc919263f
> change-id: 20260710-add-milkv-duo256m-1662c5cafb35
>
> Best regards,
Applied to u-boot-riscv/main, thanks.
Best regards,
Leo
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 0/2] board: sophgo: add support for Milk-V Duo 256M
2026-07-23 14:44 [PATCH v2 0/2] board: sophgo: add support for Milk-V Duo 256M Hiago De Franco
` (2 preceding siblings ...)
2026-08-05 15:50 ` [PATCH v2 0/2] " Leo Liang via U-Boot
@ 2026-08-22 9:15 ` Andrei Lalaev
2026-08-25 12:24 ` Hiago De Franco
3 siblings, 1 reply; 14+ messages in thread
From: Andrei Lalaev @ 2026-08-22 9:15 UTC (permalink / raw)
To: hfranco; +Cc: andrey.lalaev, u-boot, u-boot
Hi Hiago,
Thank you for the patches.
From your cover letter I understood that SD card is supported.
However whatever I try, I always get the following error:
U-Boot 2026.07-00002-gbd5e3de2ed6a (Aug 22 2026 - 10:27:48 +0200)milkv_duo_256m
DRAM: 256 MiB
Core: 20 devices, 13 uclasses, devicetree: separate
MMC: mmc@4310000: 0
Loading Environment from nowhere... OK
In: serial@4140000
Out: serial@4140000
Err: serial@4140000
Net:
Warning: ethernet@4070000 (eth0) using random MAC address - 16:21:8c:10:cd:96
eth0: ethernet@4070000
Hit any key to stop autoboot: 0
milkv_duo_256m# mmc info
Card did not respond to voltage select! : -110
milkv_duo_256m# mmc rescan
Card did not respond to voltage select! : -110
I tried 2 different SD cards and got the same result.
Am I doing something wrong, or is there something else I need to configure?
Best regards,
Andrei Lalaev
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 0/2] board: sophgo: add support for Milk-V Duo 256M
2026-08-22 9:15 ` Andrei Lalaev
@ 2026-08-25 12:24 ` Hiago De Franco
2026-08-25 18:01 ` Andrei Lalaev
0 siblings, 1 reply; 14+ messages in thread
From: Hiago De Franco @ 2026-08-25 12:24 UTC (permalink / raw)
To: Andrei Lalaev; +Cc: u-boot, u-boot
Hi Andrei,
On Sat, Aug 22, 2026 at 11:15:10AM +0200, Andrei Lalaev wrote:
> Hi Hiago,
>
> Thank you for the patches.
>
> From your cover letter I understood that SD card is supported.
> However whatever I try, I always get the following error:
>
> U-Boot 2026.07-00002-gbd5e3de2ed6a (Aug 22 2026 - 10:27:48 +0200)milkv_duo_256m
>
> DRAM: 256 MiB
> Core: 20 devices, 13 uclasses, devicetree: separate
> MMC: mmc@4310000: 0
> Loading Environment from nowhere... OK
> In: serial@4140000
> Out: serial@4140000
> Err: serial@4140000
> Net:
> Warning: ethernet@4070000 (eth0) using random MAC address - 16:21:8c:10:cd:96
> eth0: ethernet@4070000
> Hit any key to stop autoboot: 0
> milkv_duo_256m# mmc info
> Card did not respond to voltage select! : -110
> milkv_duo_256m# mmc rescan
> Card did not respond to voltage select! : -110
>
>
> I tried 2 different SD cards and got the same result.
>
> Am I doing something wrong, or is there something else I need to configure?
You are most likely missing this patch:
https://lore.kernel.org/all/20260507234836.284918-1-hfranco@baylibre.com/
This is needed in order to make the SD card work. This patch is already
merged on main branch, as commit 3a4a8963aace ("mmc: cv1800b_sdhci:
honor 'no-1-8-v' DT property").
Check this patch and let me know if it works now ;)
>
>
> Best regards,
> Andrei Lalaev
Regards,
Hiago.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 0/2] board: sophgo: add support for Milk-V Duo 256M
2026-08-25 12:24 ` Hiago De Franco
@ 2026-08-25 18:01 ` Andrei Lalaev
2026-08-27 13:30 ` Hiago De Franco
0 siblings, 1 reply; 14+ messages in thread
From: Andrei Lalaev @ 2026-08-25 18:01 UTC (permalink / raw)
To: Hiago De Franco; +Cc: u-boot, u-boot
On 25.08.26 14:24, Hiago De Franco wrote:
> Hi Andrei,
>
> On Sat, Aug 22, 2026 at 11:15:10AM +0200, Andrei Lalaev wrote:
>> Hi Hiago,
>>
>> Thank you for the patches.
>>
>> From your cover letter I understood that SD card is supported.
>> However whatever I try, I always get the following error:
>>
>> U-Boot 2026.07-00002-gbd5e3de2ed6a (Aug 22 2026 - 10:27:48 +0200)milkv_duo_256m
>>
>> DRAM: 256 MiB
>> Core: 20 devices, 13 uclasses, devicetree: separate
>> MMC: mmc@4310000: 0
>> Loading Environment from nowhere... OK
>> In: serial@4140000
>> Out: serial@4140000
>> Err: serial@4140000
>> Net:
>> Warning: ethernet@4070000 (eth0) using random MAC address - 16:21:8c:10:cd:96
>> eth0: ethernet@4070000
>> Hit any key to stop autoboot: 0
>> milkv_duo_256m# mmc info
>> Card did not respond to voltage select! : -110
>> milkv_duo_256m# mmc rescan
>> Card did not respond to voltage select! : -110
>>
>>
>> I tried 2 different SD cards and got the same result.
>>
>> Am I doing something wrong, or is there something else I need to configure?
>
> You are most likely missing this patch:
>
> https://lore.kernel.org/all/20260507234836.284918-1-hfranco@baylibre.com/
>
> This is needed in order to make the SD card work. This patch is already
> merged on main branch, as commit 3a4a8963aace ("mmc: cv1800b_sdhci:
> honor 'no-1-8-v' DT property").
>
> Check this patch and let me know if it works now ;)
Thank you for your response:)
I also tried the latest main branch (so all patches are definitely included)
and had the same problem.
I guess I somehow managed to fix the problem, so below I'll describe what I did
and would like to hear your thoughts about it.
When I generated `fip.bin` using precompiled binaries from fiptool repo [1],
it started working most of the time. Previously I was using an FSBL manually generated
using official SDK [2]. However, I would still occasionally get
voltage select error and timeouts.
So I started comparing FSBL and U-boot from Sophgo (2021.10) and
I couldn't find any differences that could explain this behaviour.
Today I found out that the kernel DTS configures the SD0_CLK pin to a different value [3].
By default, we have 0x48 in IOBLK_G10_REG_SD0_CLK register, but if I set it to 0x84
like kernel does, it magically starts to work all the time.
I understand why increasing the drive strength fixed timeout issues, but I don't understand
why I don't see the same problem with the U-Boot from Sophgo (2021.10).
1 - https://github.com/sophgo/fiptool
2 - https://github.com/milkv-duo/duo-buildroot-sdk-v2/tree/main
3 - https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/riscv/boot/dts/sophgo/sg2002-milkv-duo256m.dts#n68
>>
>>
>> Best regards,
>> Andrei Lalaev
>
> Regards,
> Hiago.
--
Best regards,
Andrei Lalaev
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 0/2] board: sophgo: add support for Milk-V Duo 256M
2026-08-25 18:01 ` Andrei Lalaev
@ 2026-08-27 13:30 ` Hiago De Franco
2026-08-27 16:04 ` Andrei Lalaev
0 siblings, 1 reply; 14+ messages in thread
From: Hiago De Franco @ 2026-08-27 13:30 UTC (permalink / raw)
To: Andrei Lalaev; +Cc: u-boot, u-boot
Hi Andrei,
On Tue, Aug 25, 2026 at 08:01:37PM +0200, Andrei Lalaev wrote:
> On 25.08.26 14:24, Hiago De Franco wrote:
> > Hi Andrei,
> >
> > On Sat, Aug 22, 2026 at 11:15:10AM +0200, Andrei Lalaev wrote:
> >> Hi Hiago,
> >>
> >> Thank you for the patches.
> >>
> >> From your cover letter I understood that SD card is supported.
> >> However whatever I try, I always get the following error:
> >>
> >> U-Boot 2026.07-00002-gbd5e3de2ed6a (Aug 22 2026 - 10:27:48 +0200)milkv_duo_256m
> >>
> >> DRAM: 256 MiB
> >> Core: 20 devices, 13 uclasses, devicetree: separate
> >> MMC: mmc@4310000: 0
> >> Loading Environment from nowhere... OK
> >> In: serial@4140000
> >> Out: serial@4140000
> >> Err: serial@4140000
> >> Net:
> >> Warning: ethernet@4070000 (eth0) using random MAC address - 16:21:8c:10:cd:96
> >> eth0: ethernet@4070000
> >> Hit any key to stop autoboot: 0
> >> milkv_duo_256m# mmc info
> >> Card did not respond to voltage select! : -110
> >> milkv_duo_256m# mmc rescan
> >> Card did not respond to voltage select! : -110
> >>
> >>
> >> I tried 2 different SD cards and got the same result.
> >>
> >> Am I doing something wrong, or is there something else I need to configure?
> >
> > You are most likely missing this patch:
> >
> > https://lore.kernel.org/all/20260507234836.284918-1-hfranco@baylibre.com/
> >
> > This is needed in order to make the SD card work. This patch is already
> > merged on main branch, as commit 3a4a8963aace ("mmc: cv1800b_sdhci:
> > honor 'no-1-8-v' DT property").
> >
> > Check this patch and let me know if it works now ;)
>
> Thank you for your response:)
>
> I also tried the latest main branch (so all patches are definitely included)
> and had the same problem.
>
> I guess I somehow managed to fix the problem, so below I'll describe what I did
> and would like to hear your thoughts about it.
>
>
> When I generated `fip.bin` using precompiled binaries from fiptool repo [1],
> it started working most of the time. Previously I was using an FSBL manually generated
> using official SDK [2]. However, I would still occasionally get
> voltage select error and timeouts.
>
> So I started comparing FSBL and U-boot from Sophgo (2021.10) and
> I couldn't find any differences that could explain this behaviour.
>
> Today I found out that the kernel DTS configures the SD0_CLK pin to a different value [3].
> By default, we have 0x48 in IOBLK_G10_REG_SD0_CLK register, but if I set it to 0x84
> like kernel does, it magically starts to work all the time.
>
> I understand why increasing the drive strength fixed timeout issues, but I don't understand
> why I don't see the same problem with the U-Boot from Sophgo (2021.10).
>
> 1 - https://github.com/sophgo/fiptool
> 2 - https://github.com/milkv-duo/duo-buildroot-sdk-v2/tree/main
> 3 - https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/riscv/boot/dts/sophgo/sg2002-milkv-duo256m.dts#n68
Thanks for digging into this.
I made some tests here on my milkv-duo 256M and I might have the answer
you are looking for, hopefully.
0x48 is SoC reset value, based on the TRM. This is what I read on my
U-Boot (main branch, like yours):
0x03001a00 SD0_CLK = 0x48 pull-down, 10800 uA <-- reset value
So on my board the BootROM already does everything Sophgo's
cvi_sdio0_pad_setting() does. SD0_CLK is the single register nobody
programs, exactly as you found. I also checked the FSBL and it never
touches SD0 and never touches drive strength, from what I could see.
I am not able to reproduce your issue, it works every time for me. I
suspect there is a difference on the hardware here: maybe your board has
less margin for the drive strength than mine, it works at the stock
50MHz even with the CLK drive strength at its minimum.
To trigger the issue, I had to force SDHCI divider from N=4 to N=2, so
doubling the clock. With that, I triggered your issue. Of course I am
not sure if this is the same issue that is triggering your, but at least
now with the double clock I was able to increase the drive strength by
writing 0x84 (the kernel value) and it fixed the issue (which makes
sense).
I was not able to properly answer the reason why Sophgo U-Boot works, so
I used Claude to look at the code for me and compare the differences,
here is what it found out:
"It is the PHY. cvi_sdhci_set_ios_post() has a DS/HS branch that does:
PHY_CONFIG (0x24c) |= BIT(0) /* TX_BPS */
PHY_TX_RX_DLY (0x240) = 0x01000100
The kernel does the same thing, unconditionally, in
cv18xx_sdhci_reset() (drivers/mmc/host/sdhci-of-dwcmshc.c):
val |= CV18XX_PHY_TX_BPS; /* PHY_CONFIG bit 0 */
val = TX_DLY(0) | TX_SRC(INVERT_CLK_TX)
| RX_DLY(0) | RX_SRC(INVERT_RX_CLK); /* == 0x01000100 */
Upstream U-Boot does neither. cv1800b_sdhci.c only writes
SDHCI_PHY_TX_RX_DLY from cv1800b_execute_tuning(), reached only through
platform_execute_tuning - and that never runs on this board, because
no-1-8-v caps us at High Speed 50MHz / 3.3V and tuning only happens in
UHS modes."
I am not 100% convinced by that, but I will take a look, we might need a
patch here on upstream to configure the PHY properly as the downstream
u-boot and kernel does. Anyway, is funny that I can only reproduce your
issue on this conditions, but these boards might not be something we can
blindly trust ;)
Could you dump these on your board, at the U-Boot prompt on unmodified
upstream main, before touching anything?
md.l 0x03001a00 8 # SD0_CLK / CMD / D0-D3 pad config
md.l 0x03001900 4 # SD0_CD, SD0_PWR_EN
md.l 0x030001f4 1 # sd_pwrsw_ctrl
md.l 0x0300101c 8 # SD0 pin mux
md.l 0x04310240 1 # PHY_TX_RX_DLY
md.l 0x0431024c 1 # PHY_CONFIG
Meanwhile I will be able to investigate this further in a couple of
days.
>
> >>
> >>
> >> Best regards,
> >> Andrei Lalaev
> >
> > Regards,
> > Hiago.
>
>
> --
> Best regards,
> Andrei Lalaev
Regards,
Hiago.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 0/2] board: sophgo: add support for Milk-V Duo 256M
2026-08-27 13:30 ` Hiago De Franco
@ 2026-08-27 16:04 ` Andrei Lalaev
2026-08-30 15:29 ` Andrei Lalaev
0 siblings, 1 reply; 14+ messages in thread
From: Andrei Lalaev @ 2026-08-27 16:04 UTC (permalink / raw)
To: Hiago De Franco; +Cc: u-boot, u-boot
Hi Hiago,
On 27.08.26 15:30, Hiago De Franco wrote:
> Hi Andrei,
>
> On Tue, Aug 25, 2026 at 08:01:37PM +0200, Andrei Lalaev wrote:
>> On 25.08.26 14:24, Hiago De Franco wrote:
>>> Hi Andrei,
>>>
>>> On Sat, Aug 22, 2026 at 11:15:10AM +0200, Andrei Lalaev wrote:
>>>> Hi Hiago,
>>>>
>>>> Thank you for the patches.
>>>>
>>>> From your cover letter I understood that SD card is supported.
>>>> However whatever I try, I always get the following error:
>>>>
>>>> U-Boot 2026.07-00002-gbd5e3de2ed6a (Aug 22 2026 - 10:27:48 +0200)milkv_duo_256m
>>>>
>>>> DRAM: 256 MiB
>>>> Core: 20 devices, 13 uclasses, devicetree: separate
>>>> MMC: mmc@4310000: 0
>>>> Loading Environment from nowhere... OK
>>>> In: serial@4140000
>>>> Out: serial@4140000
>>>> Err: serial@4140000
>>>> Net:
>>>> Warning: ethernet@4070000 (eth0) using random MAC address - 16:21:8c:10:cd:96
>>>> eth0: ethernet@4070000
>>>> Hit any key to stop autoboot: 0
>>>> milkv_duo_256m# mmc info
>>>> Card did not respond to voltage select! : -110
>>>> milkv_duo_256m# mmc rescan
>>>> Card did not respond to voltage select! : -110
>>>>
>>>>
>>>> I tried 2 different SD cards and got the same result.
>>>>
>>>> Am I doing something wrong, or is there something else I need to configure?
>>>
>>> You are most likely missing this patch:
>>>
>>> https://lore.kernel.org/all/20260507234836.284918-1-hfranco@baylibre.com/
>>>
>>> This is needed in order to make the SD card work. This patch is already
>>> merged on main branch, as commit 3a4a8963aace ("mmc: cv1800b_sdhci:
>>> honor 'no-1-8-v' DT property").
>>>
>>> Check this patch and let me know if it works now ;)
>>
>> Thank you for your response:)
>>
>> I also tried the latest main branch (so all patches are definitely included)
>> and had the same problem.
>>
>> I guess I somehow managed to fix the problem, so below I'll describe what I did
>> and would like to hear your thoughts about it.
>>
>>
>> When I generated `fip.bin` using precompiled binaries from fiptool repo [1],
>> it started working most of the time. Previously I was using an FSBL manually generated
>> using official SDK [2]. However, I would still occasionally get
>> voltage select error and timeouts.
>>
>> So I started comparing FSBL and U-boot from Sophgo (2021.10) and
>> I couldn't find any differences that could explain this behaviour.
>>
>> Today I found out that the kernel DTS configures the SD0_CLK pin to a different value [3].
>> By default, we have 0x48 in IOBLK_G10_REG_SD0_CLK register, but if I set it to 0x84
>> like kernel does, it magically starts to work all the time.
>>
>> I understand why increasing the drive strength fixed timeout issues, but I don't understand
>> why I don't see the same problem with the U-Boot from Sophgo (2021.10).
>>
>> 1 - https://github.com/sophgo/fiptool
>> 2 - https://github.com/milkv-duo/duo-buildroot-sdk-v2/tree/main
>> 3 - https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/riscv/boot/dts/sophgo/sg2002-milkv-duo256m.dts#n68
>
> Thanks for digging into this.
>
> I made some tests here on my milkv-duo 256M and I might have the answer
> you are looking for, hopefully.
>
> 0x48 is SoC reset value, based on the TRM. This is what I read on my
> U-Boot (main branch, like yours):
>
> 0x03001a00 SD0_CLK = 0x48 pull-down, 10800 uA <-- reset value
>
> So on my board the BootROM already does everything Sophgo's
> cvi_sdio0_pad_setting() does. SD0_CLK is the single register nobody
> programs, exactly as you found. I also checked the FSBL and it never
> touches SD0 and never touches drive strength, from what I could see.
>
> I am not able to reproduce your issue, it works every time for me. I
> suspect there is a difference on the hardware here: maybe your board has
> less margin for the drive strength than mine, it works at the stock
> 50MHz even with the CLK drive strength at its minimum.
>
> To trigger the issue, I had to force SDHCI divider from N=4 to N=2, so
> doubling the clock. With that, I triggered your issue. Of course I am
> not sure if this is the same issue that is triggering your, but at least
> now with the double clock I was able to increase the drive strength by
> writing 0x84 (the kernel value) and it fixed the issue (which makes
> sense).
That's interesting. Thank you for your investigation.
> I was not able to properly answer the reason why Sophgo U-Boot works, so
> I used Claude to look at the code for me and compare the differences,
> here is what it found out:
>
> "It is the PHY. cvi_sdhci_set_ios_post() has a DS/HS branch that does:
>
> PHY_CONFIG (0x24c) |= BIT(0) /* TX_BPS */
> PHY_TX_RX_DLY (0x240) = 0x01000100
>
> The kernel does the same thing, unconditionally, in
> cv18xx_sdhci_reset() (drivers/mmc/host/sdhci-of-dwcmshc.c):
>
> val |= CV18XX_PHY_TX_BPS; /* PHY_CONFIG bit 0 */
> val = TX_DLY(0) | TX_SRC(INVERT_CLK_TX)
> | RX_DLY(0) | RX_SRC(INVERT_RX_CLK); /* == 0x01000100 */
>
> Upstream U-Boot does neither. cv1800b_sdhci.c only writes
> SDHCI_PHY_TX_RX_DLY from cv1800b_execute_tuning(), reached only through
> platform_execute_tuning - and that never runs on this board, because
> no-1-8-v caps us at High Speed 50MHz / 3.3V and tuning only happens in
> UHS modes."
>
> I am not 100% convinced by that, but I will take a look, we might need a
> patch here on upstream to configure the PHY properly as the downstream
> u-boot and kernel does. Anyway, is funny that I can only reproduce your
> issue on this conditions, but these boards might not be something we can
> blindly trust ;)
>
> Could you dump these on your board, at the U-Boot prompt on unmodified
> upstream main, before touching anything?
>
> md.l 0x03001a00 8 # SD0_CLK / CMD / D0-D3 pad config
> md.l 0x03001900 4 # SD0_CD, SD0_PWR_EN
> md.l 0x030001f4 1 # sd_pwrsw_ctrl
> md.l 0x0300101c 8 # SD0 pin mux
> md.l 0x04310240 1 # PHY_TX_RX_DLY
> md.l 0x0431024c 1 # PHY_CONFIG
Sure, here is the register dump before `mmc rescan`:
# SD0_CLK / CMD / D0-D3 pad config
milkv_duo_256m# md.l 0x03001a00 8
03001a00: 00000048 00000044 00000044 00000044 H...D...D...D...
03001a10: 00000044 00000044 00000010 00000000 D...D...........
# SD0_CD, SD0_PWR_EN
milkv_duo_256m# md.l 0x03001900 4
03001900: 00000044 00000048 00000048 00000044 D...H...H...D...
# sd_pwrsw_ctrl
milkv_duo_256m# md.l 0x030001f4 1
030001f4: 00001209 ....
# SD0 pin mux
milkv_duo_256m# md.l 0x0300101c 8
0300101c: 00000000 00000000 00000000 00000000 ................
0300102c: 00000000 00000000 00000000 00000000 ................
# PHY_TX_RX_DLY
milkv_duo_256m# md.l 0x04310240 1
04310240: 00000000 ....
# PHY_CONFIG
milkv_duo_256m# md.l 0x0431024c 1
0431024c: 00000000 ....
and after:
milkv_duo_256m# mmc rescan
unable to select a mode
# SD0_CLK / CMD / D0-D3 pad config
milkv_duo_256m# md.l 0x03001a00 8
03001a00: 00000048 00000044 00000044 00000044 H...D...D...D...
03001a10: 00000044 00000044 00000010 00000000 D...D...........
# SD0_CD, SD0_PWR_EN
milkv_duo_256m# md.l 0x03001900 4
03001900: 00000044 00000048 00000048 00000044 D...H...H...D...
# sd_pwrsw_ctrl
milkv_duo_256m# md.l 0x030001f4 1
030001f4: 00001209 ....
# SD0 pin mux
milkv_duo_256m# md.l 0x0300101c 8
0300101c: 00000000 00000000 00000000 00000000 ................
0300102c: 00000000 00000000 00000000 00000000 ................
# PHY_TX_RX_DLY
milkv_duo_256m# md.l 0x04310240 1
04310240: 00000000 ....
# PHY_CONFIG
milkv_duo_256m# md.l 0x0431024c 1
0431024c: 00000000 ....
And if I try to rescan several more times (until SD card is detected
and `mmc info` succeeds), all the registers have the same values as before.
I will probably dump registers with downstream U-Boot and
tracing enabled this weekend.
> Meanwhile I will be able to investigate this further in a couple of
> days.
Thank you for your assistance :)
>>
>>>>
>>>>
>>>> Best regards,
>>>> Andrei Lalaev
>>>
>>> Regards,
>>> Hiago.
>>
>>
>> --
>> Best regards,
>> Andrei Lalaev
>
> Regards,
> Hiago.
--
Best regards,
Andrei Lalaev
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 0/2] board: sophgo: add support for Milk-V Duo 256M
2026-08-27 16:04 ` Andrei Lalaev
@ 2026-08-30 15:29 ` Andrei Lalaev
2026-09-04 20:29 ` Hiago De Franco
0 siblings, 1 reply; 14+ messages in thread
From: Andrei Lalaev @ 2026-08-30 15:29 UTC (permalink / raw)
To: Hiago De Franco; +Cc: u-boot, u-boot
Hi Hiago,
So, I've dumped the registers using downstream U-Boot and yes, Claude was right.
By default, downstream driver configures the PHY, so the PHY registers
have the following values:
# PHY_TX_RX_DLY
milkv_duo_256m# md.l 0x04310240 1
04310240: 01000100 ....
# PHY_CONFIG
milkv_duo_256m# md.l 0x0431024c 1
0431024c: 00000001 ....
With upstream U-Boot, the same registers are always 0.
Simply setting `PHY_TX_RX_DLY` to `0x01000100` is enough to get
the SD card working.
The attached patch contains the backported PHY configuration from the downstream
driver & upstream kernel. Could you please take a look and check if it
resolves the issue on your side when increasing the clock?
Thank you!
---
drivers/mmc/cv1800b_sdhci.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/drivers/mmc/cv1800b_sdhci.c b/drivers/mmc/cv1800b_sdhci.c
index b756649f90f3..5c129682daba 100644
--- a/drivers/mmc/cv1800b_sdhci.c
+++ b/drivers/mmc/cv1800b_sdhci.c
@@ -8,11 +8,17 @@
#include <sdhci.h>
#include <linux/delay.h>
+#define CV18XX_SDHCI_MSHC_CTRL 0x200
+#define CV18XX_SDHCI_PHY_CONFIG 0x24c
#define SDHCI_PHY_TX_RX_DLY 0x240
#define MMC_MAX_CLOCK 375000000
#define TUNE_MAX_PHCODE 128
#define PHY_TX_SRC_INVERT BIT(8)
+#define PHY_RX_SRC_INVERT BIT(24)
+
+#define CV18XX_LATANCY_1T BIT(1)
+#define CV18XX_PHY_TX_BPS BIT(0)
struct cv1800b_sdhci_plat {
struct mmc_config cfg;
@@ -64,10 +70,29 @@ static int cv1800b_execute_tuning(struct mmc *mmc, u8 opcode)
}
#endif
+static int cv1800b_deferred_probe(struct sdhci_host *host)
+{
+ u32 val;
+
+ val = sdhci_readl(host, CV18XX_SDHCI_MSHC_CTRL);
+ val |= CV18XX_LATANCY_1T;
+ sdhci_writel(host, val, CV18XX_SDHCI_MSHC_CTRL);
+
+ val = sdhci_readl(host, CV18XX_SDHCI_PHY_CONFIG);
+ val |= CV18XX_PHY_TX_BPS;
+ sdhci_writel(host, val, CV18XX_SDHCI_PHY_CONFIG);
+
+ val = PHY_TX_SRC_INVERT | PHY_RX_SRC_INVERT;
+ sdhci_writel(host, val, SDHCI_PHY_TX_RX_DLY);
+
+ return 0;
+}
+
const struct sdhci_ops cv1800b_sdhci_sd_ops = {
#if CONFIG_IS_ENABLED(MMC_SUPPORTS_TUNING)
.platform_execute_tuning = cv1800b_execute_tuning,
#endif
+ .deferred_probe = cv1800b_deferred_probe,
};
static int cv1800b_sdhci_bind(struct udevice *dev)
--
2.55.0
--
Best regards,
Andrei Lalaev
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH v2 0/2] board: sophgo: add support for Milk-V Duo 256M
2026-08-30 15:29 ` Andrei Lalaev
@ 2026-09-04 20:29 ` Hiago De Franco
2026-09-05 13:34 ` Andrei Lalaev
0 siblings, 1 reply; 14+ messages in thread
From: Hiago De Franco @ 2026-09-04 20:29 UTC (permalink / raw)
To: Andrei Lalaev; +Cc: u-boot, u-boot
Hi Andrei,
On Sun, Aug 30, 2026 at 05:29:59PM +0200, Andrei Lalaev wrote:
> Hi Hiago,
>
> So, I've dumped the registers using downstream U-Boot and yes, Claude was right.
> By default, downstream driver configures the PHY, so the PHY registers
> have the following values:
>
> # PHY_TX_RX_DLY
> milkv_duo_256m# md.l 0x04310240 1
> 04310240: 01000100 ....
>
> # PHY_CONFIG
> milkv_duo_256m# md.l 0x0431024c 1
> 0431024c: 00000001 ....
>
>
> With upstream U-Boot, the same registers are always 0.
>
> Simply setting `PHY_TX_RX_DLY` to `0x01000100` is enough to get
> the SD card working.
>
> The attached patch contains the backported PHY configuration from the downstream
> driver & upstream kernel. Could you please take a look and check if it
> resolves the issue on your side when increasing the clock?
First, apologies for the delay on my answer, it was a busy week.
I tested your patch and it works fine ;)
Thanks for the fix. Would you mind sending this patch to u-boot ML?
If you do, add:
Fixes: eb36f28ff721 ("mmc: cv1800b: Add sdhci driver support for cv1800b SoC")
>
> Thank you!
>
> ---
> drivers/mmc/cv1800b_sdhci.c | 25 +++++++++++++++++++++++++
> 1 file changed, 25 insertions(+)
>
> diff --git a/drivers/mmc/cv1800b_sdhci.c b/drivers/mmc/cv1800b_sdhci.c
> index b756649f90f3..5c129682daba 100644
> --- a/drivers/mmc/cv1800b_sdhci.c
> +++ b/drivers/mmc/cv1800b_sdhci.c
> @@ -8,11 +8,17 @@
> #include <sdhci.h>
> #include <linux/delay.h>
>
> +#define CV18XX_SDHCI_MSHC_CTRL 0x200
> +#define CV18XX_SDHCI_PHY_CONFIG 0x24c
> #define SDHCI_PHY_TX_RX_DLY 0x240
> #define MMC_MAX_CLOCK 375000000
> #define TUNE_MAX_PHCODE 128
>
> #define PHY_TX_SRC_INVERT BIT(8)
> +#define PHY_RX_SRC_INVERT BIT(24)
> +
> +#define CV18XX_LATANCY_1T BIT(1)
> +#define CV18XX_PHY_TX_BPS BIT(0)
>
> struct cv1800b_sdhci_plat {
> struct mmc_config cfg;
> @@ -64,10 +70,29 @@ static int cv1800b_execute_tuning(struct mmc *mmc, u8 opcode)
> }
> #endif
>
> +static int cv1800b_deferred_probe(struct sdhci_host *host)
> +{
> + u32 val;
> +
> + val = sdhci_readl(host, CV18XX_SDHCI_MSHC_CTRL);
> + val |= CV18XX_LATANCY_1T;
> + sdhci_writel(host, val, CV18XX_SDHCI_MSHC_CTRL);
> +
> + val = sdhci_readl(host, CV18XX_SDHCI_PHY_CONFIG);
> + val |= CV18XX_PHY_TX_BPS;
> + sdhci_writel(host, val, CV18XX_SDHCI_PHY_CONFIG);
> +
> + val = PHY_TX_SRC_INVERT | PHY_RX_SRC_INVERT;
> + sdhci_writel(host, val, SDHCI_PHY_TX_RX_DLY);
> +
> + return 0;
> +}
> +
> const struct sdhci_ops cv1800b_sdhci_sd_ops = {
> #if CONFIG_IS_ENABLED(MMC_SUPPORTS_TUNING)
> .platform_execute_tuning = cv1800b_execute_tuning,
> #endif
> + .deferred_probe = cv1800b_deferred_probe,
> };
>
> static int cv1800b_sdhci_bind(struct udevice *dev)
> --
> 2.55.0
>
>
> --
> Best regards,
> Andrei Lalaev
Regards,
--
Hiago
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 0/2] board: sophgo: add support for Milk-V Duo 256M
2026-09-04 20:29 ` Hiago De Franco
@ 2026-09-05 13:34 ` Andrei Lalaev
0 siblings, 0 replies; 14+ messages in thread
From: Andrei Lalaev @ 2026-09-05 13:34 UTC (permalink / raw)
To: Hiago De Franco; +Cc: u-boot, u-boot
Hi Hiago,
On 04.09.26 22:29, Hiago De Franco wrote:
> Hi Andrei,
>
> On Sun, Aug 30, 2026 at 05:29:59PM +0200, Andrei Lalaev wrote:
>> Hi Hiago,
>>
>> So, I've dumped the registers using downstream U-Boot and yes, Claude was right.
>> By default, downstream driver configures the PHY, so the PHY registers
>> have the following values:
>>
>> # PHY_TX_RX_DLY
>> milkv_duo_256m# md.l 0x04310240 1
>> 04310240: 01000100 ....
>>
>> # PHY_CONFIG
>> milkv_duo_256m# md.l 0x0431024c 1
>> 0431024c: 00000001 ....
>>
>>
>> With upstream U-Boot, the same registers are always 0.
>>
>> Simply setting `PHY_TX_RX_DLY` to `0x01000100` is enough to get
>> the SD card working.
>>
>> The attached patch contains the backported PHY configuration from the downstream
>> driver & upstream kernel. Could you please take a look and check if it
>> resolves the issue on your side when increasing the clock?
>
> First, apologies for the delay on my answer, it was a busy week.
>
> I tested your patch and it works fine ;)
> Thanks for the fix. Would you mind sending this patch to u-boot ML?
Sure, I will do it over the next few days. Thank you for your help and testing :)
--
Best regards,
Andrei Lalaev
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2026-09-06 7:08 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-23 14:44 [PATCH v2 0/2] board: sophgo: add support for Milk-V Duo 256M Hiago De Franco
2026-07-23 14:44 ` [PATCH v2 1/2] board: sophgo: move ethernet driver to common directory Hiago De Franco
2026-08-05 15:29 ` Leo Liang via U-Boot
2026-07-23 14:44 ` [PATCH v2 2/2] board: sophgo: add support for Milk-V Duo 256M Hiago De Franco
2026-08-05 15:31 ` Leo Liang via U-Boot
2026-08-05 15:50 ` [PATCH v2 0/2] " Leo Liang via U-Boot
2026-08-22 9:15 ` Andrei Lalaev
2026-08-25 12:24 ` Hiago De Franco
2026-08-25 18:01 ` Andrei Lalaev
2026-08-27 13:30 ` Hiago De Franco
2026-08-27 16:04 ` Andrei Lalaev
2026-08-30 15:29 ` Andrei Lalaev
2026-09-04 20:29 ` Hiago De Franco
2026-09-05 13:34 ` Andrei Lalaev
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.