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
Recompression output (input -> decompress -> compress -> output) is different from input #3
Comments
Hi, @protyposis , i do the same test on v3.2-cn firmware.
|
@skytina thank you for your feedback! I also tested Including the report in #2 (comment), we have 3 confirmations that repacking of v3.2 works correctly. Please be advised that repacking of lower versions still does not work correctly. I have a report that flashing a repacked 3.1 firmware with the differences explained above resulted in a broken camera (does not turn on). |
There seems to be an issue somewhere in the decompression and/or compression algorithms, because unmodified recompressed firmware data is different from the original firmware data. As long as this issue isn't solved, I do not recommend anyone to try and flash a recompressed/repacked firmware, it will most likely fail and possibly damage the camera.
This can be tested using the
npm run test <firmwarefile>
command, which will unpack and decompress the firmware sections, recompress them, and compare differences. It will output differences like this:Some information about how the compression algorithm works can be found here and in a reverse engineering SE question. The first line tells that the original firmware file has a lookup encoded with
3
bytes length at lookup buffer index137
, whereas the recompression selected lookup buffer index199
. Inspecting the lookup buffer shows that the 3 bytes can be found at both locations (actually it can be found in even more locations), but the recompression selects199
because it's nearest to the tail of the circular lookup buffer where the reverse lookup search begins.In most cases taking the nearest lookup index from the tail of the lookup buffer yields the correct lookup index, it's just in a few rare cases where it is wrong. This probably means that
199
but only at137
which the compression algorithm would then select correctlyThe text was updated successfully, but these errors were encountered: