mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-11 07:47:33 +00:00
Export the raw device version to the client --verbose output
It turns out this is really useful for debugging UEFI firmware updates which typically use the 0x-prefixed version numbers without a version format.
This commit is contained in:
parent
297d1598ef
commit
10079e6b8c
@ -49,6 +49,7 @@ typedef struct {
|
||||
gchar *version_lowest;
|
||||
gchar *version_bootloader;
|
||||
FwupdVersionFormat version_format;
|
||||
guint32 version_raw;
|
||||
GPtrArray *checksums;
|
||||
guint32 flashes_left;
|
||||
guint32 install_duration;
|
||||
@ -1113,6 +1114,8 @@ fwupd_device_incorporate (FwupdDevice *self, FwupdDevice *donor)
|
||||
fwupd_device_set_version_bootloader (self, priv_donor->version_bootloader);
|
||||
if (priv->version_format == FWUPD_VERSION_FORMAT_UNKNOWN)
|
||||
fwupd_device_set_version_format (self, priv_donor->version_format);
|
||||
if (priv->version_raw == 0)
|
||||
fwupd_device_set_version_raw (self, priv_donor->version_raw);
|
||||
for (guint i = 0; i < priv_donor->guids->len; i++) {
|
||||
const gchar *tmp = g_ptr_array_index (priv_donor->guids, i);
|
||||
fwupd_device_add_guid (self, tmp);
|
||||
@ -1257,6 +1260,11 @@ fwupd_device_to_variant_full (FwupdDevice *device, FwupdDeviceFlags flags)
|
||||
FWUPD_RESULT_KEY_VERSION_BOOTLOADER,
|
||||
g_variant_new_string (priv->version_bootloader));
|
||||
}
|
||||
if (priv->version_raw > 0) {
|
||||
g_variant_builder_add (&builder, "{sv}",
|
||||
FWUPD_RESULT_KEY_VERSION_RAW,
|
||||
g_variant_new_uint32 (priv->version_raw));
|
||||
}
|
||||
if (priv->flashes_left > 0) {
|
||||
g_variant_builder_add (&builder, "{sv}",
|
||||
FWUPD_RESULT_KEY_FLASHES_LEFT,
|
||||
@ -1464,6 +1472,10 @@ fwupd_device_from_key_value (FwupdDevice *device, const gchar *key, GVariant *va
|
||||
fwupd_device_set_version_format (device, g_variant_get_uint32 (value));
|
||||
return;
|
||||
}
|
||||
if (g_strcmp0 (key, FWUPD_RESULT_KEY_VERSION_RAW) == 0) {
|
||||
fwupd_device_set_version_raw (device, g_variant_get_uint32 (value));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1593,6 +1605,41 @@ fwupd_device_set_version_format (FwupdDevice *device, FwupdVersionFormat version
|
||||
priv->version_format = version_format;
|
||||
}
|
||||
|
||||
/**
|
||||
* fwupd_device_get_version_raw:
|
||||
* @device: A #FwupdDevice
|
||||
*
|
||||
* Gets the raw version number from the hardware before converted to a string.
|
||||
*
|
||||
* Returns: the hardware version, or 0 if unset
|
||||
*
|
||||
* Since: 1.3.6
|
||||
**/
|
||||
guint32
|
||||
fwupd_device_get_version_raw (FwupdDevice *device)
|
||||
{
|
||||
FwupdDevicePrivate *priv = GET_PRIVATE (device);
|
||||
g_return_val_if_fail (FWUPD_IS_DEVICE (device), 0);
|
||||
return priv->version_raw;
|
||||
}
|
||||
|
||||
/**
|
||||
* fwupd_device_set_version_raw:
|
||||
* @device: A #FwupdDevice
|
||||
* @version_raw: the raw hardware version
|
||||
*
|
||||
* Sets the raw version number from the hardware before converted to a string.
|
||||
*
|
||||
* Since: 1.3.6
|
||||
**/
|
||||
void
|
||||
fwupd_device_set_version_raw (FwupdDevice *device, guint32 version_raw)
|
||||
{
|
||||
FwupdDevicePrivate *priv = GET_PRIVATE (device);
|
||||
g_return_if_fail (FWUPD_IS_DEVICE (device));
|
||||
priv->version_raw = version_raw;
|
||||
}
|
||||
|
||||
/**
|
||||
* fwupd_device_get_update_message:
|
||||
* @device: A #FwupdDevice
|
||||
@ -1810,6 +1857,8 @@ fwupd_device_to_json (FwupdDevice *device, JsonBuilder *builder)
|
||||
fwupd_device_json_add_string (builder, FWUPD_RESULT_KEY_VERSION_FORMAT,
|
||||
fwupd_version_format_to_string (priv->version_format));
|
||||
fwupd_device_json_add_int (builder, FWUPD_RESULT_KEY_FLASHES_LEFT, priv->flashes_left);
|
||||
if (priv->version_raw > 0)
|
||||
fwupd_device_json_add_int (builder, FWUPD_RESULT_KEY_VERSION_RAW, priv->version_raw);
|
||||
if (priv->icons->len > 0) {
|
||||
json_builder_set_member_name (builder, "Icons");
|
||||
json_builder_begin_array (builder);
|
||||
@ -1909,6 +1958,10 @@ fwupd_device_to_string (FwupdDevice *device)
|
||||
fwupd_version_format_to_string (priv->version_format));
|
||||
if (priv->flashes_left < 2)
|
||||
fwupd_pad_kv_int (str, FWUPD_RESULT_KEY_FLASHES_LEFT, priv->flashes_left);
|
||||
if (priv->version_raw > 0) {
|
||||
g_autofree gchar *tmp = g_strdup_printf ("0x%08x", (guint) priv->version_raw);
|
||||
fwupd_pad_kv_str (str, FWUPD_RESULT_KEY_VERSION_RAW, tmp);
|
||||
}
|
||||
if (priv->icons->len > 0) {
|
||||
g_autoptr(GString) tmp = g_string_new (NULL);
|
||||
for (guint i = 0; i < priv->icons->len; i++) {
|
||||
|
@ -62,6 +62,9 @@ void fwupd_device_set_version_lowest (FwupdDevice *device,
|
||||
const gchar *fwupd_device_get_version_bootloader (FwupdDevice *device);
|
||||
void fwupd_device_set_version_bootloader (FwupdDevice *device,
|
||||
const gchar *version_bootloader);
|
||||
guint32 fwupd_device_get_version_raw (FwupdDevice *device);
|
||||
void fwupd_device_set_version_raw (FwupdDevice *device,
|
||||
guint32 version_raw);
|
||||
FwupdVersionFormat fwupd_device_get_version_format (FwupdDevice *device);
|
||||
void fwupd_device_set_version_format (FwupdDevice *device,
|
||||
FwupdVersionFormat version_format);
|
||||
|
@ -51,6 +51,7 @@ G_BEGIN_DECLS
|
||||
#define FWUPD_RESULT_KEY_VENDOR "Vendor" /* s */
|
||||
#define FWUPD_RESULT_KEY_VERSION_BOOTLOADER "VersionBootloader" /* s */
|
||||
#define FWUPD_RESULT_KEY_VERSION_FORMAT "VersionFormat" /* u */
|
||||
#define FWUPD_RESULT_KEY_VERSION_RAW "VersionRaw" /* u */
|
||||
#define FWUPD_RESULT_KEY_VERSION_LOWEST "VersionLowest" /* s */
|
||||
#define FWUPD_RESULT_KEY_VERSION "Version" /* s */
|
||||
|
||||
|
@ -409,6 +409,8 @@ LIBFWUPD_1.3.4 {
|
||||
LIBFWUPD_1.3.6 {
|
||||
global:
|
||||
fwupd_device_get_protocol;
|
||||
fwupd_device_get_version_raw;
|
||||
fwupd_device_set_protocol;
|
||||
fwupd_device_set_version_raw;
|
||||
local: *;
|
||||
} LIBFWUPD_1.3.4;
|
||||
|
@ -109,6 +109,7 @@ FuDevice *fu_device_new (void);
|
||||
#define fu_device_set_version_lowest(d,v) fwupd_device_set_version_lowest(FWUPD_DEVICE(d),v)
|
||||
#define fu_device_set_version_bootloader(d,v) fwupd_device_set_version_bootloader(FWUPD_DEVICE(d),v)
|
||||
#define fu_device_set_version_format(d,v) fwupd_device_set_version_format(FWUPD_DEVICE(d),v)
|
||||
#define fu_device_set_version_raw(d,v) fwupd_device_set_version_raw(FWUPD_DEVICE(d),v)
|
||||
#define fu_device_set_flashes_left(d,v) fwupd_device_set_flashes_left(FWUPD_DEVICE(d),v)
|
||||
#define fu_device_set_install_duration(d,v) fwupd_device_set_install_duration(FWUPD_DEVICE(d),v)
|
||||
#define fu_device_get_checksums(d) fwupd_device_get_checksums(FWUPD_DEVICE(d))
|
||||
@ -131,6 +132,7 @@ FuDevice *fu_device_new (void);
|
||||
#define fu_device_get_version_lowest(d) fwupd_device_get_version_lowest(FWUPD_DEVICE(d))
|
||||
#define fu_device_get_version_bootloader(d) fwupd_device_get_version_bootloader(FWUPD_DEVICE(d))
|
||||
#define fu_device_get_version_format(d) fwupd_device_get_version_format(FWUPD_DEVICE(d))
|
||||
#define fu_device_get_version_raw(d) fwupd_device_get_version_raw(FWUPD_DEVICE(d))
|
||||
#define fu_device_get_vendor_id(d) fwupd_device_get_vendor_id(FWUPD_DEVICE(d))
|
||||
#define fu_device_get_flashes_left(d) fwupd_device_get_flashes_left(FWUPD_DEVICE(d))
|
||||
#define fu_device_get_install_duration(d) fwupd_device_get_install_duration(FWUPD_DEVICE(d))
|
||||
|
@ -228,6 +228,7 @@ fu_ebitdo_device_set_version (FuEbitdoDevice *self, guint32 version)
|
||||
g_autofree gchar *tmp = NULL;
|
||||
tmp = g_strdup_printf ("%u.%02u", version / 100, version % 100);
|
||||
fu_device_set_version (FU_DEVICE (self), tmp, FWUPD_VERSION_FORMAT_PAIR);
|
||||
fu_device_set_version_raw (FU_DEVICE (self), version);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -682,6 +682,7 @@ fu_uefi_device_probe (FuDevice *device, GError **error)
|
||||
version_format = fu_device_get_version_format (device);
|
||||
version = fu_common_version_from_uint32 (self->fw_version, version_format);
|
||||
fu_device_set_version (device, version, version_format);
|
||||
fu_device_set_version_raw (device, self->fw_version);
|
||||
if (self->fw_version_lowest != 0) {
|
||||
version_lowest = fu_common_version_from_uint32 (self->fw_version_lowest,
|
||||
version_format);
|
||||
|
@ -61,6 +61,7 @@ fu_vli_usbhub_pd_device_probe (FuDevice *device, GError **error)
|
||||
/* use header to populate device info */
|
||||
fwver_str = fu_common_version_from_uint32 (fwver, FWUPD_VERSION_FORMAT_QUAD);
|
||||
fu_device_set_version (device, fwver_str, FWUPD_VERSION_FORMAT_QUAD);
|
||||
fu_device_set_version_raw (device, fwver);
|
||||
instance_id1 = g_strdup_printf ("VLI_USBHUB_PD\\VID_%04X&PID_%04X",
|
||||
GUINT16_FROM_LE (self->hdr.vid),
|
||||
GUINT16_FROM_LE (self->hdr.pid));
|
||||
|
@ -42,6 +42,7 @@ fu_wacom_emr_device_setup (FuDevice *device, GError **error)
|
||||
fu_device_remove_flag (device, FWUPD_DEVICE_FLAG_IS_BOOTLOADER);
|
||||
version = fu_common_version_from_uint16 (fw_ver, FWUPD_VERSION_FORMAT_PAIR);
|
||||
fu_device_set_version (device, version, FWUPD_VERSION_FORMAT_PAIR);
|
||||
fu_device_set_version_raw (device, fw_ver);
|
||||
}
|
||||
|
||||
/* success */
|
||||
|
Loading…
Reference in New Issue
Block a user