Use the CFI manufacturer ID to set the vendor

This commit is contained in:
Richard Hughes 2022-03-31 13:29:32 +01:00
parent ea9dd851af
commit 356bd2fa5e
2 changed files with 146 additions and 63 deletions

View File

@ -1,8 +1,35 @@
[CFI\FLASHID_3730] # No Manufacturer
Name = A25Lxxx [CFI\FLASHID_0020]
CfiDeviceCmdChipErase = 0xc7 Name = M25PxxA/xx
CfiDeviceCmdChipErase = 0xC7
CfiDeviceCmdSectorErase = 0x00
[CFI\FLASHID_00BF]
Name = PCT/SST25VFxxx/xxxA
CfiDeviceCmdReadId = 0x90
CfiDeviceCmdChipErase = 0x60
CfiDeviceCmdSectorErase = 0x20
[CFI\FLASHID_009D]
Name = PM25LDxxx
CfiDeviceCmdReadId = 0x90
CfiDeviceCmdChipErase = 0xC7
CfiDeviceCmdSectorErase = 0xD7
[CFI\FLASHID_009D]
Name = PM25LVxxx
CfiDeviceCmdReadId = 0xAB
CfiDeviceCmdChipErase = 0xC7
CfiDeviceCmdSectorErase = 0xD7
[CFI\FLASHID_00EF]
Name = W25XxxBV/W25XxxCL
CfiDeviceCmdChipErase = 0xC7
CfiDeviceCmdSectorErase = 0x20 CfiDeviceCmdSectorErase = 0x20
# Fujitsu
[CFI\FLASHID_04]
Vendor = Fujitsu
# Atmel
[CFI\FLASHID_1F]
Vendor = Atmel
[CFI\FLASHID_1F65] [CFI\FLASHID_1F65]
Name = AT25F512A/B Name = AT25F512A/B
CfiDeviceCmdReadId = 0x15 CfiDeviceCmdReadId = 0x15
@ -10,65 +37,123 @@ CfiDeviceCmdChipErase = 0x62
CfiDeviceCmdSectorErase = 0x00 CfiDeviceCmdSectorErase = 0x00
FirmwareSizeMax = 0x10000 FirmwareSizeMax = 0x10000
# EON
[CFI\FLASHID_1C]
Vendor = EON
[CFI\FLASHID_1C31] [CFI\FLASHID_1C31]
Name = EN25Fxx Name = EN25Fxx
CfiDeviceCmdChipErase = 0x60 CfiDeviceCmdChipErase = 0x60
CfiDeviceCmdSectorErase = 0x20 CfiDeviceCmdSectorErase = 0x20
[CFI\FLASHID_C840] # ST
Name = GD25Qxxx [CFI\FLASHID_20]
CfiDeviceCmdChipErase = 0xC7 Vendor = ST
# Catalyst
[CFI\FLASHID_31]
Vendor = Catalyst
# AMIC
[CFI\FLASHID_37]
Vendor = AMIC
[CFI\FLASHID_3730]
Name = A25Lxxx
CfiDeviceCmdChipErase = 0xc7
CfiDeviceCmdSectorErase = 0x20 CfiDeviceCmdSectorErase = 0x20
[CFI\FLASHID_0020] # SyncMOS
Name = M25PxxA/xx [CFI\FLASHID_40]
CfiDeviceCmdChipErase = 0xC7 Vendor = SyncMOS
CfiDeviceCmdSectorErase = 0x00
# ESI
[CFI\FLASHID_4A]
Vendor = ESI
# Alliance
[CFI\FLASHID_52]
Vendor = Alliance
# Tenx
[CFI\FLASHID_5E]
Vendor = Tenx
# Sanyo
[CFI\FLASHID_62]
Vendor = Sanyo
# AMIC
[CFI\FLASHID_7F]
Vendor = AMIC
[CFI\FLASHID_7F9D21]
Name = A49LF040A
FirmwareSizeMax = 0x20000
[CFI\FLASHID_89]
Vendor = Intel
# Elite
[CFI\FLASHID_8C]
Vendor = Elite
# Texas Instruments
[CFI\FLASHID_97]
Vendor = Texas Instruments
# PMC
[CFI\FLASHID_9D]
Vendor = PMC
# Fudan
[CFI\FLASHID_A1]
Vendor = Fudan
# Hyundai
[CFI\FLASHID_AD]
Vendor = Hyundai
# Sharp
[CFI\FLASHID_B0]
Vendor = Sharp
# SST
[CFI\FLASHID_BF]
Vendor = SST
# Macronix
[CFI\FLASHID_C2]
Vendor = Macronix
[CFI\FLASHID_C220] [CFI\FLASHID_C220]
Name = MX25Lxxx/xxxC/xxxE Name = MX25Lxxx/xxxC/xxxE
CfiDeviceCmdChipErase = 0x60 CfiDeviceCmdChipErase = 0x60
CfiDeviceCmdSectorErase = 0x20 CfiDeviceCmdSectorErase = 0x20
[CFI\FLASHID_C222] [CFI\FLASHID_C222]
Name = MX25Lxxx1E Name = MX25Lxxx1E
CfiDeviceCmdChipErase = 0x60 CfiDeviceCmdChipErase = 0x60
CfiDeviceCmdSectorErase = 0x20 CfiDeviceCmdSectorErase = 0x20
[CFI\FLASHID_00BF] # GigaDevice
Name = PCT/SST25VFxxx/xxxA [CFI\FLASHID_C8]
CfiDeviceCmdReadId = 0x90 Vendor = GigaDevice
CfiDeviceCmdChipErase = 0x60 [CFI\FLASHID_C840]
CfiDeviceCmdSectorErase = 0x20 Name = GD25Qxxx
[CFI\FLASHID_009D]
Name = PM25LDxxx
CfiDeviceCmdReadId = 0x90
CfiDeviceCmdChipErase = 0xC7
CfiDeviceCmdSectorErase = 0xD7
[CFI\FLASHID_009D]
Name = PM25LVxxx
CfiDeviceCmdReadId = 0xAB
CfiDeviceCmdChipErase = 0xC7
CfiDeviceCmdSectorErase = 0xD7
[CFI\FLASHID_00EF]
Name = W25XxxBV/W25XxxCL
CfiDeviceCmdChipErase = 0xC7 CfiDeviceCmdChipErase = 0xC7
CfiDeviceCmdSectorErase = 0x20 CfiDeviceCmdSectorErase = 0x20
#[CFI\FLASHID_XXXX] # Nantronics
#Name = FM25Fxxx [CFI\FLASHID_D5]
#CfiDeviceCmdChipErase = 0xC7 Vendor = Nantronics
#CfiDeviceCmdSectorErase = 0x20
#[CFI\FLASHID_XXXX] # Winbond
#Name = KH25LxxxxE [CFI\FLASHID_DA]
#CfiDeviceCmdChipErase = 0x60 Vendor = Winbond
#CfiDeviceCmdSectorErase = 0x20
#[CFI\FLASHID_XXXX] # Winbond (ex Nexcom)
#Name = MX25Vxxx [CFI\FLASHID_EF]
#CfiDeviceCmdChipErase = 0x60 Vendor = Winbond
#CfiDeviceCmdSectorErase = 0x20 [CFI\FLASHID_EF4018]
Name = W25Q128
FirmwareSizeMax = 0x1000000
# Fidelix
[CFI\FLASHID_F8]
Vendor = Fidelix

