From: Uwe Kleine-Koenig <u.kleine-koenig@xxxxxxxxxxxxxx> The i.MX8MP uses a protocol similar to the MXS. The relevant differences are: - Maximal transfer size is 1020 - HID reports must be sent to EP1 instead of using a control transfer - The FW_DOWNLOAD command must not be send. Signed-off-by: Uwe Kleine-Koenig <u.kleine-koenig@xxxxxxxxxxxxxx> --- scripts/imx/imx-usb-loader.c | 65 +++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 23 deletions(-) diff --git a/scripts/imx/imx-usb-loader.c b/scripts/imx/imx-usb-loader.c index 3e96c86f2f29..40a85ee26105 100644 --- a/scripts/imx/imx-usb-loader.c +++ b/scripts/imx/imx-usb-loader.c @@ -71,6 +71,7 @@ struct mach_id { #define DEV_IMX 0 #define DEV_MXS 1 unsigned char dev_type; + unsigned char hid_endpoint; }; struct usb_work { @@ -177,6 +178,13 @@ static const struct mach_id imx_ids[] = { .header_type = HDR_MX53, .mode = MODE_HID, .max_transfer = 1024, + }, { + .vid = 0x1fc9, + .pid = 0x0146, + .name = "i.MX8MP", + .max_transfer = 1020, + .dev_type = DEV_MXS, + .hid_endpoint = 1, }, { .vid = 0x1fc9, .pid = 0x012b, @@ -522,15 +530,24 @@ static int transfer(int report, unsigned char *p, unsigned cnt, int *last_trans) if (report < 3) { memcpy(&tmp[1], p, cnt); - err = libusb_control_transfer(usb_dev_handle, - CTRL_OUT, - HID_SET_REPORT, - (HID_REPORT_TYPE_OUTPUT << 8) | report, - 0, - tmp, cnt + 1, 1000); - *last_trans = (err > 0) ? err - 1 : 0; - if (err > 0) - err = 0; + if (mach_id->hid_endpoint) { + int trans; + err = libusb_interrupt_transfer(usb_dev_handle, + mach_id->hid_endpoint, tmp, cnt + 1, &trans, 1000); + if (err == 0 && last_trans) + *last_trans = trans - 1; + } else { + err = libusb_control_transfer(usb_dev_handle, + CTRL_OUT, + HID_SET_REPORT, + (HID_REPORT_TYPE_OUTPUT << 8) | report, + 0, + tmp, cnt + 1, 1000); + if (err > 0) { + *last_trans = err - 1; + err = 0; + } + } } else { *last_trans = 0; memset(&tmp[1], 0, cnt); @@ -1507,20 +1524,22 @@ static int mxs_load_file(libusb_device_handle *dev, uint8_t *data, int size) void *p; int cnt; - dl_command.sign = htonl(0x424c5443); /* Signature: BLTC */ - dl_command.tag = htonl(0x1); - dl_command.size = htonl(size); - dl_command.flags = 0; - dl_command.rsvd[0] = 0; - dl_command.rsvd[1] = 0; - dl_command.cmd = MXS_CMD_FW_DOWNLOAD; - dl_command.dw_size = htonl(size); - - err = transfer(1, (unsigned char *) &dl_command, 20, &last_trans); - if (err) { - printf("transfer error at init step: err=%i, last_trans=%i\n", - err, last_trans); - return err; + if (!mach_id->hid_endpoint) { + dl_command.sign = htonl(0x424c5443); /* Signature: BLTC */ + dl_command.tag = htonl(0x1); + dl_command.size = htonl(size); + dl_command.flags = 0; + dl_command.rsvd[0] = 0; + dl_command.rsvd[1] = 0; + dl_command.cmd = MXS_CMD_FW_DOWNLOAD; + dl_command.dw_size = htonl(size); + + err = transfer(1, (unsigned char *) &dl_command, 20, &last_trans); + if (err) { + printf("transfer error at init step: err=%i, last_trans=%i\n", + err, last_trans); + return err; + } } p = data; -- 2.30.2 _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox