バックナンバーはこちら。
https://www.simulationroom999.com/blog/In-vehicle-external-storage-backnumber/
はじめに
FatFs WinシミュレーションでSDカードに直接制御する話。
「FatFsでパーティション分け」の続き。
前回にFatFsでパーティション分けをしたので、
各パーティションをFatFsでフォーマットしてみる。
登場人物
博識フクロウのフクさん

イラストACにて公開の「kino_k」さんのイラストを使用しています。
https://www.ac-illust.com/main/profile.php?id=iKciwKA9&area=1
エンジニア歴8年の太郎くん

イラストACにて公開の「しのみ」さんのイラストを使用しています。
https://www.ac-illust.com/main/profile.php?id=uCKphAW2&area=1
フォーマット方針

今回は前回分割した4つのパーティションに対してフォーマットをするんだよね。

そうだね。
何も考えずにフォーマットしても良いけど、
ここは意図的にFAT32とexFATを交互に使ってみようかと思う。

そういえば、exFATも対応してそうだったね。

ここらへんのフォーマットの話の時にちらっと出てきてた。

とりあえず、以下の方針にしよう。
- 第1パーティション:FAT32、au=4096
- 第2パーティション:exFAT、au=4096
- 第3パーティション:exFAT、au=8192
- 第4パーティション:FAT32、au=8192

おー!

じゃ、ざっとやってみよう。
各パーティションのフォーマット実施
FatFs module test monitor (LFN, CP932, UTF-8)
PD#0 <== RAM Disk (135MB, 512 bytes * 276480 sectors)
PD#1 <== \\.\PhysicalDrive1 (14832MB, 512 bytes * 30375936 sectors)
PD#2 <== \\.\PhysicalDrive2 (Not Ready)
PD#3 <== \\.\PhysicalDrive3 (Not Ready)
PD#4 <== PhysicalDrive4 (Not Ready)
PD#5 <== PhysicalDrive5 (Not Ready)
PD#6 <== PhysicalDrive6 (Not Ready)
PD#7 <== PhysicalDrive7 (Not Ready)
PD#8 <== PhysicalDrive8 (Not Ready)
PD#9 <== PhysicalDrive9 (Not Ready)
Multiple partition is enabled. Logical drives are associated with the patitions as follows:
"0:" ==> PT#1 in PD#0
"1:" ==> PD#1
"2:" ==> PT#1 in PD#1
"3:" ==> PT#2 in PD#1
"4:" ==> PT#3 in PD#1
"5:" ==> PT#4 in PD#1
"6:" ==> PD#5
"7:" ==> PD#0
>fm 2 2 4096
The volume will be formatted. Are you sure? (Y/n)=Y
rc=0 FR_OK
>fm 3 4 4096
The volume will be formatted. Are you sure? (Y/n)=Y
rc=0 FR_OK
>fm 4 4 8192
The volume will be formatted. Are you sure? (Y/n)=Y
rc=0 FR_OK
>fm 5 2 8192
The volume will be formatted. Are you sure? (Y/n)=Y
rc=0 FR_OK
>fi 2
rc=0 FR_OK
>fs 2:
FAT type = FAT32
Cluster size = 4096 bytes
Sectors/FAT = 7416
Number of FATs = 1
Number of clusters = 948310
Volume start sector = 63
FAT start sector = 136
Root DIR start cluster = 2
Data start sector = 7552
No volume label
Volume S/N is 52B4-7BAA
0 files, 0 bytes.
0 folders.
4210130 KiB total disk space.
3793236 KiB available.
>fi 3
rc=0 FR_OK
>fs 3:
FAT type = exFAT
Cluster size = 4096 bytes
Sectors/FAT = 7416
Number of FATs = 1
Number of clusters = 948309
Volume start sector = 7594038
FAT start sector = 7594070
Root DIR start cluster = 33
Data start sector = 7601536
No volume label
Volume S/N is 52B4-7BB1
0 files, 0 bytes.
0 folders.
4210130 KiB total disk space.
3793108 KiB available.
>fi 4
rc=0 FR_OK
>fs 4:
FAT type = exFAT
Cluster size = 8192 bytes
Sectors/FAT = 3709
Number of FATs = 1
Number of clusters = 474386
Volume start sector = 15188013
FAT start sector = 15188045
Root DIR start cluster = 11
Data start sector = 15191808
No volume label
Volume S/N is 52B4-7BBB
0 files, 0 bytes.
0 folders.
4210130 KiB total disk space.
3795008 KiB available.
>fi 5
rc=0 FR_OK
>fs 5:
FAT type = FAT32
Cluster size = 8192 bytes
Sectors/FAT = 3708
Number of FATs = 1
Number of clusters = 474384
Volume start sector = 22781988
FAT start sector = 22782084
Root DIR start cluster = 2
Data start sector = 22785792
No volume label
Volume S/N is 52B4-7BC7
0 files, 0 bytes.
0 folders.
4210130 KiB total disk space.
3795064 KiB available.
>
フォーマット結果確認

Windowsのディスク管理を見てみると・・・。


うん!
FAT32、exFAT、exFAT、FAT32の順番でフォーマットされてる!

どうやらうまく行ったようだ。(よかった)
ソースコードについて

今回使用したコードはGitHubに上げてるんで、必要があれば参照してみるとよいだろう

まぁとりあえず動かしてみるってのが手っ取り早いよねー。
まとめ

まとめだよ。
- パーティションのフォーマットはFAT32とexFAT混在で。
- FAT32、au=4096。
- exFAT、au=4096。
- exFAT、au=8192。
- FAT32、au=8192。
- フォーマット実施。
- 問題なくフォーマットできた。
- Windowsのディスク管理上からも確認。
バックナンバーはこちら。