mirror of
https://git.proxmox.com/git/fwupd
synced 2025-05-31 02:35:37 +00:00
dfu: Correctly erase STM32 devices when transfer size is less than sector size
This commit is contained in:
parent
f32e4c0666
commit
f6ee6043c5
@ -276,14 +276,15 @@ fu_dfu_target_stm_download_element (FuDfuTarget *target,
|
|||||||
|
|
||||||
/* for DfuSe devices we need to handle the erase and setting
|
/* for DfuSe devices we need to handle the erase and setting
|
||||||
* the sectory address manually */
|
* the sectory address manually */
|
||||||
offset_dev = fu_chunk_get_address (chk) + (i * transfer_size);
|
offset_dev = i * transfer_size;
|
||||||
sector = fu_dfu_target_get_sector_for_addr (target, offset_dev);
|
while (offset_dev < (i + 1) * transfer_size) {
|
||||||
|
sector = fu_dfu_target_get_sector_for_addr (target, fu_chunk_get_address (chk) + offset_dev);
|
||||||
if (sector == NULL) {
|
if (sector == NULL) {
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
FWUPD_ERROR,
|
FWUPD_ERROR,
|
||||||
FWUPD_ERROR_NOT_SUPPORTED,
|
FWUPD_ERROR_NOT_SUPPORTED,
|
||||||
"no memory sector at 0x%04x",
|
"no memory sector at 0x%04x",
|
||||||
(guint) offset_dev);
|
(guint) fu_chunk_get_address (chk) + offset_dev);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (!fu_dfu_sector_has_cap (sector, DFU_SECTOR_CAP_WRITEABLE)) {
|
if (!fu_dfu_sector_has_cap (sector, DFU_SECTOR_CAP_WRITEABLE)) {
|
||||||
@ -291,7 +292,7 @@ fu_dfu_target_stm_download_element (FuDfuTarget *target,
|
|||||||
FWUPD_ERROR,
|
FWUPD_ERROR,
|
||||||
FWUPD_ERROR_NOT_SUPPORTED,
|
FWUPD_ERROR_NOT_SUPPORTED,
|
||||||
"memory sector at 0x%04x is not writable",
|
"memory sector at 0x%04x is not writable",
|
||||||
(guint) offset_dev);
|
(guint) fu_chunk_get_address (chk) + offset_dev);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,6 +307,8 @@ fu_dfu_target_stm_download_element (FuDfuTarget *target,
|
|||||||
fu_dfu_sector_get_address (sector),
|
fu_dfu_sector_get_address (sector),
|
||||||
fu_dfu_sector_get_address (sector) + fu_dfu_sector_get_size (sector));
|
fu_dfu_sector_get_address (sector) + fu_dfu_sector_get_size (sector));
|
||||||
}
|
}
|
||||||
|
offset_dev += fu_dfu_sector_get_size (sector);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 2nd pass: actually erase sectors */
|
/* 2nd pass: actually erase sectors */
|
||||||
|
Loading…
Reference in New Issue
Block a user