blob: 33330f20bceb265bb9bc82a6e273e89f1b0c8b2b [file] [log] [blame]
Andrew Duggan4e811252014-04-03 15:17:57 -07001#include "updateutil.h"
2
3const char *update_error_str[] = {
4 "success", // UPDATE_SUCCESS
5 "failed", // UPDATE_FAIL
6 "timeout", // UPDATE_FAIL_TIMEOUT
7 "invalid firmware image", // UPDATE_FAIL_VERIFY_IMAGE
8 "checksum does not match image", // UPDATE_FAIL_VERIFY_CHECKSUM
9 "image firmware size does not match device", // UPDATE_FAIL_VERIFY_FIRMWARE_SIZE
10 "image config size does not match device", // UPDATE_FAIL_VERIFY_CONFIG_SIZE
11 "image version is unsupported", // UPDATE_FAIL_UNSUPPORTED_IMAGE_VERSION
12 "failed to find F01 on device", // UPDATE_FAIL_NO_FUNCTION_01
13 "failed to find F34 on device", // UPDATE_FAIL_NO_FUNCTION_34
14 "failed to query the basic properties in F01", // UPDATE_FAIL_QUERY_BASIC_PROPERTIES
15 "failed to read F34 query registers", // UPDATE_FAIL_READ_F34_QUERIES
16 "failed to read the bootloader id", // UPDATE_FAIL_READ_BOOTLOADER_ID
17 "failed to read F34 control registers", // UPDATE_FAIL_READ_F34_CONTROLS
18 "failed to write the bootloader id", // UPDATE_FAIL_WRITE_BOOTLOADER_ID
19 "failed to enable flash programming", // UPDATE_FAIL_ENABLE_FLASH_PROGRAMMING
20 "failed to reach idle state", // UPDATE_FAIL_NOT_IN_IDLE_STATE
21 "programming is not enabled", // UPDATE_FAIL_PROGRAMMING_NOT_ENABLED
22 "failed to scan the PDT", // UPDATE_FAIL_SCAN_PDT
23 "failed to read the device status", // UPDATE_FAIL_READ_DEVICE_STATUS
24 "device not in the bootloader after enabling programming", // UPDATE_FAIL_DEVICE_NOT_IN_BOOTLOADER
25 "failed to read F01 control 0 register", // UPDATE_FAIL_READ_F01_CONTROL_0
26 "failed to write F01 control 0 register", // UPDATE_FAIL_WRITE_F01_CONTROL_0
27 "failed to write initial zeros", // UPDATE_FAIL_WRITE_INITIAL_ZEROS
28 "failed to write block", // UPDATE_FAIL_WRITE_BLOCK
29 "failed to write the flash command", // UPDATE_FAIL_WRITE_FLASH_COMMAND
30 "timeout waiting for idle", // UPDATE_FAIL_TIMEOUT_WAITING_FOR_IDLE
31 "failed to write erase all command", // UPDATE_FAIL_ERASE_ALL
32 "the firmware image is older then the firmware on the device", // UPDATE_FAIL_FIRMWARE_IMAGE_IS_OLDER
33 "invalid parameter", // UPDATE_FAIL_INVALID_PARAMETER
34 "failed to open firmware image file", // UPDATE_FAIL_OPEN_FIRMWARE_IMAGE
35};
36
37const char * update_err_to_string(int err)
38{
39 return update_error_str[err];
40}
41
42unsigned long extract_long(const unsigned char *data)
43{
44 return (unsigned long)data [0]
45 + (unsigned long)data [1] * 0x100
46 + (unsigned long)data [2] * 0x10000
47 + (unsigned long)data [3] * 0x1000000;
48}
49
50unsigned short extract_short(const unsigned char *data)
51{
52 return (unsigned long)data [0]
53 + (unsigned long)data [1] * 0x100;
54}