Skip to main content
Visitor II
May 12, 2018
Question

STM32F4 eMMC support

  • May 12, 2018
  • 6 replies
  • 19754 views

Posted on May 12, 2018 at 13:47

Hello there,

I am writing in regard to those 2 topics:

https://community.st.com/thread/49792-sm32l4-interface-with-an-emmc

I am using an STM32L452 chip and trying to fully utilize the SanDisk 8GB eMMC memory (

SDINBDG4-8G

). I have found out that the is no eMMC HAL written for the L4 family. Because of that, I tried STM32F412, as it uses SDIO not SDMMC peripheral (the same thing but other name?), and it has HAL written. I have found out however, that as pointed out here

it doesnt work. There are no examples of eMMC usage in STM32Cube_FW_F4_V1.0. From the code it also seems that it only supports memories up to 2 GB. Trying to use the code I was unable to write anything to the momory, like the mentioned topic, even though over a year passed since it was posted.

At the moment I have a serious design dilemma. I cannot afford the time to write the driver from scratch or try to fix the existing one. Could I please ask for an explanation what is the state of the eMMC driver for each STM32F4 and STM32L4 devices, do they indeed not work? Is there a way to make them work? Also, what is the real difference between SDIO which F4 utilize and SDMMC peripherals which L4 utilize? I would appreciate all help.

https://community.st.com/people/DAHMEN.IMEN

‌ ?

Note: this post was migrated and contained many threaded conversations, some content may be missing.

    This topic has been closed for replies.

    6 replies

    Graduate II
    May 12, 2018
    Posted on May 12, 2018 at 14:12

    The constraining issue here tends to be that no ST board (NUCLEO, DISCO, EVAL) is provided with an eMMC memory, and thus no driver to have a software driver. The BSP library is constructed of things that actually exist in the ST universe.

    I've seen people with eMMC to MMC (fullsize) card adapters, so I assume the internal mechanics are the same as SD/MMC cards and the sub-4G vs above relates to the command set used and the block addressing. The assumption again here is were talking about basically the same die and it is either encapsulated in a chip carrier vs a card form-factor.

    I am mildly curious, so will fish around to see if I can find an eMMC break-out board with something in the 16-32GB range.

    Visitor II
    May 12, 2018
    Posted on May 12, 2018 at 14:23

    Glad I have obtained you attention, thank you for help.

    For my tests I have used

    http://www.st.com/content/st_com/en/products/evaluation-tools/product-evaluation-tools/mcu-eval-tools/stm32-mcu-eval-tools/stm32-mcu-nucleo/nucleo-f412zg.html

      and

    https://www.amazon.com/dp/B076HTDH2J

      adapter:0690X00000604ceQAA.jpg

    Like I described the initialization code seems to work. What does not is writing to the memory (returns errors) and reading I cannot tell, since I cannot write, but I assume it works. Also I am concerned about maximum of 2 GB capacity. Even thought you say that its just about instruction set, maybe the MMC 4.2 standard which STM32 uses is not compatible with higher capacities?

    Also, as long I understand that libs are there if the hardware is there (on demo boards) its hard to believe that someone wrote this HAL without testing it. Or...?

    Graduate II
    May 12, 2018
    Posted on May 12, 2018 at 14:56

    That looks like an reasonable adapter, but a little on the pricey side.

    Something like this to interface to a board mounted device might be another route

    https://www.amazon.com/eMMC-Module-Reader-Board-upgrade/dp/B074HQ4QHF/ref=pd_sbs_469_7?_encoding=UTF8&pd_rd_i=B074HQ4QHF&pd_rd_r=HW42KSKSKHD9TZ0PJ9J9&pd_rd_w=B0ZNy&pd_rd_wg=H1elq&psc=1&refRID=HW42KSKSKHD9TZ0PJ9J9

     

    There are some other module/board mounted eMMC for the Nintendo Switch, couple of 32GB things dropped out of eBay

    >>its hard to believe that someone wrote this HAL without testing it. Or...?

    Yeah, my view of this is that very minimal or narrow testing is done. So if the example on the bench works with a little demo code it ships. This is not quite the same as something that is usable in the real-world with a part from Brand X instead of Brand Y, or on all parts 128MB thru 128GB. I don't think there is any 'dog-fooding' where they are forced to use a collections of drivers in some real-world demo where several components are pulled together in an application use-case that you or I might find remotely useful or deliverable.

    Visitor II
    May 17, 2018
    Posted on May 17, 2018 at 13:47

    Hello, I've used emmc with stm32f405 and stm32f429 and they work fine

    Visitor II
    May 17, 2018
    Posted on May 17, 2018 at 13:49

    Can you provide working examples?

    Visitor II
    December 19, 2018

    did u get it working?can you help me with sample code i am trying to interface emmc with stm32l4

    Visitor II
    May 18, 2018

    Posted on May 18, 2018 at 06:55

    I have attached a project which i did on a stm32f405 chip. I used the HAL MMC functions and FATFS for read write operations. I linked them by functions in /src/eMMC_drivers and /src/user_diskio. Feel free to ask if any doubt.

    ________________

    Attachments :

    heees.rar :

    Visitor II
    May 18, 2018
    Posted on May 18, 2018 at 06:59

    Thank you,

    I will check it out monday morning. Have a nice weekend.

    Visitor II
    May 18, 2018
    Posted on May 18, 2018 at 07:15

    Sure.

    Visitor II
    May 21, 2018
    Posted on May 21, 2018 at 11:54

    Some update from

    Riddell.Gideon

    ‌ on this topic:

    https://community.st.com/0D70X000006SzPlSAK

    Visitor II
    May 21, 2018
    Posted on May 21, 2018 at 23:31

    I looked into the HAL_MMC_GetCardCSD() function and it seems to be fine and i tallied the BlockNbr and Block Size from the eMMC datasheet the capacity turns out to be 1 GB.

    from a formula i looked up on internet:

    {

    capacity = BLOCKNR *BLOCK_LEN 

    MULT = 2^(C_SIZE_MULT+2)

    BLOCKNR = (C_SIZE+1) * MULT

    BLOCK_LEN = 2^READ_BL_LEN

    }

    where from the eMMC datasheet (Kingston)  C_SIZE = 0xfff, C_SIZE_MULT = 0x07 (Bytes) and READ_BL_LEN = 0x09 (512 Bytes)

    capacity = (0x1000)*(2^(9))*(2^(9)) = 1073741824 Bytes.

    So it turns out for eMMC greater than 2GB read EXT_CSD register where, capacity is SEC_COUNT*512.

    Visitor II
    December 19, 2018
    Hi,
    Please talk to Clive.