Hello community, here is the log from the commit of package imx-usb-loader for openSUSE:Factory checked in at 2017-10-13 14:20:43 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/imx-usb-loader (Old) and /work/SRC/openSUSE:Factory/.imx-usb-loader.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "imx-usb-loader" Fri Oct 13 14:20:43 2017 rev:6 rq:533855 version:0.0~git20171009 Changes: -------- --- /work/SRC/openSUSE:Factory/imx-usb-loader/imx-usb-loader.changes 2017-04-29 10:54:00.748090183 +0200 +++ /work/SRC/openSUSE:Factory/.imx-usb-loader.new/imx-usb-loader.changes 2017-10-13 14:21:05.155042700 +0200 @@ -1,0 +2,9 @@ +Fri Oct 13 09:01:26 UTC 2017 - [email protected] + +- Update to git20171009: + * Add support for U-Boot header (mx6_usb_sdp_spl.conf) + * Add support for i.MX6SLL device + * Add support for i.MX7ULP device (mx7ulp_usb_work.conf) + * Add '-b' and '-D' filter options + +------------------------------------------------------------------- Old: ---- imx_usb_loader-1491839092.75d8237.tar.bz2 New: ---- imx_usb_loader-1507537358.7e77787.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ imx-usb-loader.spec ++++++ --- /var/tmp/diff_new_pack.b1u4rH/_old 2017-10-13 14:21:05.691019135 +0200 +++ /var/tmp/diff_new_pack.b1u4rH/_new 2017-10-13 14:21:05.691019135 +0200 @@ -17,10 +17,10 @@ # -%define git_version 1491839092.75d8237 +%define git_version 1507537358.7e77787 Name: imx-usb-loader -Version: 0.0~git20170410 +Version: 0.0~git20171009 Release: 0 Summary: Vybrid/i.MX recovery utility License: LGPL-2.1+ @@ -57,8 +57,10 @@ %config %{_sysconfdir}/imx-loader.d/mx50_usb_work.conf %config %{_sysconfdir}/imx-loader.d/mx51_usb_work.conf %config %{_sysconfdir}/imx-loader.d/mx53_usb_work.conf +%config %{_sysconfdir}/imx-loader.d/mx6_usb_sdp_spl.conf %config %{_sysconfdir}/imx-loader.d/mx6_usb_work.conf %config %{_sysconfdir}/imx-loader.d/mx7_usb_work.conf +%config %{_sysconfdir}/imx-loader.d/mx7ulp_usb_work.conf %config %{_sysconfdir}/imx-loader.d/vybrid_usb_work.conf %doc COPYING %doc README.md ++++++ imx_usb_loader-1491839092.75d8237.tar.bz2 -> imx_usb_loader-1507537358.7e77787.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imx_usb_loader-1491839092.75d8237/Makefile new/imx_usb_loader-1507537358.7e77787/Makefile --- old/imx_usb_loader-1491839092.75d8237/Makefile 2017-04-10 17:44:52.000000000 +0200 +++ new/imx_usb_loader-1507537358.7e77787/Makefile 2017-10-09 10:22:38.000000000 +0200 @@ -22,7 +22,7 @@ imx_usb.o : imx_usb.c imx_sdp.h portable.h $(CC) -c $*.c -o $@ -pipe -ggdb $(USBCFLAGS) $(CFLAGS) $(CONFCPPFLAGS) -%.o : %.c imx_sdp.h portable.h +%.o : %.c imx_sdp.h portable.h image.h $(CC) -c $*.c -o $@ -pipe -ggdb $(CFLAGS) $(CONFCPPFLAGS) imx_usb: imx_usb.o imx_sdp.o diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imx_usb_loader-1491839092.75d8237/README.md new/imx_usb_loader-1507537358.7e77787/README.md --- old/imx_usb_loader-1491839092.75d8237/README.md 2017-04-10 17:44:52.000000000 +0200 +++ new/imx_usb_loader-1507537358.7e77787/README.md 2017-10-09 10:22:38.000000000 +0200 @@ -3,7 +3,7 @@ i.MX/Vybrid recovery utility ## Description -This utility allows to download and execute code on Freescale i.MX5/i.MX6 +This utility allows to download and execute code on Freescale i.MX5/i.MX6/i.MX7 and Vybrid SoCs through the Serial Download Protocol (SDP). Depending on the board, there is usually some kind of recovery button to bring the SoC into serial download boot mode, check documentation of your hardware. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imx_usb_loader-1491839092.75d8237/image.h new/imx_usb_loader-1507537358.7e77787/image.h --- old/imx_usb_loader-1491839092.75d8237/image.h 1970-01-01 01:00:00.000000000 +0100 +++ new/imx_usb_loader-1507537358.7e77787/image.h 2017-10-09 10:22:38.000000000 +0200 @@ -0,0 +1,217 @@ +/* + * (C) Copyright 2008 Semihalf + * + * (C) Copyright 2000-2005 + * Wolfgang Denk, DENX Software Engineering, [email protected]. + * + * SPDX-License-Identifier: GPL-2.0+ + ******************************************************************** + * NOTE: This header file defines an interface to U-Boot. Including + * this (unmodified) header file in another file is considered normal + * use of U-Boot, and does *not* fall under the heading of "derived + * work". + ******************************************************************** + */ + +#ifndef __IMAGE_H__ +#define __IMAGE_H__ + +#include <stdint.h> +typedef uint32_t __be32; + +/* + * Operating System Codes + * + * The following are exposed to uImage header. + * Do not change values for backward compatibility. + */ +enum { + IH_OS_INVALID = 0, /* Invalid OS */ + IH_OS_OPENBSD, /* OpenBSD */ + IH_OS_NETBSD, /* NetBSD */ + IH_OS_FREEBSD, /* FreeBSD */ + IH_OS_4_4BSD, /* 4.4BSD */ + IH_OS_LINUX, /* Linux */ + IH_OS_SVR4, /* SVR4 */ + IH_OS_ESIX, /* Esix */ + IH_OS_SOLARIS, /* Solaris */ + IH_OS_IRIX, /* Irix */ + IH_OS_SCO, /* SCO */ + IH_OS_DELL, /* Dell */ + IH_OS_NCR, /* NCR */ + IH_OS_LYNXOS, /* LynxOS */ + IH_OS_VXWORKS, /* VxWorks */ + IH_OS_PSOS, /* pSOS */ + IH_OS_QNX, /* QNX */ + IH_OS_U_BOOT, /* Firmware */ + IH_OS_RTEMS, /* RTEMS */ + IH_OS_ARTOS, /* ARTOS */ + IH_OS_UNITY, /* Unity OS */ + IH_OS_INTEGRITY, /* INTEGRITY */ + IH_OS_OSE, /* OSE */ + IH_OS_PLAN9, /* Plan 9 */ + IH_OS_OPENRTOS, /* OpenRTOS */ + + IH_OS_COUNT, +}; + +/* + * CPU Architecture Codes (supported by Linux) + * + * The following are exposed to uImage header. + * Do not change values for backward compatibility. + */ +enum { + IH_ARCH_INVALID = 0, /* Invalid CPU */ + IH_ARCH_ALPHA, /* Alpha */ + IH_ARCH_ARM, /* ARM */ + IH_ARCH_I386, /* Intel x86 */ + IH_ARCH_IA64, /* IA64 */ + IH_ARCH_MIPS, /* MIPS */ + IH_ARCH_MIPS64, /* MIPS 64 Bit */ + IH_ARCH_PPC, /* PowerPC */ + IH_ARCH_S390, /* IBM S390 */ + IH_ARCH_SH, /* SuperH */ + IH_ARCH_SPARC, /* Sparc */ + IH_ARCH_SPARC64, /* Sparc 64 Bit */ + IH_ARCH_M68K, /* M68K */ + IH_ARCH_NIOS, /* Nios-32 */ + IH_ARCH_MICROBLAZE, /* MicroBlaze */ + IH_ARCH_NIOS2, /* Nios-II */ + IH_ARCH_BLACKFIN, /* Blackfin */ + IH_ARCH_AVR32, /* AVR32 */ + IH_ARCH_ST200, /* STMicroelectronics ST200 */ + IH_ARCH_SANDBOX, /* Sandbox architecture (test only) */ + IH_ARCH_NDS32, /* ANDES Technology - NDS32 */ + IH_ARCH_OPENRISC, /* OpenRISC 1000 */ + IH_ARCH_ARM64, /* ARM64 */ + IH_ARCH_ARC, /* Synopsys DesignWare ARC */ + IH_ARCH_X86_64, /* AMD x86_64, Intel and Via */ + IH_ARCH_XTENSA, /* Xtensa */ + + IH_ARCH_COUNT, +}; + +/* + * Image Types + * + * "Standalone Programs" are directly runnable in the environment + * provided by U-Boot; it is expected that (if they behave + * well) you can continue to work in U-Boot after return from + * the Standalone Program. + * "OS Kernel Images" are usually images of some Embedded OS which + * will take over control completely. Usually these programs + * will install their own set of exception handlers, device + * drivers, set up the MMU, etc. - this means, that you cannot + * expect to re-enter U-Boot except by resetting the CPU. + * "RAMDisk Images" are more or less just data blocks, and their + * parameters (address, size) are passed to an OS kernel that is + * being started. + * "Multi-File Images" contain several images, typically an OS + * (Linux) kernel image and one or more data images like + * RAMDisks. This construct is useful for instance when you want + * to boot over the network using BOOTP etc., where the boot + * server provides just a single image file, but you want to get + * for instance an OS kernel and a RAMDisk image. + * + * "Multi-File Images" start with a list of image sizes, each + * image size (in bytes) specified by an "uint32_t" in network + * byte order. This list is terminated by an "(uint32_t)0". + * Immediately after the terminating 0 follow the images, one by + * one, all aligned on "uint32_t" boundaries (size rounded up to + * a multiple of 4 bytes - except for the last file). + * + * "Firmware Images" are binary images containing firmware (like + * U-Boot or FPGA images) which usually will be programmed to + * flash memory. + * + * "Script files" are command sequences that will be executed by + * U-Boot's command interpreter; this feature is especially + * useful when you configure U-Boot to use a real shell (hush) + * as command interpreter (=> Shell Scripts). + * + * The following are exposed to uImage header. + * Do not change values for backward compatibility. + */ + +enum { + IH_TYPE_INVALID = 0, /* Invalid Image */ + IH_TYPE_STANDALONE, /* Standalone Program */ + IH_TYPE_KERNEL, /* OS Kernel Image */ + IH_TYPE_RAMDISK, /* RAMDisk Image */ + IH_TYPE_MULTI, /* Multi-File Image */ + IH_TYPE_FIRMWARE, /* Firmware Image */ + IH_TYPE_SCRIPT, /* Script file */ + IH_TYPE_FILESYSTEM, /* Filesystem Image (any type) */ + IH_TYPE_FLATDT, /* Binary Flat Device Tree Blob */ + IH_TYPE_KWBIMAGE, /* Kirkwood Boot Image */ + IH_TYPE_IMXIMAGE, /* Freescale IMXBoot Image */ + IH_TYPE_UBLIMAGE, /* Davinci UBL Image */ + IH_TYPE_OMAPIMAGE, /* TI OMAP Config Header Image */ + IH_TYPE_AISIMAGE, /* TI Davinci AIS Image */ + /* OS Kernel Image, can run from any load address */ + IH_TYPE_KERNEL_NOLOAD, + IH_TYPE_PBLIMAGE, /* Freescale PBL Boot Image */ + IH_TYPE_MXSIMAGE, /* Freescale MXSBoot Image */ + IH_TYPE_GPIMAGE, /* TI Keystone GPHeader Image */ + IH_TYPE_ATMELIMAGE, /* ATMEL ROM bootable Image */ + IH_TYPE_SOCFPGAIMAGE, /* Altera SOCFPGA Preloader */ + IH_TYPE_X86_SETUP, /* x86 setup.bin Image */ + IH_TYPE_LPC32XXIMAGE, /* x86 setup.bin Image */ + IH_TYPE_LOADABLE, /* A list of typeless images */ + IH_TYPE_RKIMAGE, /* Rockchip Boot Image */ + IH_TYPE_RKSD, /* Rockchip SD card */ + IH_TYPE_RKSPI, /* Rockchip SPI image */ + IH_TYPE_ZYNQIMAGE, /* Xilinx Zynq Boot Image */ + IH_TYPE_ZYNQMPIMAGE, /* Xilinx ZynqMP Boot Image */ + IH_TYPE_FPGA, /* FPGA Image */ + IH_TYPE_VYBRIDIMAGE, /* VYBRID .vyb Image */ + IH_TYPE_TEE, /* Trusted Execution Environment OS Image */ + IH_TYPE_FIRMWARE_IVT, /* Firmware Image with HABv4 IVT */ + + IH_TYPE_COUNT, /* Number of image types */ +}; + +/* + * Compression Types + * + * The following are exposed to uImage header. + * Do not change values for backward compatibility. + */ +enum { + IH_COMP_NONE = 0, /* No Compression Used */ + IH_COMP_GZIP, /* gzip Compression Used */ + IH_COMP_BZIP2, /* bzip2 Compression Used */ + IH_COMP_LZMA, /* lzma Compression Used */ + IH_COMP_LZO, /* lzo Compression Used */ + IH_COMP_LZ4, /* lz4 Compression Used */ + + IH_COMP_COUNT, +}; + +#define IH_MAGIC 0x27051956 /* Image Magic Number */ +#define IH_NMLEN 32 /* Image Name Length */ + +/* Reused from common.h */ +#define ROUND(a, b) (((a) + (b) - 1) & ~((b) - 1)) + +/* + * Legacy format image header, + * all data in network byte order (aka natural aka bigendian). + */ +typedef struct image_header { + __be32 ih_magic; /* Image Header Magic Number */ + __be32 ih_hcrc; /* Image Header CRC Checksum */ + __be32 ih_time; /* Image Creation Timestamp */ + __be32 ih_size; /* Image Data Size */ + __be32 ih_load; /* Data Load Address */ + __be32 ih_ep; /* Entry Point Address */ + __be32 ih_dcrc; /* Image Data CRC Checksum */ + uint8_t ih_os; /* Operating System */ + uint8_t ih_arch; /* CPU architecture */ + uint8_t ih_type; /* Image Type */ + uint8_t ih_comp; /* Compression Type */ + uint8_t ih_name[IH_NMLEN]; /* Image Name */ +} image_header_t; + +#endif /* __IMAGE_H__ */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imx_usb_loader-1491839092.75d8237/imx_sdp.c new/imx_usb_loader-1507537358.7e77787/imx_sdp.c --- old/imx_usb_loader-1491839092.75d8237/imx_sdp.c 2017-04-10 17:44:52.000000000 +0200 +++ new/imx_usb_loader-1507537358.7e77787/imx_sdp.c 2017-10-09 10:22:38.000000000 +0200 @@ -29,6 +29,7 @@ #include "portable.h" #include "imx_sdp.h" +#include "image.h" int debugmode = 0; #ifdef __GNUC__ @@ -84,7 +85,8 @@ unsigned i = 0; while (i < cnt) { char c = *src++; - if ((!c) || (c == ' ') || (c == 0x0d) || (c == '\n') || (c == '#') || (c == ':')) { + if ((!c) || (c == ' ') || (c == 0x0d) || (c == '\n') || + (c == '#') || (c == ':') || (c == ',')) { src--; break; } @@ -334,6 +336,10 @@ p += 10; p = skip(p,','); usb->header_type = HDR_MX51; + } else if (strncmp(p, "uboot_header", 12) == 0) { + p += 12; + p = skip(p,','); + usb->header_type = HDR_UBOOT; } else { usb->header_type = HDR_MX53; } @@ -1169,6 +1175,12 @@ if (hdr->barker == IVT_BARKER) return 1; } + case HDR_UBOOT: + { + image_header_t *image = (image_header_t *)p; + if (BE32(image->ih_magic) == IH_MAGIC) + return 1; + } } return 0; } @@ -1275,6 +1287,12 @@ } break; } + case HDR_UBOOT: + { + image_header_t *hdr = (image_header_t *)p; + *dladdr = BE32(hdr->ih_load) - sizeof(image_header_t); + *header_addr = *dladdr; + } } return 0; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imx_usb_loader-1491839092.75d8237/imx_sdp.h new/imx_usb_loader-1507537358.7e77787/imx_sdp.h --- old/imx_usb_loader-1491839092.75d8237/imx_sdp.h 2017-04-10 17:44:52.000000000 +0200 +++ new/imx_usb_loader-1507537358.7e77787/imx_sdp.h 2017-10-09 10:22:38.000000000 +0200 @@ -62,6 +62,7 @@ #define HDR_NONE 0 #define HDR_MX51 1 #define HDR_MX53 2 +#define HDR_UBOOT 3 unsigned char header_type; unsigned dcd_addr; struct ram_area ram[8]; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imx_usb_loader-1491839092.75d8237/imx_usb.c new/imx_usb_loader-1507537358.7e77787/imx_usb.c --- old/imx_usb_loader-1491839092.75d8237/imx_usb.c 2017-04-10 17:44:52.000000000 +0200 +++ new/imx_usb_loader-1507537358.7e77787/imx_usb.c 2017-10-09 10:22:38.000000000 +0200 @@ -40,7 +40,8 @@ struct mach_id; struct mach_id { - struct mach_id * next; + struct mach_id *next; + struct mach_id *nextbatch; unsigned short vid; unsigned short pid; char file_name[256]; @@ -85,24 +86,50 @@ libusb_free_config_descriptor(config); } } -/* - {0x066f, 0x3780, "mx23", 0, 1024, MODE_HID, HDR_NONE}, - {0x15a2, 0x004f, "mx28", 0, 1024, MODE_HID, HDR_NONE}, - {0x15a2, 0x0052, "mx50", 0, 1024, MODE_HID, HDR_MX53}, - {0x15a2, 0x0054, "mx6", 0x10000000, 1024, MODE_HID, HDR_MX53}, - {0x15a2, 0x0041, "mx51", 0x90000000, 64, MODE_BULK, HDR_MX51}, - {0x15a2, 0x004e, "mx53", 0x70000000, 512, MODE_BULK, HDR_MX53}, - {0x066f, 0x37ff, "linux gadget", 512, MODE_BULK, HDR_NONE}, -}; -*/ + +static struct mach_id *parse_imx_mach(const char **pp) +{ + unsigned short vid; + unsigned short pid; + struct mach_id *curr = NULL; + const char *p = *pp; + + while (*p==' ') p++; + if (p[0] == '#') + return NULL; + vid = get_val(&p, 16); + if (p[0] != ':') { + printf("Syntax error(missing ':'): %s [%s]\n", p, *pp); + return NULL; + } + p++; + pid = get_val(&p, 16); + if (p[0] != ',') { + printf("Syntax error(missing ','): %s [%s]\n", p, *pp); + return NULL; + } + p++; + while (*p==' ') p++; + if (!(vid && pid)) { + printf("vid/pid cannot be 0: %s [%s]\n", p, *pp); + return NULL; + } + curr = (struct mach_id *)malloc(sizeof(struct mach_id)); + curr->next = NULL; + curr->nextbatch = NULL; + curr->vid = vid; + curr->pid = pid; + p = move_string(curr->file_name, p, sizeof(curr->file_name) - 1); + + *pp = p; + return curr; +} /* * Parse USB specific machine configuration */ static struct mach_id *parse_imx_conf(char const *filename) { - unsigned short vid; - unsigned short pid; char line[512]; struct mach_id *head = NULL; struct mach_id *tail = NULL; @@ -117,38 +144,26 @@ while (fgets(line, sizeof(line), xfile) != NULL) { p = line; - while (*p==' ') p++; - if (p[0] == '#') - continue; - vid = get_val(&p, 16); - if (p[0] != ':') { - printf("Syntax error(missing ':'): %s [%s]\n", p, line); - continue; - } - p++; - pid = get_val(&p, 16); - if (p[0] != ',') { - printf("Syntax error(missing ','): %s [%s]\n", p, line); - continue; - } - p++; - while (*p==' ') p++; - if (!(vid && pid)) { - printf("vid/pid cannot be 0: %s [%s]\n", p, line); + curr = parse_imx_mach(&p); + if (!curr) continue; - } - curr = (struct mach_id *)malloc(sizeof(struct mach_id)); - curr->next = NULL; - curr->vid = vid; - curr->pid = pid; - move_string(curr->file_name, p, sizeof(curr->file_name) - 1); + if (!head) head = curr; if (tail) tail->next = curr; tail = curr; printf("vid=0x%04x pid=0x%04x file_name=%s\n", curr->vid, curr->pid, curr->file_name); + + while (p[0] == ',') { + p++; + // Second machine in batch... + curr->nextbatch = parse_imx_mach(&p); + curr = curr->nextbatch; + printf("-> vid=0x%04x pid=0x%04x file_name=%s\n", curr->vid, curr->pid, curr->file_name); + } } + fclose(xfile); return head; } @@ -165,7 +180,7 @@ } -static libusb_device *find_imx_dev(libusb_device **devs, struct mach_id **pp_id, struct mach_id *list) +static libusb_device *find_imx_dev(libusb_device **devs, struct mach_id **pp_id, struct mach_id *list, int bus, int address) { int i = 0; struct mach_id *p; @@ -174,6 +189,9 @@ libusb_device *dev = devs[i++]; if (!dev) break; + if ((bus >= 0 && libusb_get_bus_number(dev) != bus) || + (address >= 0 && libusb_get_device_address(dev) != address)) + continue; int r = libusb_get_device_descriptor(dev, &desc); if (r < 0) { fprintf(stderr, "failed to get device descriptor"); @@ -323,6 +341,8 @@ " -d --debugmode Enable debug logs\n" " -c --configdir=DIR Reading configuration directory from non standard\n" " directory.\n" + " -b --bus=NUM Filter bus number.\n" + " -D --device=NUM Filter device address.\n" "\n" "And where [JOBS...] are\n" " FILE [-lLOADADDR] [-sSIZE] ...\n" @@ -333,7 +353,7 @@ } int parse_opts(int argc, char * const *argv, char const **configdir, - int *verify, struct sdp_work **cmd_head) + int *verify, struct sdp_work **cmd_head, int *bus, int *address) { int c; @@ -342,10 +362,12 @@ {"debugmode", no_argument, 0, 'd' }, {"verify", no_argument, 0, 'v' }, {"configdir", required_argument, 0, 'c' }, + {"bus", required_argument, 0, 'b' }, + {"device", required_argument, 0, 'D' }, {0, 0, 0, 0 }, }; - while ((c = getopt_long(argc, argv, "+hdvc:", long_options, NULL)) != -1) { + while ((c = getopt_long(argc, argv, "+hdvc:b:D:", long_options, NULL)) != -1) { switch (c) { case 'h': @@ -361,6 +383,12 @@ case 'c': *configdir = optarg; break; + case 'b': + *bus = atoi(optarg); + break; + case 'D': + *address = atoi(optarg); + break; } } @@ -454,7 +482,8 @@ } int do_autodetect_dev(char const *base_path, char const *conf_path, - struct mach_id *list, int verify, struct sdp_work *cmd_head) + struct mach_id *list, int verify, struct sdp_work *cmd_head, + int bus, int address) { struct sdp_dev *p_id; struct mach_id *mach; @@ -462,7 +491,7 @@ libusb_device *dev; int err = 0; ssize_t cnt; - struct sdp_work *curr; + struct sdp_work *curr = NULL; libusb_device_handle *h = NULL; char const *conf; int retry; @@ -479,72 +508,81 @@ if (debugmode) print_devs(devs); - dev = find_imx_dev(devs, &mach, list); + dev = find_imx_dev(devs, &mach, list, bus, address); + libusb_free_device_list(devs, 1); if (!dev) { - libusb_free_device_list(devs, 1); err = LIBUSB_ERROR_NO_DEVICE; goto out_deinit_usb; } - err = libusb_open(dev, &h); - libusb_free_device_list(devs, 1); - if (err < 0) { - fprintf(stderr, "Could not open device vid=0x%x pid=0x%x: %s, err=%d\n", - mach->vid, mach->pid, libusb_strerror(err), err); - goto out_deinit_usb; - } - - // Get machine specific configuration file.. - conf = conf_file_name(mach->file_name, base_path, conf_path); - if (conf == NULL) { - err = LIBUSB_ERROR_OTHER; - goto out_close_usb; - } - - p_id = parse_conf(conf); - if (!p_id) { - err = LIBUSB_ERROR_OTHER; - goto out_close_usb; - } + while (mach) { + // Get machine specific configuration file.. + conf = conf_file_name(mach->file_name, base_path, conf_path); + if (conf == NULL) { + err = LIBUSB_ERROR_OTHER; + break; + } - if (p_id->mode == MODE_HID) - p_id->transfer = &transfer_hid; - if (p_id->mode == MODE_BULK) - p_id->transfer = &transfer_bulk; + p_id = parse_conf(conf); + if (!p_id) { + err = LIBUSB_ERROR_OTHER; + break; + } - // By default, use work from config file... - curr = p_id->work; + if (p_id->mode == MODE_HID) + p_id->transfer = &transfer_hid; + if (p_id->mode == MODE_BULK) + p_id->transfer = &transfer_bulk; + + curr = p_id->work; + + // Prefer work from command line, disable batch mode... + if (cmd_head) { + curr = cmd_head; + mach->nextbatch = NULL; + } + + if (curr == NULL) { + fprintf(stderr, "no job found\n"); + err = LIBUSB_ERROR_OTHER; + break; + } - if (cmd_head != NULL) - curr = cmd_head; + // Wait for device... + printf("Trying to open device vid=0x%04x pid=0x%04x", mach->vid, mach->pid); + fflush(stdout); + for (retry = 0; retry < 50; retry++) { + h = libusb_open_device_with_vid_pid(NULL, mach->vid, mach->pid); + if (h) + break; - if (curr == NULL) { - fprintf(stderr, "no job found\n"); - err = LIBUSB_ERROR_OTHER; - goto out_close_usb; - } + msleep(500); + if (retry % 2) + printf("."); + fflush(stdout); + } + printf("\n"); + if (!h) { + err = LIBUSB_ERROR_NO_DEVICE; + fprintf(stderr, "Could not open device vid=0x%04x pid=0x%04x\n", + mach->vid, mach->pid); + break; + } -retry: - // USB private pointer is libusb device handle... - p_id->priv = h; + // USB private pointer is libusb device handle... + p_id->priv = h; - err = do_work(p_id, &curr, verify); - dbg_printf("do_work finished with err=%d, curr=%p\n", err, curr); + err = do_work(p_id, &curr, verify); + dbg_printf("do_work finished with err=%d, curr=%p\n", err, curr); -out_close_usb: - libusb_close(h); + libusb_close(h); - /* More work to do? Try to rediscover the same device */ - if (curr && !(err < 0)) { - for (retry = 0; retry < 10; retry++) { - msleep(3000); - h = libusb_open_device_with_vid_pid(NULL, mach->vid, mach->pid); - if (h) - goto retry; + if (err) + break; - fprintf(stderr, "Could not open device vid=0x%x pid=0x%x err=%d\n", - mach->vid, mach->pid, err); - } + // We might have to retry the same machine in case of plugin... + if (!curr) + mach = mach->nextbatch; } out_deinit_usb: @@ -561,8 +599,10 @@ char const *conf; char const *base_path = get_base_path(argv[0]); char const *conf_path = get_global_conf_path(); + int bus = -1; + int address = -1; - err = parse_opts(argc, argv, &conf_path, &verify, &cmd_head); + err = parse_opts(argc, argv, &conf_path, &verify, &cmd_head, &bus, &address); if (err < 0) return EXIT_FAILURE; else if (err > 0) @@ -577,7 +617,7 @@ if (!list) return EXIT_FAILURE; - err = do_autodetect_dev(base_path, conf_path, list, verify, cmd_head); + err = do_autodetect_dev(base_path, conf_path, list, verify, cmd_head, bus, address); if (err < 0) return EXIT_FAILURE; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imx_usb_loader-1491839092.75d8237/imx_usb.conf new/imx_usb_loader-1507537358.7e77787/imx_usb.conf --- old/imx_usb_loader-1491839092.75d8237/imx_usb.conf 2017-04-10 17:44:52.000000000 +0200 +++ new/imx_usb_loader-1507537358.7e77787/imx_usb.conf 2017-10-09 10:22:38.000000000 +0200 @@ -8,8 +8,12 @@ 0x15a2:0x0071, mx6_usb_work.conf 0x15a2:0x007d, mx6_usb_work.conf 0x15a2:0x0080, mx6_usb_work.conf +0x1fc9:0x0128, mx6_usb_work.conf 0x15a2:0x0076, mx7_usb_work.conf +0x1fc9:0x0126, mx7ulp_usb_work.conf 0x15a2:0x0041, mx51_usb_work.conf 0x15a2:0x004e, mx53_usb_work.conf 0x15a2:0x006a, vybrid_usb_work.conf 0x066f:0x37ff, linux_gadget.conf +0x1b67:0x4fff, mx6_usb_sdp_spl.conf +0x0525:0xb4a4, mx6_usb_sdp_spl.conf diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imx_usb_loader-1491839092.75d8237/mx6_usb_sdp_spl.conf new/imx_usb_loader-1507537358.7e77787/mx6_usb_sdp_spl.conf --- old/imx_usb_loader-1491839092.75d8237/mx6_usb_sdp_spl.conf 1970-01-01 01:00:00.000000000 +0100 +++ new/imx_usb_loader-1507537358.7e77787/mx6_usb_sdp_spl.conf 2017-10-09 10:22:38.000000000 +0200 @@ -0,0 +1,4 @@ +mx6_spl_sdp +#hid/bulk,[old_header,]max packet size, {ram start, ram size}(repeat valid ram areas) +#In SPL, we typically load u-boot.img which has a U-boot header... +hid,uboot_header,1024,0x10000000,1G,0x00907000,0x31000 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imx_usb_loader-1491839092.75d8237/mx7ulp_usb_work.conf new/imx_usb_loader-1507537358.7e77787/mx7ulp_usb_work.conf --- old/imx_usb_loader-1491839092.75d8237/mx7ulp_usb_work.conf 1970-01-01 01:00:00.000000000 +0100 +++ new/imx_usb_loader-1507537358.7e77787/mx7ulp_usb_work.conf 2017-10-09 10:22:38.000000000 +0200 @@ -0,0 +1,3 @@ +mx7ulp +#hid/bulk,[old_header,]max packet size,dcd_addr,{ram start, ram size}(repeat valid ram areas) +hid,1024,0x2f020000,0x60000000,1G,0x900000,0x40000
