main: dfuError state means DFU mode

If the device reports the dfuError state it must already be in
DFU mode and we do not need to detach.

Also remove non-necessary break after exit().

Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
DFU mode vendor, product, and serial specification

The "-d" option has been expanded to allow separate specification of the
vendor and product IDs for a device in DFU mode.  This enhancement was
done in a backwards compatible fashion such that anyone using the previous
"-d" functionality should see identical matching behaviour (i.e. same
vendor and product ID expected in both run-time and DFU mode).  To specify
DFU mode vendor and product IDs, add a comma to the end of the run-time
vendor and product ID specifier, followed by the DFU mode vendor and
product ID.  For example, "-d 1111:2222,3333:4444" will match only a
run-time device with vendor ID 0x1111 and product ID 0x2222, OR a DFU mode
device with vendor ID 0x3333 and product ID 0x4444.  Leaving any component
blank will match any device for that field (e.g. "-d 1111:,:4444" will
match a run-time device with vendor ID 0x1111 and ANY product ID, OR a DFU
mode device with ANY vendor ID but the product ID must be 0x4444).

The "-S" option has been expanded to allow separate specification of the
serial number for a device in DFU mode.  A DFU mode serial number is
specified by adding a comma following the run-time serial number, followed
by the DFU mode serial number.  If no comma is found in the argument then
the same serial number will be expected in both run-time and DFU mode.  If
a comma is present but no serial number is specified after the comma, then
any serial number is permitted for a device in DFU mode.  Note that comma
is not a valid character in a USB serial number, so this parsing shouldn't
conflict with the ability to specify any valid serial number.
Do not bail if GET_STATUS is not supported in appIDLE state

According to both versions of DFU specification(v. 1.1 and 1.0) it is
optional for a DFU compatible device to implement GET_STATUS request
in appIDLE state, which means that current behaviour of dfu-util,
namely to bail out if GET_STATUS request fails, is incompatible with
devices that do not implement aforementioned request in appIDLE state.
This commit adds the support of such devices by making assumption that
device is in appIDLE state if GET_STATUS returns -EPIPE and proceeding
to send DFU_DETACH request.

[Bradley Scott]
- remove old extraneous space in dfu_get_status() call
- initialize all fields of status structure
- only report state and status if it was retrieved successfully

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Reviewed-by: Bradley Scott <Bradley.Scott@confuseacat.org>
Tested-by: Bradley Scott <Bradley.Scott@confuseacat.org>
Signed-off-by: Bradley Scott <Bradley.Scott@confuseacat.org>
Use AC_CONFIG_HEADERS instead of AM_CONFIG_HEADER

AM_CONFIG_HEADER has been deprecated for years and has been removed from
autotools 1.13.
dfuse: Explicit set the dfuse_address when leaving

Otherwise the dfuse leave request will jump to the wrong place
as soon as the download is longer than one DFU transfer.
dfuse: Verbose decode failing special commands
dfuse_mem: Device Feature is not erasable, despite tagged as 'g' on STM32F407

[Tormod]
Move free() so we do not reference the free'd string.
Add quirk for transfer size 64 on M-Audio Sonic device

Thanks to Raf D for reporting the needed transfer size.

Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
Merge git://gitorious.org/dfu-util/dfu-util
add stm32 poll timeout quirk

before:
 Download from image offset 00051800 to memory 08055800-08055fff, size 2048
   Poll timeout 64 ms
 Download from image offset 00052000 to memory 08056000-08056523, size 1316
   Poll timeout 64 ms
File downloaded successfully
make prog  0.39s user 0.04s system 1% cpu 30.188 total

after:
 Download from image offset 00051800 to memory 08055800-08055fff, size 2048
   Poll timeout 5 ms
 Download from image offset 00052000 to memory 08056000-08056523, size 1316
   Poll timeout 5 ms
File downloaded successfully
make prog  0.40s user 0.02s system 2% cpu 19.057 total