Skip to contentSkip to conversation

spacemit: k1: two small fixes found on a Milk-V Jupiter

PATCH In review Hung-Chun Tseng 3 participants 6 messages Oct 27 RISC-V SpacemiT SoC Support

lore
Share & tools
lore
#0 lore raw

cover spacemit: k1: two small fixes found on a Milk-V Jupiter

Two small fixes I ran into while booting the mainline SPL and U-Boot from an SD card on a Milk-V Jupiter.

Patch 1 enables the GigaDevice SPI NOR ID table, which the Jupiter's GD25Q64 needs; "sf probe" detects it on the board with the patch.

Patch 2 initialises the EEPROM index that read_ddr_info() passes to read_tlvinfo_tlv_eeprom(). It is build-tested only; on the Jupiter the current compiler happens to pass 0 already, and the DDR TLV fields are read correctly.

Hung-Chun Tseng (2):
configs: k1: enable GigaDevice SPI NOR flash support
spacemit: k1: initialise the EEPROM index in read_ddr_info()

 board/spacemit/k1/spl.c       | 2 +-
 configs/spacemit_k1_defconfig | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/2 configs: k1: enable GigaDevice SPI NOR flash support

The Milk-V Jupiter boots from a GigaDevice GD25Q64 SPI NOR flash, but spacemit_k1_defconfig only enables the Winbond ID table, so neither the SPL nor U-Boot proper can detect it:

jedec_spi_nor flash@0: unrecognized JEDEC id bytes: c8, 40, 17

Enable SPI_FLASH_GIGADEVICE. With it, "sf probe" on a Jupiter reports:

SF: Detected gd25q64 with page size 256 Bytes, erase size 4 KiB, total 8 MiB

---
 configs/spacemit_k1_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/spacemit_k1_defconfig +1 -0
index 8ee9baa13..b8f777e89 100644
@@ -88,6 +88,7 @@ CONFIG_MMC_HS400_ES_SUPPORT=y
 CONFIG_MMC_HS400_SUPPORT=y
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_SPACEMIT=y
+CONFIG_SPI_FLASH_GIGADEVICE=y
 CONFIG_SPI_FLASH_WINBOND=y
 CONFIG_NVME_PCI=y
 CONFIG_PCIE_DW_SPACEMIT=y
Signature · 1 line
2.43.0
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] configs: k1: enable GigaDevice SPI NOR flash support

Quoted 20 lines · Hung-Chun Tseng

The Milk-V Jupiter boots from a GigaDevice GD25Q64 SPI NOR flash, but spacemit_k1_defconfig only enables the Winbond ID table, so neither the SPL nor U-Boot proper can detect it:

jedec_spi_nor flash@0: unrecognized JEDEC id bytes: c8, 40, 17

Enable SPI_FLASH_GIGADEVICE. With it, "sf probe" on a Jupiter reports:

SF: Detected gd25q64 with page size 256 Bytes, erase size 4 KiB, total 8 MiB

---
 configs/spacemit_k1_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/spacemit_k1_defconfig +0 -0
index 8ee9baa13..b8f777e89 100644

configs/spacemit_k1_defconfig CONFIG_MMC_HS400_ES_SUPPORT=y · line 94

Quoted 7 lines
configs/spacemit_k1_defconfig +1 -0
@@ -88,6 +88,7 @@ CONFIG_MMC_HS400_ES_SUPPORT=y
 CONFIG_MMC_HS400_SUPPORT=y
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_SPACEMIT=y
+CONFIG_SPI_FLASH_GIGADEVICE=y
 CONFIG_SPI_FLASH_WINBOND=y
 CONFIG_NVME_PCI=y
 CONFIG_PCIE_DW_SPACEMIT=y

LGTM

#3 lore raw

PATCH 2/2 spacemit: k1: initialise the EEPROM index in read_ddr_info()

In reply to Hung-Chun Tseng

read_ddr_info() passes i to read_tlvinfo_tlv_eeprom() as the EEPROM device index before giving it a value, so which device is read depends on whatever is on the stack. read_product_name() does the same call with i set to 0.

Initialise i to 0 in read_ddr_info() as well.

Fixes 83026cf8f90b ("spacemit: k1: Add DDR firmware support to SPL")
---
 board/spacemit/k1/spl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
board/spacemit/k1/spl.c +1 -1
index cc0e26bb0..60f5d8c56 100644
@@ -332,7 +332,7 @@ int read_ddr_info(struct ddr_cfg *cfg)
 	struct tlvinfo_header *tlv_hdr;
 	struct tlvinfo_tlv *tlv_entry;
 	u32 size, entry_size;
-	int ret, i;
+	int ret, i = 0;
 	bool found = false;
 
 	if (!cfg)
Signature · 1 line
2.43.0
Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] spacemit: k1: initialise the EEPROM index in read_ddr_info()

Quoted 18 lines · Hung-Chun Tseng

read_ddr_info() passes i to read_tlvinfo_tlv_eeprom() as the EEPROM device index before giving it a value, so which device is read depends on whatever is on the stack. read_product_name() does the same call with i set to 0.

Initialise i to 0 in read_ddr_info() as well.

Fixes 83026cf8f90b ("spacemit: k1: Add DDR firmware support to SPL")
---
 board/spacemit/k1/spl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
board/spacemit/k1/spl.c +0 -0
index cc0e26bb0..60f5d8c56 100644

board/spacemit/k1/spl.c int read_ddr_info(struct ddr_cfg *cfg) · line 338

Quoted 8 lines
board/spacemit/k1/spl.c +1 -1
@@ -332,7 +332,7 @@ int read_ddr_info(struct ddr_cfg *cfg)
 	struct tlvinfo_header *tlv_hdr;
 	struct tlvinfo_tlv *tlv_entry;
 	u32 size, entry_size;
-	int ret, i;
+	int ret, i = 0;
 	bool found = false;
 
 	if (!cfg)

LGTM

maintainer Reviewed-by on the v1 series
#5 lore raw
In reply to Hung-Chun Tseng

Hi Hung-Chun,

Quoted 11 lines · Hung-Chun Tseng

Two small fixes I ran into while booting the mainline SPL and U-Boot from an SD card on a Milk-V Jupiter.

Patch 1 enables the GigaDevice SPI NOR ID table, which the Jupiter's GD25Q64 needs; "sf probe" detects it on the board with the patch.

Patch 2 initialises the EEPROM index that read_ddr_info() passes to read_tlvinfo_tlv_eeprom(). It is build-tested only; on the Jupiter the current compiler happens to pass 0 already, and the DDR TLV fields are read correctly.

Quoted 8 lines

Hung-Chun Tseng (2):
configs: k1: enable GigaDevice SPI NOR flash support
spacemit: k1: initialise the EEPROM index in read_ddr_info()

 board/spacemit/k1/spl.c       | 2 +-
 configs/spacemit_k1_defconfig | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

for the series, with

Signature · 1 line
Yixun Lan (dlan)