Cannot write to uSD card

Hi RenesasRulz members,

I have modified the SDMMC_HAL_FRWK_FX_MG_AP example to use SDHI1 and the following pin configuration on a PK-S5D9 with QSPI disconnected and a uSD connector added:

Pin Group Selection: Mixed

Operation Mode: SD_MMC 4-Bit

CLK: P500

CMD: P501

DAT0: P502

DAT1: P503

DAT2: P503

DAT3: P504

DAT4: None

DAT5: None

DAT6: None

DAT7: None

CD: P706

WP: None

I formatted a 4GB uSD card on my PC as FAT32, and also created a short Readme.txt file using the PC.

I am able to open, read, and close the existing file, but if I try to create a directory or create a new file, fx_directory_create or fx_file_create return 35d, or 0x23, which is FX_WRITE_PROTECT (0x23) Underlying media is write protected according to the FileX manual.

As far as I know, there is no write protect pin on the uSD card.  Is there something that I may have configured incorrectly that might be causing an inability to write to the uSD card?

Thanks in advance for any help.  I am going to try adding the FileX/ThreadX source to see if I can find out more about why writes are failing.  I have also attached a zip file with my exported project, hoping that someone can take a look.

Best regards,

Scott

SDcardTestOnS5D9.zip

Parents Reply Children
  • The SD/MMC driver incorreclty always reads the state of the WP bit in the SDHI peripheral when the card type is set to SD Card :-

    r_sdmmc_write_protect_get() is called in the function R_SDMMC_Open().

    The function r_sdmmc_write_protect_get() probably should be something like :-

    and set Write Protect to "Not Used" in the configurator, then the WP pin of the SDHI peripheral does not have to be used.

    The SD/MMC driver is in clear text so can be edited. Exclude the original from the build so it doesn't get overwritten, and copy it to the src/ directory to make the changes :-