1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-04-12 05:17:09 +00:00

fix(core/bootloader): correctly handle images smaller than one chunk

This commit is contained in:
matejcik 2023-04-07 13:27:57 +02:00 committed by matejcik
parent 056ac9d70a
commit dd4d020a76
2 changed files with 5 additions and 1 deletions

View File

@ -0,0 +1 @@
Fix installation of images smaller than 128kB.

View File

@ -597,7 +597,10 @@ int process_msg_FirmwareUpload(uint8_t iface_num, uint32_t msg_size,
// request the rest of the first chunk
MSG_SEND_INIT(FirmwareRequest);
chunk_requested = IMAGE_CHUNK_SIZE - read_offset;
uint32_t chunk_limit = (firmware_remaining > IMAGE_CHUNK_SIZE)
? IMAGE_CHUNK_SIZE
: firmware_remaining;
chunk_requested = chunk_limit - read_offset;
MSG_SEND_ASSIGN_REQUIRED_VALUE(offset, read_offset);
MSG_SEND_ASSIGN_REQUIRED_VALUE(length, chunk_requested);
MSG_SEND(FirmwareRequest);