greybus: firmware: Update Documentation and sample application
Update documentation and sample application to capture the 'status' byte in backend version operation and new error types in backend firmware update operation. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
parent
5e10f0047a
commit
6136cce89c
@ -93,12 +93,28 @@ Following are the IOCTLs and their data structures available to the user:
|
|||||||
#define GB_FW_BACKEND_FW_STATUS_FAIL_FETCH 0x03
|
#define GB_FW_BACKEND_FW_STATUS_FAIL_FETCH 0x03
|
||||||
#define GB_FW_BACKEND_FW_STATUS_FAIL_WRITE 0x04
|
#define GB_FW_BACKEND_FW_STATUS_FAIL_WRITE 0x04
|
||||||
#define GB_FW_BACKEND_FW_STATUS_INT 0x05
|
#define GB_FW_BACKEND_FW_STATUS_INT 0x05
|
||||||
|
#define GB_FW_BACKEND_FW_STATUS_RETRY 0x06
|
||||||
|
#define GB_FW_BACKEND_FW_STATUS_NOT_SUPPORTED 0x07
|
||||||
|
|
||||||
struct fw_mgmt_ioc_get_fw {
|
#define GB_FW_BACKEND_VERSION_STATUS_SUCCESS 0x01
|
||||||
__u8 firmware_tag[GB_FIRMWARE_TAG_MAX_LEN];
|
#define GB_FW_BACKEND_VERSION_STATUS_NOT_AVAILABLE 0x02
|
||||||
__u16 major;
|
#define GB_FW_BACKEND_VERSION_STATUS_NOT_SUPPORTED 0x03
|
||||||
__u16 minor;
|
#define GB_FW_BACKEND_VERSION_STATUS_RETRY 0x04
|
||||||
} __packed;
|
#define GB_FW_BACKEND_VERSION_STATUS_FAIL_INT 0x05
|
||||||
|
|
||||||
|
|
||||||
|
struct fw_mgmt_ioc_get_intf_version {
|
||||||
|
__u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_LEN];
|
||||||
|
__u16 major;
|
||||||
|
__u16 minor;
|
||||||
|
} __attribute__ ((__packed__));
|
||||||
|
|
||||||
|
struct fw_mgmt_ioc_get_backend_version {
|
||||||
|
__u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_LEN];
|
||||||
|
__u16 major;
|
||||||
|
__u16 minor;
|
||||||
|
__u8 status;
|
||||||
|
} __attribute__ ((__packed__));
|
||||||
|
|
||||||
struct fw_mgmt_ioc_intf_load_and_validate {
|
struct fw_mgmt_ioc_intf_load_and_validate {
|
||||||
__u8 firmware_tag[GB_FIRMWARE_TAG_MAX_LEN];
|
__u8 firmware_tag[GB_FIRMWARE_TAG_MAX_LEN];
|
||||||
@ -114,8 +130,8 @@ struct fw_mgmt_ioc_backend_fw_update {
|
|||||||
} __packed;
|
} __packed;
|
||||||
|
|
||||||
#define FW_MGMT_IOCTL_BASE 'S'
|
#define FW_MGMT_IOCTL_BASE 'S'
|
||||||
#define FW_MGMT_IOC_GET_INTF_FW _IOR(FW_MGMT_IOCTL_BASE, 0, struct fw_mgmt_ioc_get_fw)
|
#define FW_MGMT_IOC_GET_INTF_FW _IOR(FW_MGMT_IOCTL_BASE, 0, struct fw_mgmt_ioc_get_intf_version)
|
||||||
#define FW_MGMT_IOC_GET_BACKEND_FW _IOWR(FW_MGMT_IOCTL_BASE, 1, struct fw_mgmt_ioc_get_fw)
|
#define FW_MGMT_IOC_GET_BACKEND_FW _IOWR(FW_MGMT_IOCTL_BASE, 1, struct fw_mgmt_ioc_get_backend_version)
|
||||||
#define FW_MGMT_IOC_INTF_LOAD_AND_VALIDATE _IOWR(FW_MGMT_IOCTL_BASE, 2, struct fw_mgmt_ioc_intf_load_and_validate)
|
#define FW_MGMT_IOC_INTF_LOAD_AND_VALIDATE _IOWR(FW_MGMT_IOCTL_BASE, 2, struct fw_mgmt_ioc_intf_load_and_validate)
|
||||||
#define FW_MGMT_IOC_INTF_BACKEND_FW_UPDATE _IOWR(FW_MGMT_IOCTL_BASE, 3, struct fw_mgmt_ioc_backend_fw_update)
|
#define FW_MGMT_IOC_INTF_BACKEND_FW_UPDATE _IOWR(FW_MGMT_IOCTL_BASE, 3, struct fw_mgmt_ioc_backend_fw_update)
|
||||||
#define FW_MGMT_IOC_SET_TIMEOUT_MS _IOW(FW_MGMT_IOCTL_BASE, 4, unsigned int)
|
#define FW_MGMT_IOC_SET_TIMEOUT_MS _IOW(FW_MGMT_IOCTL_BASE, 4, unsigned int)
|
||||||
|
@ -71,7 +71,8 @@ static const char *fwdev = FW_DEV_DEFAULT;
|
|||||||
static int fw_update_type = FW_UPDATE_TYPE_DEFAULT;
|
static int fw_update_type = FW_UPDATE_TYPE_DEFAULT;
|
||||||
static int fw_timeout = FW_TIMEOUT_DEFAULT;
|
static int fw_timeout = FW_TIMEOUT_DEFAULT;
|
||||||
|
|
||||||
static struct fw_mgmt_ioc_get_fw fw_info;
|
static struct fw_mgmt_ioc_get_intf_version intf_fw_info;
|
||||||
|
static struct fw_mgmt_ioc_get_backend_version backend_fw_info;
|
||||||
static struct fw_mgmt_ioc_intf_load_and_validate intf_load;
|
static struct fw_mgmt_ioc_intf_load_and_validate intf_load;
|
||||||
static struct fw_mgmt_ioc_backend_fw_update backend_update;
|
static struct fw_mgmt_ioc_backend_fw_update backend_update;
|
||||||
|
|
||||||
@ -87,7 +88,7 @@ static int update_intf_firmware(int fd)
|
|||||||
/* Get Interface Firmware Version */
|
/* Get Interface Firmware Version */
|
||||||
printf("Get Interface Firmware Version\n");
|
printf("Get Interface Firmware Version\n");
|
||||||
|
|
||||||
ret = ioctl(fd, FW_MGMT_IOC_GET_INTF_FW, &fw_info);
|
ret = ioctl(fd, FW_MGMT_IOC_GET_INTF_FW, &intf_fw_info);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
printf("Failed to get interface firmware version: %s (%d)\n",
|
printf("Failed to get interface firmware version: %s (%d)\n",
|
||||||
fwdev, ret);
|
fwdev, ret);
|
||||||
@ -95,7 +96,8 @@ static int update_intf_firmware(int fd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
printf("Interface Firmware tag (%s), major (%d), minor (%d)\n",
|
printf("Interface Firmware tag (%s), major (%d), minor (%d)\n",
|
||||||
fw_info.firmware_tag, fw_info.major, fw_info.minor);
|
intf_fw_info.firmware_tag, intf_fw_info.major,
|
||||||
|
intf_fw_info.minor);
|
||||||
|
|
||||||
/* Try Interface Firmware load over Unipro */
|
/* Try Interface Firmware load over Unipro */
|
||||||
printf("Loading Interface Firmware\n");
|
printf("Loading Interface Firmware\n");
|
||||||
@ -143,34 +145,51 @@ static int update_backend_firmware(int fd)
|
|||||||
/* Get Backend Firmware Version */
|
/* Get Backend Firmware Version */
|
||||||
printf("Getting Backend Firmware Version\n");
|
printf("Getting Backend Firmware Version\n");
|
||||||
|
|
||||||
fw_info.major = 0;
|
strncpy((char *)&backend_fw_info.firmware_tag, firmware_tag,
|
||||||
fw_info.minor = 0;
|
|
||||||
strncpy((char *)&fw_info.firmware_tag, firmware_tag,
|
|
||||||
GB_FIRMWARE_U_TAG_MAX_LEN);
|
GB_FIRMWARE_U_TAG_MAX_LEN);
|
||||||
|
|
||||||
ret = ioctl(fd, FW_MGMT_IOC_GET_BACKEND_FW, &fw_info);
|
retry_fw_version:
|
||||||
|
ret = ioctl(fd, FW_MGMT_IOC_GET_BACKEND_FW, &backend_fw_info);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
printf("Failed to get backend firmware version: %s (%d)\n",
|
printf("Failed to get backend firmware version: %s (%d)\n",
|
||||||
fwdev, ret);
|
fwdev, ret);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Backend Firmware tag (%s), major (%d), minor (%d)\n",
|
printf("Backend Firmware tag (%s), major (%d), minor (%d), status (%d)\n",
|
||||||
fw_info.firmware_tag, fw_info.major, fw_info.minor);
|
backend_fw_info.firmware_tag, backend_fw_info.major,
|
||||||
|
backend_fw_info.minor, backend_fw_info.status);
|
||||||
|
|
||||||
|
if (backend_fw_info.status == GB_FW_U_BACKEND_VERSION_STATUS_RETRY)
|
||||||
|
goto retry_fw_version;
|
||||||
|
|
||||||
|
if ((backend_fw_info.status != GB_FW_U_BACKEND_VERSION_STATUS_SUCCESS)
|
||||||
|
&& (backend_fw_info.status != GB_FW_U_BACKEND_VERSION_STATUS_NOT_AVAILABLE)) {
|
||||||
|
printf("Failed to get backend firmware version: %s (%d)\n",
|
||||||
|
fwdev, backend_fw_info.status);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Try Backend Firmware Update over Unipro */
|
/* Try Backend Firmware Update over Unipro */
|
||||||
printf("Updating Backend Firmware\n");
|
printf("Updating Backend Firmware\n");
|
||||||
|
|
||||||
backend_update.status = 0;
|
|
||||||
strncpy((char *)&backend_update.firmware_tag, firmware_tag,
|
strncpy((char *)&backend_update.firmware_tag, firmware_tag,
|
||||||
GB_FIRMWARE_U_TAG_MAX_LEN);
|
GB_FIRMWARE_U_TAG_MAX_LEN);
|
||||||
|
|
||||||
|
retry_fw_update:
|
||||||
|
backend_update.status = 0;
|
||||||
|
|
||||||
ret = ioctl(fd, FW_MGMT_IOC_INTF_BACKEND_FW_UPDATE, &backend_update);
|
ret = ioctl(fd, FW_MGMT_IOC_INTF_BACKEND_FW_UPDATE, &backend_update);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
printf("Failed to load backend firmware: %s (%d)\n", fwdev, ret);
|
printf("Failed to load backend firmware: %s (%d)\n", fwdev, ret);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (backend_update.status == GB_FW_U_BACKEND_FW_STATUS_RETRY) {
|
||||||
|
printf("Retrying firmware update: %d\n", backend_update.status);
|
||||||
|
goto retry_fw_update;
|
||||||
|
}
|
||||||
|
|
||||||
if (backend_update.status != GB_FW_U_BACKEND_FW_STATUS_SUCCESS) {
|
if (backend_update.status != GB_FW_U_BACKEND_FW_STATUS_SUCCESS) {
|
||||||
printf("Load status says loading failed: %d\n",
|
printf("Load status says loading failed: %d\n",
|
||||||
backend_update.status);
|
backend_update.status);
|
||||||
|
Loading…
Reference in New Issue
Block a user