how to initialize (erase) an SD card

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

how to initialize (erase) an SD card

ソリューションへジャンプ
2,481件の閲覧回数
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 解決策
1,476件の閲覧回数
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 返答(返信)
1,477件の閲覧回数
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 件の賞賛
返信
1,476件の閲覧回数
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 件の賞賛
返信