-
Notifications
You must be signed in to change notification settings - Fork 3k
bd: Add MBR block device for standard storage partitioning #3936
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
Conversation
_size = fromle32(table->entries[_part-1].lba_size) * sector; | ||
|
||
// Check that block addresses are valid | ||
printf("offset %lld\n", _offset); |
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.
Is this intended to be printed always (not a debug msg) ? or just left behind?
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.
Ah whoops, good catch 👍
@simonqhughes please review |
HeapBlockDevice bd(BLOCK_COUNT*BLOCK_SIZE, BLOCK_SIZE); | ||
|
||
// Testing formatting of master boot record | ||
void test_mbr_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.
code style same as the implementation
void test_mbr_format()
{
//code here
}
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.
Ah good catch 👍
655d485
to
ab5a2b9
Compare
I kinda get this but does the FATFileSystem mount a MBRBlockDevice? |
You can, it depends on how you structure your classes: SDBlockDevice sd(s0, s1, s2, s3); // SD card
MBRBlockDevice part1(&sd, 1); // Partition 1 on SD card
FATFileSystem fs("fat", &part1); // FAT filesystem on partition 1 Should be noted the MBRBlockDevice is optional. External storage doesn't need an mbr for pcs, and chanfs already traverses an mbr if it runs into one. The MBRBlockDevice is useful if you want to access other partitions on the device while still allowing mountability across other devices. It also provides a few other uses, such as defining storage regions at manufacturing time, or storing partition attributes. |
@geky LGTM. Just need an API page for this and stage some updates to storage docs in the handbook that show how to use it. |
@geky any news on the docs update? |
I added a blurb in the API page for the block device API that links to the documentation in the MBRBlockDevice.h header: I'm not sure the MBR block device needs it's own handbook page as it's just one part of the storage apis, but let me know if you want more documentation. (The doxygen in the class contains example usage). |
I also added a bit more to the class documentation and included the SD card example. |
|
||
// Little-endian conversion, should compile to noop | ||
// if system is little-endian | ||
static inline uint32_t tole32(uint32_t a) { |
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.
can you align the code style
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.
Good catch, should be updated
TEST_ASSERT_EQUAL(0, err); | ||
|
||
// Test attributes on partitions | ||
printf("partition 1 partition number: %d\n", part1.get_partition_number()); |
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.
Do we need all these prints? if they fail, these numbers will be printed as part of the error?
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.
The output would help debugging what went wrong in the test. Multiple attributes may be wrong, but the assert would stop after the first.
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.
Understood, but still the test should not print anything if is all green ? This is more for future request (than solving it here with this PR) - having logging library. Some tests already have something like DEBUG_PRINT
that is a config attribute and by default disabled. Is it time now to consider having something similar to it - a proper replacement?
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.
I rambled grumpily over here: #4317 (comment), there's also related discussion over there.
It does seem like we should have a configurable logging/debug we can remove at compile time, but I'm going to leave these as is for now. They aren't currently causing a problem, and we should probably apply a consistent solution to all of the tests we have in a seperate pr.
/morph test-nightly |
Result: FAILUREYour command has finished executing! Here's what you wrote!
OutputTest failed! |
|
@geky Any update on this ? |
/morph test-nightly |
Result: SUCCESSYour command has finished executing! Here's what you wrote!
OutputAll builds and test passed! |
This saves 64 blocks (32KB when used with 512B blocks) and drops the minimum storage size from 64KB to 32KB.
Found an issue with how the fat filesystem calculated the minimum block count required without the MBR (3ee77e3). Sorry about creating the rereview. |
/morph test-nightly |
Result: FAILUREYour command has finished executing! Here's what you wrote!
OutputTest failed! |
This is a sporadic udp packet loss error fixed by this guy: #4369 |
/morph test-nightly |
Result: FAILUREYour command has finished executing! Here's what you wrote!
OutputTest failed! |
/morph test-nightly |
Result: FAILUREYour command has finished executing! Here's what you wrote!
OutputTest failed! |
/morph test-nightly |
Result: SUCCESSYour command has finished executing! Here's what you wrote!
OutputAll builds and test passed! |
Woah! One got through! LGTM? |
The MBRBlockDevice adds support for standard storage partitioning. This is the standard partitioning scheme everyone knows and loves (and is probably using underneath their OS). For more information:
https://en.wikipedia.org/wiki/Master_boot_record
Here's the example:
Also comes in with tests and doxygen.
cc @simonqhughes