Liam Battershell

improving the write speed of the sdhc-fatfs-mpc5748g example project

Discussion created by Liam Battershell on Jun 25, 2019

Hi All

 

I responded to a question about sd card write speeds on the DEVKIT-MPC5748G as i am having some of my own issues with that but i thought it might be a good idea to create a new post as the other one was a couple of years old now. Anyway here was my question...

 

 I am in the process of testing writes to the SD card using the sdhc-fatfs-mpc5748g example from s32ds and it seems I am getting speeds varying between 4 and 80 KB/s(goodput) depending on how much data I give to the FAT file write function. I have had a look and it seems to me that the SD card is only ever getting to 20MHZ clock speed and is not correctly switching to 4 bit mode. This seems to be because out of the box there is some confusion about endianness and the processing of the SCR data. This leads to the card being read as not supporting 4-bit mode. In testing I have tried changing the SD_SendScr(sd_card_t *card) to make it swap the byte sequence and after that it does correctly identify the sd card as supporting 4bit transfers and I can see the data on the scope on dat0-3 but it gets stuck on the second time it calls SD_SendScr(sd_card_t *card) and just waits for a transfer that never completes. The elmChan firmware, the framework middleware and the configuration all contain references (and comments) about endianness and to me it is unclear where the issue should be addressed so that the "truth" is passed on to all the relevant layers of the implementation without needing to have things like this in uSDHC_CopyHostConfig confusing things...

 

    /*
     * Endianness is already handled by uSDHC_PROT_CTRL_EMODE in uSDHC,
     * no need to swap byte sequence since and so
     * we are setting big-endian in SD layer.
     */
    card_config->endianMode = uSDHC_ENDIAN_MODE_BIG;

 

Anyway if anyone has managed to get the #SD card demo working at a reasonable speed on the devkit-mpc5748g and wouldn’t mind sharing the code/configuration details with me, or if anyone could provide any assistance I would greatly appreciate it.

 

Many thanks

 

Liam B

Outcomes