xref: /aosp_15_r20/external/rmi4utils/rmi4update/updateutil.cpp (revision a248dafd7653b99fc45f9d29e5f139b04f2f28bc)
1 /*
2  * Copyright (C) 2014 Andrew Duggan
3  * Copyright (C) 2014 Synaptics Inc
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #include <sys/types.h>
19 
20 #include "updateutil.h"
21 
22 const char *update_error_str[] = {
23 	"success",							// UPDATE_SUCCESS
24 	"failed",							// UPDATE_FAIL
25 	"timeout",							// UPDATE_FAIL_TIMEOUT
26 	"invalid firmware image",					// UPDATE_FAIL_VERIFY_IMAGE
27 	"checksum does not match image",				// UPDATE_FAIL_VERIFY_CHECKSUM
28 	"image firmware size does not match device",			// UPDATE_FAIL_VERIFY_FIRMWARE_SIZE
29 	"image config size does not match device",			// UPDATE_FAIL_VERIFY_CONFIG_SIZE
30 	"image product ID does not match device",			// UPDATE_FAIL_VERIFY_IMAGE_PRODUCTID_NOT_MATCH
31 	"image version is unsupported",					// UPDATE_FAIL_UNSUPPORTED_IMAGE_VERSION
32 	"failed to find F01 on device",					// UPDATE_FAIL_NO_FUNCTION_01
33 	"failed to find F34 on device",					// UPDATE_FAIL_NO_FUNCTION_34
34 	"failed to query the basic properties in F01",			// UPDATE_FAIL_QUERY_BASIC_PROPERTIES
35 	"failed to read F34 query registers",				// UPDATE_FAIL_READ_F34_QUERIES
36 	"failed to read the bootloader id",				// UPDATE_FAIL_READ_BOOTLOADER_ID
37 	"failed to read F34 control registers",				// UPDATE_FAIL_READ_F34_CONTROLS
38 	"failed to write the bootloader id",				// UPDATE_FAIL_WRITE_BOOTLOADER_ID
39 	"failed to enable flash programming",				// UPDATE_FAIL_ENABLE_FLASH_PROGRAMMING
40 	"failed to reach idle state",					// UPDATE_FAIL_NOT_IN_IDLE_STATE
41 	"programming is not enabled",					// UPDATE_FAIL_PROGRAMMING_NOT_ENABLED
42 	"failed to scan the PDT",					// UPDATE_FAIL_SCAN_PDT
43 	"failed to read the device status",				// UPDATE_FAIL_READ_DEVICE_STATUS
44 	"device not in the bootloader after enabling programming",	// UPDATE_FAIL_DEVICE_NOT_IN_BOOTLOADER
45 	"failed to read F01 control 0 register",			// UPDATE_FAIL_READ_F01_CONTROL_0
46 	"failed to write F01 control 0 register",			// UPDATE_FAIL_WRITE_F01_CONTROL_0
47 	"failed to write initial zeros",				// UPDATE_FAIL_WRITE_INITIAL_ZEROS
48 	"failed to write block",					// UPDATE_FAIL_WRITE_BLOCK
49 	"failed to write the flash command",				// UPDATE_FAIL_WRITE_FLASH_COMMAND
50 	"timeout waiting for attn",					// UPDATE_FAIL_TIMEOUT_WAITING_FOR_ATTN
51 	"failed to write erase all command",				// UPDATE_FAIL_ERASE_ALL
52 	"the firmware image is older then the firmware on the device",	// UPDATE_FAIL_FIRMWARE_IMAGE_IS_OLDER
53 	"invalid parameter",						// UPDATE_FAIL_INVALID_PARAMETER
54 	"failed to open firmware image file",				// UPDATE_FAIL_OPEN_FIRMWARE_IMAGE
55 	"write protection is activated",			// UPDATE_FAIL_WRITE_PROTECTED
56 };
57 
update_err_to_string(int err)58 const char * update_err_to_string(int err)
59 {
60 	return update_error_str[err];
61 }
62