mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-16 17:42:02 +00:00
parent
ad1e0e81b2
commit
db763bf05d
@ -403,6 +403,8 @@ static void detect_installation(vendor_header *current_vhdr, image_header *curre
|
||||
*is_upgrade = sectrue;
|
||||
}
|
||||
|
||||
static int firmware_upload_chunk_retry = FIRMWARE_UPLOAD_CHUNK_RETRY_COUNT;
|
||||
|
||||
int process_msg_FirmwareUpload(uint8_t iface_num, uint32_t msg_size, uint8_t *buf)
|
||||
{
|
||||
MSG_RECV_INIT(FirmwareUpload);
|
||||
@ -496,6 +498,16 @@ int process_msg_FirmwareUpload(uint8_t iface_num, uint32_t msg_size, uint8_t *bu
|
||||
}
|
||||
|
||||
if (sectrue != check_single_hash(hdr.hashes + firmware_block * 32, chunk_buffer + firstskip, chunk_size - firstskip)) {
|
||||
|
||||
if (firmware_upload_chunk_retry > 0) {
|
||||
--firmware_upload_chunk_retry;
|
||||
MSG_SEND_INIT(FirmwareRequest);
|
||||
MSG_SEND_ASSIGN_VALUE(offset, firmware_block * IMAGE_CHUNK_SIZE);
|
||||
MSG_SEND_ASSIGN_VALUE(length, chunk_requested);
|
||||
MSG_SEND(FirmwareRequest);
|
||||
return (int)firmware_remaining;
|
||||
}
|
||||
|
||||
MSG_SEND_INIT(Failure);
|
||||
MSG_SEND_ASSIGN_VALUE(code, FailureType_Failure_ProcessError);
|
||||
MSG_SEND_ASSIGN_STRING(message, "Invalid chunk hash");
|
||||
@ -514,6 +526,7 @@ int process_msg_FirmwareUpload(uint8_t iface_num, uint32_t msg_size, uint8_t *bu
|
||||
|
||||
firmware_remaining -= chunk_requested;
|
||||
firmware_block++;
|
||||
firmware_upload_chunk_retry = FIRMWARE_UPLOAD_CHUNK_RETRY_COUNT;
|
||||
|
||||
if (firmware_remaining > 0) {
|
||||
chunk_requested = (firmware_remaining > IMAGE_CHUNK_SIZE) ? IMAGE_CHUNK_SIZE : firmware_remaining;
|
||||
|
@ -27,6 +27,7 @@
|
||||
#define USB_TIMEOUT 500
|
||||
#define USB_PACKET_SIZE 64
|
||||
|
||||
#define FIRMWARE_UPLOAD_CHUNK_RETRY_COUNT 2
|
||||
#define FIRMWARE_SECTORS_COUNT 13
|
||||
extern const uint8_t firmware_sectors[FIRMWARE_SECTORS_COUNT];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user