mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-08 05:17:31 +00:00
trivial: Export the DFU version constants into libfwupdplugin
This commit is contained in:
parent
be8634d2cb
commit
2dd6462c0c
@ -8,26 +8,6 @@
|
|||||||
|
|
||||||
#include "fu-dfu-firmware.h"
|
#include "fu-dfu-firmware.h"
|
||||||
|
|
||||||
/**
|
|
||||||
* DfuVersion:
|
|
||||||
* @DFU_VERSION_UNKNOWN: Format unknown
|
|
||||||
* @DFU_VERSION_DFU_1_0: DFU 1.0
|
|
||||||
* @DFU_VERSION_DFU_1_1: DFU 1.1
|
|
||||||
* @DFU_VERSION_DFUSE: DfuSe
|
|
||||||
* @DFU_VERSION_ATMEL_AVR: Atmel AVR
|
|
||||||
*
|
|
||||||
* The known versions of the DFU standard in BCD format.
|
|
||||||
**/
|
|
||||||
typedef enum {
|
|
||||||
DFU_VERSION_UNKNOWN = 0,
|
|
||||||
DFU_VERSION_DFU_1_0 = 0x0100,
|
|
||||||
DFU_VERSION_DFU_1_1 = 0x0110,
|
|
||||||
DFU_VERSION_DFUSE = 0x011a, /* defined by ST */
|
|
||||||
DFU_VERSION_ATMEL_AVR = 0xff01, /* made up */
|
|
||||||
/*< private >*/
|
|
||||||
DFU_VERSION_LAST
|
|
||||||
} DfuVersion;
|
|
||||||
|
|
||||||
guint8 fu_dfu_firmware_get_footer_len (FuDfuFirmware *self);
|
guint8 fu_dfu_firmware_get_footer_len (FuDfuFirmware *self);
|
||||||
GBytes *fu_dfu_firmware_append_footer (FuDfuFirmware *self,
|
GBytes *fu_dfu_firmware_append_footer (FuDfuFirmware *self,
|
||||||
GBytes *contents,
|
GBytes *contents,
|
||||||
|
@ -379,7 +379,7 @@ fu_dfu_firmware_init (FuDfuFirmware *self)
|
|||||||
priv->vid = 0xffff;
|
priv->vid = 0xffff;
|
||||||
priv->pid = 0xffff;
|
priv->pid = 0xffff;
|
||||||
priv->release = 0xffff;
|
priv->release = 0xffff;
|
||||||
priv->dfu_version = DFU_VERSION_DFU_1_0;
|
priv->dfu_version = FU_DFU_FIRMARE_VERSION_DFU_1_0;
|
||||||
fu_firmware_add_flag (FU_FIRMWARE (self), FU_FIRMWARE_FLAG_HAS_CHECKSUM);
|
fu_firmware_add_flag (FU_FIRMWARE (self), FU_FIRMWARE_FLAG_HAS_CHECKSUM);
|
||||||
fu_firmware_add_flag (FU_FIRMWARE (self), FU_FIRMWARE_FLAG_HAS_VID_PID);
|
fu_firmware_add_flag (FU_FIRMWARE (self), FU_FIRMWARE_FLAG_HAS_VID_PID);
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,51 @@ struct _FuDfuFirmwareClass
|
|||||||
FuFirmwareClass parent_class;
|
FuFirmwareClass parent_class;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FU_DFU_FIRMARE_VERSION_UNKNOWN:
|
||||||
|
*
|
||||||
|
* Unknown version of the DFU standard in BCD format.
|
||||||
|
*
|
||||||
|
* Since: 1.6.1
|
||||||
|
**/
|
||||||
|
#define FU_DFU_FIRMARE_VERSION_UNKNOWN (0u)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FU_DFU_FIRMARE_VERSION_DFU_1_0:
|
||||||
|
*
|
||||||
|
* The 1.0 version of the DFU standard in BCD format.
|
||||||
|
*
|
||||||
|
* Since: 1.6.1
|
||||||
|
**/
|
||||||
|
#define FU_DFU_FIRMARE_VERSION_DFU_1_0 (0x0100)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FU_DFU_FIRMARE_VERSION_DFU_1_1:
|
||||||
|
*
|
||||||
|
* The 1.1 version of the DFU standard in BCD format.
|
||||||
|
*
|
||||||
|
* Since: 1.6.1
|
||||||
|
**/
|
||||||
|
#define FU_DFU_FIRMARE_VERSION_DFU_1_1 (0x0110)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FU_DFU_FIRMARE_VERSION_DFUSE:
|
||||||
|
*
|
||||||
|
* The DfuSe version of the DFU standard in BCD format, defined by ST.
|
||||||
|
*
|
||||||
|
* Since: 1.6.1
|
||||||
|
**/
|
||||||
|
#define FU_DFU_FIRMARE_VERSION_DFUSE (0x011a)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FU_DFU_FIRMARE_VERSION_ATMEL_AVR:
|
||||||
|
*
|
||||||
|
* The Atmel AVR version of the DFU standard in BCD format.
|
||||||
|
*
|
||||||
|
* Since: 1.6.1
|
||||||
|
**/
|
||||||
|
#define FU_DFU_FIRMARE_VERSION_ATMEL_AVR (0xff01)
|
||||||
|
|
||||||
FuFirmware *fu_dfu_firmware_new (void);
|
FuFirmware *fu_dfu_firmware_new (void);
|
||||||
guint16 fu_dfu_firmware_get_vid (FuDfuFirmware *self);
|
guint16 fu_dfu_firmware_get_vid (FuDfuFirmware *self);
|
||||||
guint16 fu_dfu_firmware_get_pid (FuDfuFirmware *self);
|
guint16 fu_dfu_firmware_get_pid (FuDfuFirmware *self);
|
||||||
|
@ -330,7 +330,7 @@ fu_dfuse_firmware_write (FuFirmware *firmware, GError **error)
|
|||||||
static void
|
static void
|
||||||
fu_dfuse_firmware_init (FuDfuseFirmware *self)
|
fu_dfuse_firmware_init (FuDfuseFirmware *self)
|
||||||
{
|
{
|
||||||
fu_dfu_firmware_set_version (FU_DFU_FIRMWARE (self), DFU_VERSION_DFUSE);
|
fu_dfu_firmware_set_version (FU_DFU_FIRMWARE (self), FU_DFU_FIRMARE_VERSION_DFUSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -78,8 +78,6 @@
|
|||||||
#include "fu-dfu-target-private.h"
|
#include "fu-dfu-target-private.h"
|
||||||
#include "fu-dfu-target-stm.h"
|
#include "fu-dfu-target-stm.h"
|
||||||
|
|
||||||
#include "fu-dfu-firmware-private.h"
|
|
||||||
|
|
||||||
static void fu_dfu_device_finalize (GObject *object);
|
static void fu_dfu_device_finalize (GObject *object);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -159,7 +157,7 @@ fu_dfu_device_get_transfer_size (FuDfuDevice *self)
|
|||||||
*
|
*
|
||||||
* Gets the DFU specification version supported by the device.
|
* Gets the DFU specification version supported by the device.
|
||||||
*
|
*
|
||||||
* Returns: integer, or 0 for unknown, e.g. %DFU_VERSION_DFU_1_1
|
* Returns: integer, or 0 for unknown, e.g. %FU_DFU_FIRMARE_VERSION_DFU_1_1
|
||||||
**/
|
**/
|
||||||
guint16
|
guint16
|
||||||
fu_dfu_device_get_version (FuDfuDevice *self)
|
fu_dfu_device_get_version (FuDfuDevice *self)
|
||||||
@ -228,7 +226,7 @@ fu_dfu_device_parse_iface_data (FuDfuDevice *self, GBytes *iface_data, GError **
|
|||||||
} else if (sz == sizeof(DfuFuncDescriptor) - 2) {
|
} else if (sz == sizeof(DfuFuncDescriptor) - 2) {
|
||||||
g_warning ("truncated DFU interface data, no bcdDFUVersion");
|
g_warning ("truncated DFU interface data, no bcdDFUVersion");
|
||||||
memcpy (&desc, buf, sz);
|
memcpy (&desc, buf, sz);
|
||||||
desc.bcdDFUVersion = DFU_VERSION_DFU_1_1;
|
desc.bcdDFUVersion = FU_DFU_FIRMARE_VERSION_DFU_1_1;
|
||||||
} else {
|
} else {
|
||||||
g_autoptr(GString) bufstr = g_string_new (NULL);
|
g_autoptr(GString) bufstr = g_string_new (NULL);
|
||||||
for (gsize i = 0; i < sz; i++)
|
for (gsize i = 0; i < sz; i++)
|
||||||
@ -249,7 +247,7 @@ fu_dfu_device_parse_iface_data (FuDfuDevice *self, GBytes *iface_data, GError **
|
|||||||
priv->version = GUINT16_FROM_LE (desc.bcdDFUVersion);
|
priv->version = GUINT16_FROM_LE (desc.bcdDFUVersion);
|
||||||
|
|
||||||
/* ST-specific */
|
/* ST-specific */
|
||||||
if (priv->version == DFU_VERSION_DFUSE &&
|
if (priv->version == FU_DFU_FIRMARE_VERSION_DFUSE &&
|
||||||
desc.bmAttributes & FU_DFU_DEVICE_ATTR_CAN_ACCELERATE)
|
desc.bmAttributes & FU_DFU_DEVICE_ATTR_CAN_ACCELERATE)
|
||||||
priv->transfer_size = 0x1000;
|
priv->transfer_size = 0x1000;
|
||||||
|
|
||||||
@ -327,24 +325,24 @@ fu_dfu_device_add_targets (FuDfuDevice *self, GError **error)
|
|||||||
/* fix up the version */
|
/* fix up the version */
|
||||||
if (priv->force_version > 0)
|
if (priv->force_version > 0)
|
||||||
priv->version = priv->force_version;
|
priv->version = priv->force_version;
|
||||||
if (priv->version == DFU_VERSION_DFU_1_0 ||
|
if (priv->version == FU_DFU_FIRMARE_VERSION_DFU_1_0 ||
|
||||||
priv->version == DFU_VERSION_DFU_1_1) {
|
priv->version == FU_DFU_FIRMARE_VERSION_DFU_1_1) {
|
||||||
g_debug ("DFU v1.1");
|
g_debug ("DFU v1.1");
|
||||||
} else if (priv->version == DFU_VERSION_ATMEL_AVR) {
|
} else if (priv->version == FU_DFU_FIRMARE_VERSION_ATMEL_AVR) {
|
||||||
g_debug ("AVR-DFU support");
|
g_debug ("AVR-DFU support");
|
||||||
priv->version = DFU_VERSION_ATMEL_AVR;
|
priv->version = FU_DFU_FIRMARE_VERSION_ATMEL_AVR;
|
||||||
} else if (priv->version == DFU_VERSION_DFUSE) {
|
} else if (priv->version == FU_DFU_FIRMARE_VERSION_DFUSE) {
|
||||||
g_debug ("STM-DFU support");
|
g_debug ("STM-DFU support");
|
||||||
} else if (priv->version == 0x0101) {
|
} else if (priv->version == 0x0101) {
|
||||||
g_debug ("DFU v1.1 assumed");
|
g_debug ("DFU v1.1 assumed");
|
||||||
priv->version = DFU_VERSION_DFU_1_1;
|
priv->version = FU_DFU_FIRMARE_VERSION_DFU_1_1;
|
||||||
} else {
|
} else {
|
||||||
g_warning ("DFU version 0x%04x invalid, v1.1 assumed", priv->version);
|
g_warning ("DFU version 0x%04x invalid, v1.1 assumed", priv->version);
|
||||||
priv->version = DFU_VERSION_DFU_1_1;
|
priv->version = FU_DFU_FIRMARE_VERSION_DFU_1_1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set expected protocol */
|
/* set expected protocol */
|
||||||
if (priv->version == DFU_VERSION_DFUSE) {
|
if (priv->version == FU_DFU_FIRMARE_VERSION_DFUSE) {
|
||||||
fu_device_add_protocol (FU_DEVICE (self), "com.st.dfuse");
|
fu_device_add_protocol (FU_DEVICE (self), "com.st.dfuse");
|
||||||
} else {
|
} else {
|
||||||
fu_device_add_protocol (FU_DEVICE (self), "org.usb.dfu");
|
fu_device_add_protocol (FU_DEVICE (self), "org.usb.dfu");
|
||||||
@ -367,10 +365,10 @@ fu_dfu_device_add_targets (FuDfuDevice *self, GError **error)
|
|||||||
|
|
||||||
/* create a target of the required type */
|
/* create a target of the required type */
|
||||||
switch (priv->version) {
|
switch (priv->version) {
|
||||||
case DFU_VERSION_DFUSE:
|
case FU_DFU_FIRMARE_VERSION_DFUSE:
|
||||||
target = fu_dfu_target_stm_new ();
|
target = fu_dfu_target_stm_new ();
|
||||||
break;
|
break;
|
||||||
case DFU_VERSION_ATMEL_AVR:
|
case FU_DFU_FIRMARE_VERSION_ATMEL_AVR:
|
||||||
target = fu_dfu_target_avr_new ();
|
target = fu_dfu_target_avr_new ();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -28,8 +28,6 @@
|
|||||||
#include "fu-dfu-sector.h"
|
#include "fu-dfu-sector.h"
|
||||||
#include "fu-dfu-target-private.h"
|
#include "fu-dfu-target-private.h"
|
||||||
|
|
||||||
#include "fu-dfu-firmware-private.h"
|
|
||||||
|
|
||||||
#define DFU_TARGET_MANIFEST_MAX_POLLING_TRIES 200
|
#define DFU_TARGET_MANIFEST_MAX_POLLING_TRIES 200
|
||||||
|
|
||||||
static void fu_dfu_target_finalize (GObject *object);
|
static void fu_dfu_target_finalize (GObject *object);
|
||||||
@ -550,7 +548,7 @@ fu_dfu_target_check_status (FuDfuTarget *self, GError **error)
|
|||||||
|
|
||||||
/* STM32-specific long errors */
|
/* STM32-specific long errors */
|
||||||
status = fu_dfu_device_get_status (priv->device);
|
status = fu_dfu_device_get_status (priv->device);
|
||||||
if (fu_dfu_device_get_version (priv->device) == DFU_VERSION_DFUSE) {
|
if (fu_dfu_device_get_version (priv->device) == FU_DFU_FIRMARE_VERSION_DFUSE) {
|
||||||
if (status == FU_DFU_STATUS_ERR_VENDOR) {
|
if (status == FU_DFU_STATUS_ERR_VENDOR) {
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
FWUPD_ERROR,
|
FWUPD_ERROR,
|
||||||
@ -806,7 +804,7 @@ fu_dfu_target_download_chunk (FuDfuTarget *self, guint16 index, GBytes *bytes, G
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* for STM32 devices, the action only occurs when we do GetStatus */
|
/* for STM32 devices, the action only occurs when we do GetStatus */
|
||||||
if (fu_dfu_device_get_version (priv->device) == DFU_VERSION_DFUSE) {
|
if (fu_dfu_device_get_version (priv->device) == FU_DFU_FIRMARE_VERSION_DFUSE) {
|
||||||
if (!fu_dfu_device_refresh (priv->device, error))
|
if (!fu_dfu_device_refresh (priv->device, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user