Booting from SD card

I’m trying to work out how to boot from the SD card. The schematic shows that the switch is made using the U44/U29 TI multiplexers. That seems to be driven by the SDIO_SW _{SEL0|SEL1|EN#) lines, but it’s not clear to me how those get driven themselves.

The only other mention of them is as GPIO inputs to the SoC. At least, the schematic suggests those are inputs. I also can’t find any references to those GPIO lines in the source code of the hart software services or U-boot.

Hi @KristofProvost :slight_smile:

Your understanding is correct - the SDIO_SW _{SEL0|SEL1|EN#) are connected to BANK 1 of the FPGA, you can see this connection on page 13 of the Icicle Kit schematics (left side of BANK 1).

In the Icicle Kit reference design repo on GitHub we have a Libero TCL script to generate a design for SD cards or eMMC - the reason you can’t see any reference to the SDIO_SW _{SEL0|SEL1} signals in software is because they are either tied low (eMMC) or high (SD) in the Libero design and not currently configurable by software. The EN# is always tied low.

The reason for this is because there is different MSS XML for each configuration and users need to build the HSS using the XML for either eMMC or SD and the PF SoC HAL will configure the MSS I/Os on boot.

We have programming files here for both eMMC and SD card which will allow you to boot from either source if you don’t want to change the FPGA design and these also contain the HSS so you won’t have to build that either.

2 Likes

Hey @KristofProvost check out the latest post - we’ve added in support to allow the HSS to configure the MSS I/Os and the SDIO_SW_SEL signals on startup so it can dynamically switch between SD or eMMC without having to reprogram the FPGA :slight_smile:

Hi, @hugh.breslin, thanks for the pointer to the updates regarding SD card switching!

I’m not sure if this is the same issue, but I’m still having trouble booting from the SD Card. Maybe I’m missing something like a kernel parameter?

I used FlashPro Express to update the board to reference design version 2020.11 (if I understand correctly, the updated HSS are included?).
Now I can see the following line in UART0 during boot:

[1.943274] HSS_MMCInit(): Attempting to select SDCARD ... Passed

Within U-Boot it looks like the SD Card is selected (“Capacity: 119.4 GiB”):

RISC-V # mmcinfo
Device: sd@20008000
Manufacturer ID: 1b
OEM: 534d
Name: ED2S5
Bus Speed: 50000000
Mode: SD High Speed (50MHz)
Rd Block Len: 512
SD version 3.0
High Capacity: Yes
Capacity: 119.4 GiB
Bus Width: 4-bit
Erase Group Size: 512 Bytes

However, when the kernel is loaded, only the eMMC is available, mmcblk0 size is ~8GB (and I can see files which I created on the eMMC before):

root@icicle-kit-es:~# lsblk
NAME         MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
mmcblk0      179:0    0  7.3G  0 disk 
|-mmcblk0p1  179:1    0   18M  0 part 
|-mmcblk0p2  179:2    0    8M  0 part 
`-mmcblk0p3  179:3    0    1G  0 part /
mmcblk0boot0 179:8    0    4M  1 disk 
mmcblk0boot1 179:16   0    4M  1 disk 

So it looks like - at some point between leaving U-Boot / entering the kernel the mux is “switched back” to eMMC?

So what am I missing here in order to have the SD card available during Linux runtime? Is there a special kernel or image required? I’m currently using the version core-image-minimal-dev-icicle-kit-es-sd-20201127112434.rootfs.wic.gz

I’m very thankful for any pointers!

I did some more digging and found the following lines in the dmesg output:

[    1.049691] mmc0: error -110 whilst initialising SD card
[    1.184665] mmc0: new high speed MMC card at address 0001
[    1.192331] mmcblk0: mmc0:0001 DG4008 7.28 GiB 
[    1.198507] mmcblk0boot0: mmc0:0001 DG4008 partition 1 4.00 MiB
[    1.206031] mmcblk0boot1: mmc0:0001 DG4008 partition 2 4.00 MiB
[    1.225283] mmcblk0rpmb: mmc0:0001 DG4008 partition 3 4.00 MiB, chardev (246::0)

Any idea where the error -110 might be originating from? The error message is the same on both, a 128GB Samsung SDHC and a 16 GB Transcend card. The cards themselves are OK, though (checked with a different card reader)

Hey @cypheon,

Nice spot! We had a look into this and heres what we can see happening:

It looks like this occurs during Linux boot – what I can see on my end is the image from SD card being loaded and when the kernel comes up and starts loading drivers it brings up the GPIO driver. Part of the GPIO driver starting up is that it initializes the GPIOs to 0 – unfortunately, this looks like the culprit as its setting GPIO2_0 to 0 and re-selecting the eMMC.

To resolve this without updating the driver or trying to build in a solution for the GPIO we’ve changed the reference design to use a register. This means that you need to write either 0 or 1 to address 0x4F00_0000 to select eMMC or SD card which will not be reset by Linux. The reference design update will be pushed out in a few days and I’ll respond here when it’s available and we’ll also be pushing out an update for the HSS to accommodate this change. They’ll be available in the 2020.12 tag.

I’m sorry for the confusion and disruption this might have caused.

2 Likes

Thanks for the quick answer! I’m happy to know the issue is on your roadmap.
I’ll wait for the 2020.12 tag then, thanks!

Hey, the tag is up! We’ve included an asset of the flashpro express job too: https://github.com/polarfire-soc/icicle-kit-reference-design/releases/tag/2020.12

1 Like

Wow, that was a lot faster than I expected! Thank you very much for the updated reference design.
After flashing, I can now boot from the SD card just as expected. It’s really great to know that the reference design is continuously improved and supported.

1 Like

Brilliant news :slight_smile:

We’re keeping the design updated to support the latest Libero versions and cores as they come out along with adding new features as we go