dfu: Support ihex files with leading comments

Also look for the EOF in the file.
This commit is contained in:
Richard Hughes 2019-01-22 09:53:17 +00:00
parent 650eea91ee
commit f6a6fe8ec5

View File

@ -33,9 +33,17 @@ dfu_firmware_detect_ihex (GBytes *bytes)
data = (guint8 *) g_bytes_get_data (bytes, &len);
if (len < 12)
return DFU_FIRMWARE_FORMAT_UNKNOWN;
if (data[0] != ':')
return DFU_FIRMWARE_FORMAT_UNKNOWN;
return DFU_FIRMWARE_FORMAT_INTEL_HEX;
/* match the first char */
if (data[0] == ':')
return DFU_FIRMWARE_FORMAT_INTEL_HEX;
/* look for the EOF line */
if (g_strstr_len ((const gchar *) data, (gssize) len, ":000000") != NULL)
return DFU_FIRMWARE_FORMAT_INTEL_HEX;
/* failed */
return DFU_FIRMWARE_FORMAT_UNKNOWN;
}
#define DFU_INHX32_RECORD_TYPE_DATA 0x00