//
{
Rc=f_mount (0, & amp; Fs);
Rc=f_mkfs (0, 0, 512);
}
CodePudding user response:
[resolved] :The debug discovery:
1, where an error
B_fat=b_vol + n_rsv;
B_dir=b_fat + n_fat * N_FATS;
B_data=https://bbs.csdn.net/topics/b_dir + n_dir;
If (n_vol & lt; B_data + au)
{
Return FR_MKFS_ABORTED;/* Too small volume */
}
N_vol value is wrong;
2, the reason is in the function disk_ioctl (DRV, GET_SECTOR_COUNT, & amp; N_vol) n_vol didn't get the right sectors to TF card;
3, library functions are older, XSdPs_SdCardInitialize initialization () function in the sector number no assignment;
4, XSdPs_SdCardInitialize () add
If (((CSD [3] & amp; CSD_STRUCT_MASK) & gt;> 22 u)==0 u) {
BlkLen=1 & lt; <[2] ((CSD & amp; READ_BLK_LEN_MASK) & gt;> U);
Mult=1 & lt; <(((CSD [1] & amp; C_SIZE_MULT_MASK) & gt;> 7 u) + 2 u);
[1] DeviceSize=(CSD & amp; C_SIZE_LOWER_MASK) & gt;> 22 u;
DeviceSize |=(CSD [2] & amp; C_SIZE_UPPER_MASK) & lt; <10 u;
DeviceSize=(DeviceSize u + 1) * Mult.
DeviceSize=DeviceSize * BlkLen;
InstancePtr - & gt; SectorCount=(DeviceSize/XSDPS_BLK_SIZE_512_MASK);
[3]} else if (((CSD & amp; CSD_STRUCT_MASK) & gt;> 22 u u)==1) {
InstancePtr - & gt; SectorCount=(((CSD [1] & amp; CSD_V2_C_SIZE_MASK) & gt;> 8 + u)
1 u) * 1024 u;
}
Namely to InstancePtr - & gt; Gives SectorCount right value, f_mkfs () go through,