mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-08 07:22:12 +00:00
libdfu: Display all the files shown with 'dfu-tool dump'
Also, show the file CRC in the debug output.
This commit is contained in:
parent
832c334548
commit
1936e4afb5
@ -54,6 +54,7 @@ typedef struct {
|
|||||||
guint16 vid;
|
guint16 vid;
|
||||||
guint16 pid;
|
guint16 pid;
|
||||||
guint16 release;
|
guint16 release;
|
||||||
|
guint32 crc;
|
||||||
DfuFirmwareFormat format;
|
DfuFirmwareFormat format;
|
||||||
} DfuFirmwarePrivate;
|
} DfuFirmwarePrivate;
|
||||||
|
|
||||||
@ -820,9 +821,10 @@ dfu_firmware_parse_data (DfuFirmware *firmware, GBytes *bytes,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* verify the checksum */
|
/* verify the checksum */
|
||||||
|
priv->crc = GUINT32_FROM_LE (ftr->crc);
|
||||||
if ((flags & DFU_FIRMWARE_PARSE_FLAG_NO_CRC_TEST) == 0) {
|
if ((flags & DFU_FIRMWARE_PARSE_FLAG_NO_CRC_TEST) == 0) {
|
||||||
crc_new = dfu_firmware_generate_crc32 (data, len - 4);
|
crc_new = dfu_firmware_generate_crc32 (data, len - 4);
|
||||||
if (GUINT32_FROM_LE (ftr->crc) != crc_new) {
|
if (priv->crc != crc_new) {
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
DFU_ERROR,
|
DFU_ERROR,
|
||||||
DFU_ERROR_INTERNAL,
|
DFU_ERROR_INTERNAL,
|
||||||
@ -1072,6 +1074,7 @@ dfu_firmware_to_string (DfuFirmware *firmware)
|
|||||||
g_string_append_printf (str, "vid: 0x%04x\n", priv->vid);
|
g_string_append_printf (str, "vid: 0x%04x\n", priv->vid);
|
||||||
g_string_append_printf (str, "pid: 0x%04x\n", priv->pid);
|
g_string_append_printf (str, "pid: 0x%04x\n", priv->pid);
|
||||||
g_string_append_printf (str, "release: 0x%04x\n", priv->release);
|
g_string_append_printf (str, "release: 0x%04x\n", priv->release);
|
||||||
|
g_string_append_printf (str, "crc: 0x%08x\n", priv->crc);
|
||||||
g_string_append_printf (str, "format: %s [0x%04x]\n",
|
g_string_append_printf (str, "format: %s [0x%04x]\n",
|
||||||
dfu_firmware_format_to_string (priv->format),
|
dfu_firmware_format_to_string (priv->format),
|
||||||
priv->format);
|
priv->format);
|
||||||
|
@ -1197,8 +1197,8 @@ dfu_tool_watch (DfuToolPrivate *priv, gchar **values, GError **error)
|
|||||||
static gboolean
|
static gboolean
|
||||||
dfu_tool_dump (DfuToolPrivate *priv, gchar **values, GError **error)
|
dfu_tool_dump (DfuToolPrivate *priv, gchar **values, GError **error)
|
||||||
{
|
{
|
||||||
g_autoptr(DfuFirmware) firmware = NULL;
|
DfuFirmwareParseFlags flags = DFU_FIRMWARE_PARSE_FLAG_NONE;
|
||||||
g_autoptr(GFile) file = NULL;
|
guint i;
|
||||||
|
|
||||||
/* check args */
|
/* check args */
|
||||||
if (g_strv_length (values) < 1) {
|
if (g_strv_length (values) < 1) {
|
||||||
@ -1209,16 +1209,31 @@ dfu_tool_dump (DfuToolPrivate *priv, gchar **values, GError **error)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* open file */
|
/* dump corrupt files */
|
||||||
firmware = dfu_firmware_new ();
|
if (priv->force) {
|
||||||
file = g_file_new_for_path (values[0]);
|
flags |= DFU_FIRMWARE_PARSE_FLAG_NO_CRC_TEST;
|
||||||
if (!dfu_firmware_parse_file (firmware, file,
|
flags |= DFU_FIRMWARE_PARSE_FLAG_NO_VERSION_TEST;
|
||||||
DFU_FIRMWARE_PARSE_FLAG_NONE,
|
}
|
||||||
priv->cancellable, error))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
/* dump to screen */
|
/* open files */
|
||||||
g_print ("%s\n", dfu_firmware_to_string (firmware));
|
for (i = 0; values[i] != NULL; i++) {
|
||||||
|
g_autoptr(DfuFirmware) firmware = NULL;
|
||||||
|
g_autoptr(GFile) file = NULL;
|
||||||
|
g_autoptr(GError) error_local = NULL;
|
||||||
|
|
||||||
|
/* dump to screen */
|
||||||
|
g_print ("Loading %s:\n", values[i]);
|
||||||
|
firmware = dfu_firmware_new ();
|
||||||
|
file = g_file_new_for_path (values[i]);
|
||||||
|
if (!dfu_firmware_parse_file (firmware, file, flags,
|
||||||
|
priv->cancellable,
|
||||||
|
&error_local)) {
|
||||||
|
g_print ("Failed to load firmware: %s\n",
|
||||||
|
error_local->message);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
g_print ("%s\n", dfu_firmware_to_string (firmware));
|
||||||
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user