Sample/tlvs/linux_tlvs.c imageBlock_post only marks the UPLOAD_IMAGE slot as complete when it receives the last block a second time.
|
if ((mapval & (1 << bit)) == 0) { |
|
DPRINTF("sample_firmwaremgmt: Image block %u already written\n", |
|
g_imageBlock.blocknum); |
|
// Check for transfer completion |
|
if(g_slothdr[UPLOAD_IMAGE].status == FWHDR_STATUS_COMPLETE) |
|
{ |
|
DPRINTF("sample_firmwaremgmt: Transfer completed, skipping redundant image block\n"); |
|
g_downloadbusy = false; |
|
return; |
|
} |
|
// Check slot header bitmap for download completion |
|
uint32_t blk_i = 0, blk_j = 0, shift = 31; |
|
uint32_t blk_whole_cnt; |
|
uint32_t last_mapval; |
|
|
|
blk_whole_cnt = g_slothdr[UPLOAD_IMAGE].blockcnt & ~0x1F; |
|
while ((blk_i < (CSMP_FWMGMT_BLKMAP_CNT - 1)) && |
|
(blk_j < blk_whole_cnt)) { |
|
if (g_slothdr[UPLOAD_IMAGE].nblkmap[blk_i] != 0) { |
|
DPRINTF("sample_firmwaremgmt: Image block transfer still not complete\n"); |
|
g_downloadbusy = false; |
|
return; |
|
} |
|
blk_i++; |
|
blk_j += 32; |
|
} |
|
last_mapval = g_slothdr[UPLOAD_IMAGE].nblkmap[blk_i]; |
|
while (blk_j < g_slothdr[UPLOAD_IMAGE].blockcnt) { |
|
if (last_mapval & (1 << shift)) { |
|
DPRINTF("sample_firmwaremgmt: Last image block transfer still not complete\n"); |
|
g_downloadbusy = false; |
|
return; |
|
} |
|
blk_j++; |
|
shift--; |
|
} |
|
|
|
// Set slot status as complete else bad image |
|
DPRINTF("sample_firmwaremgmt: Image block transfer complete, filehash matched!\n"); |
|
g_slothdr[UPLOAD_IMAGE].status = FWHDR_STATUS_COMPLETE; |
Sample/tlvs/linux_tlvs.c imageBlock_post only marks the UPLOAD_IMAGE slot as complete when it receives the last block a second time.
csmp-agent-lib/sample/tlvs/linux_tlvs.c
Lines 801 to 840 in 7b3213e