sdc erase handling of sdhc sdxc card

Report here problems in any of ChibiOS components. This forum is NOT for support.
User avatar
alex31
Posts: 391
Joined: Fri May 25, 2012 10:23 am
Location: toulouse, france
Has thanked: 40 times
Been thanked: 67 times
Contact:

sdc erase handling of sdhc sdxc card

Postby alex31 » Sun Jan 28, 2024 10:34 am

Hi,

sdcErase fails for high capacity SD card.

from https://chlazza.nfshost.com/sdcardinfo.html, note 10 => 10. SDSC Card (CCS=0) uses byte unit address and SDHC and SDXC Cards (CCS=1) use block unit address (512 bytes unit).

So the test in sdcErase seems inverted
tested with if ((sdcp->cardmode & SDC_MODE_HIGH_CAPACITY) == 0U)
and it works !

when the following patch is applied, sdcErase works for sdhc card.

Code: Select all

diff --git a/os/hal/src/hal_sdc.c b/os/hal/src/hal_sdc.c
index e2c6452f7..7160f255a 100644
--- a/os/hal/src/hal_sdc.c
+++ b/os/hal/src/hal_sdc.c
@@ -967,7 +967,7 @@ bool sdcErase(SDCDriver *sdcp, uint32_t startblk, uint32_t endblk) {
   sdcp->state = BLK_WRITING;
 
   /* Handling command differences between HC and normal cards.*/
-  if ((sdcp->cardmode & SDC_MODE_HIGH_CAPACITY) != 0U) {
+  if ((sdcp->cardmode & SDC_MODE_HIGH_CAPACITY) == 0U) {
     startblk *= MMCSD_BLOCK_SIZE;
     endblk *= MMCSD_BLOCK_SIZE;
   }


Alexandre

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 18 guests