From patchwork Fri May 10 05:52:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1933716 X-Patchwork-Delegate: uboot@andestech.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=mBh/UCnu; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VbJ2K6bChz20fh for ; Fri, 10 May 2024 15:52:57 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 10C80887A4; Fri, 10 May 2024 07:52:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.b="mBh/UCnu"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A941188577; Fri, 10 May 2024 07:52:45 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from smtp-relay-canonical-1.canonical.com (smtp-relay-canonical-1.canonical.com [185.125.188.121]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id C6B23884AE for ; Fri, 10 May 2024 07:52:43 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=heinrich.schuchardt@canonical.com Received: from LT2ubnt.. (unknown [149.11.192.251]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPSA id 55FFA3FE0A; Fri, 10 May 2024 05:52:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1715320359; bh=cjmslehnP5/Oa3VzcSEtcdpsEIt0v3psT/YV11dRHyQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mBh/UCnuS3d+AU/91xV4ZgsoZoqn+C+s/WHPSRy+l6LW0xCDqJCw+4Yuvrn4SnTN2 j9fHOcU8CP9Qiy1OeLyMPnBKgWjxVrVeDoXVYb2EAlICsZBPNGXwtjawB7Nlbc8bnK TBxVrAW4/W3oD9CCp4snwxMC4JSEISTzehbxp1IindiXeerLSjCjdbPKJGK5fTuC0V mwr9d3czzD0qturO7W1wRrjp+IYv7PsJUWiaWfmeAzecqqxUeiEge+W+/+e8S2oJCg 4nCGoytuBvmxKnnArpCPPp602Ktejv4VjAl1T5TfOv076bHrgyrPk94+oYn8a/Ag// 5J/kUpw9d0h8g== From: Heinrich Schuchardt To: Minda Chen , Hal Feng , Rick Chen , Leo Cc: Aurelien Jarno , Lukasz Tekieli , Lukas Funke , Shiji Yang , Shengyu Qu , Michal Simek , Seung-Woo Kim , Mason Huo , E Shattow , u-boot@lists.denx.de, Heinrich Schuchardt Subject: [PATCH v4 1/5] board: starfive: function to read eMMC size Date: Fri, 10 May 2024 07:52:17 +0200 Message-ID: <20240510055223.11617-2-heinrich.schuchardt@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240510055223.11617-1-heinrich.schuchardt@canonical.com> References: <20240510055223.11617-1-heinrich.schuchardt@canonical.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean The EEPROM provides information about the size of the eMMC. Provide a new function get_mmc_size_from_eeprom() to read it. Signed-off-by: Heinrich Schuchardt Reviewed-by: E. Shattow --- v4: no change v3: no change v2: fix typos in get_mmc_size_from_eeprom() description --- arch/riscv/include/asm/arch-jh7110/eeprom.h | 7 +++++++ board/starfive/visionfive2/Kconfig | 9 +++++++++ .../visionfive2/visionfive2-i2c-eeprom.c | 18 ++++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/arch/riscv/include/asm/arch-jh7110/eeprom.h b/arch/riscv/include/asm/arch-jh7110/eeprom.h index 62d184aeb57..45ad2a5f7bc 100644 --- a/arch/riscv/include/asm/arch-jh7110/eeprom.h +++ b/arch/riscv/include/asm/arch-jh7110/eeprom.h @@ -12,6 +12,13 @@ u8 get_pcb_revision_from_eeprom(void); u32 get_ddr_size_from_eeprom(void); +/** + * get_mmc_size_from_eeprom() - read eMMC size from EEPROM + * + * @return: size in GiB or 0 on error. + */ +u32 get_mmc_size_from_eeprom(void); + /** * get_product_id_from_eeprom - get product ID string * diff --git a/board/starfive/visionfive2/Kconfig b/board/starfive/visionfive2/Kconfig index 2186a939646..d7e8a7a7d78 100644 --- a/board/starfive/visionfive2/Kconfig +++ b/board/starfive/visionfive2/Kconfig @@ -50,4 +50,13 @@ config BOARD_SPECIFIC_OPTIONS # dummy imply PHY_LIB imply PHY_MSCC +config STARFIVE_NO_EMMC + bool "Report eMMC size as zero" + help + The serial number string in the EEPROM is meant to report the + size of onboard eMMC. Unfortunately some Milk-V Mars CM Lite + modules without eMMC show a non-zero size here. + + Set to 'Y' if you have a Mars CM Lite module. + endif diff --git a/board/starfive/visionfive2/visionfive2-i2c-eeprom.c b/board/starfive/visionfive2/visionfive2-i2c-eeprom.c index 5095a0e9fdb..9648a270494 100644 --- a/board/starfive/visionfive2/visionfive2-i2c-eeprom.c +++ b/board/starfive/visionfive2/visionfive2-i2c-eeprom.c @@ -548,6 +548,24 @@ u32 get_ddr_size_from_eeprom(void) return hextoul(&pbuf.eeprom.atom1.data.pstr[14], NULL); } +u32 get_mmc_size_from_eeprom(void) +{ + u32 size; + + if (IS_ENABLED(CONFIG_STARFIVE_NO_EMMC)) + return 0; + + if (read_eeprom()) + return 0; + + size = dectoul(&pbuf.eeprom.atom1.data.pstr[19], NULL); + + if (pbuf.eeprom.atom1.data.pstr[21] == 'T') + size <<= 10; + + return size; +} + U_BOOT_LONGHELP(mac, "\n" " - display EEPROM content\n" From patchwork Fri May 10 05:52:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1933717 X-Patchwork-Delegate: uboot@andestech.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=pKgHdk+4; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VbJ2W3Wjtz20fh for ; Fri, 10 May 2024 15:53:07 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6A7A48884C; Fri, 10 May 2024 07:52:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.b="pKgHdk+4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 991C088719; Fri, 10 May 2024 07:52:46 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from smtp-relay-canonical-1.canonical.com (smtp-relay-canonical-1.canonical.com [185.125.188.121]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id B4F5388176 for ; Fri, 10 May 2024 07:52:44 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=heinrich.schuchardt@canonical.com Received: from LT2ubnt.. (unknown [149.11.192.251]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPSA id 9302B40819; Fri, 10 May 2024 05:52:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1715320361; bh=AboStmdkWG28z01kFWLqmL5kZ3GjzxeVNnSwOp1zM7o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pKgHdk+4rTs1nxdZYoXwU6FSWDvYCaruFI3GoPYKHWk8oU5n1BO+tiMxqvnrh4onf ZvV6mh/P1PYfwdy9R00t8HElWiftdO/cDloBurIbU8yfAufBIXp6jasLUp0Veh8zxE GBUCZNHQlJ7GDyPUb/jtlpijy7WGrycoQV3jYuGN7eKlDcpZfXvpAFrAp3cRL+4VoE 3AMJpCSxYrZrfs64cxAPOuLpqBl/Hv8GcUzQE4S1xcI1t/XpdEdQusm2T1TBfhO1W3 5vdL0GfCAlBxy8fUiJhBcuoUxKjcCdD5FJyuhlFhh4s8dXfoSjElcvG1ziaFczp6V3 ti1qoYt/muAIA== From: Heinrich Schuchardt To: Minda Chen , Hal Feng , Rick Chen , Leo Cc: Aurelien Jarno , Lukasz Tekieli , Lukas Funke , Shiji Yang , Shengyu Qu , Michal Simek , Seung-Woo Kim , Mason Huo , E Shattow , u-boot@lists.denx.de, Heinrich Schuchardt Subject: [PATCH v4 2/5] board: add support for Milk-V Mars CM Date: Fri, 10 May 2024 07:52:18 +0200 Message-ID: <20240510055223.11617-3-heinrich.schuchardt@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240510055223.11617-1-heinrich.schuchardt@canonical.com> References: <20240510055223.11617-1-heinrich.schuchardt@canonical.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean We already support the VisionFive 2 and the Milk-V Mars board by patching the VisionFive 2 device tree. With this patch the same is done for the Milk-V Mars CM. Signed-off-by: Heinrich Schuchardt Tested-by: E. Shattow Reviewed-by: E. Shattow --- v4: no change v3: no change v2: rename spl_fdt_fixup_marc() to spl_fdt_fixup_mars_cm() rename device-trees for Mars CM and Mars CM Lite change model and compatible properties --- board/starfive/visionfive2/spl.c | 28 ++++++++++++++++++- .../visionfive2/starfive_visionfive2.c | 11 +++++++- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/board/starfive/visionfive2/spl.c b/board/starfive/visionfive2/spl.c index ca61b5be227..b555189556a 100644 --- a/board/starfive/visionfive2/spl.c +++ b/board/starfive/visionfive2/spl.c @@ -129,6 +129,30 @@ void spl_fdt_fixup_mars(void *fdt) } } +void spl_fdt_fixup_mars_cm(void *fdt) +{ + const char *compat; + const char *model; + + spl_fdt_fixup_mars(fdt); + + if (!get_mmc_size_from_eeprom()) { + int offset; + + model = "Milk-V Mars CM Lite"; + compat = "milkv,mars-cm-lite\0starfive,jh7110"; + + offset = fdt_path_offset(fdt, "/soc/pinctrl/mmc0-pins/mmc0-pins-rest"); + /* GPIOMUX(22, GPOUT_SYS_SDIO0_RST, GPOEN_ENABLE, GPI_NONE) */ + fdt_setprop_u32(fdt, offset, "pinmux", 0xff130016); + } else { + model = "Milk-V Mars CM"; + compat = "milkv,mars-cm\0starfive,jh7110"; + } + fdt_setprop(fdt, fdt_path_offset(fdt, "/"), "compatible", compat, sizeof(compat)); + fdt_setprop_string(fdt, fdt_path_offset(fdt, "/"), "model", model); +} + void spl_fdt_fixup_version_a(void *fdt) { static const char compat[] = "starfive,visionfive-2-v1.2a\0starfive,jh7110"; @@ -236,7 +260,9 @@ void spl_perform_fixups(struct spl_image_info *spl_image) pr_err("Can't read EEPROM\n"); return; } - if (!strncmp(product_id, "MARS", 4)) { + if (!strncmp(product_id, "MARC", 4)) { + spl_fdt_fixup_mars_cm(spl_image->fdt_addr); + } else if (!strncmp(product_id, "MARS", 4)) { spl_fdt_fixup_mars(spl_image->fdt_addr); } else if (!strncmp(product_id, "VF7110", 6)) { version = get_pcb_revision_from_eeprom(); diff --git a/board/starfive/visionfive2/starfive_visionfive2.c b/board/starfive/visionfive2/starfive_visionfive2.c index a86bca533b2..6be53489626 100644 --- a/board/starfive/visionfive2/starfive_visionfive2.c +++ b/board/starfive/visionfive2/starfive_visionfive2.c @@ -19,6 +19,10 @@ DECLARE_GLOBAL_DATA_PTR; #define JH7110_L2_PREFETCHER_HART_OFFSET 0x2000 #define FDTFILE_MILK_V_MARS \ "starfive/jh7110-milkv-mars.dtb" +#define FDTFILE_MILK_V_MARS_CM \ + "starfive/jh7110-milkv-mars-cm.dtb" +#define FDTFILE_MILK_V_MARS_CM_LITE \ + "starfive/jh7110-milkv-mars-cm-lite.dtb" #define FDTFILE_VISIONFIVE2_1_2A \ "starfive/jh7110-starfive-visionfive-2-v1.2a.dtb" #define FDTFILE_VISIONFIVE2_1_3B \ @@ -61,7 +65,12 @@ static void set_fdtfile(void) log_err("Can't read EEPROM\n"); return; } - if (!strncmp(product_id, "MARS", 4)) { + if (!strncmp(product_id, "MARC", 4)) { + if (get_mmc_size_from_eeprom()) + fdtfile = FDTFILE_MILK_V_MARS_CM; + else + fdtfile = FDTFILE_MILK_V_MARS_CM_LITE; + } else if (!strncmp(product_id, "MARS", 4)) { fdtfile = FDTFILE_MILK_V_MARS; } else if (!strncmp(product_id, "VF7110", 6)) { version = get_pcb_revision_from_eeprom(); From patchwork Fri May 10 05:52:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1933718 X-Patchwork-Delegate: uboot@andestech.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=E+OMFCbV; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VbJ2j1Wqjz20fh for ; Fri, 10 May 2024 15:53:17 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CD17788856; Fri, 10 May 2024 07:52:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.b="E+OMFCbV"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3EBF68884C; Fri, 10 May 2024 07:52:49 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from smtp-relay-canonical-1.canonical.com (smtp-relay-canonical-1.canonical.com [185.125.188.121]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id EF77D88176 for ; Fri, 10 May 2024 07:52:46 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=heinrich.schuchardt@canonical.com Received: from LT2ubnt.. (unknown [149.11.192.251]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPSA id CD73C4081A; Fri, 10 May 2024 05:52:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1715320362; bh=1o9wFFSuj8fNvKXRoOmhhztIp5Uq4zFVIianpDwINIE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=E+OMFCbVeai2GYpfxa5WfZp4J7hHEWu94Ly6xd8jVeisjr7HI18HT95+wEDpgKr5m tCzyEBNtMdwStqCo5yWqyB9zR7w6OHR4FWmFnGkXQWh2edeqVnxi4SEcsigCjDn4cr v+RfXjy40ib3xIPUTFM7DAlSy0QITvFMBmCgvz0xircqKIeSu+0Iumovb8YVOWQpR5 yTqov4WDOfOqLtHWxFqSjtrEGmWc64N3bydT24VBbNhFgEWP4wOaqtT8Y34C5yb8i2 qgO9FZNnh3DwmRdVpl6G06ui2kcHo2IVxsGJG+xODTdKdx35RDP3HB6yVLRXPNrFib WFrvP+Z/b6xJQ== From: Heinrich Schuchardt To: Minda Chen , Hal Feng , Rick Chen , Leo Cc: Aurelien Jarno , Lukasz Tekieli , Lukas Funke , Shiji Yang , Shengyu Qu , Michal Simek , Seung-Woo Kim , Mason Huo , E Shattow , u-boot@lists.denx.de, Heinrich Schuchardt Subject: [PATCH v4 3/5] doc: Milk-V Mars CM and Milk-V Mars CM Lite Date: Fri, 10 May 2024 07:52:19 +0200 Message-ID: <20240510055223.11617-4-heinrich.schuchardt@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240510055223.11617-1-heinrich.schuchardt@canonical.com> References: <20240510055223.11617-1-heinrich.schuchardt@canonical.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Provide a man-page describing the usage of U-Boot on the Milk-V Mars CM and Milk-V Mars CM Lite boards. Signed-off-by: Heinrich Schuchardt Reviewed-by: E Shattow --- v4: remove .rst extension from toctree links remove superfluous word 'connected' describing booting from SPI flash v3: correct device-tree names suggest not to use mac initialize refer to XMODEM-1K v2: refer to tio as tool for booting via UART describe how to update serial number description updates as suggested by E. Shattow --- doc/board/starfive/index.rst | 1 + doc/board/starfive/milk-v_mars_cm.rst | 193 ++++++++++++++++++++++++++ 2 files changed, 194 insertions(+) create mode 100644 doc/board/starfive/milk-v_mars_cm.rst diff --git a/doc/board/starfive/index.rst b/doc/board/starfive/index.rst index 2762bf74c11..afa85ad2540 100644 --- a/doc/board/starfive/index.rst +++ b/doc/board/starfive/index.rst @@ -7,5 +7,6 @@ StarFive .. toctree:: :maxdepth: 1 - milk-v_mars.rst + milk-v_mars + milk-v_mars_cm visionfive2 diff --git a/doc/board/starfive/milk-v_mars_cm.rst b/doc/board/starfive/milk-v_mars_cm.rst new file mode 100644 index 00000000000..68561adadfc --- /dev/null +++ b/doc/board/starfive/milk-v_mars_cm.rst @@ -0,0 +1,193 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +Milk-V Mars CM +============== + +U-Boot for the Milk-V Mars CM uses the same U-Boot binaries as the VisionFive 2 +board. In U-Boot SPL the actual board is detected and the device-tree patched +accordingly. + +The Milk-V Mars CM Lite comes without eMMC and needs a different pin muxing +than the Milk-V Mars CM. The availability and size of the eMMC shows up in the +serial number displayed by the *mac* command, e.g. +MARC-V10-2340-D002E016-00000304. The number after the E is the MMC size. U-Boot +takes a value of E000 as an indicator for the Lite version. Unfortunately the +vendor has not set this value correctly on some Lite boards. + +Please, use CONFIG_STARFIVE_NO_EMMC=y if EEPROM data indicates eMMC is present +on the Milk-V Mars CM Lite. Otherwise you will not be able to read from the +SD-card. + +The serial number can be corrected using the *mac* command: + +.. code-block:: + + mac read_eeprom + mac product_id MARC-V10-2340-D002E000-00000304 + mac write_eeprom + +.. note:: + + The *mac initialize* command overwrites the vendor string and the MAC + addresses. This is why it is avoided here. + +By default the EEPROM is write protected. The write protection may be overcome +by connecting the "GND" and "EN" test pads on top of the module. + +Building +~~~~~~~~ + +1. Add the RISC-V toolchain to your PATH. +2. Setup ARCH & cross compilation environment variable: + +.. code-block:: none + + export CROSS_COMPILE= + +The M-mode software OpenSBI provides the supervisor binary interface (SBI) and +is responsible for the switch to S-Mode. It is a prerequisite to build U-Boot. +Support for the JH7110 was introduced in OpenSBI 1.2. It is recommended to use +a current release. + +.. code-block:: console + + git clone https://github.com/riscv/opensbi.git + cd opensbi + make PLATFORM=generic FW_TEXT_START=0x40000000 + +(*FW_TEXT_START* is not needed anymore after OpenSBI patch d4d2582eef7a +"firmware: remove FW_TEXT_START" which should appear in OpenSBI 1.5.) + +Now build the U-Boot SPL and U-Boot proper. + +.. code-block:: console + + cd + make starfive_visionfive2_defconfig + make OPENSBI=$(opensbi_dir)/build/platform/generic/firmware/fw_dynamic.bin + +This will generate the U-Boot SPL image (spl/u-boot-spl.bin.normal.out) as well +as the FIT image (u-boot.itb) with OpenSBI and U-Boot. + +Device-tree selection +~~~~~~~~~~~~~~~~~~~~~ + +Depending on the board version U-Boot sets variable $fdtfile to either +starfive/jh7110-milkv-mars-cm.dtb (with eMMC storage) or +starfive/jh7110-milkv-mars-cm-lite.dtb (without eMMC storage). + +To overrule this selection the variable can be set manually and saved in the +environment + +:: + + env set fdtfile my_device-tree.dtb + env save + +or the configuration variable CONFIG_DEFAULT_FDT_FILE can be used to set to +provide a default value. + +The variable *$fdtfile* is used in the boot process to automatically load +a device-tree provided by the operating system. For details of the boot +process refer to the :doc:`U-Boot Standard Boot <../../../develop/bootstd>` +description. + +Boot source selection +~~~~~~~~~~~~~~~~~~~~~ + +The low speed connector nRPIBOOT line is used to switch the boot source. + +* If nRPIBOOT is connected to ground, the board boots from UART. +* If nRPIBOOT is not connected, the board boots from SPI flash. + +Compute module boards typically have a switch or jumper for this line. + +Flashing a new U-Boot version +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +U-Boot SPL is provided as file spl/u-boot-spl.bin.normal.out. Main U-Boot is +in file u-boot.itb. + +Assuming your new U-Boot version is on partition 1 of an SD-card you could +install it to the SPI flash with: + +:: + + sf probe + load mmc 0:1 $kernel_addr_r u-boot-spl.bin.normal.out + sf update $kernel_addr_r 0 $filesize + load mmc 0:1 $kernel_addr_r u-boot.itb + sf update $kernel_addr_r 0x100000 $filesize + +For loading the files from a TFTP server refer to the dhcp and tftpboot +commands. + +After updating U-Boot you may want to reboot and reset the environment to the +default. + +:: + + env default -f -a + env save + +Booting from UART +~~~~~~~~~~~~~~~~~ + +For booting via UART U-Boot must be built with CONFIG_SPL_YMODEM_SUPPORT=y. + +With nRPIBOOT connected to ground for UART boot, power the board and upload +u-boot-spl.bin.normal.out via XMODEM. Then upload u-boot.itb via YMODEM. + +The XMODEM implementation in the boot ROM is not fully specification compliant. +It sends too many NAKs in a row. Tio is a terminal emulation that tolerates +these faults. + +:: + + $ tio -b 115200 --databits 8 --flow none --stopbits 1 /dev/ttyUSB0 + [08:14:54.700] tio v2.7 + [08:14:54.700] Press ctrl-t q to quit + [08:14:54.701] Connected + + (C)StarFive + CCC + (C)StarFive + CCCCCCCC + +Press *ctrl-t x* to initiate XMODEM-1K transfer. + +:: + + [08:15:14.778] Send file with XMODEM + [08:15:22.459] Sending file 'u-boot-spl.bin.normal.out' + [08:15:22.459] Press any key to abort transfer + ........................................................................ + .......................................................................| + [08:15:22.459] Done + + U-Boot SPL 2024.07-rc1-00075-gd6a4ab20097 (Apr 25 2024 - 16:32:10 +0200) + DDR version: dc2e84f0. + Trying to boot from UART + CC + +Press *ctrl-t y* to initiate YMODEM transfer. + +:: + + [08:15:50.331] Send file with YMODEM + [08:15:53.540] Sending file 'u-boot.itb' + [08:15:53.540] Press any key to abort transfer + ........................................................................ + … + ...............| + [08:15:53.540] Done + Loaded 1040599 bytes + + + U-Boot 2024.07-rc1-00075-gd6a4ab20097 (Apr 25 2024 - 16:32:10 +0200) + +Booting from SPI flash +~~~~~~~~~~~~~~~~~~~~~~ + +With nRPIBOOT disconnected from ground for SPI boot, power up the board. You +should see the U-Boot prompt on the serial console. From patchwork Fri May 10 05:52:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1933719 X-Patchwork-Delegate: uboot@andestech.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=EtgHfL0l; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VbJ2v39jBz20fh for ; Fri, 10 May 2024 15:53:27 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3A55D884AA; Fri, 10 May 2024 07:52:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.b="EtgHfL0l"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 594DC88864; Fri, 10 May 2024 07:52:50 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from smtp-relay-canonical-1.canonical.com (smtp-relay-canonical-1.canonical.com [185.125.188.121]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 866B7887FF for ; Fri, 10 May 2024 07:52:48 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=heinrich.schuchardt@canonical.com Received: from LT2ubnt.. (unknown [149.11.192.251]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPSA id 9A6E64081B; Fri, 10 May 2024 05:52:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1715320364; bh=jA4VGWSu8f3cpE01yCJf/rt7epBIIxRw9CODiL/doCM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EtgHfL0lhpWaLSVmKFJ8KWdnwmkSMdMXS8KoUQbQGO4jyiCedGob8Su7JD3HHZsor qzk1Cv1D84Vel6F1LftKjW4cypDCh9AtDv7UMDFPUU+g1mvIreBCU0IVZnMulXFTM3 jXScK8YdiEf0SNHZYISNV/WpqKDJuI8cJOWEXqfEJexql5FSAFrzNnXTe2I1l28X4+ ho80Cg8U6uOJasCcrOurSrHu7cZc/Ut7VsJCLw0AN7rAzMwHlo+6jqzy31tPVuCXV6 jrR5IHQYZBC0+Ire1bHqoA0e6B1S99Lxlm1sIGXuc8QdV3/TuUru3nHAuD9E9TAKuT xrq2QMpQXgfSw== From: Heinrich Schuchardt To: Minda Chen , Hal Feng , Rick Chen , Leo Cc: Aurelien Jarno , Lukasz Tekieli , Lukas Funke , Shiji Yang , Shengyu Qu , Michal Simek , Seung-Woo Kim , Mason Huo , E Shattow , u-boot@lists.denx.de, Heinrich Schuchardt Subject: [PATCH v4 4/5] configs: visionfive2: enable SPL_YMODEM_SUPPORT Date: Fri, 10 May 2024 07:52:20 +0200 Message-ID: <20240510055223.11617-5-heinrich.schuchardt@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240510055223.11617-1-heinrich.schuchardt@canonical.com> References: <20240510055223.11617-1-heinrich.schuchardt@canonical.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean We can use U-Boot for recovering JH7110 based boards via UART if CONFIG_SPL_YMODEM_SUPPORT=y. * Send u-boot-spl.normal.out via XMODEM. * Send u-boot.itb via YMODEM. Signed-off-by: Heinrich Schuchardt Reviewed-by: E. Shattow --- v4: no change v3: no change v2: no change --- configs/starfive_visionfive2_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/starfive_visionfive2_defconfig b/configs/starfive_visionfive2_defconfig index 3bbd1dbd67c..174ac24dc74 100644 --- a/configs/starfive_visionfive2_defconfig +++ b/configs/starfive_visionfive2_defconfig @@ -62,6 +62,7 @@ CONFIG_SPL_I2C=y CONFIG_SPL_DM_SPI_FLASH=y CONFIG_SPL_DM_RESET=y CONFIG_SPL_SPI_LOAD=y +CONFIG_SPL_YMODEM_SUPPORT=y CONFIG_SYS_PROMPT="StarFive # " CONFIG_CMD_EEPROM=y CONFIG_SYS_EEPROM_SIZE=512 From patchwork Fri May 10 05:52:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1933720 X-Patchwork-Delegate: uboot@andestech.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=tgXNA888; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VbJ352drJz20fh for ; Fri, 10 May 2024 15:53:37 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9915B88852; Fri, 10 May 2024 07:52:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.b="tgXNA888"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4429988719; Fri, 10 May 2024 07:52:52 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from smtp-relay-canonical-1.canonical.com (smtp-relay-canonical-1.canonical.com [185.125.188.121]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2B50088860 for ; Fri, 10 May 2024 07:52:50 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=heinrich.schuchardt@canonical.com Received: from LT2ubnt.. (unknown [149.11.192.251]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPSA id 0EB4F4081C; Fri, 10 May 2024 05:52:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1715320365; bh=dOqodkXXHqnbCwLm91MIqwfc+jXoRMMHu+smwsaCrac=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tgXNA888qzX/t68kSFlXAa2rVogprm4+lv2p/dLgDAOSuZ37/LWoaUBVz0RX2tYRR RfVGpErDYq6Y0OCHktrkgwTKQqWPCtsn77RQfPKELKGoBbHFUUFgtRORHRFI50qFrj w9QPIi/qYzXuNYOKRijBXpElLd9vs5xQSIB68vGnGkTMzMbNR58HQ1fkwsndDzyng2 vNDA1wtvwZfnGqo3OCRaEyg0mapk5lcpKYDmHbCJqSmS9ElWyJGINcF8Ha597Wm7ZP rnU6VQjyvstwmBkUew6nhQrK/sYm7fSwiPKBuHJMRrg1rm0c/jQ2h2R2u1qWJZVPu0 CUoItB/CfuAfg== From: Heinrich Schuchardt To: Minda Chen , Hal Feng , Rick Chen , Leo Cc: Aurelien Jarno , Lukasz Tekieli , Lukas Funke , Shiji Yang , Shengyu Qu , Michal Simek , Seung-Woo Kim , Mason Huo , E Shattow , u-boot@lists.denx.de, Heinrich Schuchardt Subject: [PATCH v4 5/5] starfive: add mac vendor sub-command Date: Fri, 10 May 2024 07:52:21 +0200 Message-ID: <20240510055223.11617-6-heinrich.schuchardt@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240510055223.11617-1-heinrich.schuchardt@canonical.com> References: <20240510055223.11617-1-heinrich.schuchardt@canonical.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean As boards from multiple vendors (Milk-V, StarFive, Pine64) use the mac command provide a sub-command to set the vendor string. Reported-by: E. Shattow Signed-off-by: Heinrich Schuchardt Tested-by: E Shattow --- v4: no change v3: new patch --- .../visionfive2/visionfive2-i2c-eeprom.c | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/board/starfive/visionfive2/visionfive2-i2c-eeprom.c b/board/starfive/visionfive2/visionfive2-i2c-eeprom.c index 9648a270494..141d3db8667 100644 --- a/board/starfive/visionfive2/visionfive2-i2c-eeprom.c +++ b/board/starfive/visionfive2/visionfive2-i2c-eeprom.c @@ -404,6 +404,24 @@ static void set_product_id(char *string) update_crc(); } +/** + * set_vendor() - set vendor name + * + * Takes a pointer to a string representing the vendor name, e.g. + * "StarFive Technology Co., Ltd.", stores it in the vendor field + * of the EEPROM local copy, and updates the CRC of the local copy. + */ +static void set_vendor(char *string) +{ + memset(pbuf.eeprom.atom1.data.vstr, 0, + sizeof(pbuf.eeprom.atom1.data.vstr)); + + snprintf(pbuf.eeprom.atom1.data.vstr, + sizeof(pbuf.eeprom.atom1.data.vstr), string); + + update_crc(); +} + const char *get_product_id_from_eeprom(void) { if (read_eeprom()) @@ -463,6 +481,9 @@ int do_mac(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) } else if (!strcmp(cmd, "product_id")) { set_product_id(argv[2]); return 0; + } else if (!strcmp(cmd, "vendor")) { + set_vendor(argv[2]); + return 0; } return CMD_RET_USAGE; @@ -586,7 +607,9 @@ U_BOOT_LONGHELP(mac, "mac bom_revision \n" " - stores a StarFive BOM revision into the local EEPROM copy\n" "mac product_id \n" - " - stores a StarFive product ID into the local EEPROM copy\n"); + " - stores a StarFive product ID into the local EEPROM copy\n" + "mac vendor \n" + " - set vendor string\n"); U_BOOT_CMD( mac, 3, 1, do_mac,