-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Add package tiny-vcdiff #17797
Add package tiny-vcdiff #17797
Conversation
I'm realizing that there's no test application for this new package. So it won't be built by the CI. I would be nice to add a simple one (you can use |
Yep, I'm currently working on that. The reason why this is a draft PR. |
You can probably squash when you rebase |
3ca9440
to
b7997a9
Compare
b7997a9
to
9ba4d2f
Compare
I think everything should be in place, now. I'm ready to be |
9ba4d2f
to
28e9e12
Compare
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.
Nice, works like a charm - some more nits:
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.
Seems CI is mostly happy, but this will need some blacklisting
Thank you for your reviews, @benpicco @fjmolinas! Is it okay if I squash all fixups before addressing your suggestions? |
Rebased on latest master. |
* vcdiff_vfs_t target = VCDIFF_VFS_INIT(fd_target); | ||
* vcdiff_set_target_driver(&vcdiff, &vcdiff_vfs_driver, &target); | ||
* | ||
* rc = vcdiff_apply_delta(&vcdiff, data, data_len); |
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 there a requirement on how this needs to be fragmented?
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.
Nope, It should work byte-wise. Like shown here.
If it doesn't, it's a bug ;-)
Has anyone an idea how to handle this CI error? |
Can you make the fall-throughs explicit with |
Well, I could. But that produces really noisy code :-/ |
/* mtd_read_page will take care of calculation the right page | ||
* it's safe to call mtd_read_page_raw: the erase driver already | ||
* prepared the sector for writing */ | ||
int rc = mtd_write_page_raw(mtd->dev, src, 0, offset, len); |
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.
Are you sure this is right? The input offset
is offset in bytes, while the offset parameter to mtd_write_page_raw
is the offset in the page being written to, shouldn't it be something like:
int rc = mtd_write_page_raw(mtd->dev, src, 0, offset, len); | |
uint32_t page = offset / mtd->dev->page_size; | |
uint32_t page_offset = (offset % mtd->dev->page_size); | |
int rc = mtd_write_page_raw(mtd->dev, src, page, page_offset, len); |
(untested)
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.
Same question goes for the read function actually.
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.
It should work to start at page 0
and let the MTD implemenation figure out the right page.
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.
But that is only if there is write_page
, not the case for mtd_flashpage
for example.
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 sorry, my bad, I misunderstood the API I think.
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.
Well, but another problem could occur: un-aligned writes (i.e. addr % FLASHPAGE_WRITE_BLOCK_ALIGNMENT
and size % FLASHPAGE_WRITE_BLOCK_SIZE
are possible troublemaker ...). Or am I wrong?
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.
yea but you don't get those through MTD - #17683 tries to fix that
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 added write alignment for the MTD backend: b705803
I think it would be nice to have working MTD ;-) Thus, I'm waiting for #17683. |
I added write alignment for this package. Once #17683 is merged, I'll add a check if the configured write alignment and MTD write alignment are compatible. |
I sneaked that in with some pre-processor magic. The package can now be compiled without |
Finally a happy Murdock :) |
1a612fb
to
0f1a1dc
Compare
Rebased on latest master. Still looking fine. @fjmolinas You faced problems with alignment on MTD flashpage, right? Could you test this PR again? I've introduced aligned writes for MTD backends. |
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.
With a rebase you can now get rid of CONFIG_TINYVCDIFF_MTD_WRITE_SIZE
size_t alignment_offset; | ||
size_t copy_len; | ||
|
||
alignment_offset = mtd->offset % CONFIG_TINYVCDIFF_MTD_WRITE_SIZE; |
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.
alignment_offset = mtd->offset % CONFIG_TINYVCDIFF_MTD_WRITE_SIZE; | |
alignment_offset = mtd->offset % mtd->write_size; |
should now be possible.
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.
vcdiff_mtd_t
requires write_size
to be known at compile time to adjust buffer sizes. But at least an assert()
would be nice to have.
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.
Could we use mtd->work_area
instead?
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 would add the dependency mtd_write_page
. Currently, I'm not using any of the write page features. Adding this module would add unnecessary code just to have the (mtd_write_page
-internal) buffer at hand. It feels a little bit hacky to me.
I'd say having assert()
s in place that make sure the buffer is aligned and large enough would be a good thing to have in place.
The default of 4 bytes seems to be a size that fits all mtd
devices available in RIOT (IIRC) and isn't wasteful in my opinion.
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.
For mtd_flashpage
it can be larger than 4, same for SD cards (but those are usually used with a filesystem)
Well, I'm happy to merge this as is and the do a follow-up PR. |
It seems like |
Oh thank you for your review! |
Contribution description
This is a WIP PR that brings tiny-vcdiff into RIOT.
I mentioned this library during my talk on the last RIOT Summit
Currently this PR supports
mtd
as backend. But avfs
will be added, too. I guess those are the obvious interfaces for such a package.Testing procedure
I will add a test later, that will make use of all implemented backends.
Issues/PRs references