On Sat, Sep 20, 2014 at 06:01:51PM +0200, Cédric Tessier wrote:
> Hi,
> 
> I've bought a BeagleBone Black rev. C board, and I was trying to install
> OpenBSD on it, but the internal eMMC was causing errors.
> 
>  sdmmc1: unknown CARD_TYPE 0x17
>  scsibus1 at sdmmc1: 2 targets, initiator 0
>  sd1 at scsibus1 targ 1 lun 0: <SD/MMC, Drive #01, > SCSI2 0/direct fixed
>  sd1: 1024MB, 512 bytes/sector, 2097152 sectors
> 
> Card type and sectors count were wrong, and accessing the device was
> causing I/O errors.
> 
> I've investigated the problem, and it looks like the support of 
> High Capacity eMMC (> 2GB) is missing.
> 
> I've written a quick and dirty patch (tested on 5.5 and snapshot) which fix 
> all my issues.
> 
> Modifications:
> - mask reserved bits for card type value

These bits do not appear to be reserved.  In your case bit 4
seems to indicate HS200/200 MHz clock capable.

Bit 5 is HS400/400 MHz clock capable.

> - read sectors count from EXT_CSD
> - fix sectors count and enable SDHC if High Capacity eMMC is detected

Is the old method of reading the block length still supported
with emmc and csd ver > 2?  That wasn't the case for normal sd card.

It seems the emmc situation is a bit different as the capacity
stored in a seperate place.

> +
> +             if (ext_csd[EXT_CSD_REV] >= 2) {
> +                     sectors =   ext_csd[EXT_CSD_SEC_COUNT + 0] << 0  |
> +                                             ext_csd[EXT_CSD_SEC_COUNT + 1] 
> << 8  |
> +                                             ext_csd[EXT_CSD_SEC_COUNT + 2] 
> << 16 |
> +                                             ext_csd[EXT_CSD_SEC_COUNT + 3] 
> << 24;
> +                     /* 
> +                      * High capacity MMC seems to report a "magic" 4096 * 
> 512 bytes
> +                      * capacity in csd, but ext_csd contains the real 
> sectors count
> +                      */
> +                     if ((sf->csd.capacity == (4096 * 512)) && 
> +                             (sectors > (2u * 1024 * 1024 * 1024) / 512)) {
> +                             sf->flags |= SFF_SDHC;
> +                             sf->csd.capacity = sectors;
> +                     }

I think this should change to

                        if (sectors > (2u * 1024 * 1024 * 1024) / 512)
                                sf->flags |= SFF_SDHC;
                        sf->csd.capacity = sectors;

All csd rev > 2 cards should report valid sectors in the extended space.

Reply via email to