Skip to content

Commit 0b87b1b

Browse files
authored
Merge pull request #562 from arduino/fix-nina-lzss-length
Bugfix: Use correct length of LZSS compressed file for decompression
2 parents 356a11a + 2e29c3c commit 0b87b1b

File tree

6 files changed

+3321
-3320
lines changed

6 files changed

+3321
-3320
lines changed

libraries/SNU/extras/NiNaBoot/NiNaBoot.ino

+2-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ int main() {
207207
/* Initialize the lzss module with the data which
208208
* it requires.
209209
*/
210-
lzss_init(&update_file, (uint32_t)SKETCH_START);
210+
uint32_t const LZSS_FILE_SIZE = update_file.size() - sizeof(ota_header.buf);
211+
lzss_init(&update_file, (uint32_t)SKETCH_START, LZSS_FILE_SIZE);
211212
/* During the process of decoding UPDATE.BIN.LZSS
212213
* is decompressed and stored as UPDATE.BIN.
213214
*/

libraries/SNU/extras/NiNaBoot/lzss.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ static uint32_t flash_addr = 0;
4848
PUBLIC FUNCTIONS
4949
**************************************************************************************/
5050

51-
void lzss_init(WiFiStorageFile * update_file_ptr, uint32_t const sketch_start)
51+
void lzss_init(WiFiStorageFile * update_file_ptr, uint32_t const sketch_start, uint32_t const lzss_file_size)
5252
{
5353
SKETCH_START = sketch_start;
5454
flash_addr = sketch_start;
5555
update_file = update_file_ptr;
56-
LZSS_FILE_SIZE = update_file->size();
56+
LZSS_FILE_SIZE = lzss_file_size;
5757
}
5858

5959
void lzss_flush()

libraries/SNU/extras/NiNaBoot/lzss.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
FUNCTION DEFINITION
1414
**************************************************************************************/
1515

16-
void lzss_init(WiFiStorageFile * update_file_ptr, uint32_t const sketch_start);
16+
void lzss_init(WiFiStorageFile * update_file_ptr, uint32_t const sketch_start, uint32_t const lzss_file_size);
1717
void lzss_decode();
1818
void lzss_flush();
1919

0 commit comments

Comments
 (0)