File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -553,6 +553,29 @@ static int stm32_sdmmc_access_write(struct disk_info *disk,
553
553
return err ;
554
554
}
555
555
556
+ static int stm32_sdmmc_access_erase (struct disk_info * disk , uint32_t sector , uint32_t count )
557
+ {
558
+ const struct device * dev = disk -> dev ;
559
+ struct stm32_sdmmc_priv * priv = dev -> data ;
560
+ int err ;
561
+
562
+ k_sem_take (& priv -> thread_lock , K_FOREVER );
563
+
564
+ err = HAL_SD_Erase (& priv -> hsd , sector , sector + count );
565
+ if (err != HAL_OK ) {
566
+ LOG_ERR ("sd erase block failed %d" , err );
567
+ err = - EIO ;
568
+ goto end ;
569
+ }
570
+
571
+ while (!stm32_sdmmc_is_card_in_transfer (& priv -> hsd )) {
572
+ }
573
+
574
+ end :
575
+ k_sem_give (& priv -> thread_lock );
576
+ return err ;
577
+ }
578
+
556
579
static int stm32_sdmmc_get_card_info (HandleTypeDef * hsd , CardInfoTypeDef * info )
557
580
{
558
581
#ifdef CONFIG_SDMMC_STM32_EMMC
@@ -606,6 +629,7 @@ static const struct disk_operations stm32_sdmmc_ops = {
606
629
.status = stm32_sdmmc_access_status ,
607
630
.read = stm32_sdmmc_access_read ,
608
631
.write = stm32_sdmmc_access_write ,
632
+ .erase = stm32_sdmmc_access_erase ,
609
633
.ioctl = stm32_sdmmc_access_ioctl ,
610
634
};
611
635
You can’t perform that action at this time.
0 commit comments