-
Notifications
You must be signed in to change notification settings - Fork 9
cli: added support to sparse images flashing #21
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Giuseppe Fabiano <gfabiano40@gmail.com>
|
|
||
| let mut fill_vec = Vec::<u8>::with_capacity(out_size); | ||
| for _ in 0..out_size / 4 { | ||
| fill_vec.extend_from_slice(&fill_value[..]); |
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.
We do something roughly equivalent inside program_storage already, so all this can simplify this branch to passing a &mut &[0u8][..] as an argument
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's not the same because the fill value is a 4 bytes that you get from the sparse file and you repeat for N times. If you set &mut &[0u8][..] you will get zero repeated for N times that not respect the sparse format.
Giving a let mut fill_value = [1, 2, 3, 4]; read from files and an let out_size = 25 ( N=5 ) you shall get something like that
[1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]
It can sure be improved but I decided to keep it simple and not modify also the firehose_program_storage function.
If you have some hint on how to handle it better I can sure improve it.
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.
How about:
fill_vec.iter().repeat(fill_value).take(out_size/4);
since the value will likely be the same, we can perhaps cache fill_value and check if it differs on each found Fill chunk, and only re-assign the vector if we need to, taking away some overhead
|
I think that I must improve the implementation because typically raw chunks are contiguos so calling for every chunk |
| } | ||
| ChunkType::Crc32 => { | ||
| // Not supported, on qcom tools is ignored, seek if present | ||
| buf.seek_relative(4)?; |
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.
Out of curiosity, is the CRC valid on your images?
I think the current approach is ok - IIUC sparse chunks can be as big as you want (which |
A first implementation to sparse images flashing. I tested it with some images and it works correctly on my qcom bench.