-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sd: prompt user for formatting if format is not VFAT compatible #1330
base: master
Are you sure you want to change the base?
Conversation
d01ec43
to
93a3b8f
Compare
Doesn't our code work with all fat file systems? Doesn't it make more sense to check if |
uint8_t work[FF_MAX_SS] = {0}; | ||
return f_mkfs("SD", ¶ms, work, sizeof(work)) == FR_OK; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is FF_MAX_SS, and what does this param do in general?
Is this suitable for production or was it possibly only a good value for the tests/simulator? Asking b/c I am not familiar, but the sd_format function was originally added for unit tests only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This set of options defines the extent of sector size used for the low level disk I/O interface, disk_read and disk_write function. Valid values are 512, 1024, 2048 and 4096. FF_MIN_SS defines minimum sector size and FF_MAX_SS defines the maximum sector size. Always set both 512 for memory card and harddisk.
Taken from FatFs configurations, http://elm-chan.org/fsw/ff/doc/config.html#max_ss. Only thing that boggled me was "SD" parameter there, but I did not encounter any issue while testing out. The card resetted and continued to work without an error.
src/rust/bitbox02/src/sd.rs
Outdated
true | ||
} | ||
|
||
pub fn sd_format() -> bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for the sd
prefix, this is in the sd
module and we don't need prefixes for namespacing like in C.
src/rust/bitbox02/src/sd.rs
Outdated
true | ||
} | ||
|
||
pub fn sd_format() -> bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-> Result<(), ()>
is more idiotmatic Rust for error handling than bool. You can see other examples for converting C bools to Results in the bitbox02/src files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, converting that to Result object
..Default::default() | ||
}) | ||
.await?; | ||
bitbox02::sd::sd_format(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one reason to make sd_format() return a Result<> is so that the compiler can warn you if you don't handle the result 😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, I intended to ask this in the pr message but forgot. Thanks, now it also handles when format fails 👍
You meant |
Not sure, what error messages do you get for a drive that is erased or a drive that has an incompatible file system? You can try with some apple fs or ntfs? |
Okay, I'll try that out with my old windows computer which I can plug the sdcard. Then I'll write the result here. |
I did a bit of research/trial and it seems the possible results for f_mount in that case would be:
In this case, I'm feeling like checking |
93a3b8f
to
2f770bc
Compare
I think with the message "SD-card needs to be formatted", we can only check We really, really, don't want people to erase their backups. There should probably also be two screens, first one confirm/cancel, and then one "pinch gesture" confirm with something like "PERMANENTELY ERASES SD-CARD". |
yes, i just listed error possibilities that could occur at that stage. then I'll update the condition to check only I'll also be adding second confirmation step as you mentioned, that's a good idea since I actually needed to cut off text to fit into one screen. I'll be adding screenshots again when I push. |
Have you thought of how to avoid false positives? For example, if the the user plugs in a working microSD card with a backup, but it is not detected correctly (we have had many "error detecting mSD card" issues in the past that is usually solved by replugging the device). Does this prompt only appear explicitly if the BitBox02 detects that the microSD card is in a known incompatible format? Or does the pompt appear anytime there is a mSD card detection error? |
Regarding the UI. Would be good to use the "hold" gesture instead of the "check mark" since it's a permutant change. |
This commit inserts a check to validate whether the sdcard where the backup will be put is VFAT compatible or not. VFAT compatilibity is crucial for using the card and lack of it could result in errors in the firmware. Therefore, when setting up the device, this commit validates it and if it is not compatible, it asks user whether he/she is okay with formatting or not. When the user confirms, SD card is formatted accordingly and the fresh SD card is ready to be used by BitBox02. Signed-off-by: asi345 <inanata15@gmail.com>
2f770bc
to
8fdab28
Compare
I pushed a new commit: @NickeZ I changed the condition to be
The first confirmation still looks like the above. Additionally I added this second confirmation screen: If you can, I also suggest you trying out the code and check that you're not getting this prompt 😅 |
This commit inserts a check to validate whether the sdcard where the backup will be put is VFAT compatible or not. VFAT compatilibity is crucial for using the card and lack of it could result in errors in the firmware. Therefore, when setting up the device, this commit validates it and if it is not compatible, it asks user whether he/she is okay with formatting or not. When the user confirms, SD card is formatted accordingly and the fresh SD card is ready to be used by BitBox02.