mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-08 12:49:24 +00:00
libdfu: Allow choosing a different alt-setting when downloading
This commit is contained in:
parent
3a40e94567
commit
b4eaec3654
@ -956,7 +956,8 @@ dfu_tool_download_target (DfuToolPrivate *priv, gchar **values, GError **error)
|
|||||||
g_set_error_literal (error,
|
g_set_error_literal (error,
|
||||||
DFU_ERROR,
|
DFU_ERROR,
|
||||||
DFU_ERROR_INTERNAL,
|
DFU_ERROR_INTERNAL,
|
||||||
"Invalid arguments, expected FILENAME");
|
"Invalid arguments, expected "
|
||||||
|
"FILENAME [ALT-SETTING]");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1000,16 +1001,36 @@ dfu_tool_download_target (DfuToolPrivate *priv, gchar **values, GError **error)
|
|||||||
flags |= DFU_TARGET_TRANSFER_FLAG_BOOT_RUNTIME;
|
flags |= DFU_TARGET_TRANSFER_FLAG_BOOT_RUNTIME;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get correct firmware object */
|
/* allow overriding the firmware alt-setting */
|
||||||
image = dfu_firmware_get_image (firmware, priv->alt_setting);
|
if (g_strv_length (values) > 1) {
|
||||||
|
guint64 tmp = g_ascii_strtoull (values[1], NULL, 10);
|
||||||
|
if (tmp > 0xff) {
|
||||||
|
g_set_error (error,
|
||||||
|
DFU_ERROR,
|
||||||
|
DFU_ERROR_INTERNAL,
|
||||||
|
"Failed to parse alt-setting '%s'", values[1]);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
image = dfu_firmware_get_image (firmware, tmp);
|
||||||
if (image == NULL) {
|
if (image == NULL) {
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
DFU_ERROR,
|
DFU_ERROR,
|
||||||
DFU_ERROR_INVALID_FILE,
|
DFU_ERROR_INVALID_FILE,
|
||||||
"could not locate image in firmware for %02x",
|
"could not locate image in firmware for %02x",
|
||||||
priv->alt_setting);
|
(guint) tmp);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
g_print ("WARNING: Using default firmware image\n");
|
||||||
|
image = dfu_firmware_get_image_default (firmware);
|
||||||
|
if (image == NULL) {
|
||||||
|
g_set_error_literal (error,
|
||||||
|
DFU_ERROR,
|
||||||
|
DFU_ERROR_INVALID_FILE,
|
||||||
|
"no default image");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* transfer */
|
/* transfer */
|
||||||
helper.last_state = DFU_STATE_DFU_ERROR;
|
helper.last_state = DFU_STATE_DFU_ERROR;
|
||||||
|
Loading…
Reference in New Issue
Block a user