Hi João Paulo,
On 10/16/26 12:52, João Paulo Gonçalves wrote:
> Add support for the Milk-V Duo S, a development board based on the
> Sophgo SG2000 SoC with 512 MiB of RAM.
>
> The SG2000 differs from the CV1800B used on the Milk-V Duo 64M and the
> SG2002 used on the Milk-V Duo 256M, but these SoCs share most of their
> IP blocks, including the CPU core, so the existing CV1800B support can
> be reused.
>
> Add a separate board directory, target and defconfig for the Duo S,
> based on the Milk-V Duo 256M ones. Like the Duo 256M, it reuses the
> common Milk-V Duo board code. The defconfig uses the upstream devicetree
> via OF_UPSTREAM.
>
> Link: https://milkv.io/docs/duo/getting-started/duos
> Signed-off-by: João Paulo Gonçalves <[email protected]>
> Acked-by: Andrei Lalaev <[email protected]>
> Acked-by: Hiago De Franco <[email protected]>
> ---
> arch/riscv/Kconfig | 4 ++
> board/sophgo/milkv_duo_s/Kconfig | 30 +++++++++++
> board/sophgo/milkv_duo_s/MAINTAINERS | 8 +++
> board/sophgo/milkv_duo_s/Makefile | 6 +++
> board/sophgo/milkv_duo_s/milkv_duo_s.env | 8 +++
> configs/milkv_duo_s_defconfig | 43 ++++++++++++++++
> doc/board/sophgo/index.rst | 1 +
> doc/board/sophgo/milkv_duo_s.rst | 86
> ++++++++++++++++++++++++++++++++
> include/configs/milkv_duo_s.h | 12 +++++
> 9 files changed, 198 insertions(+)
>
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index 386241efd4a0..df10354e9aef 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -32,6 +32,9 @@ config TARGET_MILKV_DUO
> config TARGET_MILKV_DUO_256M
> bool "Support Milk-V Duo 256M Board"
>
> +config TARGET_MILKV_DUO_S
> + bool "Support Milk-V Duo S Board"
> +
> config TARGET_OPENPITON_RISCV64
> bool "Support RISC-V cores on OpenPiton SoC"
>
> @@ -125,6 +128,7 @@ 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/milkv_duo_s/Kconfig"
> source "board/sophgo/licheerv_nano/Kconfig"
> source "board/spacemit/k1/Kconfig"
> source "board/spacemit/k3/Kconfig"
> diff --git a/board/sophgo/milkv_duo_s/Kconfig
> b/board/sophgo/milkv_duo_s/Kconfig
> new file mode 100644
> index 000000000000..6ec6bd65d938
> --- /dev/null
> +++ b/board/sophgo/milkv_duo_s/Kconfig
> @@ -0,0 +1,30 @@
> +if TARGET_MILKV_DUO_S
> +
> +config SYS_BOARD
> + default "milkv_duo_s"
> +
> +config SYS_VENDOR
> + default "sophgo"
> +
> +config SYS_CPU
> + default "cv1800b"
> +
> +config SYS_CONFIG_NAME
> + default "milkv_duo_s"
> +
> +# 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_s/MAINTAINERS
> b/board/sophgo/milkv_duo_s/MAINTAINERS
> new file mode 100644
> index 000000000000..86533c03fd9a
> --- /dev/null
> +++ b/board/sophgo/milkv_duo_s/MAINTAINERS
> @@ -0,0 +1,8 @@
> +Milk-V Duo S
> +M: Andrei Lalaev <[email protected]>
> +M: Hiago De Franco <[email protected]>
> +S: Maintained
> +F: board/sophgo/milkv_duo_s/
> +F: configs/milkv_duo_s_defconfig
> +F: doc/board/sophgo/milkv_duo_s.rst
> +F: include/configs/milkv_duo_s.h
> diff --git a/board/sophgo/milkv_duo_s/Makefile
> b/board/sophgo/milkv_duo_s/Makefile
> new file mode 100644
> index 000000000000..a1b6aaee1489
> --- /dev/null
> +++ b/board/sophgo/milkv_duo_s/Makefile
> @@ -0,0 +1,6 @@
> +# SPDX-License-Identifier: GPL-2.0+
> +#
> +# Copyright (c) 2026, João Paulo Gonçalves <[email protected]>
> +
> +obj-y += ../milkv_duo/board.o
> +obj-$(CONFIG_NET_LEGACY) += ../common/ethernet.o
> diff --git a/board/sophgo/milkv_duo_s/milkv_duo_s.env
> b/board/sophgo/milkv_duo_s/milkv_duo_s.env
> new file mode 100644
> index 000000000000..4c9f53d08118
> --- /dev/null
> +++ b/board/sophgo/milkv_duo_s/milkv_duo_s.env
> @@ -0,0 +1,8 @@
> +fdt_addr_r=0x84000000
> +fdtfile=DEFAULT_DEVICE_TREE.dtb
Sorry I do not understand, what is "DEFAULT_DEVICE_TREE.dtb" where is
this file actually?
> +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_s_defconfig b/configs/milkv_duo_s_defconfig
> new file mode 100644
> index 000000000000..41a31c4ad46c
> --- /dev/null
> +++ b/configs/milkv_duo_s_defconfig
> @@ -0,0 +1,43 @@
> +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="sophgo/sg2000-milkv-duo-s"
> +CONFIG_SYS_LOAD_ADDR=0x80080000
> +CONFIG_IDENT_STRING=" milkv_duo_s"
> +CONFIG_TARGET_MILKV_DUO_S=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_s# "
Delete CONFIG_SYS_PROMPT there is no purpose for non-default here
> +# 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_OF_UPSTREAM=y
> +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 19c9a19b1d4b..61aceafceea3 100644
> --- a/doc/board/sophgo/index.rst
> +++ b/doc/board/sophgo/index.rst
> @@ -7,4 +7,5 @@ Sophgo
>
> milkv_duo
> milkv_duo_256m
> + milkv_duo_s
> licheerv_nano
> diff --git a/doc/board/sophgo/milkv_duo_s.rst
> b/doc/board/sophgo/milkv_duo_s.rst
> new file mode 100644
> index 000000000000..2ae749a08215
> --- /dev/null
> +++ b/doc/board/sophgo/milkv_duo_s.rst
> @@ -0,0 +1,86 @@
> +.. SPDX-License-Identifier: GPL-2.0+
> +
> +Milk-V Duo S
> +============
> +
> +SG2000 RISC-V SoC
> +-----------------
> +The SG2000 is a high-performance, low-power 64-bit RISC-V/ARM SoC from
> Sophgo.
> +
> +Mainline support
> +----------------
> +Support for the following drivers is 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_s_defconfig
> + make
Consider this variation:
export CROSS_COMPILE=<riscv64 toolchain prefix>
make -C u-boot.git O=../u-boot milkv_duo_s_defconfig
make -C u-boot.git O=../u-boot
> +
> +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 S
> + default configuration.
> +
> +2. Use mainline OpenSBI with a newer version than 1.5 to generate fw_dynamic.
Suspicious statement, I think it is wrong here.
Is this in regard to mainline OpenSBI commit f7a92f6b ("lib: utils/fdt:
Add support for parsing riscv,isa-extensions") ? If so, a short
statement e.g. "Use OpenSBI for generic platform with support for
parsing riscv,isa-extensions, introduced in mainline OpenSBI v1.6
release" or simply "Use mainline OpenSBI v1.6+" because you don't tell
us anyways why it is important that the needed change happens between
v1.5 and v1.6 OpenSBI version.
> + Use FW_FDT_PATH to point to sg2000-milkv-duo-s.dtb device tree file while
> + compiling fw_dynamic. Example:
> +
> +.. code-block:: console
> +
> + cd open-sbi
> + PLATFORM=generic
> FW_FDT_PATH=../u-boot/dts/upstream/src/riscv/sophgo/sg2000-milkv-duo-s.dtb
> make
See above comment about setting the O= make variable. Consider this again:
make -C opensbi.git O=../opensbi clean
make -C opensbi.git O=../opensbi PLATFORM=generic
FW_FDT_PATH=../u-boot/dts/upstream/src/riscv/sophgo/sg2000-milkv-duo-s.dtb
An explicit invocation of clean target before generic platform build
should be listed because of a well-known OpenSBI build problem:
https://lore.kernel.org/opensbi/[email protected]/
> +
> +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
I think this description is correct but it just sounds strange to me
with the word "unified" for a mix of libre open source software into
third-party proprietary tools and proprietary executable code blob.
Consider "Use the vendor-provided fiptool [1] to prepare FSBL containing..."
> + FSBL, OpenSBI, and U-Boot.
"SPL, OpenSBI with initial device tree and U-Boot payload"
> + Note that you will have to use the file cv181x.bin as the FSBL.
Naming what we would want from U-Boot SPL to be known as "SPL" and then
wrapped with mkimage action to become "FSBL" is more easily
understandable. We do not have this yet, but think about a future where
there is U-Boot SPL and mkimage support here, how would you describe
this? Use that and apply it to the third party vendor workflow now.
If cv181x.bin is ready-to-go rename as "fip.bin" and SoC BootROM loader
functionality accepts this (no fiptool) then yes it is also true to
describe as "FSBL".
In fact the terminology FSBL and SPL may be equivalent but we can make
this arbitrary distinction in documentation to make it clearer what is
the compiled executable code SPL and what is the SPL image formed with
additional preparation.
> +
> +4. Place the generated fip.bin file into the FAT partition of the SD card.
Consider "Place the prepared fip.bin file" or better "Copy the prepared
FSBL as fip.bin file into the FAT partition of the SD card."
I like "prepared" word to describe wrapping up one or many data sources
in a header expected by the SoC BootROM loader functionality.
> +
> +5. Set the board's boot core selection switch to RISC-V.
> +
> +6. 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.
"The board will automatically load the FSBL from file fip.bin on the "
and name here the circumstances, is it the first FAT partition of msdos
label on SD Card? Is GPT GUID parition valid? It must be FAT16 or FAT32?
What exactly are the conditions for this?
"Subsequently, it will execute the SPL, and transition to OpenSBI with
U-Boot main app as the OpenSBI payload."
> +
> +[1]: https://github.com/sophgo/fiptool
> +
> +Sample boot log from Milk-V Duo S board
> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> +.. code-block:: none
> +
> + U-Boot 2026.10-g3c39950264fd (Oct 16 2026 - 19:45:23 +0000) milkv_duo_s
> +
> + DRAM: 512 MiB
> + Core: 28 devices, 13 uclasses, devicetree: separate
> + MMC: mmc@4310000: 0, mmc@4320000: 2, mmc@4300000: 1
> + Loading Environment from nowhere... OK
> + In: serial@4140000
> + Out: serial@4140000
> + Err: serial@4140000
> + Net:
> + Warning: ethernet@4070000 (eth0) using random MAC address -
> de:19:4d:5d:74:41
> + eth0: ethernet@4070000
> + Hit any key to stop autoboot: 0
> + milkv_duo_s#
> diff --git a/include/configs/milkv_duo_s.h b/include/configs/milkv_duo_s.h
> new file mode 100644
> index 000000000000..f60aa23fc181
> --- /dev/null
> +++ b/include/configs/milkv_duo_s.h
> @@ -0,0 +1,12 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +/*
> + * Copyright (c) 2026, João Paulo Gonçalves <[email protected]>
> + *
> + */
> +
> +#ifndef __CONFIG_H
> +#define __CONFIG_H
> +
> +#define CFG_SYS_SDRAM_BASE 0x80000000
> +
> +#endif /* __CONFIG_H */
>
If able, please reverse-engineer / port support for the Milk-V Duo S
FSBL image format to U-Boot mkimage tool. Also look more closely at
fully-relocatable OpenSBI fw_dynamic.bin support.
-E Shattow