edison-fw / meta-intel-edison

Here is the meta-intel-edison that builds, tries to stay up to date. Master is based on Yocto Poky Gatesgarth LTS 5.10.yy vanilla kernels. It builds a 32bit kernel (Gatesgarth branch 64bit) with ACPI enabled and corresponding rootfs. Telegram group: https://t.me/IntelEdison Web-site:
https://edison-fw.github.io/meta-intel-edison/
MIT License
60 stars 37 forks source link

SD card not detected properly in U-Boot #136

Closed humanoid2050 closed 2 years ago

humanoid2050 commented 2 years ago

At least as far back as the Dunfell branch, U-Boot (as installed) does not properly detect an SD card when using a Sparkfun microSD Block. Product page Schematic A very long time ago (like when Intel was still supporting the Edison) U-Boot was able to see the uSD card.

When the card slot is empty

=> mmc dev 1
Card did not respond to voltage select! : -110

When the card slot is populated

=> mmc dev 1
MMC: no card present

Presumably, this is the U-Boot analog of #135, which focused on the kernel. Investigation into that issue indicated that the Sparkfun board and the Edison-Arduino board use different hardware for the uSD socket. The Sparkfun board has a "normally closed" switch on the Card Detect (CD) line. This means that when no card is present, the CD line is shorted to ground. Inserting the card breaks the contact. The Edison-Arduino board uses a "normally open" switch internally with an external pullup to 1.8V on the line.

I had assumed that the patch meta-intel-edison/meta-intel-edison-bsp/recipes-bsp/u-boot/files/0004-x86-edison-Enable-SD-card-detect-on-the-SDHCI-2.patch was responsible for configuring the GPIO line that U-Boot uses for CD, but altering and even removing the patch produced absolutely no observable changes to the behavior.

andy-shev commented 2 years ago

To your last paragraph: U-Bott does not have a GPIO driver for Intel Tangier, that's why changing flags do nothing. But putting 'cd-inverted' into DTS should have an effect (as we exercised in #135 for cd_override_level).

andy-shev commented 2 years ago

It seems I have nailed down what's going on in U-Boot. The firmware sets the mode for SD CD pin to native (mode 1), while in Linux kernel we first switch it to mode 0 (GPIO). That's why U-Boot doesn't ignore its state.

TL;DR: please test these two patches (@htot drop anything in your tree except these two along with https://github.com/andy-shev/u-boot/commit/20d551a84d7a, so you will have only three patches on top of upstream U-Boot) https://github.com/andy-shev/u-boot/commit/87f693a59df3b76952c8f5fadf13ce586dc2b1b2 followed by https://github.com/andy-shev/u-boot/commit/c5cfab637085991ebc44b052c2790fa19048ee7d.

htot commented 2 years ago

Sure. I see it might be worth upgrading U-Boot to 2021.10 in our image.

andy-shev commented 2 years ago

No response from the reporter @humanoid2050 and works for me, hence closing.

htot commented 2 years ago

For completeness I just tested these patches on Edison-Arduino. When SD card is not present:

=> ls mmc 1
Card did not respond to voltage select! : -110
Couldn't find partition mmc 1

When SD card is present:

=> ls mmc 1
            .disk/
            boot/
            casper/
            dists/
            EFI/
            install/
 1073741824   casper-rw
            pics/
            pool/
            preseed/
      134   autorun.inf
    18809   md5sum.txt
      229   README.diskdefines
  2501488   wubi.exe
    32256   ldlinux.sys
            syslinux/
 11015538   mb_bios_z490m_f20d.zip
            mb_bios_z490m_f20d/

7 file(s), 11 dir(s)

I didn't see any differences between booting with SD card inserted or not.

Other info:

=> fstype mmc 1
fat
=> fstypes
Supported filesystems: fat, ext4, btrfs
=> mmcinfo
Device: mmc@ff3fa000
Manufacturer ID: 2
OEM: 544d
Name: SD02G 
Bus Speed: 50000000
Mode: SD High Speed (50MHz)
Rd Block Len: 512
SD version 2.0
High Capacity: No
Capacity: 1.8 GiB
Bus Width: 4-bit
Erase Group Size: 512 Bytes

Seems to work fine on Edison-Arduino. I hope to force push later this evening. @humanoid2050 would you have time to test on your platform?

humanoid2050 commented 2 years ago

I should be able to. I tried cobbling it together myself, but somehow I fixed uboot but broke kernel in a new way.

htot commented 2 years ago

force pushed to htot/master and htot/gatesgarth

humanoid2050 commented 2 years ago

Allrighty. Pulled the latest gatesgarth. Built, compiled, flashed just fine. U-Boot and kernel both react properly to the SD card being inserted and removed!

htot commented 2 years ago

Thanks for testing @humanoid2050