View File

@ -169,36 +169,34 @@ fu_cfi_device_finalize(GObject *object)
G_OBJECT_CLASS(fu_cfi_device_parent_class)->finalize(object); G_OBJECT_CLASS(fu_cfi_device_parent_class)->finalize(object);
} }
/* returns at most 4 chars from the ID, or %NULL if no different from existing ID */
static gchar *
fu_cfi_device_get_flash_id_jedec(FuCfiDevice *self)
{
FuCfiDevicePrivate *priv = GET_PRIVATE(self);
if (priv->flash_id == NULL)
return NULL;
if (strlen(priv->flash_id) <= 4)
return NULL;
return g_strndup(priv->flash_id, 4);
}
static gboolean static gboolean
fu_cfi_device_setup(FuDevice *device, GError **error) fu_cfi_device_setup(FuDevice *device, GError **error)
{ {
gsize flash_idsz = 0;
FuCfiDevice *self = FU_CFI_DEVICE(device); FuCfiDevice *self = FU_CFI_DEVICE(device);
FuCfiDevicePrivate *priv = GET_PRIVATE(self); FuCfiDevicePrivate *priv = GET_PRIVATE(self);
g_autofree gchar *flash_id_jedec = NULL;
/* least specific so adding first */ /* sanity check */
flash_id_jedec = fu_cfi_device_get_flash_id_jedec(self); if (priv->flash_id != NULL)
if (flash_id_jedec != NULL) { flash_idsz = strlen(priv->flash_id);
fu_device_add_instance_str(device, "FLASHID", flash_id_jedec); if (flash_idsz == 0 || flash_idsz % 2 != 0) {
g_set_error_literal(error,
G_IO_ERROR,
G_IO_ERROR_NOT_SUPPORTED,
"not a valid flash-id");
return FALSE;
}
/* typically this will add quirk strings of 2, 4, then 6 bytes */
for (guint i = 0; i < flash_idsz; i += 2) {
g_autofree gchar *flash_id = g_strndup(priv->flash_id, i + 2);
fu_device_add_instance_str(device, "FLASHID", flash_id);
if (!fu_device_build_instance_id_quirk(device, error, "CFI", "FLASHID", NULL)) if (!fu_device_build_instance_id_quirk(device, error, "CFI", "FLASHID", NULL))
return FALSE; return FALSE;
} }
/* this is most specific and can override */ /* success */
fu_device_add_instance_str(device, "FLASHID", priv->flash_id); return TRUE;
return fu_device_build_instance_id_quirk(device, error, "CFI", "FLASHID", NULL);
} }
/** /**