how to initialize (erase) an SD card

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

how to initialize (erase) an SD card

跳至解决方案
1,704 次查看
MPotts
Contributor III

Hi,

 

I have mnaged to get the sample MQX SPI and SDcard drivers working and can fread() and fwrite() sectors to an SD card with no problems (so far). I also need to erase the card but I don't think there is any facility to do this at the SDcard driver level. I assume I will have to drop back to SPI level and send some low-level SD/SPI commands. Does anyone have experience with this that they could share.

 

Thanks,

Mark

标签 (1)
标记 (1)
0 项奖励
1 解答
699 次查看
PetrM
Senior Contributor I

Hello,

 

well, there are 3 options:

1) Don't erase anything, just format the drive/paritition, which means normal write to few first sectors with partition information, FAT table and root directory. That's what MFS does during format. The old data are not accesible anymore.

2) Simply write some pattern (zeros) all over the SD card space.

3) Add support for SD SPI erase commands that should behave similarly to CMD24 which is already there. And there should be new erase IOCTL command at generic SD card level calling the new low level SD SPI commands.

 

Regards,

PetrM

 

在原帖中查看解决方案

0 项奖励
2 回复数
700 次查看
PetrM
Senior Contributor I

Hello,

 

well, there are 3 options:

1) Don't erase anything, just format the drive/paritition, which means normal write to few first sectors with partition information, FAT table and root directory. That's what MFS does during format. The old data are not accesible anymore.

2) Simply write some pattern (zeros) all over the SD card space.

3) Add support for SD SPI erase commands that should behave similarly to CMD24 which is already there. And there should be new erase IOCTL command at generic SD card level calling the new low level SD SPI commands.

 

Regards,

PetrM

 

0 项奖励
699 次查看
MPotts
Contributor III

Hi Petr,

 

Thanks for the adv ice. I am not using a file system but rather using the entire card as a giant hash table. This means that option 1 would not help and option 2 would be very time consuming. I will try option 2 to perform a low-level SPI erase and let you know the result. I will look at CMD24 as a guide.

 

Thanks,

Mark

0 项奖励