mirror of
https://git.proxmox.com/git/fwupd
synced 2025-07-26 04:46:55 +00:00
dell-dock:Add atomic support
This commit is contained in:
parent
9b0316ce25
commit
b33a162b4c
@ -55,6 +55,36 @@ DellDockBlobMajorOffset = 0x7F52
|
|||||||
DellDockBlobMinorOffset = 0x7F53
|
DellDockBlobMinorOffset = 0x7F53
|
||||||
InstallDuration = 3
|
InstallDuration = 3
|
||||||
|
|
||||||
|
# Atomic USB hub1
|
||||||
|
[USB\VID_413C&PID_B06F&atomic_hub]
|
||||||
|
Name = RTS5413 in Dell dock
|
||||||
|
Summary = USB 3.1 Generation 1 Hub
|
||||||
|
ParentGuid = USB\VID_413C&PID_B06E&hub&atomic_embedded
|
||||||
|
Plugin = dell_dock
|
||||||
|
Vendor = Dell Inc.
|
||||||
|
Icon = dock-usb
|
||||||
|
FirmwareSize = 0x10000
|
||||||
|
Flags = require-ac,updatable,dual-image,usable-during-update
|
||||||
|
DellDockUnlockTarget = 8
|
||||||
|
DellDockBlobMajorOffset = 0x7F6E
|
||||||
|
DellDockBlobMinorOffset = 0x7F6F
|
||||||
|
InstallDuration = 14
|
||||||
|
|
||||||
|
# Atomic USB hub2
|
||||||
|
[USB\VID_413C&PID_B06E&atomic_hub]
|
||||||
|
Name = RTS5487 in Dell dock
|
||||||
|
Summary = USB 3.1 Generation 2 Hub
|
||||||
|
ParentGuid = USB\VID_413C&PID_B06E&hub&atomic_embedded
|
||||||
|
Vendor = Dell Inc.
|
||||||
|
Plugin = dell_dock
|
||||||
|
Icon = dock-usb
|
||||||
|
FirmwareSize = 0x10000
|
||||||
|
Flags = require-ac,updatable,has-bridge,dual-image,usable-during-update
|
||||||
|
DellDockUnlockTarget = 7
|
||||||
|
DellDockBlobMajorOffset = 0x7F52
|
||||||
|
DellDockBlobMinorOffset = 0x7F53
|
||||||
|
InstallDuration = 3
|
||||||
|
|
||||||
# Embedded Controller
|
# Embedded Controller
|
||||||
# Name is intentionally not set (it's queried by dock)
|
# Name is intentionally not set (it's queried by dock)
|
||||||
[USB\VID_413C&PID_B06E&hub&embedded]
|
[USB\VID_413C&PID_B06E&hub&embedded]
|
||||||
@ -73,6 +103,22 @@ DellDockVersionLowest = 01.00.00.00
|
|||||||
DellDockBlobVersionOffset = 0x1AFC0
|
DellDockBlobVersionOffset = 0x1AFC0
|
||||||
InstallDuration = 60
|
InstallDuration = 60
|
||||||
|
|
||||||
|
#Atomic Embedded Controller
|
||||||
|
# Name is intentionally not set (it's queried by dock)
|
||||||
|
[USB\VID_413C&PID_B06E&hub&atomic_embedded]
|
||||||
|
Name = Dell dock
|
||||||
|
Summary = High performance dock
|
||||||
|
Plugin = dell_dock
|
||||||
|
Vendor = Dell Inc.
|
||||||
|
VendorId = USB:0x413C
|
||||||
|
Icon = dock-usb
|
||||||
|
FirmwareSizeMin = 0x1FFC0
|
||||||
|
FirmwareSizeMax = 0x20000
|
||||||
|
Flags = require-ac,dual-image,self-recovery,usable-during-update
|
||||||
|
DellDockUnlockTarget = 1
|
||||||
|
DellDockBlobVersionOffset = 0x1AFC0
|
||||||
|
InstallDuration = 60
|
||||||
|
|
||||||
# Representation of overall dock update
|
# Representation of overall dock update
|
||||||
[USB\VID_413C&PID_B06E&hub&status]
|
[USB\VID_413C&PID_B06E&hub&status]
|
||||||
Name = Package level of Dell dock
|
Name = Package level of Dell dock
|
||||||
@ -95,6 +141,17 @@ FirmwareSize = 24
|
|||||||
InstallDuration = 5
|
InstallDuration = 5
|
||||||
DellDockBlobVersionOffset = 0x14
|
DellDockBlobVersionOffset = 0x14
|
||||||
|
|
||||||
|
# Representation of overall dock update
|
||||||
|
[USB\VID_413C&PID_B06E&hub&atomic_status]
|
||||||
|
Name = Package level of Dell dock
|
||||||
|
Summary = A representation of dock update status
|
||||||
|
Plugin = dell_dock
|
||||||
|
Vendor = Dell Inc.
|
||||||
|
Flags = self-recovery,usable-during-update
|
||||||
|
FirmwareSize = 24
|
||||||
|
InstallDuration = 5
|
||||||
|
DellDockBlobVersionOffset = 0x14
|
||||||
|
|
||||||
# MST Hub
|
# MST Hub
|
||||||
[MST-panamera-vmm5331-259]
|
[MST-panamera-vmm5331-259]
|
||||||
Name = VMM5331 in Dell dock
|
Name = VMM5331 in Dell dock
|
||||||
@ -112,6 +169,23 @@ DellDockBlobMinorOffset = 0x18401
|
|||||||
DellDockBlobBuildOffset = 0x18402
|
DellDockBlobBuildOffset = 0x18402
|
||||||
Icon = video-display
|
Icon = video-display
|
||||||
|
|
||||||
|
#Atomic MST Hub
|
||||||
|
[MST-cayenne-vmm6210-257]
|
||||||
|
Name = VMM6210 in Dell dock
|
||||||
|
Summary = Multi Stream Transport controller
|
||||||
|
Vendor = Dell Inc.
|
||||||
|
Plugin = dell_dock
|
||||||
|
ParentGuid = USB\VID_413C&PID_B06E&hub&atomic_embedded
|
||||||
|
Flags = skips-restart,require-ac,dual-image,usable-during-update
|
||||||
|
FirmwareSize = 1048576
|
||||||
|
DellDockUnlockTarget = 9
|
||||||
|
InstallDuration = 95
|
||||||
|
DellDockInstallDurationI2C = 360
|
||||||
|
DellDockBlobMajorOffset = 0x4000
|
||||||
|
DellDockBlobMinorOffset = 0x4001
|
||||||
|
DellDockBlobBuildOffset = 0x4002
|
||||||
|
Icon = video-display
|
||||||
|
|
||||||
# Thunderbolt controller
|
# Thunderbolt controller
|
||||||
[TBT-00d4b070]
|
[TBT-00d4b070]
|
||||||
Name = Thunderbolt controller in Dell dock
|
Name = Thunderbolt controller in Dell dock
|
||||||
|
@ -35,11 +35,19 @@
|
|||||||
#define DELL_DOCK_VM5331_INSTANCE_ID "MST-panamera-vmm5331-259"
|
#define DELL_DOCK_VM5331_INSTANCE_ID "MST-panamera-vmm5331-259"
|
||||||
#define GR_USB_VID 0x8087
|
#define GR_USB_VID 0x8087
|
||||||
#define GR_USB_PID 0x0B40
|
#define GR_USB_PID 0x0B40
|
||||||
|
#define DELL_DOCK_ATOMIC_STATUS_INSTANCE_ID "USB\\VID_413C&PID_B06E&hub&atomic_status"
|
||||||
|
#define DELL_DOCK_ATOMIC_EC_INSTANCE_ID "USB\\VID_413C&PID_B06E&hub&atomic_embedded"
|
||||||
|
#define DELL_DOCK_VMM6210_INSTANCE_ID "MST-cayenne-vmm6210-257"
|
||||||
|
#define ATOMIC_HUB2_PID 0x548A
|
||||||
|
#define ATOMIC_HUB1_PID 0x541A
|
||||||
|
#define DELL_VID 0x413C
|
||||||
|
|
||||||
|
#define WD19_BASE 0x04
|
||||||
|
#define ATOMIC_BASE 0x05
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
fu_dell_dock_set_power(FuDevice *device, guint8 target, gboolean enabled, GError **error);
|
fu_dell_dock_set_power(FuDevice *device, guint8 target, gboolean enabled, GError **error);
|
||||||
void
|
void
|
||||||
fu_dell_dock_will_replug(FuDevice *device);
|
fu_dell_dock_will_replug(FuDevice *device);
|
||||||
|
|
||||||
void
|
void
|
||||||
fu_dell_dock_clone_updatable(FuDevice *device);
|
fu_dell_dock_clone_updatable(FuDevice *device);
|
||||||
|
@ -29,12 +29,19 @@ struct _FuDellDockHub {
|
|||||||
G_DEFINE_TYPE(FuDellDockHub, fu_dell_dock_hub, FU_TYPE_HID_DEVICE)
|
G_DEFINE_TYPE(FuDellDockHub, fu_dell_dock_hub, FU_TYPE_HID_DEVICE)
|
||||||
|
|
||||||
void
|
void
|
||||||
fu_dell_dock_hub_add_instance(FuDevice *device)
|
fu_dell_dock_hub_add_instance(FuDevice *device, guint8 ec_type)
|
||||||
{
|
{
|
||||||
g_autofree gchar *devid =
|
g_autofree gchar *devid = NULL;
|
||||||
g_strdup_printf("USB\\VID_%04X&PID_%04X&hub",
|
|
||||||
(guint)fu_usb_device_get_vid(FU_USB_DEVICE(device)),
|
if (ec_type == ATOMIC_BASE) {
|
||||||
(guint)fu_usb_device_get_pid(FU_USB_DEVICE(device)));
|
devid = g_strdup_printf("USB\\VID_%04X&PID_%04X&atomic_hub",
|
||||||
|
(guint)fu_usb_device_get_vid(FU_USB_DEVICE(device)),
|
||||||
|
(guint)fu_usb_device_get_pid(FU_USB_DEVICE(device)));
|
||||||
|
} else {
|
||||||
|
devid = g_strdup_printf("USB\\VID_%04X&PID_%04X&hub",
|
||||||
|
(guint)fu_usb_device_get_vid(FU_USB_DEVICE(device)),
|
||||||
|
(guint)fu_usb_device_get_pid(FU_USB_DEVICE(device)));
|
||||||
|
}
|
||||||
fu_device_add_instance_id(device, devid);
|
fu_device_add_instance_id(device, devid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,9 +50,6 @@ fu_dell_dock_hub_probe(FuDevice *device, GError **error)
|
|||||||
{
|
{
|
||||||
fu_device_set_logical_id(device, "hub");
|
fu_device_set_logical_id(device, "hub");
|
||||||
fu_device_add_protocol(device, "com.dell.dock");
|
fu_device_add_protocol(device, "com.dell.dock");
|
||||||
/* delay if we have the bridge until we've probed behind it */
|
|
||||||
if (!fu_device_has_private_flag(device, FU_DELL_DOCK_HUB_FLAG_HAS_BRIDGE))
|
|
||||||
fu_dell_dock_hub_add_instance(device);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -32,4 +32,4 @@ G_DECLARE_FINAL_TYPE(FuDellDockHub, fu_dell_dock_hub, FU, DELL_DOCK_HUB, FuHidDe
|
|||||||
FuDellDockHub *
|
FuDellDockHub *
|
||||||
fu_dell_dock_hub_new(FuUsbDevice *device);
|
fu_dell_dock_hub_new(FuUsbDevice *device);
|
||||||
void
|
void
|
||||||
fu_dell_dock_hub_add_instance(FuDevice *device);
|
fu_dell_dock_hub_add_instance(FuDevice *device, guint8 ec_type);
|
||||||
|
@ -33,7 +33,6 @@
|
|||||||
#define EC_GET_FW_UPDATE_STATUS 0x0f
|
#define EC_GET_FW_UPDATE_STATUS 0x0f
|
||||||
|
|
||||||
#define EXPECTED_DOCK_INFO_SIZE 0xb7
|
#define EXPECTED_DOCK_INFO_SIZE 0xb7
|
||||||
#define WD19_BASE 0x04
|
|
||||||
|
|
||||||
#define TBT_MODE_MASK 0x01
|
#define TBT_MODE_MASK 0x01
|
||||||
|
|
||||||
@ -183,6 +182,13 @@ fu_dell_dock_module_is_usb4(FuDevice *device)
|
|||||||
return self->data->module_type == MODULE_TYPE_130_USB4;
|
return self->data->module_type == MODULE_TYPE_130_USB4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
guint8
|
||||||
|
fu_dell_dock_get_ec_type(FuDevice *device)
|
||||||
|
{
|
||||||
|
FuDellDockEc *self = FU_DELL_DOCK_EC(device);
|
||||||
|
return self->base_type;
|
||||||
|
}
|
||||||
|
|
||||||
const gchar *
|
const gchar *
|
||||||
fu_dell_dock_ec_get_module_type(FuDevice *device)
|
fu_dell_dock_ec_get_module_type(FuDevice *device)
|
||||||
{
|
{
|
||||||
@ -344,8 +350,10 @@ fu_dell_dock_is_valid_dock(FuDevice *device, GError **error)
|
|||||||
if (self->base_type == WD19_BASE) {
|
if (self->base_type == WD19_BASE) {
|
||||||
fu_device_add_instance_id(device, DELL_DOCK_EC_INSTANCE_ID);
|
fu_device_add_instance_id(device, DELL_DOCK_EC_INSTANCE_ID);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
} else if (self->base_type == ATOMIC_BASE) {
|
||||||
|
fu_device_add_instance_id(device, DELL_DOCK_ATOMIC_EC_INSTANCE_ID);
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_set_error(error,
|
g_set_error(error,
|
||||||
FWUPD_ERROR,
|
FWUPD_ERROR,
|
||||||
FWUPD_ERROR_NOT_SUPPORTED,
|
FWUPD_ERROR_NOT_SUPPORTED,
|
||||||
@ -815,6 +823,7 @@ fu_dell_dock_ec_write_fw(FuDevice *device,
|
|||||||
data = g_bytes_get_data(fw, &fw_size);
|
data = g_bytes_get_data(fw, &fw_size);
|
||||||
write_size = (fw_size / HIDI2C_MAX_WRITE) >= 1 ? HIDI2C_MAX_WRITE : fw_size;
|
write_size = (fw_size / HIDI2C_MAX_WRITE) >= 1 ? HIDI2C_MAX_WRITE : fw_size;
|
||||||
dynamic_version = g_strndup((gchar *)data + self->blob_version_offset, 11);
|
dynamic_version = g_strndup((gchar *)data + self->blob_version_offset, 11);
|
||||||
|
g_debug("writing EC firmware version %s", dynamic_version);
|
||||||
|
|
||||||
/* meet the minimum EC version */
|
/* meet the minimum EC version */
|
||||||
if ((flags & FWUPD_INSTALL_FLAG_FORCE) == 0 &&
|
if ((flags & FWUPD_INSTALL_FLAG_FORCE) == 0 &&
|
||||||
|
@ -47,3 +47,5 @@ gboolean
|
|||||||
fu_dell_dock_ec_commit_package(FuDevice *device, GBytes *blob_fw, GError **error);
|
fu_dell_dock_ec_commit_package(FuDevice *device, GBytes *blob_fw, GError **error);
|
||||||
gboolean
|
gboolean
|
||||||
fu_dell_dock_module_is_usb4(FuDevice *device);
|
fu_dell_dock_module_is_usb4(FuDevice *device);
|
||||||
|
guint8
|
||||||
|
fu_dell_dock_get_ec_type(FuDevice *device);
|
||||||
|
@ -24,16 +24,24 @@
|
|||||||
|
|
||||||
#define I2C_MST_ADDRESS 0x72
|
#define I2C_MST_ADDRESS 0x72
|
||||||
|
|
||||||
/* MST registers */
|
/* Panamera MST registers */
|
||||||
#define MST_RC_TRIGGER_ADDR 0x2000fc
|
#define PANAMERA_MST_RC_TRIGGER_ADDR 0x2000fc
|
||||||
#define MST_CORE_MCU_BOOTLOADER_STS 0x20010c
|
#define PANAMERA_MST_CORE_MCU_BOOTLOADER_STS 0x20010c
|
||||||
#define MST_RC_COMMAND_ADDR 0x200110
|
#define PANAMERA_MST_RC_COMMAND_ADDR 0x200110
|
||||||
#define MST_RC_OFFSET_ADDR 0x200114
|
#define PANAMERA_MST_RC_OFFSET_ADDR 0x200114
|
||||||
#define MST_RC_LENGTH_ADDR 0x200118
|
#define PANAMERA_MST_RC_LENGTH_ADDR 0x200118
|
||||||
#define MST_RC_DATA_ADDR 0x200120
|
#define PANAMERA_MST_RC_DATA_ADDR 0x200120
|
||||||
#define MST_CORE_MCU_FW_VERSION 0x200160
|
#define PANAMERA_MST_CORE_MCU_FW_VERSION 0x200160
|
||||||
#define MST_REG_QUAD_DISABLE 0x200fc0
|
#define PANAMERA_MST_REG_QUAD_DISABLE 0x200fc0
|
||||||
#define MST_REG_HDCP22_DISABLE 0x200f90
|
#define PANAMERA_MST_REG_HDCP22_DISABLE 0x200f90
|
||||||
|
|
||||||
|
/* Cayenne MST registers */
|
||||||
|
#define CAYENNE_MST_RC_TRIGGER_ADDR 0x2020021C
|
||||||
|
#define CAYENNE_MST_CORE_MCU_BOOTLOADER_STS 0x2020022C
|
||||||
|
#define CAYENNE_MST_RC_COMMAND_ADDR 0x20200280
|
||||||
|
#define CAYENNE_MST_RC_OFFSET_ADDR 0x20200284
|
||||||
|
#define CAYENNE_MST_RC_LENGTH_ADDR 0x20200288
|
||||||
|
#define CAYENNE_MST_RC_DATA_ADDR 0x20200290
|
||||||
|
|
||||||
/* MST remote control commands */
|
/* MST remote control commands */
|
||||||
#define MST_CMD_ENABLE_REMOTE_CONTROL 0x1
|
#define MST_CMD_ENABLE_REMOTE_CONTROL 0x1
|
||||||
@ -45,6 +53,10 @@
|
|||||||
#define MST_CMD_WRITE_MEMORY 0x21
|
#define MST_CMD_WRITE_MEMORY 0x21
|
||||||
#define MST_CMD_READ_MEMORY 0x31
|
#define MST_CMD_READ_MEMORY 0x31
|
||||||
|
|
||||||
|
/* Cayenne specific remote control commands */
|
||||||
|
#define MST_CMD_CRC16_CHECKSUM 0x17
|
||||||
|
#define MST_CMD_ACTIVATE_FW 0x18
|
||||||
|
|
||||||
/* Arguments related to flashing */
|
/* Arguments related to flashing */
|
||||||
#define FLASH_SECTOR_ERASE_4K 0x1000
|
#define FLASH_SECTOR_ERASE_4K 0x1000
|
||||||
#define FLASH_SECTOR_ERASE_32K 0x2000
|
#define FLASH_SECTOR_ERASE_32K 0x2000
|
||||||
@ -69,28 +81,48 @@
|
|||||||
/* firmware file offsets */
|
/* firmware file offsets */
|
||||||
#define MST_BLOB_VERSION_OFFSET 0x06F0
|
#define MST_BLOB_VERSION_OFFSET 0x06F0
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
Panamera_mst,
|
||||||
|
Cayenne_mst,
|
||||||
|
Unknown,
|
||||||
|
} MSTType;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
Bank0,
|
Bank0,
|
||||||
Bank1,
|
Bank1,
|
||||||
ESM,
|
ESM,
|
||||||
|
Cayenne,
|
||||||
} MSTBank;
|
} MSTBank;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
guint start;
|
guint start;
|
||||||
guint length;
|
guint length;
|
||||||
|
guint checksum_cmd;
|
||||||
} MSTBankAttributes;
|
} MSTBankAttributes;
|
||||||
|
|
||||||
const MSTBankAttributes bank0_attributes = {
|
const MSTBankAttributes bank0_attributes = {
|
||||||
.start = 0,
|
.start = 0,
|
||||||
.length = EEPROM_BANK_OFFSET,
|
.length = EEPROM_BANK_OFFSET,
|
||||||
|
.checksum_cmd = MST_CMD_CHECKSUM,
|
||||||
};
|
};
|
||||||
|
|
||||||
const MSTBankAttributes bank1_attributes = {
|
const MSTBankAttributes bank1_attributes = {
|
||||||
.start = EEPROM_BANK_OFFSET,
|
.start = EEPROM_BANK_OFFSET,
|
||||||
.length = EEPROM_BANK_OFFSET,
|
.length = EEPROM_BANK_OFFSET,
|
||||||
|
.checksum_cmd = MST_CMD_CHECKSUM,
|
||||||
};
|
};
|
||||||
|
|
||||||
const MSTBankAttributes esm_attributes = {.start = EEPROM_ESM_OFFSET, .length = 0x3ffff};
|
const MSTBankAttributes esm_attributes = {
|
||||||
|
.start = EEPROM_ESM_OFFSET,
|
||||||
|
.length = 0x3ffff,
|
||||||
|
.checksum_cmd = MST_CMD_CHECKSUM,
|
||||||
|
};
|
||||||
|
|
||||||
|
const MSTBankAttributes cayenne_attributes = {
|
||||||
|
.start = 0,
|
||||||
|
.length = 0x50000,
|
||||||
|
.checksum_cmd = MST_CMD_CRC16_CHECKSUM,
|
||||||
|
};
|
||||||
|
|
||||||
FuHIDI2CParameters mst_base_settings = {
|
FuHIDI2CParameters mst_base_settings = {
|
||||||
.i2ctargetaddr = I2C_MST_ADDRESS,
|
.i2ctargetaddr = I2C_MST_ADDRESS,
|
||||||
@ -104,6 +136,10 @@ struct _FuDellDockMst {
|
|||||||
guint64 blob_major_offset;
|
guint64 blob_major_offset;
|
||||||
guint64 blob_minor_offset;
|
guint64 blob_minor_offset;
|
||||||
guint64 blob_build_offset;
|
guint64 blob_build_offset;
|
||||||
|
guint32 mst_rc_trigger_addr;
|
||||||
|
guint32 mst_rc_command_addr;
|
||||||
|
guint32 mst_rc_data_addr;
|
||||||
|
guint32 mst_core_mcu_bootloader_addr;
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE(FuDellDockMst, fu_dell_dock_mst, FU_TYPE_DEVICE)
|
G_DEFINE_TYPE(FuDellDockMst, fu_dell_dock_mst, FU_TYPE_DEVICE)
|
||||||
@ -131,6 +167,9 @@ fu_dell_dock_mst_get_bank_attribs(MSTBank bank, const MSTBankAttributes **out, G
|
|||||||
case ESM:
|
case ESM:
|
||||||
*out = &esm_attributes;
|
*out = &esm_attributes;
|
||||||
break;
|
break;
|
||||||
|
case Cayenne:
|
||||||
|
*out = &cayenne_attributes;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
g_set_error(error,
|
g_set_error(error,
|
||||||
FWUPD_ERROR,
|
FWUPD_ERROR,
|
||||||
@ -143,7 +182,7 @@ fu_dell_dock_mst_get_bank_attribs(MSTBank bank, const MSTBankAttributes **out, G
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
fu_dell_dock_mst_rc_command(FuDevice *proxy,
|
fu_dell_dock_mst_rc_command(FuDevice *device,
|
||||||
guint8 cmd,
|
guint8 cmd,
|
||||||
guint32 length,
|
guint32 length,
|
||||||
guint32 offset,
|
guint32 offset,
|
||||||
@ -199,7 +238,7 @@ fu_dell_dock_mst_query_active_bank(FuDevice *proxy, MSTBank *active, GError **er
|
|||||||
gsize length = 4;
|
gsize length = 4;
|
||||||
|
|
||||||
if (!fu_dell_dock_mst_read_register(proxy,
|
if (!fu_dell_dock_mst_read_register(proxy,
|
||||||
MST_CORE_MCU_BOOTLOADER_STS,
|
PANAMERA_MST_CORE_MCU_BOOTLOADER_STS,
|
||||||
length,
|
length,
|
||||||
&bytes,
|
&bytes,
|
||||||
error)) {
|
error)) {
|
||||||
@ -218,10 +257,10 @@ fu_dell_dock_mst_query_active_bank(FuDevice *proxy, MSTBank *active, GError **er
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
fu_dell_dock_mst_disable_remote_control(FuDevice *proxy, GError **error)
|
fu_dell_dock_mst_disable_remote_control(FuDevice *device, GError **error)
|
||||||
{
|
{
|
||||||
g_debug("MST: Disabling remote control");
|
g_debug("MST: Disabling remote control");
|
||||||
return fu_dell_dock_mst_rc_command(proxy,
|
return fu_dell_dock_mst_rc_command(device,
|
||||||
MST_CMD_DISABLE_REMOTE_CONTROL,
|
MST_CMD_DISABLE_REMOTE_CONTROL,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
@ -230,13 +269,13 @@ fu_dell_dock_mst_disable_remote_control(FuDevice *proxy, GError **error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
fu_dell_dock_mst_enable_remote_control(FuDevice *proxy, GError **error)
|
fu_dell_dock_mst_enable_remote_control(FuDevice *device, GError **error)
|
||||||
{
|
{
|
||||||
g_autoptr(GError) error_local = NULL;
|
g_autoptr(GError) error_local = NULL;
|
||||||
const gchar *data = "PRIUS";
|
const gchar *data = "PRIUS";
|
||||||
|
|
||||||
g_debug("MST: Enabling remote control");
|
g_debug("MST: Enabling remote control");
|
||||||
if (!fu_dell_dock_mst_rc_command(proxy,
|
if (!fu_dell_dock_mst_rc_command(device,
|
||||||
MST_CMD_ENABLE_REMOTE_CONTROL,
|
MST_CMD_ENABLE_REMOTE_CONTROL,
|
||||||
5,
|
5,
|
||||||
0,
|
0,
|
||||||
@ -244,23 +283,25 @@ fu_dell_dock_mst_enable_remote_control(FuDevice *proxy, GError **error)
|
|||||||
&error_local)) {
|
&error_local)) {
|
||||||
g_debug("Failed to enable remote control: %s", error_local->message);
|
g_debug("Failed to enable remote control: %s", error_local->message);
|
||||||
/* try to disable / re-enable */
|
/* try to disable / re-enable */
|
||||||
if (!fu_dell_dock_mst_disable_remote_control(proxy, error))
|
if (!fu_dell_dock_mst_disable_remote_control(device, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
return fu_dell_dock_mst_enable_remote_control(proxy, error);
|
return fu_dell_dock_mst_enable_remote_control(device, error);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
fu_dell_dock_trigger_rc_command(FuDevice *proxy, GError **error)
|
fu_dell_dock_trigger_rc_command(FuDevice *device, GError **error)
|
||||||
{
|
{
|
||||||
const guint8 *result = NULL;
|
const guint8 *result = NULL;
|
||||||
|
FuDevice *proxy = fu_device_get_proxy(device);
|
||||||
|
FuDellDockMst *self = FU_DELL_DOCK_MST(device);
|
||||||
guint32 tmp;
|
guint32 tmp;
|
||||||
|
|
||||||
/* Trigger the write */
|
/* Trigger the write */
|
||||||
tmp = MST_TRIGGER_WRITE;
|
tmp = MST_TRIGGER_WRITE;
|
||||||
if (!fu_dell_dock_mst_write_register(proxy,
|
if (!fu_dell_dock_mst_write_register(proxy,
|
||||||
MST_RC_TRIGGER_ADDR,
|
self->mst_rc_trigger_addr,
|
||||||
(guint8 *)&tmp,
|
(guint8 *)&tmp,
|
||||||
sizeof(guint32),
|
sizeof(guint32),
|
||||||
error)) {
|
error)) {
|
||||||
@ -272,7 +313,7 @@ fu_dell_dock_trigger_rc_command(FuDevice *proxy, GError **error)
|
|||||||
for (guint i = 0; i < 1000; i++) {
|
for (guint i = 0; i < 1000; i++) {
|
||||||
g_autoptr(GBytes) bytes = NULL;
|
g_autoptr(GBytes) bytes = NULL;
|
||||||
if (!fu_dell_dock_mst_read_register(proxy,
|
if (!fu_dell_dock_mst_read_register(proxy,
|
||||||
MST_RC_COMMAND_ADDR,
|
self->mst_rc_command_addr,
|
||||||
sizeof(guint32),
|
sizeof(guint32),
|
||||||
&bytes,
|
&bytes,
|
||||||
error)) {
|
error)) {
|
||||||
@ -290,7 +331,7 @@ fu_dell_dock_trigger_rc_command(FuDevice *proxy, GError **error)
|
|||||||
switch (tmp) {
|
switch (tmp) {
|
||||||
/* need to enable remote control */
|
/* need to enable remote control */
|
||||||
case 4:
|
case 4:
|
||||||
return fu_dell_dock_mst_enable_remote_control(proxy, error);
|
return fu_dell_dock_mst_enable_remote_control(device, error);
|
||||||
/* error scenarios */
|
/* error scenarios */
|
||||||
case 3:
|
case 3:
|
||||||
g_set_error_literal(error, G_IO_ERROR, G_IO_ERROR_FAILED, "Unknown error");
|
g_set_error_literal(error, G_IO_ERROR, G_IO_ERROR_FAILED, "Unknown error");
|
||||||
@ -316,7 +357,7 @@ fu_dell_dock_trigger_rc_command(FuDevice *proxy, GError **error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
fu_dell_dock_mst_rc_command(FuDevice *proxy,
|
fu_dell_dock_mst_rc_command(FuDevice *device,
|
||||||
guint8 cmd,
|
guint8 cmd,
|
||||||
guint32 length,
|
guint32 length,
|
||||||
guint32 offset,
|
guint32 offset,
|
||||||
@ -324,6 +365,8 @@ fu_dell_dock_mst_rc_command(FuDevice *proxy,
|
|||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
/* 4 for cmd, 4 for offset, 4 for length, 4 for garbage */
|
/* 4 for cmd, 4 for offset, 4 for length, 4 for garbage */
|
||||||
|
FuDellDockMst *self = FU_DELL_DOCK_MST(device);
|
||||||
|
FuDevice *proxy = fu_device_get_proxy(device);
|
||||||
gint buffer_len = (data == NULL) ? 12 : length + 16;
|
gint buffer_len = (data == NULL) ? 12 : length + 16;
|
||||||
g_autofree guint8 *buffer = g_malloc0(buffer_len);
|
g_autofree guint8 *buffer = g_malloc0(buffer_len);
|
||||||
guint32 tmp;
|
guint32 tmp;
|
||||||
@ -342,35 +385,31 @@ fu_dell_dock_mst_rc_command(FuDevice *proxy,
|
|||||||
memcpy(buffer + 16, data, length);
|
memcpy(buffer + 16, data, length);
|
||||||
|
|
||||||
/* write the combined register stream */
|
/* write the combined register stream */
|
||||||
if (!fu_dell_dock_mst_write_register(proxy, MST_RC_COMMAND_ADDR, buffer, buffer_len, error))
|
if (!fu_dell_dock_mst_write_register(proxy,
|
||||||
|
self->mst_rc_command_addr,
|
||||||
|
buffer,
|
||||||
|
buffer_len,
|
||||||
|
error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return fu_dell_dock_trigger_rc_command(proxy, error);
|
return fu_dell_dock_trigger_rc_command(device, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static MSTType
|
||||||
fu_dell_dock_mst_read_chipid(FuDevice *proxy, guint16 *chip_id, GError **error)
|
fu_dell_dock_mst_check_type(FuDevice *device)
|
||||||
{
|
{
|
||||||
g_autoptr(GBytes) bytes = NULL;
|
GPtrArray *instance_ids;
|
||||||
const guint8 *data;
|
const gchar *tmp = NULL;
|
||||||
gsize length = 4;
|
|
||||||
|
|
||||||
g_return_val_if_fail(chip_id != NULL, FALSE);
|
instance_ids = fu_device_get_instance_ids(device);
|
||||||
|
for (guint i = 0; i < instance_ids->len; i++) {
|
||||||
/* run an RC command to get data from memory */
|
tmp = g_ptr_array_index(instance_ids, i);
|
||||||
if (!fu_dell_dock_mst_rc_command(proxy,
|
if (g_strcmp0(tmp, DELL_DOCK_VMM6210_INSTANCE_ID) == 0)
|
||||||
MST_CMD_READ_MEMORY,
|
return Cayenne_mst;
|
||||||
length,
|
else if (g_strcmp0(tmp, DELL_DOCK_VM5331_INSTANCE_ID) == 0)
|
||||||
MST_CHIPID_OFFSET,
|
return Panamera_mst;
|
||||||
NULL,
|
}
|
||||||
error))
|
return Unknown;
|
||||||
return FALSE;
|
|
||||||
if (!fu_dell_dock_mst_read_register(proxy, MST_RC_DATA_ADDR, length, &bytes, error))
|
|
||||||
return FALSE;
|
|
||||||
data = g_bytes_get_data(bytes, &length);
|
|
||||||
*chip_id = (data[1] << 8) | data[2];
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -382,14 +421,15 @@ fu_dell_dock_mst_check_offset(guint8 byte, guint8 offset)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
fu_d19_mst_check_fw(FuDevice *proxy, GError **error)
|
fu_d19_mst_check_fw(FuDevice *device, GError **error)
|
||||||
{
|
{
|
||||||
|
FuDellDockMst *self = FU_DELL_DOCK_MST(device);
|
||||||
g_autoptr(GBytes) bytes = NULL;
|
g_autoptr(GBytes) bytes = NULL;
|
||||||
const guint8 *data;
|
const guint8 *data;
|
||||||
gsize length = 4;
|
gsize length = 4;
|
||||||
|
|
||||||
if (!fu_dell_dock_mst_read_register(proxy,
|
if (!fu_dell_dock_mst_read_register(fu_device_get_proxy(device),
|
||||||
MST_CORE_MCU_BOOTLOADER_STS,
|
self->mst_core_mcu_bootloader_addr,
|
||||||
length,
|
length,
|
||||||
&bytes,
|
&bytes,
|
||||||
error))
|
error))
|
||||||
@ -412,13 +452,81 @@ fu_d19_mst_check_fw(FuDevice *proxy, GError **error)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static guint16
|
||||||
|
fu_dell_dock_mst_get_crc(guint8 type, guint32 length, const guint8 *payload_data)
|
||||||
|
{
|
||||||
|
static const guint16 CRC16_table[] = {
|
||||||
|
0x0000, 0x8005, 0x800f, 0x000a, 0x801b, 0x001e, 0x0014, 0x8011, 0x8033, 0x0036, 0x003c,
|
||||||
|
0x8039, 0x0028, 0x802d, 0x8027, 0x0022, 0x8063, 0x0066, 0x006c, 0x8069, 0x0078, 0x807d,
|
||||||
|
0x8077, 0x0072, 0x0050, 0x8055, 0x805f, 0x005a, 0x804b, 0x004e, 0x0044, 0x8041, 0x80c3,
|
||||||
|
0x00c6, 0x00cc, 0x80c9, 0x00d8, 0x80dd, 0x80d7, 0x00d2, 0x00f0, 0x80f5, 0x80ff, 0x00fa,
|
||||||
|
0x80eb, 0x00ee, 0x00e4, 0x80e1, 0x00a0, 0x80a5, 0x80af, 0x00aa, 0x80bb, 0x00be, 0x00b4,
|
||||||
|
0x80b1, 0x8093, 0x0096, 0x009c, 0x8099, 0x0088, 0x808d, 0x8087, 0x0082, 0x8183, 0x0186,
|
||||||
|
0x018c, 0x8189, 0x0198, 0x819d, 0x8197, 0x0192, 0x01b0, 0x81b5, 0x81bf, 0x01ba, 0x81ab,
|
||||||
|
0x01ae, 0x01a4, 0x81a1, 0x01e0, 0x81e5, 0x81ef, 0x01ea, 0x81fb, 0x01fe, 0x01f4, 0x81f1,
|
||||||
|
0x81d3, 0x01d6, 0x01dc, 0x81d9, 0x01c8, 0x81cd, 0x81c7, 0x01c2, 0x0140, 0x8145, 0x814f,
|
||||||
|
0x014a, 0x815b, 0x015e, 0x0154, 0x8151, 0x8173, 0x0176, 0x017c, 0x8179, 0x0168, 0x816d,
|
||||||
|
0x8167, 0x0162, 0x8123, 0x0126, 0x012c, 0x8129, 0x0138, 0x813d, 0x8137, 0x0132, 0x0110,
|
||||||
|
0x8115, 0x811f, 0x011a, 0x810b, 0x010e, 0x0104, 0x8101, 0x8303, 0x0306, 0x030c, 0x8309,
|
||||||
|
0x0318, 0x831d, 0x8317, 0x0312, 0x0330, 0x8335, 0x833f, 0x033a, 0x832b, 0x032e, 0x0324,
|
||||||
|
0x8321, 0x0360, 0x8365, 0x836f, 0x036a, 0x837b, 0x037e, 0x0374, 0x8371, 0x8353, 0x0356,
|
||||||
|
0x035c, 0x8359, 0x0348, 0x834d, 0x8347, 0x0342, 0x03c0, 0x83c5, 0x83cf, 0x03ca, 0x83db,
|
||||||
|
0x03de, 0x03d4, 0x83d1, 0x83f3, 0x03f6, 0x03fc, 0x83f9, 0x03e8, 0x83ed, 0x83e7, 0x03e2,
|
||||||
|
0x83a3, 0x03a6, 0x03ac, 0x83a9, 0x03b8, 0x83bd, 0x83b7, 0x03b2, 0x0390, 0x8395, 0x839f,
|
||||||
|
0x039a, 0x838b, 0x038e, 0x0384, 0x8381, 0x0280, 0x8285, 0x828f, 0x028a, 0x829b, 0x029e,
|
||||||
|
0x0294, 0x8291, 0x82b3, 0x02b6, 0x02bc, 0x82b9, 0x02a8, 0x82ad, 0x82a7, 0x02a2, 0x82e3,
|
||||||
|
0x02e6, 0x02ec, 0x82e9, 0x02f8, 0x82fd, 0x82f7, 0x02f2, 0x02d0, 0x82d5, 0x82df, 0x02da,
|
||||||
|
0x82cb, 0x02ce, 0x02c4, 0x82c1, 0x8243, 0x0246, 0x024c, 0x8249, 0x0258, 0x825d, 0x8257,
|
||||||
|
0x0252, 0x0270, 0x8275, 0x827f, 0x027a, 0x826b, 0x026e, 0x0264, 0x8261, 0x0220, 0x8225,
|
||||||
|
0x822f, 0x022a, 0x823b, 0x023e, 0x0234, 0x8231, 0x8213, 0x0216, 0x021c, 0x8219, 0x0208,
|
||||||
|
0x820d, 0x8207, 0x0202};
|
||||||
|
static const guint16 CRC8_table[] = {
|
||||||
|
0x00, 0xd5, 0x7f, 0xaa, 0xfe, 0x2b, 0x81, 0x54, 0x29, 0xfc, 0x56, 0x83, 0xd7, 0x02,
|
||||||
|
0xa8, 0x7d, 0x52, 0x87, 0x2d, 0xf8, 0xac, 0x79, 0xd3, 0x06, 0x7b, 0xae, 0x04, 0xd1,
|
||||||
|
0x85, 0x50, 0xfa, 0x2f, 0xa4, 0x71, 0xdb, 0x0e, 0x5a, 0x8f, 0x25, 0xf0, 0x8d, 0x58,
|
||||||
|
0xf2, 0x27, 0x73, 0xa6, 0x0c, 0xd9, 0xf6, 0x23, 0x89, 0x5c, 0x08, 0xdd, 0x77, 0xa2,
|
||||||
|
0xdf, 0x0a, 0xa0, 0x75, 0x21, 0xf4, 0x5e, 0x8b, 0x9d, 0x48, 0xe2, 0x37, 0x63, 0xb6,
|
||||||
|
0x1c, 0xc9, 0xb4, 0x61, 0xcb, 0x1e, 0x4a, 0x9f, 0x35, 0xe0, 0xcf, 0x1a, 0xb0, 0x65,
|
||||||
|
0x31, 0xe4, 0x4e, 0x9b, 0xe6, 0x33, 0x99, 0x4c, 0x18, 0xcd, 0x67, 0xb2, 0x39, 0xec,
|
||||||
|
0x46, 0x93, 0xc7, 0x12, 0xb8, 0x6d, 0x10, 0xc5, 0x6f, 0xba, 0xee, 0x3b, 0x91, 0x44,
|
||||||
|
0x6b, 0xbe, 0x14, 0xc1, 0x95, 0x40, 0xea, 0x3f, 0x42, 0x97, 0x3d, 0xe8, 0xbc, 0x69,
|
||||||
|
0xc3, 0x16, 0xef, 0x3a, 0x90, 0x45, 0x11, 0xc4, 0x6e, 0xbb, 0xc6, 0x13, 0xb9, 0x6c,
|
||||||
|
0x38, 0xed, 0x47, 0x92, 0xbd, 0x68, 0xc2, 0x17, 0x43, 0x96, 0x3c, 0xe9, 0x94, 0x41,
|
||||||
|
0xeb, 0x3e, 0x6a, 0xbf, 0x15, 0xc0, 0x4b, 0x9e, 0x34, 0xe1, 0xb5, 0x60, 0xca, 0x1f,
|
||||||
|
0x62, 0xb7, 0x1d, 0xc8, 0x9c, 0x49, 0xe3, 0x36, 0x19, 0xcc, 0x66, 0xb3, 0xe7, 0x32,
|
||||||
|
0x98, 0x4d, 0x30, 0xe5, 0x4f, 0x9a, 0xce, 0x1b, 0xb1, 0x64, 0x72, 0xa7, 0x0d, 0xd8,
|
||||||
|
0x8c, 0x59, 0xf3, 0x26, 0x5b, 0x8e, 0x24, 0xf1, 0xa5, 0x70, 0xda, 0x0f, 0x20, 0xf5,
|
||||||
|
0x5f, 0x8a, 0xde, 0x0b, 0xa1, 0x74, 0x09, 0xdc, 0x76, 0xa3, 0xf7, 0x22, 0x88, 0x5d,
|
||||||
|
0xd6, 0x03, 0xa9, 0x7c, 0x28, 0xfd, 0x57, 0x82, 0xff, 0x2a, 0x80, 0x55, 0x01, 0xd4,
|
||||||
|
0x7e, 0xab, 0x84, 0x51, 0xfb, 0x2e, 0x7a, 0xaf, 0x05, 0xd0, 0xad, 0x78, 0xd2, 0x07,
|
||||||
|
0x53, 0x86, 0x2c, 0xf9};
|
||||||
|
guint8 val;
|
||||||
|
guint16 crc = 0;
|
||||||
|
const guint8 *message = payload_data;
|
||||||
|
|
||||||
|
if (type == 8) {
|
||||||
|
for (guint32 byte = 0; byte < length; ++byte) {
|
||||||
|
val = (guint8)(message[byte] ^ crc);
|
||||||
|
crc = CRC8_table[val];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (guint32 byte = 0; byte < length; ++byte) {
|
||||||
|
val = (guint8)(message[byte] ^ (crc >> 8));
|
||||||
|
crc = CRC16_table[val] ^ (crc << 8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return crc;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
fu_dell_dock_mst_checksum_bank(FuDevice *proxy,
|
fu_dell_dock_mst_checksum_bank(FuDevice *device,
|
||||||
GBytes *blob_fw,
|
GBytes *blob_fw,
|
||||||
MSTBank bank,
|
MSTBank bank,
|
||||||
gboolean *checksum,
|
gboolean *checksum,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
|
FuDellDockMst *self = FU_DELL_DOCK_MST(device);
|
||||||
g_autoptr(GBytes) csum_bytes = NULL;
|
g_autoptr(GBytes) csum_bytes = NULL;
|
||||||
const MSTBankAttributes *attribs = NULL;
|
const MSTBankAttributes *attribs = NULL;
|
||||||
gsize length = 0;
|
gsize length = 0;
|
||||||
@ -444,14 +552,19 @@ fu_dell_dock_mst_checksum_bank(FuDevice *proxy,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* checksum the file */
|
/* checksum the file */
|
||||||
for (guint i = attribs->start; i < attribs->length + attribs->start; i++) {
|
if (attribs->checksum_cmd == MST_CMD_CRC16_CHECKSUM)
|
||||||
payload_sum += data[i];
|
payload_sum =
|
||||||
|
fu_dell_dock_mst_get_crc(16, (attribs->length + attribs->start), data);
|
||||||
|
else {
|
||||||
|
for (guint i = attribs->start; i < attribs->length + attribs->start; i++) {
|
||||||
|
payload_sum += data[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
g_debug("MST: Payload checksum: 0x%x", payload_sum);
|
g_debug("MST: Payload checksum: 0x%x", payload_sum);
|
||||||
|
|
||||||
/* checksum the bank */
|
/* checksum the bank */
|
||||||
if (!fu_dell_dock_mst_rc_command(proxy,
|
if (!fu_dell_dock_mst_rc_command(device,
|
||||||
MST_CMD_CHECKSUM,
|
attribs->checksum_cmd,
|
||||||
attribs->length,
|
attribs->length,
|
||||||
attribs->start,
|
attribs->start,
|
||||||
NULL,
|
NULL,
|
||||||
@ -460,7 +573,11 @@ fu_dell_dock_mst_checksum_bank(FuDevice *proxy,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
/* read result from data register */
|
/* read result from data register */
|
||||||
if (!fu_dell_dock_mst_read_register(proxy, MST_RC_DATA_ADDR, 4, &csum_bytes, error))
|
if (!fu_dell_dock_mst_read_register(fu_device_get_proxy(device),
|
||||||
|
self->mst_rc_data_addr,
|
||||||
|
4,
|
||||||
|
&csum_bytes,
|
||||||
|
error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
data = g_bytes_get_data(csum_bytes, NULL);
|
data = g_bytes_get_data(csum_bytes, NULL);
|
||||||
bank_sum = GUINT32_FROM_LE(data[0] | data[1] << 8 | data[2] << 16 | data[3] << 24);
|
bank_sum = GUINT32_FROM_LE(data[0] | data[1] << 8 | data[2] << 16 | data[3] << 24);
|
||||||
@ -472,7 +589,7 @@ fu_dell_dock_mst_checksum_bank(FuDevice *proxy,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
fu_dell_dock_mst_erase_bank(FuDevice *proxy, MSTBank bank, GError **error)
|
fu_dell_dock_mst_erase_panamera_bank(FuDevice *device, MSTBank bank, GError **error)
|
||||||
{
|
{
|
||||||
const MSTBankAttributes *attribs = NULL;
|
const MSTBankAttributes *attribs = NULL;
|
||||||
guint32 sector;
|
guint32 sector;
|
||||||
@ -483,7 +600,7 @@ fu_dell_dock_mst_erase_bank(FuDevice *proxy, MSTBank bank, GError **error)
|
|||||||
for (guint32 i = attribs->start; i < attribs->start + attribs->length; i += 0x10000) {
|
for (guint32 i = attribs->start; i < attribs->start + attribs->length; i += 0x10000) {
|
||||||
sector = FLASH_SECTOR_ERASE_64K | (i / 0x10000);
|
sector = FLASH_SECTOR_ERASE_64K | (i / 0x10000);
|
||||||
g_debug("MST: Erasing sector 0x%x", sector);
|
g_debug("MST: Erasing sector 0x%x", sector);
|
||||||
if (!fu_dell_dock_mst_rc_command(proxy,
|
if (!fu_dell_dock_mst_rc_command(device,
|
||||||
MST_CMD_ERASE_FLASH,
|
MST_CMD_ERASE_FLASH,
|
||||||
4,
|
4,
|
||||||
0,
|
0,
|
||||||
@ -499,6 +616,29 @@ fu_dell_dock_mst_erase_bank(FuDevice *proxy, MSTBank bank, GError **error)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
fu_dell_dock_mst_erase_cayenne(FuDevice *device, GError **error)
|
||||||
|
{
|
||||||
|
guint8 data[4] = {0, 0x30, 0, 0};
|
||||||
|
|
||||||
|
for (guint8 i = 0; i < 5; i++) {
|
||||||
|
data[0] = i;
|
||||||
|
if (!fu_dell_dock_mst_rc_command(device,
|
||||||
|
MST_CMD_ERASE_FLASH,
|
||||||
|
4,
|
||||||
|
0,
|
||||||
|
(guint8 *)&data,
|
||||||
|
error)) {
|
||||||
|
g_prefix_error(error, "Failed to erase sector: %d", i);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g_debug("MST: Waiting for flash clear to settle");
|
||||||
|
g_usleep(5000000);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
fu_dell_dock_write_flash_bank(FuDevice *device,
|
fu_dell_dock_write_flash_bank(FuDevice *device,
|
||||||
GBytes *blob_fw,
|
GBytes *blob_fw,
|
||||||
@ -519,7 +659,7 @@ fu_dell_dock_write_flash_bank(FuDevice *device,
|
|||||||
|
|
||||||
g_debug("MST: Writing payload to bank %u", bank);
|
g_debug("MST: Writing payload to bank %u", bank);
|
||||||
for (guint i = attribs->start; i < end; i += write_size) {
|
for (guint i = attribs->start; i < end; i += write_size) {
|
||||||
if (!fu_dell_dock_mst_rc_command(fu_device_get_proxy(device),
|
if (!fu_dell_dock_mst_rc_command(device,
|
||||||
MST_CMD_WRITE_FLASH,
|
MST_CMD_WRITE_FLASH,
|
||||||
write_size,
|
write_size,
|
||||||
i,
|
i,
|
||||||
@ -538,7 +678,7 @@ fu_dell_dock_write_flash_bank(FuDevice *device,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
fu_dell_dock_mst_stop_esm(FuDevice *proxy, GError **error)
|
fu_dell_dock_mst_stop_esm(FuDevice *device, GError **error)
|
||||||
{
|
{
|
||||||
g_autoptr(GBytes) quad_bytes = NULL;
|
g_autoptr(GBytes) quad_bytes = NULL;
|
||||||
g_autoptr(GBytes) hdcp_bytes = NULL;
|
g_autoptr(GBytes) hdcp_bytes = NULL;
|
||||||
@ -548,10 +688,10 @@ fu_dell_dock_mst_stop_esm(FuDevice *proxy, GError **error)
|
|||||||
guint8 data_out[sizeof(guint32)];
|
guint8 data_out[sizeof(guint32)];
|
||||||
|
|
||||||
/* disable ESM first */
|
/* disable ESM first */
|
||||||
if (!fu_dell_dock_mst_rc_command(proxy,
|
if (!fu_dell_dock_mst_rc_command(device,
|
||||||
MST_CMD_WRITE_MEMORY,
|
MST_CMD_WRITE_MEMORY,
|
||||||
length,
|
length,
|
||||||
MST_RC_TRIGGER_ADDR,
|
PANAMERA_MST_RC_TRIGGER_ADDR,
|
||||||
(guint8 *)&payload,
|
(guint8 *)&payload,
|
||||||
error))
|
error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -560,47 +700,55 @@ fu_dell_dock_mst_stop_esm(FuDevice *proxy, GError **error)
|
|||||||
g_usleep(200);
|
g_usleep(200);
|
||||||
|
|
||||||
/* disable QUAD mode */
|
/* disable QUAD mode */
|
||||||
if (!fu_dell_dock_mst_rc_command(proxy,
|
if (!fu_dell_dock_mst_rc_command(device,
|
||||||
MST_CMD_READ_MEMORY,
|
MST_CMD_READ_MEMORY,
|
||||||
length,
|
length,
|
||||||
MST_REG_QUAD_DISABLE,
|
PANAMERA_MST_REG_QUAD_DISABLE,
|
||||||
NULL,
|
NULL,
|
||||||
error))
|
error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (!fu_dell_dock_mst_read_register(proxy, MST_RC_DATA_ADDR, length, &quad_bytes, error))
|
if (!fu_dell_dock_mst_read_register(fu_device_get_proxy(device),
|
||||||
|
PANAMERA_MST_RC_DATA_ADDR,
|
||||||
|
length,
|
||||||
|
&quad_bytes,
|
||||||
|
error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
data = g_bytes_get_data(quad_bytes, &length);
|
data = g_bytes_get_data(quad_bytes, &length);
|
||||||
memcpy(data_out, data, length);
|
memcpy(data_out, data, length);
|
||||||
data_out[0] = 0x00;
|
data_out[0] = 0x00;
|
||||||
if (!fu_dell_dock_mst_rc_command(proxy,
|
if (!fu_dell_dock_mst_rc_command(device,
|
||||||
MST_CMD_WRITE_MEMORY,
|
MST_CMD_WRITE_MEMORY,
|
||||||
length,
|
length,
|
||||||
MST_REG_QUAD_DISABLE,
|
PANAMERA_MST_REG_QUAD_DISABLE,
|
||||||
data_out,
|
data_out,
|
||||||
error))
|
error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* disable HDCP2.2 */
|
/* disable HDCP2.2 */
|
||||||
if (!fu_dell_dock_mst_rc_command(proxy,
|
if (!fu_dell_dock_mst_rc_command(device,
|
||||||
MST_CMD_READ_MEMORY,
|
MST_CMD_READ_MEMORY,
|
||||||
length,
|
length,
|
||||||
MST_REG_HDCP22_DISABLE,
|
PANAMERA_MST_REG_HDCP22_DISABLE,
|
||||||
NULL,
|
NULL,
|
||||||
error))
|
error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (!fu_dell_dock_mst_read_register(proxy, MST_RC_DATA_ADDR, length, &hdcp_bytes, error))
|
if (!fu_dell_dock_mst_read_register(fu_device_get_proxy(device),
|
||||||
|
PANAMERA_MST_RC_DATA_ADDR,
|
||||||
|
length,
|
||||||
|
&hdcp_bytes,
|
||||||
|
error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
data = g_bytes_get_data(hdcp_bytes, &length);
|
data = g_bytes_get_data(hdcp_bytes, &length);
|
||||||
memcpy(data_out, data, length);
|
memcpy(data_out, data, length);
|
||||||
data_out[0] = data[0] & (1 << 2);
|
data_out[0] = data[0] & (1 << 2);
|
||||||
if (!fu_dell_dock_mst_rc_command(proxy,
|
if (!fu_dell_dock_mst_rc_command(device,
|
||||||
MST_CMD_WRITE_MEMORY,
|
MST_CMD_WRITE_MEMORY,
|
||||||
length,
|
length,
|
||||||
MST_REG_HDCP22_DISABLE,
|
PANAMERA_MST_REG_HDCP22_DISABLE,
|
||||||
data_out,
|
data_out,
|
||||||
error))
|
error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -609,7 +757,7 @@ fu_dell_dock_mst_stop_esm(FuDevice *proxy, GError **error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
fu_dell_dock_mst_invalidate_bank(FuDevice *proxy, MSTBank bank_in_use, GError **error)
|
fu_dell_dock_mst_invalidate_bank(FuDevice *device, MSTBank bank_in_use, GError **error)
|
||||||
{
|
{
|
||||||
const MSTBankAttributes *attribs;
|
const MSTBankAttributes *attribs;
|
||||||
g_autoptr(GBytes) bytes = NULL;
|
g_autoptr(GBytes) bytes = NULL;
|
||||||
@ -626,11 +774,15 @@ fu_dell_dock_mst_invalidate_bank(FuDevice *proxy, MSTBank bank_in_use, GError **
|
|||||||
crc_offset = attribs->start + EEPROM_TAG_OFFSET + 12;
|
crc_offset = attribs->start + EEPROM_TAG_OFFSET + 12;
|
||||||
|
|
||||||
/* Read CRC byte to flip */
|
/* Read CRC byte to flip */
|
||||||
if (!fu_dell_dock_mst_rc_command(proxy, MST_CMD_READ_FLASH, 4, crc_offset, NULL, error)) {
|
if (!fu_dell_dock_mst_rc_command(device, MST_CMD_READ_FLASH, 4, crc_offset, NULL, error)) {
|
||||||
g_prefix_error(error, "failed to read tag from flash: ");
|
g_prefix_error(error, "failed to read tag from flash: ");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (!fu_dell_dock_mst_read_register(proxy, MST_RC_DATA_ADDR, 1, &bytes, error)) {
|
if (!fu_dell_dock_mst_read_register(fu_device_get_proxy(device),
|
||||||
|
PANAMERA_MST_RC_DATA_ADDR,
|
||||||
|
1,
|
||||||
|
&bytes,
|
||||||
|
error)) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
crc_tag = g_bytes_get_data(bytes, NULL);
|
crc_tag = g_bytes_get_data(bytes, NULL);
|
||||||
@ -646,7 +798,7 @@ fu_dell_dock_mst_invalidate_bank(FuDevice *proxy, MSTBank bank_in_use, GError **
|
|||||||
sector,
|
sector,
|
||||||
bank_in_use);
|
bank_in_use);
|
||||||
/* offset for last 4k of bank# */
|
/* offset for last 4k of bank# */
|
||||||
if (!fu_dell_dock_mst_rc_command(proxy,
|
if (!fu_dell_dock_mst_rc_command(device,
|
||||||
MST_CMD_ERASE_FLASH,
|
MST_CMD_ERASE_FLASH,
|
||||||
4,
|
4,
|
||||||
0,
|
0,
|
||||||
@ -661,7 +813,7 @@ fu_dell_dock_mst_invalidate_bank(FuDevice *proxy, MSTBank bank_in_use, GError **
|
|||||||
g_debug("Writing 0x00 byte to 0x%x to invalidate bank %u",
|
g_debug("Writing 0x00 byte to 0x%x to invalidate bank %u",
|
||||||
crc_offset,
|
crc_offset,
|
||||||
bank_in_use);
|
bank_in_use);
|
||||||
if (!fu_dell_dock_mst_rc_command(proxy,
|
if (!fu_dell_dock_mst_rc_command(device,
|
||||||
MST_CMD_WRITE_FLASH,
|
MST_CMD_WRITE_FLASH,
|
||||||
4,
|
4,
|
||||||
crc_offset,
|
crc_offset,
|
||||||
@ -672,7 +824,7 @@ fu_dell_dock_mst_invalidate_bank(FuDevice *proxy, MSTBank bank_in_use, GError **
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* re-read for comparison */
|
/* re-read for comparison */
|
||||||
if (!fu_dell_dock_mst_rc_command(proxy,
|
if (!fu_dell_dock_mst_rc_command(device,
|
||||||
MST_CMD_READ_FLASH,
|
MST_CMD_READ_FLASH,
|
||||||
4,
|
4,
|
||||||
crc_offset,
|
crc_offset,
|
||||||
@ -681,8 +833,8 @@ fu_dell_dock_mst_invalidate_bank(FuDevice *proxy, MSTBank bank_in_use, GError **
|
|||||||
g_prefix_error(error, "failed to read tag from flash: ");
|
g_prefix_error(error, "failed to read tag from flash: ");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (!fu_dell_dock_mst_read_register(proxy,
|
if (!fu_dell_dock_mst_read_register(fu_device_get_proxy(device),
|
||||||
MST_RC_DATA_ADDR,
|
PANAMERA_MST_RC_DATA_ADDR,
|
||||||
4,
|
4,
|
||||||
&bytes_new,
|
&bytes_new,
|
||||||
error)) {
|
error)) {
|
||||||
@ -727,7 +879,7 @@ fu_dell_dock_mst_write_bank(FuDevice *device,
|
|||||||
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_WRITE, 84);
|
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_WRITE, 84);
|
||||||
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_VERIFY, 1);
|
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_VERIFY, 1);
|
||||||
|
|
||||||
if (!fu_dell_dock_mst_erase_bank(fu_device_get_proxy(device), bank, error))
|
if (!fu_dell_dock_mst_erase_panamera_bank(device, bank, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
fu_progress_step_done(progress);
|
fu_progress_step_done(progress);
|
||||||
|
|
||||||
@ -739,11 +891,7 @@ fu_dell_dock_mst_write_bank(FuDevice *device,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
fu_progress_step_done(progress);
|
fu_progress_step_done(progress);
|
||||||
|
|
||||||
if (!fu_dell_dock_mst_checksum_bank(fu_device_get_proxy(device),
|
if (!fu_dell_dock_mst_checksum_bank(device, fw, bank, &checksum, error))
|
||||||
fw,
|
|
||||||
bank,
|
|
||||||
&checksum,
|
|
||||||
error))
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (!checksum) {
|
if (!checksum) {
|
||||||
g_debug("MST: Failed to verify checksum on bank %u", bank);
|
g_debug("MST: Failed to verify checksum on bank %u", bank);
|
||||||
@ -761,83 +909,49 @@ fu_dell_dock_mst_write_bank(FuDevice *device,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static FuProgress *
|
||||||
fu_dell_dock_mst_write_fw(FuDevice *device,
|
fu_dell_dock_mst_set_local_progress(FuProgress *progress, guint steps)
|
||||||
FuFirmware *firmware,
|
|
||||||
FuProgress *progress,
|
|
||||||
FwupdInstallFlags flags,
|
|
||||||
GError **error)
|
|
||||||
{
|
{
|
||||||
FuDellDockMst *self = FU_DELL_DOCK_MST(device);
|
|
||||||
FuProgress *progress_local;
|
FuProgress *progress_local;
|
||||||
MSTBank bank_in_use = 0;
|
progress_local = fu_progress_get_child(progress);
|
||||||
|
fu_progress_set_id(progress_local, G_STRLOC);
|
||||||
|
fu_progress_set_steps(progress_local, steps);
|
||||||
|
|
||||||
|
return progress_local;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
fu_dell_dock_mst_write_panamera(FuDevice *device,
|
||||||
|
GBytes *fw,
|
||||||
|
FwupdInstallFlags flags,
|
||||||
|
FuProgress *progress,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
gboolean checksum = FALSE;
|
gboolean checksum = FALSE;
|
||||||
|
MSTBank bank_in_use = 0;
|
||||||
guint8 order[2] = {ESM, Bank0};
|
guint8 order[2] = {ESM, Bank0};
|
||||||
guint16 chip_id;
|
FuProgress *progress_local;
|
||||||
const guint8 *data;
|
|
||||||
g_autofree gchar *dynamic_version = NULL;
|
|
||||||
g_autoptr(GBytes) fw = NULL;
|
|
||||||
|
|
||||||
g_return_val_if_fail(device != NULL, FALSE);
|
|
||||||
g_return_val_if_fail(FU_IS_FIRMWARE(firmware), FALSE);
|
|
||||||
g_return_val_if_fail(fu_device_get_proxy(device) != NULL, FALSE);
|
|
||||||
|
|
||||||
/* progress */
|
|
||||||
fu_progress_set_id(progress, G_STRLOC);
|
fu_progress_set_id(progress, G_STRLOC);
|
||||||
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_BUSY, 1); /* enable */
|
fu_progress_add_flag(progress, FU_PROGRESS_FLAG_GUESSED);
|
||||||
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_WRITE, 99);
|
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_BUSY, 10); /* stop esm */
|
||||||
|
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_WRITE, 90);
|
||||||
/* get default image */
|
|
||||||
fw = fu_firmware_get_bytes(firmware, error);
|
|
||||||
if (fw == NULL)
|
|
||||||
return FALSE;
|
|
||||||
data = g_bytes_get_data(fw, NULL);
|
|
||||||
|
|
||||||
dynamic_version = g_strdup_printf("%02x.%02x.%02x",
|
|
||||||
data[self->blob_major_offset],
|
|
||||||
data[self->blob_minor_offset],
|
|
||||||
data[self->blob_build_offset]);
|
|
||||||
g_debug("writing MST firmware version %s", dynamic_version);
|
|
||||||
|
|
||||||
/* determine the flash order */
|
/* determine the flash order */
|
||||||
if (!fu_dell_dock_mst_query_active_bank(fu_device_get_proxy(device), &bank_in_use, error))
|
if (!fu_dell_dock_mst_query_active_bank(fu_device_get_proxy(device), &bank_in_use, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (bank_in_use == Bank0)
|
if (bank_in_use == Bank0)
|
||||||
order[1] = Bank1;
|
order[1] = Bank1;
|
||||||
|
|
||||||
/* enable remote control */
|
|
||||||
if (!fu_dell_dock_mst_enable_remote_control(fu_device_get_proxy(device), error))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
/* Read Synaptics MST chip ID */
|
|
||||||
if (!fu_dell_dock_mst_read_chipid(fu_device_get_proxy(device), &chip_id, error))
|
|
||||||
return FALSE;
|
|
||||||
if (chip_id != EXPECTED_CHIPID) {
|
|
||||||
g_set_error(error,
|
|
||||||
G_IO_ERROR,
|
|
||||||
G_IO_ERROR_FAILED,
|
|
||||||
"Unknown MST chip found %x",
|
|
||||||
chip_id);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ESM needs special handling during flash process*/
|
/* ESM needs special handling during flash process*/
|
||||||
if (!fu_dell_dock_mst_stop_esm(fu_device_get_proxy(device), error))
|
if (!fu_dell_dock_mst_stop_esm(device, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
fu_progress_step_done(progress);
|
fu_progress_step_done(progress);
|
||||||
|
|
||||||
|
progress_local = fu_dell_dock_mst_set_local_progress(progress, 2);
|
||||||
/* Write each bank in order */
|
/* Write each bank in order */
|
||||||
progress_local = fu_progress_get_child(progress);
|
|
||||||
fu_progress_set_id(progress_local, G_STRLOC);
|
|
||||||
fu_progress_set_steps(progress_local, 2);
|
|
||||||
for (guint phase = 0; phase < 2; phase++) {
|
for (guint phase = 0; phase < 2; phase++) {
|
||||||
g_debug("MST: Checking bank %u", order[phase]);
|
g_debug("MST: Checking bank %u", order[phase]);
|
||||||
if (!fu_dell_dock_mst_checksum_bank(fu_device_get_proxy(device),
|
if (!fu_dell_dock_mst_checksum_bank(device, fw, order[phase], &checksum, error))
|
||||||
fw,
|
|
||||||
order[phase],
|
|
||||||
&checksum,
|
|
||||||
error))
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (checksum) {
|
if (checksum) {
|
||||||
g_debug("MST: bank %u is already up to date", order[phase]);
|
g_debug("MST: bank %u is already up to date", order[phase]);
|
||||||
@ -854,18 +968,127 @@ fu_dell_dock_mst_write_fw(FuDevice *device,
|
|||||||
fu_progress_step_done(progress_local);
|
fu_progress_step_done(progress_local);
|
||||||
}
|
}
|
||||||
/* invalidate the previous bank */
|
/* invalidate the previous bank */
|
||||||
if (!fu_dell_dock_mst_invalidate_bank(fu_device_get_proxy(device), bank_in_use, error)) {
|
if (!fu_dell_dock_mst_invalidate_bank(device, bank_in_use, error)) {
|
||||||
g_prefix_error(error, "failed to invalidate bank %u: ", bank_in_use);
|
g_prefix_error(error, "failed to invalidate bank %u: ", bank_in_use);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
fu_progress_step_done(progress);
|
fu_progress_step_done(progress);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
fu_dell_dock_mst_write_cayenne(FuDevice *device,
|
||||||
|
GBytes *fw,
|
||||||
|
FwupdInstallFlags flags,
|
||||||
|
FuProgress *progress,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
gboolean checksum = FALSE;
|
||||||
|
guint retries = 2;
|
||||||
|
|
||||||
|
fu_progress_set_id(progress, G_STRLOC);
|
||||||
|
fu_progress_add_flag(progress, FU_PROGRESS_FLAG_GUESSED);
|
||||||
|
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_ERASE, 15); /* erase */
|
||||||
|
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_WRITE, 90);
|
||||||
|
|
||||||
|
for (guint i = 0; i < retries; i++) {
|
||||||
|
if (!fu_dell_dock_mst_erase_cayenne(device, error))
|
||||||
|
return FALSE;
|
||||||
|
fu_progress_step_done(progress);
|
||||||
|
if (!fu_dell_dock_write_flash_bank(device,
|
||||||
|
fw,
|
||||||
|
Cayenne,
|
||||||
|
fu_progress_get_child(progress),
|
||||||
|
error))
|
||||||
|
return FALSE;
|
||||||
|
if (!fu_dell_dock_mst_checksum_bank(device, fw, Cayenne, &checksum, error))
|
||||||
|
return FALSE;
|
||||||
|
fu_progress_step_done(progress);
|
||||||
|
if (!checksum) {
|
||||||
|
g_debug("MST: Failed to verify checksum");
|
||||||
|
fu_progress_reset(progress);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* failed after all our retries */
|
||||||
|
if (!checksum) {
|
||||||
|
g_set_error(error, G_IO_ERROR, G_IO_ERROR_FAILED, "Failed to write to bank");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
/* activate the FW */
|
||||||
|
if (!fu_dell_dock_mst_rc_command(device,
|
||||||
|
MST_CMD_ACTIVATE_FW,
|
||||||
|
g_bytes_get_size(fw),
|
||||||
|
0x0,
|
||||||
|
NULL,
|
||||||
|
error)) {
|
||||||
|
g_prefix_error(error, "Failed to activate FW: ");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
fu_dell_dock_mst_write_fw(FuDevice *device,
|
||||||
|
FuFirmware *firmware,
|
||||||
|
FuProgress *progress,
|
||||||
|
FwupdInstallFlags flags,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
FuDellDockMst *self = FU_DELL_DOCK_MST(device);
|
||||||
|
const guint8 *data;
|
||||||
|
g_autofree gchar *dynamic_version = NULL;
|
||||||
|
g_autoptr(GBytes) fw = NULL;
|
||||||
|
MSTType type;
|
||||||
|
|
||||||
|
g_return_val_if_fail(device != NULL, FALSE);
|
||||||
|
g_return_val_if_fail(FU_IS_FIRMWARE(firmware), FALSE);
|
||||||
|
g_return_val_if_fail(fu_device_get_proxy(device) != NULL, FALSE);
|
||||||
|
|
||||||
|
/* open the hub*/
|
||||||
|
if (!fu_device_open(fu_device_get_proxy(device), error))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
/* open up access to controller bus */
|
||||||
|
if (!fu_dell_dock_set_power(device, self->unlock_target, TRUE, error))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
/* get default image */
|
||||||
|
fw = fu_firmware_get_bytes(firmware, error);
|
||||||
|
if (fw == NULL)
|
||||||
|
return FALSE;
|
||||||
|
data = g_bytes_get_data(fw, NULL);
|
||||||
|
|
||||||
|
dynamic_version = g_strdup_printf("%02x.%02x.%02x",
|
||||||
|
data[self->blob_major_offset],
|
||||||
|
data[self->blob_minor_offset],
|
||||||
|
data[self->blob_build_offset]);
|
||||||
|
g_debug("writing MST firmware version %s", dynamic_version);
|
||||||
|
|
||||||
|
/* enable remote control */
|
||||||
|
if (!fu_dell_dock_mst_enable_remote_control(device, error))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
type = fu_dell_dock_mst_check_type(device);
|
||||||
|
if (type == Panamera_mst) {
|
||||||
|
if (!fu_dell_dock_mst_write_panamera(device, fw, flags, progress, error))
|
||||||
|
return FALSE;
|
||||||
|
} else if (type == Cayenne_mst) {
|
||||||
|
if (!fu_dell_dock_mst_write_cayenne(device, fw, flags, progress, error))
|
||||||
|
return FALSE;
|
||||||
|
} else {
|
||||||
|
g_set_error(error, FWUPD_ERROR, FWUPD_ERROR_NOT_SUPPORTED, "Unknown mst found");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/* dock will reboot to re-read; this is to appease the daemon */
|
/* dock will reboot to re-read; this is to appease the daemon */
|
||||||
fu_device_set_version_format(device, FWUPD_VERSION_FORMAT_TRIPLET);
|
fu_device_set_version_format(device, FWUPD_VERSION_FORMAT_TRIPLET);
|
||||||
fu_device_set_version(device, dynamic_version);
|
fu_device_set_version(device, dynamic_version);
|
||||||
|
|
||||||
/* disable remote control now */
|
/* disable remote control now */
|
||||||
return fu_dell_dock_mst_disable_remote_control(fu_device_get_proxy(device), error);
|
return fu_dell_dock_mst_disable_remote_control(device, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -917,7 +1140,7 @@ fu_dell_dock_mst_setup(FuDevice *device, GError **error)
|
|||||||
const gchar *version;
|
const gchar *version;
|
||||||
|
|
||||||
/* sanity check that we can talk to MST */
|
/* sanity check that we can talk to MST */
|
||||||
if (!fu_d19_mst_check_fw(fu_device_get_proxy(device), error))
|
if (!fu_d19_mst_check_fw(device, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* set version from EC if we know it */
|
/* set version from EC if we know it */
|
||||||
@ -936,8 +1159,31 @@ fu_dell_dock_mst_setup(FuDevice *device, GError **error)
|
|||||||
static gboolean
|
static gboolean
|
||||||
fu_dell_dock_mst_probe(FuDevice *device, GError **error)
|
fu_dell_dock_mst_probe(FuDevice *device, GError **error)
|
||||||
{
|
{
|
||||||
|
MSTType type;
|
||||||
|
FuDellDockMst *self = FU_DELL_DOCK_MST(device);
|
||||||
|
|
||||||
fu_device_set_logical_id(FU_DEVICE(device), "mst");
|
fu_device_set_logical_id(FU_DEVICE(device), "mst");
|
||||||
|
|
||||||
|
/* confige mst register via instance id*/
|
||||||
|
type = fu_dell_dock_mst_check_type(device);
|
||||||
|
switch (type) {
|
||||||
|
case Cayenne_mst:
|
||||||
|
self->mst_rc_trigger_addr = CAYENNE_MST_RC_TRIGGER_ADDR;
|
||||||
|
self->mst_rc_command_addr = CAYENNE_MST_RC_COMMAND_ADDR;
|
||||||
|
self->mst_rc_data_addr = CAYENNE_MST_RC_DATA_ADDR;
|
||||||
|
self->mst_core_mcu_bootloader_addr = CAYENNE_MST_CORE_MCU_BOOTLOADER_STS;
|
||||||
|
return TRUE;
|
||||||
|
case Panamera_mst:
|
||||||
|
self->mst_rc_trigger_addr = PANAMERA_MST_RC_TRIGGER_ADDR;
|
||||||
|
self->mst_rc_command_addr = PANAMERA_MST_RC_COMMAND_ADDR;
|
||||||
|
self->mst_rc_data_addr = PANAMERA_MST_RC_DATA_ADDR;
|
||||||
|
self->mst_core_mcu_bootloader_addr = PANAMERA_MST_CORE_MCU_BOOTLOADER_STS;
|
||||||
|
return TRUE;
|
||||||
|
case Unknown:
|
||||||
|
default:
|
||||||
|
g_set_error(error, FWUPD_ERROR, FWUPD_ERROR_NOT_SUPPORTED, "Unknown mst found");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +75,10 @@ fu_plugin_dell_dock_probe(FuPlugin *plugin, FuDevice *proxy, GError **error)
|
|||||||
|
|
||||||
/* create mst endpoint */
|
/* create mst endpoint */
|
||||||
mst_device = fu_dell_dock_mst_new();
|
mst_device = fu_dell_dock_mst_new();
|
||||||
instance = DELL_DOCK_VM5331_INSTANCE_ID;
|
if (fu_dell_dock_get_ec_type(FU_DEVICE(ec_device)) == ATOMIC_BASE)
|
||||||
|
instance = DELL_DOCK_VMM6210_INSTANCE_ID;
|
||||||
|
else
|
||||||
|
instance = DELL_DOCK_VM5331_INSTANCE_ID;
|
||||||
fu_device_set_context(FU_DEVICE(mst_device), ctx);
|
fu_device_set_context(FU_DEVICE(mst_device), ctx);
|
||||||
fu_device_add_guid(FU_DEVICE(mst_device), fwupd_guid_hash_string(instance));
|
fu_device_add_guid(FU_DEVICE(mst_device), fwupd_guid_hash_string(instance));
|
||||||
fu_device_add_child(FU_DEVICE(ec_device), FU_DEVICE(mst_device));
|
fu_device_add_child(FU_DEVICE(ec_device), FU_DEVICE(mst_device));
|
||||||
@ -85,7 +88,9 @@ fu_plugin_dell_dock_probe(FuPlugin *plugin, FuDevice *proxy, GError **error)
|
|||||||
|
|
||||||
/* create package version endpoint */
|
/* create package version endpoint */
|
||||||
status_device = fu_dell_dock_status_new();
|
status_device = fu_dell_dock_status_new();
|
||||||
if (fu_dell_dock_module_is_usb4(FU_DEVICE(ec_device)))
|
if (fu_dell_dock_get_ec_type(FU_DEVICE(ec_device)) == ATOMIC_BASE)
|
||||||
|
instance = DELL_DOCK_ATOMIC_STATUS_INSTANCE_ID;
|
||||||
|
else if (fu_dell_dock_module_is_usb4(FU_DEVICE(ec_device)))
|
||||||
instance = DELL_DOCK_DOCK2_INSTANCE_ID;
|
instance = DELL_DOCK_DOCK2_INSTANCE_ID;
|
||||||
else
|
else
|
||||||
instance = DELL_DOCK_DOCK1_INSTANCE_ID;
|
instance = DELL_DOCK_DOCK1_INSTANCE_ID;
|
||||||
@ -104,18 +109,36 @@ fu_plugin_dell_dock_probe(FuPlugin *plugin, FuDevice *proxy, GError **error)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* lastly add instance IDs for hub */
|
|
||||||
fu_dell_dock_hub_add_instance(proxy);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* prefer to use EC if in the transaction and parent if it is not */
|
||||||
|
static FuDevice *
|
||||||
|
fu_plugin_dell_dock_get_ec(GPtrArray *devices)
|
||||||
|
{
|
||||||
|
FuDevice *ec_parent = NULL;
|
||||||
|
for (gint i = devices->len - 1; i >= 0; i--) {
|
||||||
|
FuDevice *dev = g_ptr_array_index(devices, i);
|
||||||
|
FuDevice *parent;
|
||||||
|
if (FU_IS_DELL_DOCK_EC(dev))
|
||||||
|
return dev;
|
||||||
|
parent = fu_device_get_parent(dev);
|
||||||
|
if (parent != NULL && FU_IS_DELL_DOCK_EC(parent))
|
||||||
|
ec_parent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ec_parent;
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
fu_plugin_backend_device_added(FuPlugin *plugin, FuDevice *device, GError **error)
|
fu_plugin_backend_device_added(FuPlugin *plugin, FuDevice *device, GError **error)
|
||||||
{
|
{
|
||||||
g_autoptr(FuDeviceLocker) locker = NULL;
|
g_autoptr(FuDeviceLocker) locker = NULL;
|
||||||
g_autoptr(FuDellDockHub) hub = NULL;
|
g_autoptr(FuDellDockHub) hub = NULL;
|
||||||
const gchar *key = NULL;
|
const gchar *key = NULL;
|
||||||
|
GPtrArray *devices;
|
||||||
|
FuDevice *ec_device;
|
||||||
|
guint8 ec_type;
|
||||||
|
|
||||||
/* not interesting */
|
/* not interesting */
|
||||||
if (!FU_IS_USB_DEVICE(device))
|
if (!FU_IS_USB_DEVICE(device))
|
||||||
@ -150,6 +173,13 @@ fu_plugin_backend_device_added(FuPlugin *plugin, FuDevice *device, GError **erro
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
fu_plugin_cache_add(plugin, key, FU_DEVICE(hub));
|
fu_plugin_cache_add(plugin, key, FU_DEVICE(hub));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* add hub instance id after ec probed */
|
||||||
|
devices = fu_plugin_get_devices(plugin);
|
||||||
|
ec_device = fu_plugin_dell_dock_get_ec(devices);
|
||||||
|
ec_type = fu_dell_dock_get_ec_type(ec_device);
|
||||||
|
fu_dell_dock_hub_add_instance(FU_DEVICE(hub), ec_type);
|
||||||
|
|
||||||
fu_plugin_device_add(plugin, FU_DEVICE(hub));
|
fu_plugin_device_add(plugin, FU_DEVICE(hub));
|
||||||
|
|
||||||
/* clear updatable flag if parent doesn't have it */
|
/* clear updatable flag if parent doesn't have it */
|
||||||
@ -233,24 +263,6 @@ fu_plugin_backend_device_removed(FuPlugin *plugin, FuDevice *device, GError **er
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* prefer to use EC if in the transaction and parent if it is not */
|
|
||||||
static FuDevice *
|
|
||||||
fu_plugin_dell_dock_get_ec(GPtrArray *devices)
|
|
||||||
{
|
|
||||||
FuDevice *ec_parent = NULL;
|
|
||||||
for (guint i = 0; i < devices->len; i++) {
|
|
||||||
FuDevice *dev = g_ptr_array_index(devices, i);
|
|
||||||
FuDevice *parent;
|
|
||||||
if (FU_IS_DELL_DOCK_EC(dev))
|
|
||||||
return dev;
|
|
||||||
parent = fu_device_get_parent(dev);
|
|
||||||
if (parent != NULL && FU_IS_DELL_DOCK_EC(parent))
|
|
||||||
ec_parent = parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ec_parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
fu_plugin_composite_prepare(FuPlugin *plugin, GPtrArray *devices, GError **error)
|
fu_plugin_composite_prepare(FuPlugin *plugin, GPtrArray *devices, GError **error)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user