summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUwe Hermann <uwe@debian.org>2011-08-31 23:10:22 +0200
committerUwe Hermann <uwe@debian.org>2011-08-31 23:10:22 +0200
commit4f6d7e7cdca36d85234058e9c16e8413e167fda9 (patch)
tree067489dc8c69eb92355929229912077df7bf1063
parent6a23e273c3df0f28149c09108950a05e835d368c (diff)
parent7167ef3f8c9ee2067db1b92cb25c482cd98a4fb5 (diff)
Import Debian changes 0.4-1
dfu-util (0.4-1) unstable; urgency=low . * New upstream release. * Standards-Version: 3.9.2 (no changes required). * Change Build-Depends libusb-dev to libusb-1.0-0-dev (upstream switch).
-rw-r--r--ChangeLog9
-rw-r--r--DEVICES.txt15
-rw-r--r--Makefile.am2
-rw-r--r--Makefile.in2
-rw-r--r--TODO2
-rw-r--r--aclocal.m414
-rwxr-xr-xconfigure248
-rw-r--r--configure.ac6
-rw-r--r--d/changelog69
-rw-r--r--d/compat1
-rw-r--r--d/control21
-rw-r--r--d/copyright34
-rw-r--r--d/docs2
-rwxr-xr-xd/rules10
-rw-r--r--d/source/format1
-rw-r--r--d/watch2
-rw-r--r--debian/changelog8
-rw-r--r--debian/control4
-rw-r--r--debian/dd/README.Debian6
-rw-r--r--debian/dd/README.source9
-rw-r--r--debian/dd/changelog5
-rw-r--r--debian/dd/compat1
-rw-r--r--debian/dd/control15
-rw-r--r--debian/dd/copyright32
-rw-r--r--debian/dd/dfu-util.cron.d.ex4
-rw-r--r--debian/dd/dfu-util.default.ex10
-rw-r--r--debian/dd/dfu-util.doc-base.EX20
-rw-r--r--debian/dd/docs3
-rw-r--r--debian/dd/emacsen-install.ex45
-rw-r--r--debian/dd/emacsen-remove.ex15
-rw-r--r--debian/dd/emacsen-startup.ex25
-rw-r--r--debian/dd/init.d.ex154
-rw-r--r--debian/dd/manpage.1.ex59
-rw-r--r--debian/dd/manpage.sgml.ex154
-rw-r--r--debian/dd/manpage.xml.ex291
-rw-r--r--debian/dd/menu.ex2
-rw-r--r--debian/dd/postinst.ex39
-rw-r--r--debian/dd/postrm.ex37
-rw-r--r--debian/dd/preinst.ex35
-rw-r--r--debian/dd/prerm.ex38
-rwxr-xr-xdebian/dd/rules7
-rw-r--r--debian/dd/source/format1
-rw-r--r--debian/dd/watch.ex23
-rw-r--r--doc/dfu-util.16
-rw-r--r--src/Makefile.am2
-rw-r--r--src/Makefile.in5
-rw-r--r--src/dfu.c69
-rw-r--r--src/dfu.h53
-rw-r--r--src/dfu_file.c190
-rw-r--r--src/dfu_file.h20
-rw-r--r--src/dfu_load.c120
-rw-r--r--src/dfu_load.h6
-rw-r--r--src/main.c529
-rw-r--r--src/usb_dfu.h2
54 files changed, 2007 insertions, 475 deletions
diff --git a/ChangeLog b/ChangeLog
index cb4027a..571df8d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+0.4:
+ o Rework to use libusb-1.0 (Stefan Schmidt)
+ o DFU suffix support (Tormod Volden, Stefan Schmidt)
+ o Sspeed up DFU downloads directly into memory (Bernard Blackham)
+ o More flexible -d vid:pid parsing (Tormod Volden)
+ o Many bug fixes and cleanups
+
+2011-07-20: Stefan Schmidt <stefan@datenfreihafen.org>
+
0.3:
o quirks: Add OpenOCD to the poll timeout quirk table.
diff --git a/DEVICES.txt b/DEVICES.txt
new file mode 100644
index 0000000..12a3e94
--- /dev/null
+++ b/DEVICES.txt
@@ -0,0 +1,15 @@
+List of supported software and hardware products:
+
+Software user (bootloader, etc)
+-------------------------------
+- Sam7DFU: http://www.openpcd.org/Sam7dfu
+- U-boot: DFU patches
+- Barebox: http://www.barebox.org/
+- Leaflabs: http://code.google.com/p/leaflabs/
+
+Products using DFU
+------------------
+- OpenPCD (sam7dfu)
+- Openmoko Neo 1973 and Freerunner (u-boot with DFU patches)
+- Leaflabs Maple
+- ATUSB from Qi Hardware
diff --git a/Makefile.am b/Makefile.am
index efdbf8a..d7a21a6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,3 +1,3 @@
SUBDIRS = src doc
-EXTRA_DIST = autogen.sh TODO
+EXTRA_DIST = autogen.sh TODO DEVICES.txt
diff --git a/Makefile.in b/Makefile.in
index d0e11aa..8430546 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -199,7 +199,7 @@ top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
SUBDIRS = src doc
-EXTRA_DIST = autogen.sh TODO
+EXTRA_DIST = autogen.sh TODO DEVICES.txt
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-recursive
diff --git a/TODO b/TODO
index a2ce411..ebd0c7d 100644
--- a/TODO
+++ b/TODO
@@ -1,7 +1,5 @@
Core:
-- DFU suffix handling
- DFU 1.1 support
-- Port to libusb 1.0 API
CLI:
- Status bar end marker or percentage values
diff --git a/aclocal.m4 b/aclocal.m4
index dccda9b..aa3003b 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -13,8 +13,8 @@
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
-m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.67],,
-[m4_warning([this file was generated for autoconf 2.67.
+m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.68],,
+[m4_warning([this file was generated for autoconf 2.68.
You have another version of autoconf. It may work, but is not guaranteed to.
If you have problems, you may need to regenerate the build system entirely.
To do so, use the procedure documented by the package, typically `autoreconf'.])])
@@ -47,7 +47,8 @@ To do so, use the procedure documented by the package, typically `autoreconf'.])
# ----------------------------------
AC_DEFUN([PKG_PROG_PKG_CONFIG],
[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
-m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
+m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
+m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
@@ -93,7 +94,8 @@ m4_define([_PKG_CONFIG],
pkg_cv_[]$1="$$1"
elif test -n "$PKG_CONFIG"; then
PKG_CHECK_EXISTS([$3],
- [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
+ [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
+ test "x$?" != "x0" && pkg_failed=yes ],
[pkg_failed=yes])
else
pkg_failed=untried
@@ -141,9 +143,9 @@ if test $pkg_failed = yes; then
AC_MSG_RESULT([no])
_PKG_SHORT_ERRORS_SUPPORTED
if test $_pkg_short_errors_supported = yes; then
- $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$2" 2>&1`
+ $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
else
- $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$2" 2>&1`
+ $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
fi
# Put the nasty error message in config.log where it belongs
echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
diff --git a/configure b/configure
index f765286..57c1b41 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.67 for dfu-util 0.3.
+# Generated by GNU Autoconf 2.68 for dfu-util 0.4.
#
#
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -89,6 +89,7 @@ fi
IFS=" "" $as_nl"
# Find who we are. Look in the path if we contain no directory separator.
+as_myself=
case $0 in #((
*[\\/]* ) as_myself=$0 ;;
*) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
@@ -214,11 +215,18 @@ IFS=$as_save_IFS
# We cannot yet assume a decent shell, so we have to provide a
# neutralization value for shells without unset; and this also
# works around shells that cannot unset nonexistent variables.
+ # Preserve -v and -x to the replacement shell.
BASH_ENV=/dev/null
ENV=/dev/null
(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
export CONFIG_SHELL
- exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"}
+ case $- in # ((((
+ *v*x* | *x*v* ) as_opts=-vx ;;
+ *v* ) as_opts=-v ;;
+ *x* ) as_opts=-x ;;
+ * ) as_opts= ;;
+ esac
+ exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"}
fi
if test x$as_have_required = xno; then :
@@ -549,8 +557,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='dfu-util'
PACKAGE_TARNAME='dfu-util'
-PACKAGE_VERSION='0.3'
-PACKAGE_STRING='dfu-util 0.3'
+PACKAGE_VERSION='0.4'
+PACKAGE_STRING='dfu-util 0.4'
PACKAGE_BUGREPORT=''
PACKAGE_URL=''
@@ -1109,7 +1117,7 @@ Try \`$0 --help' for more information"
$as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
$as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
- : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
+ : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}"
;;
esac
@@ -1247,7 +1255,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures dfu-util 0.3 to adapt to many kinds of systems.
+\`configure' configures dfu-util 0.4 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1313,7 +1321,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of dfu-util 0.3:";;
+ short | recursive ) echo "Configuration of dfu-util 0.4:";;
esac
cat <<\_ACEOF
@@ -1411,8 +1419,8 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-dfu-util configure 0.3
-generated by GNU Autoconf 2.67
+dfu-util configure 0.4
+generated by GNU Autoconf 2.68
Copyright (C) 2010 Free Software Foundation, Inc.
This configure script is free software; the Free Software Foundation
@@ -1458,7 +1466,7 @@ sed 's/^/| /' conftest.$ac_ext >&5
ac_retval=1
fi
- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
as_fn_set_status $ac_retval
} # ac_fn_c_try_compile
@@ -1504,7 +1512,7 @@ fi
# interfere with the next link command; also delete a directory that is
# left behind by Apple's compiler. We do this before executing the actions.
rm -rf conftest.dSYM conftest_ipa8_conftest.oo
- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
as_fn_set_status $ac_retval
} # ac_fn_c_try_link
@@ -1541,7 +1549,7 @@ sed 's/^/| /' conftest.$ac_ext >&5
ac_retval=1
fi
- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
as_fn_set_status $ac_retval
} # ac_fn_c_try_cpp
@@ -1583,7 +1591,7 @@ sed 's/^/| /' conftest.$ac_ext >&5
ac_retval=$ac_status
fi
rm -rf conftest.dSYM conftest_ipa8_conftest.oo
- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
as_fn_set_status $ac_retval
} # ac_fn_c_try_run
@@ -1596,10 +1604,10 @@ fi
ac_fn_c_check_header_mongrel ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
- if eval "test \"\${$3+set}\"" = set; then :
+ if eval \${$3+:} false; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
$as_echo_n "checking for $2... " >&6; }
-if eval "test \"\${$3+set}\"" = set; then :
+if eval \${$3+:} false; then :
$as_echo_n "(cached) " >&6
fi
eval ac_res=\$$3
@@ -1662,7 +1670,7 @@ $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
$as_echo_n "checking for $2... " >&6; }
-if eval "test \"\${$3+set}\"" = set; then :
+if eval \${$3+:} false; then :
$as_echo_n "(cached) " >&6
else
eval "$3=\$ac_header_compiler"
@@ -1671,7 +1679,7 @@ eval ac_res=\$$3
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
fi
- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_c_check_header_mongrel
@@ -1684,7 +1692,7 @@ ac_fn_c_check_header_compile ()
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
$as_echo_n "checking for $2... " >&6; }
-if eval "test \"\${$3+set}\"" = set; then :
+if eval \${$3+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -1702,7 +1710,7 @@ fi
eval ac_res=\$$3
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_c_check_header_compile
@@ -1715,7 +1723,7 @@ ac_fn_c_check_type ()
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
$as_echo_n "checking for $2... " >&6; }
-if eval "test \"\${$3+set}\"" = set; then :
+if eval \${$3+:} false; then :
$as_echo_n "(cached) " >&6
else
eval "$3=no"
@@ -1756,7 +1764,7 @@ fi
eval ac_res=\$$3
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_c_check_type
@@ -1768,7 +1776,7 @@ ac_fn_c_check_func ()
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
$as_echo_n "checking for $2... " >&6; }
-if eval "test \"\${$3+set}\"" = set; then :
+if eval \${$3+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -1823,15 +1831,15 @@ fi
eval ac_res=\$$3
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_c_check_func
cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by dfu-util $as_me 0.3, which was
-generated by GNU Autoconf 2.67. Invocation command line was
+It was created by dfu-util $as_me 0.4, which was
+generated by GNU Autoconf 2.68. Invocation command line was
$ $0 $@
@@ -2089,7 +2097,7 @@ $as_echo "$as_me: loading site script $ac_site_file" >&6;}
|| { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "failed to load site script $ac_site_file
-See \`config.log' for more details" "$LINENO" 5 ; }
+See \`config.log' for more details" "$LINENO" 5; }
fi
done
@@ -2226,7 +2234,7 @@ am__api_version='1.11'
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5
$as_echo_n "checking for a BSD-compatible install... " >&6; }
if test -z "$INSTALL"; then
-if test "${ac_cv_path_install+set}" = set; then :
+if ${ac_cv_path_install+:} false; then :
$as_echo_n "(cached) " >&6
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
@@ -2313,11 +2321,11 @@ am_lf='
'
case `pwd` in
*[\\\"\#\$\&\'\`$am_lf]*)
- as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5 ;;
+ as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;;
esac
case $srcdir in
*[\\\"\#\$\&\'\`$am_lf\ \ ]*)
- as_fn_error $? "unsafe srcdir value: \`$srcdir'" "$LINENO" 5 ;;
+ as_fn_error $? "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;;
esac
# Do `set' in a subshell so we don't clobber the current shell's
@@ -2403,7 +2411,7 @@ if test "$cross_compiling" != no; then
set dummy ${ac_tool_prefix}strip; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_STRIP+set}" = set; then :
+if ${ac_cv_prog_STRIP+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$STRIP"; then
@@ -2443,7 +2451,7 @@ if test -z "$ac_cv_prog_STRIP"; then
set dummy strip; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then :
+if ${ac_cv_prog_ac_ct_STRIP+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$ac_ct_STRIP"; then
@@ -2496,7 +2504,7 @@ INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5
$as_echo_n "checking for a thread-safe mkdir -p... " >&6; }
if test -z "$MKDIR_P"; then
- if test "${ac_cv_path_mkdir+set}" = set; then :
+ if ${ac_cv_path_mkdir+:} false; then :
$as_echo_n "(cached) " >&6
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
@@ -2547,7 +2555,7 @@ do
set dummy $ac_prog; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_AWK+set}" = set; then :
+if ${ac_cv_prog_AWK+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$AWK"; then
@@ -2587,7 +2595,7 @@ done
$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
set x ${MAKE-make}
ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
-if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\"" = set; then :
+if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then :
$as_echo_n "(cached) " >&6
else
cat >conftest.make <<\_ACEOF
@@ -2645,7 +2653,7 @@ fi
# Define the identity of the package.
PACKAGE=dfu-util
- VERSION=0.3
+ VERSION=0.4
cat >>confdefs.h <<_ACEOF
@@ -2737,7 +2745,7 @@ if test -n "$ac_tool_prefix"; then
set dummy ${ac_tool_prefix}gcc; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_CC+set}" = set; then :
+if ${ac_cv_prog_CC+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$CC"; then
@@ -2777,7 +2785,7 @@ if test -z "$ac_cv_prog_CC"; then
set dummy gcc; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then :
+if ${ac_cv_prog_ac_ct_CC+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$ac_ct_CC"; then
@@ -2830,7 +2838,7 @@ if test -z "$CC"; then
set dummy ${ac_tool_prefix}cc; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_CC+set}" = set; then :
+if ${ac_cv_prog_CC+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$CC"; then
@@ -2870,7 +2878,7 @@ if test -z "$CC"; then
set dummy cc; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_CC+set}" = set; then :
+if ${ac_cv_prog_CC+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$CC"; then
@@ -2929,7 +2937,7 @@ if test -z "$CC"; then
set dummy $ac_tool_prefix$ac_prog; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_CC+set}" = set; then :
+if ${ac_cv_prog_CC+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$CC"; then
@@ -2973,7 +2981,7 @@ do
set dummy $ac_prog; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then :
+if ${ac_cv_prog_ac_ct_CC+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$ac_ct_CC"; then
@@ -3028,7 +3036,7 @@ fi
test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "no acceptable C compiler found in \$PATH
-See \`config.log' for more details" "$LINENO" 5 ; }
+See \`config.log' for more details" "$LINENO" 5; }
# Provide some information about the compiler.
$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
@@ -3143,7 +3151,7 @@ sed 's/^/| /' conftest.$ac_ext >&5
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error 77 "C compiler cannot create executables
-See \`config.log' for more details" "$LINENO" 5 ; }
+See \`config.log' for more details" "$LINENO" 5; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
@@ -3186,7 +3194,7 @@ else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "cannot compute suffix of executables: cannot compile and link
-See \`config.log' for more details" "$LINENO" 5 ; }
+See \`config.log' for more details" "$LINENO" 5; }
fi
rm -f conftest conftest$ac_cv_exeext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
@@ -3245,7 +3253,7 @@ $as_echo "$ac_try_echo"; } >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "cannot run C compiled programs.
If you meant to cross compile, use \`--host'.
-See \`config.log' for more details" "$LINENO" 5 ; }
+See \`config.log' for more details" "$LINENO" 5; }
fi
fi
fi
@@ -3256,7 +3264,7 @@ rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
ac_clean_files=$ac_clean_files_save
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
$as_echo_n "checking for suffix of object files... " >&6; }
-if test "${ac_cv_objext+set}" = set; then :
+if ${ac_cv_objext+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -3297,7 +3305,7 @@ sed 's/^/| /' conftest.$ac_ext >&5
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "cannot compute suffix of object files: cannot compile
-See \`config.log' for more details" "$LINENO" 5 ; }
+See \`config.log' for more details" "$LINENO" 5; }
fi
rm -f conftest.$ac_cv_objext conftest.$ac_ext
fi
@@ -3307,7 +3315,7 @@ OBJEXT=$ac_cv_objext
ac_objext=$OBJEXT
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
-if test "${ac_cv_c_compiler_gnu+set}" = set; then :
+if ${ac_cv_c_compiler_gnu+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -3344,7 +3352,7 @@ ac_test_CFLAGS=${CFLAGS+set}
ac_save_CFLAGS=$CFLAGS
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
$as_echo_n "checking whether $CC accepts -g... " >&6; }
-if test "${ac_cv_prog_cc_g+set}" = set; then :
+if ${ac_cv_prog_cc_g+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_save_c_werror_flag=$ac_c_werror_flag
@@ -3422,7 +3430,7 @@ else
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
-if test "${ac_cv_prog_cc_c89+set}" = set; then :
+if ${ac_cv_prog_cc_c89+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_cv_prog_cc_c89=no
@@ -3583,7 +3591,7 @@ depcc="$CC" am_compiler_list=
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
$as_echo_n "checking dependency style of $depcc... " >&6; }
-if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then :
+if ${am_cv_CC_dependencies_compiler_type+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
@@ -3714,13 +3722,14 @@ fi
+
if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_PKG_CONFIG+set}" = set; then :
+if ${ac_cv_path_PKG_CONFIG+:} false; then :
$as_echo_n "(cached) " >&6
else
case $PKG_CONFIG in
@@ -3763,7 +3772,7 @@ if test -z "$ac_cv_path_PKG_CONFIG"; then
set dummy pkg-config; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then :
+if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then :
$as_echo_n "(cached) " >&6
else
case $ac_pt_PKG_CONFIG in
@@ -3836,12 +3845,13 @@ if test -n "$USB_CFLAGS"; then
pkg_cv_USB_CFLAGS="$USB_CFLAGS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
- { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libusb >= 0.1.4\""; } >&5
- ($PKG_CONFIG --exists --print-errors "libusb >= 0.1.4") 2>&5
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libusb-1.0 >= 1.0.0\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "libusb-1.0 >= 1.0.0") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
- pkg_cv_USB_CFLAGS=`$PKG_CONFIG --cflags "libusb >= 0.1.4" 2>/dev/null`
+ pkg_cv_USB_CFLAGS=`$PKG_CONFIG --cflags "libusb-1.0 >= 1.0.0" 2>/dev/null`
+ test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
fi
@@ -3852,12 +3862,13 @@ if test -n "$USB_LIBS"; then
pkg_cv_USB_LIBS="$USB_LIBS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
- { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libusb >= 0.1.4\""; } >&5
- ($PKG_CONFIG --exists --print-errors "libusb >= 0.1.4") 2>&5
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libusb-1.0 >= 1.0.0\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "libusb-1.0 >= 1.0.0") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
- pkg_cv_USB_LIBS=`$PKG_CONFIG --libs "libusb >= 0.1.4" 2>/dev/null`
+ pkg_cv_USB_LIBS=`$PKG_CONFIG --libs "libusb-1.0 >= 1.0.0" 2>/dev/null`
+ test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
fi
@@ -3877,18 +3888,18 @@ else
_pkg_short_errors_supported=no
fi
if test $_pkg_short_errors_supported = yes; then
- USB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "libusb >= 0.1.4" 2>&1`
+ USB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libusb-1.0 >= 1.0.0" 2>&1`
else
- USB_PKG_ERRORS=`$PKG_CONFIG --print-errors "libusb >= 0.1.4" 2>&1`
+ USB_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libusb-1.0 >= 1.0.0" 2>&1`
fi
# Put the nasty error message in config.log where it belongs
echo "$USB_PKG_ERRORS" >&5
- as_fn_error $? "*** Required libusb >= 0.1.4 not installed ***" "$LINENO" 5
+ as_fn_error $? "*** Required libusb-1.0 >= 1.0.0 not installed ***" "$LINENO" 5
elif test $pkg_failed = untried; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
- as_fn_error $? "*** Required libusb >= 0.1.4 not installed ***" "$LINENO" 5
+ as_fn_error $? "*** Required libusb-1.0 >= 1.0.0 not installed ***" "$LINENO" 5
else
USB_CFLAGS=$pkg_cv_USB_CFLAGS
USB_LIBS=$pkg_cv_USB_LIBS
@@ -3899,7 +3910,7 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for usb_path2devnum in -lusbpath" >&5
$as_echo_n "checking for usb_path2devnum in -lusbpath... " >&6; }
-if test "${ac_cv_lib_usbpath_usb_path2devnum+set}" = set; then :
+if ${ac_cv_lib_usbpath_usb_path2devnum+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
@@ -3933,7 +3944,7 @@ LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_usbpath_usb_path2devnum" >&5
$as_echo "$ac_cv_lib_usbpath_usb_path2devnum" >&6; }
-if test "x$ac_cv_lib_usbpath_usb_path2devnum" = x""yes; then :
+if test "x$ac_cv_lib_usbpath_usb_path2devnum" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBUSBPATH 1
_ACEOF
@@ -3959,7 +3970,7 @@ if test -n "$CPP" && test -d "$CPP"; then
CPP=
fi
if test -z "$CPP"; then
- if test "${ac_cv_prog_CPP+set}" = set; then :
+ if ${ac_cv_prog_CPP+:} false; then :
$as_echo_n "(cached) " >&6
else
# Double quotes because CPP needs to be expanded
@@ -4075,7 +4086,7 @@ else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
-See \`config.log' for more details" "$LINENO" 5 ; }
+See \`config.log' for more details" "$LINENO" 5; }
fi
ac_ext=c
@@ -4087,7 +4098,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
-if test "${ac_cv_path_GREP+set}" = set; then :
+if ${ac_cv_path_GREP+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -z "$GREP"; then
@@ -4150,7 +4161,7 @@ $as_echo "$ac_cv_path_GREP" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
$as_echo_n "checking for egrep... " >&6; }
-if test "${ac_cv_path_EGREP+set}" = set; then :
+if ${ac_cv_path_EGREP+:} false; then :
$as_echo_n "(cached) " >&6
else
if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
@@ -4217,7 +4228,7 @@ $as_echo "$ac_cv_path_EGREP" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
$as_echo_n "checking for ANSI C header files... " >&6; }
-if test "${ac_cv_header_stdc+set}" = set; then :
+if ${ac_cv_header_stdc+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -4361,7 +4372,7 @@ done
# Checks for typedefs, structures, and compiler characteristics.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5
$as_echo_n "checking for an ANSI C-conforming const... " >&6; }
-if test "${ac_cv_c_const+set}" = set; then :
+if ${ac_cv_c_const+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -4440,7 +4451,7 @@ $as_echo "#define const /**/" >>confdefs.h
fi
ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default"
-if test "x$ac_cv_type_size_t" = x""yes; then :
+if test "x$ac_cv_type_size_t" = xyes; then :
else
@@ -4455,7 +4466,7 @@ fi
for ac_header in stdlib.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default"
-if test "x$ac_cv_header_stdlib_h" = x""yes; then :
+if test "x$ac_cv_header_stdlib_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_STDLIB_H 1
_ACEOF
@@ -4466,7 +4477,7 @@ done
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU libc compatible malloc" >&5
$as_echo_n "checking for GNU libc compatible malloc... " >&6; }
-if test "${ac_cv_func_malloc_0_nonnull+set}" = set; then :
+if ${ac_cv_func_malloc_0_nonnull+:} false; then :
$as_echo_n "(cached) " >&6
else
if test "$cross_compiling" = yes; then :
@@ -4521,7 +4532,7 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working memcmp" >&5
$as_echo_n "checking for working memcmp... " >&6; }
-if test "${ac_cv_func_memcmp_working+set}" = set; then :
+if ${ac_cv_func_memcmp_working+:} false; then :
$as_echo_n "(cached) " >&6
else
if test "$cross_compiling" = yes; then :
@@ -4584,7 +4595,7 @@ esac
for ac_func in memset
do :
ac_fn_c_check_func "$LINENO" "memset" "ac_cv_func_memset"
-if test "x$ac_cv_func_memset" = x""yes; then :
+if test "x$ac_cv_func_memset" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_MEMSET 1
_ACEOF
@@ -4659,10 +4670,21 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
:end' >>confcache
if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
if test -w "$cache_file"; then
- test "x$cache_file" != "x/dev/null" &&
+ if test "x$cache_file" != "x/dev/null"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
$as_echo "$as_me: updating cache $cache_file" >&6;}
- cat confcache >$cache_file
+ if test ! -f "$cache_file" || test -h "$cache_file"; then
+ cat confcache >"$cache_file"
+ else
+ case $cache_file in #(
+ */* | ?:*)
+ mv -f confcache "$cache_file"$$ &&
+ mv -f "$cache_file"$$ "$cache_file" ;; #(
+ *)
+ mv -f confcache "$cache_file" ;;
+ esac
+ fi
+ fi
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
@@ -4714,7 +4736,7 @@ if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
-: ${CONFIG_STATUS=./config.status}
+: "${CONFIG_STATUS=./config.status}"
ac_write_fail=0
ac_clean_files_save=$ac_clean_files
ac_clean_files="$ac_clean_files $CONFIG_STATUS"
@@ -4815,6 +4837,7 @@ fi
IFS=" "" $as_nl"
# Find who we are. Look in the path if we contain no directory separator.
+as_myself=
case $0 in #((
*[\\/]* ) as_myself=$0 ;;
*) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
@@ -5121,8 +5144,8 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by dfu-util $as_me 0.3, which was
-generated by GNU Autoconf 2.67. Invocation command line was
+This file was extended by dfu-util $as_me 0.4, which was
+generated by GNU Autoconf 2.68. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
CONFIG_HEADERS = $CONFIG_HEADERS
@@ -5187,8 +5210,8 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-dfu-util config.status 0.3
-configured by $0, generated by GNU Autoconf 2.67,
+dfu-util config.status 0.4
+configured by $0, generated by GNU Autoconf 2.68,
with options \\"\$ac_cs_config\\"
Copyright (C) 2010 Free Software Foundation, Inc.
@@ -5322,7 +5345,7 @@ do
"src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;;
"doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;;
- *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5 ;;
+ *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
esac
done
@@ -5345,9 +5368,10 @@ fi
# after its creation but before its name has been assigned to `$tmp'.
$debug ||
{
- tmp=
+ tmp= ac_tmp=
trap 'exit_status=$?
- { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status
+ : "${ac_tmp:=$tmp}"
+ { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status
' 0
trap 'as_fn_exit 1' 1 2 13 15
}
@@ -5355,12 +5379,13 @@ $debug ||
{
tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
- test -n "$tmp" && test -d "$tmp"
+ test -d "$tmp"
} ||
{
tmp=./conf$$-$RANDOM
(umask 077 && mkdir "$tmp")
} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
+ac_tmp=$tmp
# Set up the scripts for CONFIG_FILES section.
# No need to generate them if there are no CONFIG_FILES.
@@ -5382,7 +5407,7 @@ else
ac_cs_awk_cr=$ac_cr
fi
-echo 'BEGIN {' >"$tmp/subs1.awk" &&
+echo 'BEGIN {' >"$ac_tmp/subs1.awk" &&
_ACEOF
@@ -5410,7 +5435,7 @@ done
rm -f conf$$subs.sh
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-cat >>"\$tmp/subs1.awk" <<\\_ACAWK &&
+cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK &&
_ACEOF
sed -n '
h
@@ -5458,7 +5483,7 @@ t delim
rm -f conf$$subs.awk
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
_ACAWK
-cat >>"\$tmp/subs1.awk" <<_ACAWK &&
+cat >>"\$ac_tmp/subs1.awk" <<_ACAWK &&
for (key in S) S_is_set[key] = 1
FS = ""
@@ -5490,7 +5515,7 @@ if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
else
cat
-fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \
+fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \
|| as_fn_error $? "could not setup config files machinery" "$LINENO" 5
_ACEOF
@@ -5524,7 +5549,7 @@ fi # test -n "$CONFIG_FILES"
# No need to generate them if there are no CONFIG_HEADERS.
# This happens for instance with `./config.status Makefile'.
if test -n "$CONFIG_HEADERS"; then
-cat >"$tmp/defines.awk" <<\_ACAWK ||
+cat >"$ac_tmp/defines.awk" <<\_ACAWK ||
BEGIN {
_ACEOF
@@ -5536,8 +5561,8 @@ _ACEOF
# handling of long lines.
ac_delim='%!_!# '
for ac_last_try in false false :; do
- ac_t=`sed -n "/$ac_delim/p" confdefs.h`
- if test -z "$ac_t"; then
+ ac_tt=`sed -n "/$ac_delim/p" confdefs.h`
+ if test -z "$ac_tt"; then
break
elif $ac_last_try; then
as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5
@@ -5638,7 +5663,7 @@ do
esac
case $ac_mode$ac_tag in
:[FHL]*:*);;
- :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5 ;;
+ :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;;
:[FH]-) ac_tag=-:-;;
:[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
esac
@@ -5657,7 +5682,7 @@ do
for ac_f
do
case $ac_f in
- -) ac_f="$tmp/stdin";;
+ -) ac_f="$ac_tmp/stdin";;
*) # Look for the file first in the build tree, then in the source tree
# (if the path is not absolute). The absolute path cannot be DOS-style,
# because $ac_f cannot contain `:'.
@@ -5666,7 +5691,7 @@ do
[\\/$]*) false;;
*) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
esac ||
- as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5 ;;
+ as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;
esac
case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
as_fn_append ac_file_inputs " '$ac_f'"
@@ -5692,8 +5717,8 @@ $as_echo "$as_me: creating $ac_file" >&6;}
esac
case $ac_tag in
- *:-:* | *:-) cat >"$tmp/stdin" \
- || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
+ *:-:* | *:-) cat >"$ac_tmp/stdin" \
+ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
esac
;;
esac
@@ -5829,21 +5854,22 @@ s&@INSTALL@&$ac_INSTALL&;t t
s&@MKDIR_P@&$ac_MKDIR_P&;t t
$ac_datarootdir_hack
"
-eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \
- || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \
+ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5
test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
- { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
- { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } &&
+ { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } &&
+ { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \
+ "$ac_tmp/out"`; test -z "$ac_out"; } &&
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
which seems to be undefined. Please make sure it is defined" >&5
$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
which seems to be undefined. Please make sure it is defined" >&2;}
- rm -f "$tmp/stdin"
+ rm -f "$ac_tmp/stdin"
case $ac_file in
- -) cat "$tmp/out" && rm -f "$tmp/out";;
- *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";;
+ -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";;
+ *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";;
esac \
|| as_fn_error $? "could not create $ac_file" "$LINENO" 5
;;
@@ -5854,20 +5880,20 @@ which seems to be undefined. Please make sure it is defined" >&2;}
if test x"$ac_file" != x-; then
{
$as_echo "/* $configure_input */" \
- && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs"
- } >"$tmp/config.h" \
+ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs"
+ } >"$ac_tmp/config.h" \
|| as_fn_error $? "could not create $ac_file" "$LINENO" 5
- if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then
+ if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
$as_echo "$as_me: $ac_file is unchanged" >&6;}
else
rm -f "$ac_file"
- mv "$tmp/config.h" "$ac_file" \
+ mv "$ac_tmp/config.h" "$ac_file" \
|| as_fn_error $? "could not create $ac_file" "$LINENO" 5
fi
else
$as_echo "/* $configure_input */" \
- && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \
+ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \
|| as_fn_error $? "could not create -" "$LINENO" 5
fi
# Compute "$ac_file"'s index in $config_headers.
diff --git a/configure.ac b/configure.ac
index 09a3a5c..c9dd2bb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
-AC_INIT([dfu-util],[0.3])
+AC_INIT([dfu-util],[0.4])
AC_CONFIG_AUX_DIR(m4)
AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
AM_CONFIG_HEADER([config.h])
@@ -16,8 +16,8 @@ AM_MAINTAINER_MODE
AC_PROG_CC
# Checks for libraries.
-PKG_CHECK_MODULES(USB, libusb >= 0.1.4,,
- AC_MSG_ERROR([*** Required libusb >= 0.1.4 not installed ***]))
+PKG_CHECK_MODULES(USB, libusb-1.0 >= 1.0.0,,
+ AC_MSG_ERROR([*** Required libusb-1.0 >= 1.0.0 not installed ***]))
AC_CHECK_LIB([usbpath],[usb_path2devnum],,,-lusb)
LIBS="$LIBS $USB_LIBS"
diff --git a/d/changelog b/d/changelog
new file mode 100644
index 0000000..9cbc42b
--- /dev/null
+++ b/d/changelog
@@ -0,0 +1,69 @@
+dfu-util (0.3-1) unstable; urgency=low
+
+ * New upstream release.
+ * Standards-Version: 3.9.1 (no changes required).
+ * debian/rules: Drop obsolete dfu-util_static removal, it's gone upstream.
+ * debian/patches/00_upload_fixes.patch: Drop, merged upstream.
+ * debian/copyright: Small updates.
+
+ -- Uwe Hermann <uwe@debian.org> Fri, 31 Dec 2010 22:32:52 +0100
+
+dfu-util (0.1-1) unstable; urgency=low
+
+ * New upstream release.
+ + Now states that only DFU 1.0 is supported (Closes: #569938).
+ * debian/control:
+ + Standards-Version: 3.9.0 (no changes required).
+ + Updated to new upstream homepage.
+ + Drop dependency on autoconf/automake, we no longer build from svn.
+ * debian/copyright: Various updates.
+ * debian/watch: Add proper URLs now, we no longer track svn snapshots.
+ * Fix "odd exit w/ upload; no error handling w/ download" (Closes: #582956).
+ Thanks C. Scott Ananian <cscott@cscott.net> for the patch!
+
+ -- Uwe Hermann <uwe@debian.org> Sat, 24 Jul 2010 15:46:44 +0200
+
+dfu-util (0.0+r4880-1) unstable; urgency=low
+
+ * Acknowledge NMU (Closes: #469892). Thanks Riku Voipio <riku.voipio@iki.fi>.
+ * New upstream release.
+ + This should also fix some broken behaviour on big-endian architectures.
+ * debian/control:
+ + Standards-Version: 3.8.0 (no changes required).
+ + Small description fix to silence bogus lintian warning.
+ * debian/copyright: Updates.
+ * debian/dfu-util.1: Dropped, now included upstream.
+ * debian/watch: Add dummy file to silence lintian (we track svn revisions).
+ * debian/rules: Remove generated files from diff.
+
+ -- Uwe Hermann <uwe@debian.org> Sun, 28 Dec 2008 05:47:51 +0100
+
+dfu-util (0.0+r4067-3.1) unstable; urgency=low
+
+ * Non-maintainer upload.
+ * 0 day NMU for RC bug
+ * Add pkg-config to build-depends and verify with pbuilder that it works,
+ closes: #469892 , thanks Sebastian Bober sbober servercare.de
+
+ -- Riku Voipio <riku.voipio@iki.fi> Wed, 28 May 2008 18:08:17 +0300
+
+dfu-util (0.0+r4067-3) unstable; urgency=low
+
+ * Add missing autoconf/automake build dependencies (Closes: #468791).
+ * I wrote a manpage, as there is none upstream.
+
+ -- Uwe Hermann <uwe@debian.org> Sat, 01 Mar 2008 16:40:04 +0100
+
+dfu-util (0.0+r4067-2) unstable; urgency=low
+
+ * Do not install the dfu-util_static binary, it's not needed in Debian.
+ * debian/copyright: Convert to the machine-readable format described at
+ http://wiki.debian.org/Proposals/CopyrightFormat.
+
+ -- Uwe Hermann <uwe@debian.org> Wed, 27 Feb 2008 21:24:42 +0100
+
+dfu-util (0.0+r4067-1) unstable; urgency=low
+
+ * Initial release (Closes: #465896).
+
+ -- Uwe Hermann <uwe@debian.org> Wed, 27 Feb 2008 16:45:28 +0100
diff --git a/d/compat b/d/compat
new file mode 100644
index 0000000..7f8f011
--- /dev/null
+++ b/d/compat
@@ -0,0 +1 @@
+7
diff --git a/d/control b/d/control
new file mode 100644
index 0000000..d061485
--- /dev/null
+++ b/d/control
@@ -0,0 +1,21 @@
+Source: dfu-util
+Section: electronics
+Priority: extra
+Maintainer: Uwe Hermann <uwe@debian.org>
+Build-Depends: cdbs, debhelper (>= 7.0.50~), autotools-dev, libusb-dev, pkg-config
+Standards-Version: 3.9.1
+Homepage: http://dfu-util.gnumonks.org/
+
+Package: dfu-util
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: Device firmware update (DFU 1.0) USB programmer
+ dfu-util is a program that implements the host (PC) side of the USB DFU 1.0
+ (Universal Serial Bus Device Firmware Upgrade) protocol.
+ .
+ Note: At this point only DFU version 1.0 is supported!
+ .
+ In the OpenMoko project (for example), this program is used to communicate
+ with the specially enhanced bootloader u-boot, which implements the DFU
+ device side.
+
diff --git a/d/copyright b/d/copyright
new file mode 100644
index 0000000..0775f91
--- /dev/null
+++ b/d/copyright
@@ -0,0 +1,34 @@
+This package was debianized by Uwe Hermann <uwe@debian.org> on
+Fri, 15 Feb 2008 12:51:18 +0100.
+
+It was downloaded from:
+
+ http://dfu-util.gnumonks.org/
+
+Upstream authors:
+
+ Weston Schmidt <weston_schmidt@yahoo.com>
+ Harald Welte <hwelte@hmw-consulting.de>
+ Stefan Schmidt <stefan@datenfreihafen.org>
+ Tormod Volden <debian.tormod@gmail.com>
+
+-------------------------------------------------------------------------------
+
+Files: *
+Copyright: © 2005-2007 Weston Schmidt <weston_schmidt@yahoo.com>
+ © 2006-2008 Harald Welte <hwelte@hmw-consulting.de>
+ © 2007-2008 OpenMoko, Inc.
+ © 2010 Tormod Volden
+License: GPL-2+
+
+On Debian systems, the complete text of the GNU General
+Public License can be found in `/usr/share/common-licenses/GPL-2'.
+
+-------------------------------------------------------------------------------
+
+Files: debian/*
+Copyright: © 2008-2010 Uwe Hermann <uwe@debian.org>
+License: GPL-2+
+ The Debian packaging is © 2008-2010, Uwe Hermann <uwe@debian.org> and
+ is licensed under the GPL (version 2 or later), see above.
+
diff --git a/d/docs b/d/docs
new file mode 100644
index 0000000..724e084
--- /dev/null
+++ b/d/docs
@@ -0,0 +1,2 @@
+README
+TODO
diff --git a/d/rules b/d/rules
new file mode 100755
index 0000000..5d0b9a9
--- /dev/null
+++ b/d/rules
@@ -0,0 +1,10 @@
+#!/usr/bin/make -f
+
+include /usr/share/cdbs/1/rules/debhelper.mk
+include /usr/share/cdbs/1/class/autotools.mk
+include /usr/share/cdbs/1/rules/utils.mk
+
+DEB_INSTALL_MANPAGES_dfu-util := doc/dfu-util.1
+
+common-binary-post-install-arch:: list-missing
+
diff --git a/d/source/format b/d/source/format
new file mode 100644
index 0000000..163aaf8
--- /dev/null
+++ b/d/source/format
@@ -0,0 +1 @@
+3.0 (quilt)
diff --git a/d/watch b/d/watch
new file mode 100644
index 0000000..114e5c6
--- /dev/null
+++ b/d/watch
@@ -0,0 +1,2 @@
+version=3
+http://dfu-util.gnumonks.org/releases/dfu-util-(.*)\.tar\.gz
diff --git a/debian/changelog b/debian/changelog
index 9cbc42b..b9b7735 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+dfu-util (0.4-1) unstable; urgency=low
+
+ * New upstream release.
+ * Standards-Version: 3.9.2 (no changes required).
+ * Change Build-Depends libusb-dev to libusb-1.0-0-dev (upstream switch).
+
+ -- Uwe Hermann <uwe@debian.org> Wed, 31 Aug 2011 23:10:22 +0200
+
dfu-util (0.3-1) unstable; urgency=low
* New upstream release.
diff --git a/debian/control b/debian/control
index d061485..a9dec46 100644
--- a/debian/control
+++ b/debian/control
@@ -2,8 +2,8 @@ Source: dfu-util
Section: electronics
Priority: extra
Maintainer: Uwe Hermann <uwe@debian.org>
-Build-Depends: cdbs, debhelper (>= 7.0.50~), autotools-dev, libusb-dev, pkg-config
-Standards-Version: 3.9.1
+Build-Depends: cdbs, debhelper (>= 7.0.50~), autotools-dev, libusb-1.0-0-dev, pkg-config
+Standards-Version: 3.9.2
Homepage: http://dfu-util.gnumonks.org/
Package: dfu-util
diff --git a/debian/dd/README.Debian b/debian/dd/README.Debian
new file mode 100644
index 0000000..65128d5
--- /dev/null
+++ b/debian/dd/README.Debian
@@ -0,0 +1,6 @@
+dfu-util for Debian
+-------------------
+
+<possible notes regarding this package - if none, delete this file>
+
+ -- Uwe Hermann <uwe@debian.org> Wed, 31 Aug 2011 23:10:05 +0200
diff --git a/debian/dd/README.source b/debian/dd/README.source
new file mode 100644
index 0000000..94c5ad6
--- /dev/null
+++ b/debian/dd/README.source
@@ -0,0 +1,9 @@
+dfu-util for Debian
+-------------------
+
+<this file describes information about the source package, see Debian policy
+manual section 4.14. You WILL either need to modify or delete this file>
+
+
+
+
diff --git a/debian/dd/changelog b/debian/dd/changelog
new file mode 100644
index 0000000..df2c12c
--- /dev/null
+++ b/debian/dd/changelog
@@ -0,0 +1,5 @@
+dfu-util (0.4-1) unstable; urgency=low
+
+ * Initial release (Closes: #nnnn) <nnnn is the bug number of your ITP>
+
+ -- Uwe Hermann <uwe@debian.org> Wed, 31 Aug 2011 23:10:05 +0200
diff --git a/debian/dd/compat b/debian/dd/compat
new file mode 100644
index 0000000..45a4fb7
--- /dev/null
+++ b/debian/dd/compat
@@ -0,0 +1 @@
+8
diff --git a/debian/dd/control b/debian/dd/control
new file mode 100644
index 0000000..84b88bb
--- /dev/null
+++ b/debian/dd/control
@@ -0,0 +1,15 @@
+Source: dfu-util
+Section: unknown
+Priority: extra
+Maintainer: Uwe Hermann <uwe@debian.org>
+Build-Depends: cdbs, debhelper (>= 8.0.0), autotools-dev
+Standards-Version: 3.9.2
+Homepage: <insert the upstream URL, if relevant>
+#Vcs-Git: git://git.debian.org/collab-maint/dfu-util.git
+#Vcs-Browser: http://git.debian.org/?p=collab-maint/dfu-util.git;a=summary
+
+Package: dfu-util
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: <insert up to 60 chars description>
+ <insert long description, indented with spaces>
diff --git a/debian/dd/copyright b/debian/dd/copyright
new file mode 100644
index 0000000..4f39646
--- /dev/null
+++ b/debian/dd/copyright
@@ -0,0 +1,32 @@
+Format: http://dep.debian.net/deps/dep5
+Upstream-Name: dfu-util
+Source: <url://example.com>
+
+Files: *
+Copyright: <years> <put author's name and email here>
+ <years> <likewise for another author>
+License: GPL-3.0+
+
+Files: debian/*
+Copyright: 2011 Uwe Hermann <uwe@debian.org>
+License: GPL-3.0+
+
+License: GPL-3.0+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+ .
+ This package is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+ .
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ .
+ On Debian systems, the complete text of the GNU General
+ Public License version 3 can be found in "/usr/share/common-licenses/GPL-3".
+
+# Please also look if there are files or directories which have a
+# different copyright/license attached and list them here.
diff --git a/debian/dd/dfu-util.cron.d.ex b/debian/dd/dfu-util.cron.d.ex
new file mode 100644
index 0000000..d59f7dc
--- /dev/null
+++ b/debian/dd/dfu-util.cron.d.ex
@@ -0,0 +1,4 @@
+#
+# Regular cron jobs for the dfu-util package
+#
+0 4 * * * root [ -x /usr/bin/dfu-util_maintenance ] && /usr/bin/dfu-util_maintenance
diff --git a/debian/dd/dfu-util.default.ex b/debian/dd/dfu-util.default.ex
new file mode 100644
index 0000000..15018ce
--- /dev/null
+++ b/debian/dd/dfu-util.default.ex
@@ -0,0 +1,10 @@
+# Defaults for dfu-util initscript
+# sourced by /etc/init.d/dfu-util
+# installed at /etc/default/dfu-util by the maintainer scripts
+
+#
+# This is a POSIX shell fragment
+#
+
+# Additional options that are passed to the Daemon.
+DAEMON_OPTS=""
diff --git a/debian/dd/dfu-util.doc-base.EX b/debian/dd/dfu-util.doc-base.EX
new file mode 100644
index 0000000..d881bd1
--- /dev/null
+++ b/debian/dd/dfu-util.doc-base.EX
@@ -0,0 +1,20 @@
+Document: dfu-util
+Title: Debian dfu-util Manual
+Author: <insert document author here>
+Abstract: This manual describes what dfu-util is
+ and how it can be used to
+ manage online manuals on Debian systems.
+Section: unknown
+
+Format: debiandoc-sgml
+Files: /usr/share/doc/dfu-util/dfu-util.sgml.gz
+
+Format: postscript
+Files: /usr/share/doc/dfu-util/dfu-util.ps.gz
+
+Format: text
+Files: /usr/share/doc/dfu-util/dfu-util.text.gz
+
+Format: HTML
+Index: /usr/share/doc/dfu-util/html/index.html
+Files: /usr/share/doc/dfu-util/html/*.html
diff --git a/debian/dd/docs b/debian/dd/docs
new file mode 100644
index 0000000..139d4b4
--- /dev/null
+++ b/debian/dd/docs
@@ -0,0 +1,3 @@
+DEVICES.txt
+README
+TODO
diff --git a/debian/dd/emacsen-install.ex b/debian/dd/emacsen-install.ex
new file mode 100644
index 0000000..fc01d1a
--- /dev/null
+++ b/debian/dd/emacsen-install.ex
@@ -0,0 +1,45 @@
+#! /bin/sh -e
+# /usr/lib/emacsen-common/packages/install/dfu-util
+
+# Written by Jim Van Zandt <jrv@debian.org>, borrowing heavily
+# from the install scripts for gettext by Santiago Vila
+# <sanvila@ctv.es> and octave by Dirk Eddelbuettel <edd@debian.org>.
+
+FLAVOR=$1
+PACKAGE=dfu-util
+
+if [ ${FLAVOR} = emacs ]; then exit 0; fi
+
+echo install/${PACKAGE}: Handling install for emacsen flavor ${FLAVOR}
+
+#FLAVORTEST=`echo $FLAVOR | cut -c-6`
+#if [ ${FLAVORTEST} = xemacs ] ; then
+# SITEFLAG="-no-site-file"
+#else
+# SITEFLAG="--no-site-file"
+#fi
+FLAGS="${SITEFLAG} -q -batch -l path.el -f batch-byte-compile"
+
+ELDIR=/usr/share/emacs/site-lisp/${PACKAGE}
+ELCDIR=/usr/share/${FLAVOR}/site-lisp/${PACKAGE}
+
+# Install-info-altdir does not actually exist.
+# Maybe somebody will write it.
+if test -x /usr/sbin/install-info-altdir; then
+ echo install/${PACKAGE}: install Info links for ${FLAVOR}
+ install-info-altdir --quiet --section "" "" --dirname=${FLAVOR} /usr/share/info/${PACKAGE}.info.gz
+fi
+
+install -m 755 -d ${ELCDIR}
+cd ${ELDIR}
+FILES=`echo *.el`
+cp ${FILES} ${ELCDIR}
+cd ${ELCDIR}
+
+cat << EOF > path.el
+(setq load-path (cons "." load-path) byte-compile-warnings nil)
+EOF
+${FLAVOR} ${FLAGS} ${FILES}
+rm -f *.el path.el
+
+exit 0
diff --git a/debian/dd/emacsen-remove.ex b/debian/dd/emacsen-remove.ex
new file mode 100644
index 0000000..33f35fe
--- /dev/null
+++ b/debian/dd/emacsen-remove.ex
@@ -0,0 +1,15 @@
+#!/bin/sh -e
+# /usr/lib/emacsen-common/packages/remove/dfu-util
+
+FLAVOR=$1
+PACKAGE=dfu-util
+
+if [ ${FLAVOR} != emacs ]; then
+ if test -x /usr/sbin/install-info-altdir; then
+ echo remove/${PACKAGE}: removing Info links for ${FLAVOR}
+ install-info-altdir --quiet --remove --dirname=${FLAVOR} /usr/share/info/dfu-util.info.gz
+ fi
+
+ echo remove/${PACKAGE}: purging byte-compiled files for ${FLAVOR}
+ rm -rf /usr/share/${FLAVOR}/site-lisp/${PACKAGE}
+fi
diff --git a/debian/dd/emacsen-startup.ex b/debian/dd/emacsen-startup.ex
new file mode 100644
index 0000000..1d94e94
--- /dev/null
+++ b/debian/dd/emacsen-startup.ex
@@ -0,0 +1,25 @@
+;; -*-emacs-lisp-*-
+;;
+;; Emacs startup file, e.g. /etc/emacs/site-start.d/50dfu-util.el
+;; for the Debian dfu-util package
+;;
+;; Originally contributed by Nils Naumann <naumann@unileoben.ac.at>
+;; Modified by Dirk Eddelbuettel <edd@debian.org>
+;; Adapted for dh-make by Jim Van Zandt <jrv@debian.org>
+
+;; The dfu-util package follows the Debian/GNU Linux 'emacsen' policy and
+;; byte-compiles its elisp files for each 'emacs flavor' (emacs19,
+;; xemacs19, emacs20, xemacs20...). The compiled code is then
+;; installed in a subdirectory of the respective site-lisp directory.
+;; We have to add this to the load-path:
+(let ((package-dir (concat "/usr/share/"
+ (symbol-name flavor)
+ "/site-lisp/dfu-util")))
+;; If package-dir does not exist, the dfu-util package must have
+;; removed but not purged, and we should skip the setup.
+ (when (file-directory-p package-dir)
+ (setq load-path (cons package-dir load-path))
+ (autoload 'dfu-util-mode "dfu-util-mode"
+ "Major mode for editing dfu-util files." t)
+ (add-to-list 'auto-mode-alist '("\\.dfu-util$" . dfu-util-mode))))
+
diff --git a/debian/dd/init.d.ex b/debian/dd/init.d.ex
new file mode 100644
index 0000000..abdbb84
--- /dev/null
+++ b/debian/dd/init.d.ex
@@ -0,0 +1,154 @@
+#!/bin/sh
+### BEGIN INIT INFO
+# Provides: dfu-util
+# Required-Start: $network $local_fs
+# Required-Stop:
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: <Enter a short description of the sortware>
+# Description: <Enter a long description of the software>
+# <...>
+# <...>
+### END INIT INFO
+
+# Author: Uwe Hermann <uwe@debian.org>
+
+# PATH should only include /usr/* if it runs after the mountnfs.sh script
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+DESC=dfu-util # Introduce a short description here
+NAME=dfu-util # Introduce the short server's name here
+DAEMON=/usr/sbin/dfu-util # Introduce the server's location here
+DAEMON_ARGS="" # Arguments to run the daemon with
+PIDFILE=/var/run/$NAME.pid
+SCRIPTNAME=/etc/init.d/$NAME
+
+# Exit if the package is not installed
+[ -x $DAEMON ] || exit 0
+
+# Read configuration variable file if it is present
+[ -r /etc/default/$NAME ] && . /etc/default/$NAME
+
+# Load the VERBOSE setting and other rcS variables
+. /lib/init/vars.sh
+
+# Define LSB log_* functions.
+# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
+. /lib/lsb/init-functions
+
+#
+# Function that starts the daemon/service
+#
+do_start()
+{
+ # Return
+ # 0 if daemon has been started
+ # 1 if daemon was already running
+ # 2 if daemon could not be started
+ start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
+ || return 1
+ start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
+ $DAEMON_ARGS \
+ || return 2
+ # Add code here, if necessary, that waits for the process to be ready
+ # to handle requests from services started subsequently which depend
+ # on this one. As a last resort, sleep for some time.
+}
+
+#
+# Function that stops the daemon/service
+#
+do_stop()
+{
+ # Return
+ # 0 if daemon has been stopped
+ # 1 if daemon was already stopped
+ # 2 if daemon could not be stopped
+ # other if a failure occurred
+ start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
+ RETVAL="$?"
+ [ "$RETVAL" = 2 ] && return 2
+ # Wait for children to finish too if this is a daemon that forks
+ # and if the daemon is only ever run from this initscript.
+ # If the above conditions are not satisfied then add some other code
+ # that waits for the process to drop all resources that could be
+ # needed by services started subsequently. A last resort is to
+ # sleep for some time.
+ start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
+ [ "$?" = 2 ] && return 2
+ # Many daemons don't delete their pidfiles when they exit.
+ rm -f $PIDFILE
+ return "$RETVAL"
+}
+
+#
+# Function that sends a SIGHUP to the daemon/service
+#
+do_reload() {
+ #
+ # If the daemon can reload its configuration without
+ # restarting (for example, when it is sent a SIGHUP),
+ # then implement that here.
+ #
+ start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
+ return 0
+}
+
+case "$1" in
+ start)
+ [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME"
+ do_start
+ case "$?" in
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+ esac
+ ;;
+ stop)
+ [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
+ do_stop
+ case "$?" in
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+ esac
+ ;;
+ status)
+ status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
+ ;;
+ #reload|force-reload)
+ #
+ # If do_reload() is not implemented then leave this commented out
+ # and leave 'force-reload' as an alias for 'restart'.
+ #
+ #log_daemon_msg "Reloading $DESC" "$NAME"
+ #do_reload
+ #log_end_msg $?
+ #;;
+ restart|force-reload)
+ #
+ # If the "reload" option is implemented then remove the
+ # 'force-reload' alias
+ #
+ log_daemon_msg "Restarting $DESC" "$NAME"
+ do_stop
+ case "$?" in
+ 0|1)
+ do_start
+ case "$?" in
+ 0) log_end_msg 0 ;;
+ 1) log_end_msg 1 ;; # Old process is still running
+ *) log_end_msg 1 ;; # Failed to start
+ esac
+ ;;
+ *)
+ # Failed to stop
+ log_end_msg 1
+ ;;
+ esac
+ ;;
+ *)
+ #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
+ echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
+ exit 3
+ ;;
+esac
+
+:
diff --git a/debian/dd/manpage.1.ex b/debian/dd/manpage.1.ex
new file mode 100644
index 0000000..dc0bb65
--- /dev/null
+++ b/debian/dd/manpage.1.ex
@@ -0,0 +1,59 @@
+.\" Hey, EMACS: -*- nroff -*-
+.\" First parameter, NAME, should be all caps
+.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
+.\" other parameters are allowed: see man(7), man(1)
+.TH DFU-UTIL SECTION "August 31, 2011"
+.\" Please adjust this date whenever revising the manpage.
+.\"
+.\" Some roff macros, for reference:
+.\" .nh disable hyphenation
+.\" .hy enable hyphenation
+.\" .ad l left justify
+.\" .ad b justify to both left and right margins
+.\" .nf disable filling
+.\" .fi enable filling
+.\" .br insert line break
+.\" .sp <n> insert n+1 empty lines
+.\" for manpage-specific macros, see man(7)
+.SH NAME
+dfu-util \- program to do something
+.SH SYNOPSIS
+.B dfu-util
+.RI [ options ] " files" ...
+.br
+.B bar
+.RI [ options ] " files" ...
+.SH DESCRIPTION
+This manual page documents briefly the
+.B dfu-util
+and
+.B bar
+commands.
+.PP
+.\" TeX users may be more comfortable with the \fB<whatever>\fP and
+.\" \fI<whatever>\fP escape sequences to invode bold face and italics,
+.\" respectively.
+\fBdfu-util\fP is a program that...
+.SH OPTIONS
+These programs follow the usual GNU command line syntax, with long
+options starting with two dashes (`-').
+A summary of options is included below.
+For a complete description, see the Info files.
+.TP
+.B \-h, \-\-help
+Show summary of options.
+.TP
+.B \-v, \-\-version
+Show version of program.
+.SH SEE ALSO
+.BR bar (1),
+.BR baz (1).
+.br
+The programs are documented fully by
+.IR "The Rise and Fall of a Fooish Bar" ,
+available via the Info system.
+.SH AUTHOR
+dfu-util was written by <upstream author>.
+.PP
+This manual page was written by Uwe Hermann <uwe@debian.org>,
+for the Debian project (and may be used by others).
diff --git a/debian/dd/manpage.sgml.ex b/debian/dd/manpage.sgml.ex
new file mode 100644
index 0000000..651f36c
--- /dev/null
+++ b/debian/dd/manpage.sgml.ex
@@ -0,0 +1,154 @@
+<!doctype refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN" [
+
+<!-- Process this file with docbook-to-man to generate an nroff manual
+ page: `docbook-to-man manpage.sgml > manpage.1'. You may view
+ the manual page with: `docbook-to-man manpage.sgml | nroff -man |
+ less'. A typical entry in a Makefile or Makefile.am is:
+
+manpage.1: manpage.sgml
+ docbook-to-man $< > $@
+
+
+ The docbook-to-man binary is found in the docbook-to-man package.
+ Please remember that if you create the nroff version in one of the
+ debian/rules file targets (such as build), you will need to include
+ docbook-to-man in your Build-Depends control field.
+
+ -->
+
+ <!-- Fill in your name for FIRSTNAME and SURNAME. -->
+ <!ENTITY dhfirstname "<firstname>FIRSTNAME</firstname>">
+ <!ENTITY dhsurname "<surname>SURNAME</surname>">
+ <!-- Please adjust the date whenever revising the manpage. -->
+ <!ENTITY dhdate "<date>August 31, 2011</date>">
+ <!-- SECTION should be 1-8, maybe w/ subsection other parameters are
+ allowed: see man(7), man(1). -->
+ <!ENTITY dhsection "<manvolnum>SECTION</manvolnum>">
+ <!ENTITY dhemail "<email>uwe@debian.org</email>">
+ <!ENTITY dhusername "Uwe Hermann">
+ <!ENTITY dhucpackage "<refentrytitle>DFU-UTIL</refentrytitle>">
+ <!ENTITY dhpackage "dfu-util">
+
+ <!ENTITY debian "<productname>Debian</productname>">
+ <!ENTITY gnu "<acronym>GNU</acronym>">
+ <!ENTITY gpl "&gnu; <acronym>GPL</acronym>">
+]>
+
+<refentry>
+ <refentryinfo>
+ <address>
+ &dhemail;
+ </address>
+ <author>
+ &dhfirstname;
+ &dhsurname;
+ </author>
+ <copyright>
+ <year>2003</year>
+ <holder>&dhusername;</holder>
+ </copyright>
+ &dhdate;
+ </refentryinfo>
+ <refmeta>
+ &dhucpackage;
+
+ &dhsection;
+ </refmeta>
+ <refnamediv>
+ <refname>&dhpackage;</refname>
+
+ <refpurpose>program to do something</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>&dhpackage;</command>
+
+ <arg><option>-e <replaceable>this</replaceable></option></arg>
+
+ <arg><option>--example <replaceable>that</replaceable></option></arg>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1>
+ <title>DESCRIPTION</title>
+
+ <para>This manual page documents briefly the
+ <command>&dhpackage;</command> and <command>bar</command>
+ commands.</para>
+
+ <para>This manual page was written for the &debian; distribution
+ because the original program does not have a manual page.
+ Instead, it has documentation in the &gnu;
+ <application>Info</application> format; see below.</para>
+
+ <para><command>&dhpackage;</command> is a program that...</para>
+
+ </refsect1>
+ <refsect1>
+ <title>OPTIONS</title>
+
+ <para>These programs follow the usual &gnu; command line syntax,
+ with long options starting with two dashes (`-'). A summary of
+ options is included below. For a complete description, see the
+ <application>Info</application> files.</para>
+
+ <variablelist>
+ <varlistentry>
+ <term><option>-h</option>
+ <option>--help</option>
+ </term>
+ <listitem>
+ <para>Show summary of options.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>-v</option>
+ <option>--version</option>
+ </term>
+ <listitem>
+ <para>Show version of program.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+ <refsect1>
+ <title>SEE ALSO</title>
+
+ <para>bar (1), baz (1).</para>
+
+ <para>The programs are documented fully by <citetitle>The Rise and
+ Fall of a Fooish Bar</citetitle> available via the
+ <application>Info</application> system.</para>
+ </refsect1>
+ <refsect1>
+ <title>AUTHOR</title>
+
+ <para>This manual page was written by &dhusername; &dhemail; for
+ the &debian; system (and may be used by others). Permission is
+ granted to copy, distribute and/or modify this document under
+ the terms of the &gnu; General Public License, Version 2 any
+ later version published by the Free Software Foundation.
+ </para>
+ <para>
+ On Debian systems, the complete text of the GNU General Public
+ License can be found in /usr/share/common-licenses/GPL.
+ </para>
+
+ </refsect1>
+</refentry>
+
+<!-- Keep this comment at the end of the file
+Local variables:
+mode: sgml
+sgml-omittag:t
+sgml-shorttag:t
+sgml-minimize-attributes:nil
+sgml-always-quote-attributes:t
+sgml-indent-step:2
+sgml-indent-data:t
+sgml-parent-document:nil
+sgml-default-dtd-file:nil
+sgml-exposed-tags:nil
+sgml-local-catalogs:nil
+sgml-local-ecat-files:nil
+End:
+-->
diff --git a/debian/dd/manpage.xml.ex b/debian/dd/manpage.xml.ex
new file mode 100644
index 0000000..3692508
--- /dev/null
+++ b/debian/dd/manpage.xml.ex
@@ -0,0 +1,291 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+
+<!--
+
+`xsltproc -''-nonet \
+ -''-param man.charmap.use.subset "0" \
+ -''-param make.year.ranges "1" \
+ -''-param make.single.year.ranges "1" \
+ /usr/share/xml/docbook/stylesheet/docbook-xsl/manpages/docbook.xsl \
+ manpage.xml'
+
+A manual page <package>.<section> will be generated. You may view the
+manual page with: nroff -man <package>.<section> | less'. A typical entry
+in a Makefile or Makefile.am is:
+
+DB2MAN = /usr/share/sgml/docbook/stylesheet/xsl/docbook-xsl/manpages/docbook.xsl
+XP = xsltproc -''-nonet -''-param man.charmap.use.subset "0"
+
+manpage.1: manpage.xml
+ $(XP) $(DB2MAN) $<
+
+The xsltproc binary is found in the xsltproc package. The XSL files are in
+docbook-xsl. A description of the parameters you can use can be found in the
+docbook-xsl-doc-* packages. Please remember that if you create the nroff
+version in one of the debian/rules file targets (such as build), you will need
+to include xsltproc and docbook-xsl in your Build-Depends control field.
+Alternatively use the xmlto command/package. That will also automatically
+pull in xsltproc and docbook-xsl.
+
+Notes for using docbook2x: docbook2x-man does not automatically create the
+AUTHOR(S) and COPYRIGHT sections. In this case, please add them manually as
+<refsect1> ... </refsect1>.
+
+To disable the automatic creation of the AUTHOR(S) and COPYRIGHT sections
+read /usr/share/doc/docbook-xsl/doc/manpages/authors.html. This file can be
+found in the docbook-xsl-doc-html package.
+
+Validation can be done using: `xmllint -''-noout -''-valid manpage.xml`
+
+General documentation about man-pages and man-page-formatting:
+man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/
+
+-->
+
+ <!-- Fill in your name for FIRSTNAME and SURNAME. -->
+ <!ENTITY dhfirstname "FIRSTNAME">
+ <!ENTITY dhsurname "SURNAME">
+ <!-- dhusername could also be set to "&dhfirstname; &dhsurname;". -->
+ <!ENTITY dhusername "Uwe Hermann">
+ <!ENTITY dhemail "uwe@debian.org">
+ <!-- SECTION should be 1-8, maybe w/ subsection other parameters are
+ allowed: see man(7), man(1) and
+ http://www.tldp.org/HOWTO/Man-Page/q2.html. -->
+ <!ENTITY dhsection "SECTION">
+ <!-- TITLE should be something like "User commands" or similar (see
+ http://www.tldp.org/HOWTO/Man-Page/q2.html). -->
+ <!ENTITY dhtitle "dfu-util User Manual">
+ <!ENTITY dhucpackage "DFU-UTIL">
+ <!ENTITY dhpackage "dfu-util">
+]>
+
+<refentry>
+ <refentryinfo>
+ <title>&dhtitle;</title>
+ <productname>&dhpackage;</productname>
+ <authorgroup>
+ <author>
+ <firstname>&dhfirstname;</firstname>
+ <surname>&dhsurname;</surname>
+ <contrib>Wrote this manpage for the Debian system.</contrib>
+ <address>
+ <email>&dhemail;</email>
+ </address>
+ </author>
+ </authorgroup>
+ <copyright>
+ <year>2007</year>
+ <holder>&dhusername;</holder>
+ </copyright>
+ <legalnotice>
+ <para>This manual page was written for the Debian system
+ (and may be used by others).</para>
+ <para>Permission is granted to copy, distribute and/or modify this
+ document under the terms of the GNU General Public License,
+ Version 2 or (at your option) any later version published by
+ the Free Software Foundation.</para>
+ <para>On Debian systems, the complete text of the GNU General Public
+ License can be found in
+ <filename>/usr/share/common-licenses/GPL</filename>.</para>
+ </legalnotice>
+ </refentryinfo>
+ <refmeta>
+ <refentrytitle>&dhucpackage;</refentrytitle>
+ <manvolnum>&dhsection;</manvolnum>
+ </refmeta>
+ <refnamediv>
+ <refname>&dhpackage;</refname>
+ <refpurpose>program to do something</refpurpose>
+ </refnamediv>
+ <refsynopsisdiv>
+ <cmdsynopsis>
+ <command>&dhpackage;</command>
+ <!-- These are several examples, how syntaxes could look -->
+ <arg choice="plain"><option>-e <replaceable>this</replaceable></option></arg>
+ <arg choice="opt"><option>--example=<parameter>that</parameter></option></arg>
+ <arg choice="opt">
+ <group choice="req">
+ <arg choice="plain"><option>-e</option></arg>
+ <arg choice="plain"><option>--example</option></arg>
+ </group>
+ <replaceable class="option">this</replaceable>
+ </arg>
+ <arg choice="opt">
+ <group choice="req">
+ <arg choice="plain"><option>-e</option></arg>
+ <arg choice="plain"><option>--example</option></arg>
+ </group>
+ <group choice="req">
+ <arg choice="plain"><replaceable>this</replaceable></arg>
+ <arg choice="plain"><replaceable>that</replaceable></arg>
+ </group>
+ </arg>
+ </cmdsynopsis>
+ <cmdsynopsis>
+ <command>&dhpackage;</command>
+ <!-- Normally the help and version options make the programs stop
+ right after outputting the requested information. -->
+ <group choice="opt">
+ <arg choice="plain">
+ <group choice="req">
+ <arg choice="plain"><option>-h</option></arg>
+ <arg choice="plain"><option>--help</option></arg>
+ </group>
+ </arg>
+ <arg choice="plain">
+ <group choice="req">
+ <arg choice="plain"><option>-v</option></arg>
+ <arg choice="plain"><option>--version</option></arg>
+ </group>
+ </arg>
+ </group>
+ </cmdsynopsis>
+ </refsynopsisdiv>
+ <refsect1 id="description">
+ <title>DESCRIPTION</title>
+ <para>This manual page documents briefly the
+ <command>&dhpackage;</command> and <command>bar</command>
+ commands.</para>
+ <para>This manual page was written for the Debian distribution
+ because the original program does not have a manual page.
+ Instead, it has documentation in the GNU <citerefentry>
+ <refentrytitle>info</refentrytitle>
+ <manvolnum>1</manvolnum>
+ </citerefentry> format; see below.</para>
+ <para><command>&dhpackage;</command> is a program that...</para>
+ </refsect1>
+ <refsect1 id="options">
+ <title>OPTIONS</title>
+ <para>The program follows the usual GNU command line syntax,
+ with long options starting with two dashes (`-'). A summary of
+ options is included below. For a complete description, see the
+ <citerefentry>
+ <refentrytitle>info</refentrytitle>
+ <manvolnum>1</manvolnum>
+ </citerefentry> files.</para>
+ <variablelist>
+ <!-- Use the variablelist.term.separator and the
+ variablelist.term.break.after parameters to
+ control the term elements. -->
+ <varlistentry>
+ <term><option>-e <replaceable>this</replaceable></option></term>
+ <term><option>--example=<replaceable>that</replaceable></option></term>
+ <listitem>
+ <para>Does this and that.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>-h</option></term>
+ <term><option>--help</option></term>
+ <listitem>
+ <para>Show summary of options.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>-v</option></term>
+ <term><option>--version</option></term>
+ <listitem>
+ <para>Show version of program.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+ <refsect1 id="files">
+ <title>FILES</title>
+ <variablelist>
+ <varlistentry>
+ <term><filename>/etc/foo.conf</filename></term>
+ <listitem>
+ <para>The system-wide configuration file to control the
+ behaviour of <application>&dhpackage;</application>. See
+ <citerefentry>
+ <refentrytitle>foo.conf</refentrytitle>
+ <manvolnum>5</manvolnum>
+ </citerefentry> for further details.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><filename>${HOME}/.foo.conf</filename></term>
+ <listitem>
+ <para>The per-user configuration file to control the
+ behaviour of <application>&dhpackage;</application>. See
+ <citerefentry>
+ <refentrytitle>foo.conf</refentrytitle>
+ <manvolnum>5</manvolnum>
+ </citerefentry> for further details.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+ <refsect1 id="environment">
+ <title>ENVIONMENT</title>
+ <variablelist>
+ <varlistentry>
+ <term><envar>FOO_CONF</envar></term>
+ <listitem>
+ <para>If used, the defined file is used as configuration
+ file (see also <xref linkend="files"/>).</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+ <refsect1 id="diagnostics">
+ <title>DIAGNOSTICS</title>
+ <para>The following diagnostics may be issued
+ on <filename class="devicefile">stderr</filename>:</para>
+ <variablelist>
+ <varlistentry>
+ <term><errortext>Bad configuration file. Exiting.</errortext></term>
+ <listitem>
+ <para>The configuration file seems to contain a broken configuration
+ line. Use the <option>--verbose</option> option, to get more info.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ <para><command>&dhpackage;</command> provides some return codes, that can
+ be used in scripts:</para>
+ <segmentedlist>
+ <segtitle>Code</segtitle>
+ <segtitle>Diagnostic</segtitle>
+ <seglistitem>
+ <seg><errorcode>0</errorcode></seg>
+ <seg>Program exited successfully.</seg>
+ </seglistitem>
+ <seglistitem>
+ <seg><errorcode>1</errorcode></seg>
+ <seg>The configuration file seems to be broken.</seg>
+ </seglistitem>
+ </segmentedlist>
+ </refsect1>
+ <refsect1 id="bugs">
+ <!-- Or use this section to tell about upstream BTS. -->
+ <title>BUGS</title>
+ <para>The program is currently limited to only work
+ with the <package>foobar</package> library.</para>
+ <para>The upstreams <acronym>BTS</acronym> can be found
+ at <ulink url="http://bugzilla.foo.tld"/>.</para>
+ </refsect1>
+ <refsect1 id="see_also">
+ <title>SEE ALSO</title>
+ <!-- In alpabetical order. -->
+ <para><citerefentry>
+ <refentrytitle>bar</refentrytitle>
+ <manvolnum>1</manvolnum>
+ </citerefentry>, <citerefentry>
+ <refentrytitle>baz</refentrytitle>
+ <manvolnum>1</manvolnum>
+ </citerefentry>, <citerefentry>
+ <refentrytitle>foo.conf</refentrytitle>
+ <manvolnum>5</manvolnum>
+ </citerefentry></para>
+ <para>The programs are documented fully by <citetitle>The Rise and
+ Fall of a Fooish Bar</citetitle> available via the <citerefentry>
+ <refentrytitle>info</refentrytitle>
+ <manvolnum>1</manvolnum>
+ </citerefentry> system.</para>
+ </refsect1>
+</refentry>
+
diff --git a/debian/dd/menu.ex b/debian/dd/menu.ex
new file mode 100644
index 0000000..0abf3c8
--- /dev/null
+++ b/debian/dd/menu.ex
@@ -0,0 +1,2 @@
+?package(dfu-util):needs="X11|text|vc|wm" section="Applications/see-menu-manual"\
+ title="dfu-util" command="/usr/bin/dfu-util"
diff --git a/debian/dd/postinst.ex b/debian/dd/postinst.ex
new file mode 100644
index 0000000..ceac200
--- /dev/null
+++ b/debian/dd/postinst.ex
@@ -0,0 +1,39 @@
+#!/bin/sh
+# postinst script for dfu-util
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+# * <postinst> `configure' <most-recently-configured-version>
+# * <old-postinst> `abort-upgrade' <new version>
+# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
+# <new-version>
+# * <postinst> `abort-remove'
+# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
+# <failed-install-package> <version> `removing'
+# <conflicting-package> <version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+ configure)
+ ;;
+
+ abort-upgrade|abort-remove|abort-deconfigure)
+ ;;
+
+ *)
+ echo "postinst called with unknown argument \`$1'" >&2
+ exit 1
+ ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/dd/postrm.ex b/debian/dd/postrm.ex
new file mode 100644
index 0000000..4d66fc6
--- /dev/null
+++ b/debian/dd/postrm.ex
@@ -0,0 +1,37 @@
+#!/bin/sh
+# postrm script for dfu-util
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+# * <postrm> `remove'
+# * <postrm> `purge'
+# * <old-postrm> `upgrade' <new-version>
+# * <new-postrm> `failed-upgrade' <old-version>
+# * <new-postrm> `abort-install'
+# * <new-postrm> `abort-install' <old-version>
+# * <new-postrm> `abort-upgrade' <old-version>
+# * <disappearer's-postrm> `disappear' <overwriter>
+# <overwriter-version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+ purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
+ ;;
+
+ *)
+ echo "postrm called with unknown argument \`$1'" >&2
+ exit 1
+ ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/dd/preinst.ex b/debian/dd/preinst.ex
new file mode 100644
index 0000000..91345ae
--- /dev/null
+++ b/debian/dd/preinst.ex
@@ -0,0 +1,35 @@
+#!/bin/sh
+# preinst script for dfu-util
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+# * <new-preinst> `install'
+# * <new-preinst> `install' <old-version>
+# * <new-preinst> `upgrade' <old-version>
+# * <old-preinst> `abort-upgrade' <new-version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+ install|upgrade)
+ ;;
+
+ abort-upgrade)
+ ;;
+
+ *)
+ echo "preinst called with unknown argument \`$1'" >&2
+ exit 1
+ ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/dd/prerm.ex b/debian/dd/prerm.ex
new file mode 100644
index 0000000..dfebdc7
--- /dev/null
+++ b/debian/dd/prerm.ex
@@ -0,0 +1,38 @@
+#!/bin/sh
+# prerm script for dfu-util
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+# * <prerm> `remove'
+# * <old-prerm> `upgrade' <new-version>
+# * <new-prerm> `failed-upgrade' <old-version>
+# * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
+# * <deconfigured's-prerm> `deconfigure' `in-favour'
+# <package-being-installed> <version> `removing'
+# <conflicting-package> <version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+ remove|upgrade|deconfigure)
+ ;;
+
+ failed-upgrade)
+ ;;
+
+ *)
+ echo "prerm called with unknown argument \`$1'" >&2
+ exit 1
+ ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/dd/rules b/debian/dd/rules
new file mode 100755
index 0000000..b43b4ea
--- /dev/null
+++ b/debian/dd/rules
@@ -0,0 +1,7 @@
+#!/usr/bin/make -f
+
+include /usr/share/cdbs/1/rules/debhelper.mk
+include /usr/share/cdbs/1/class/autotools.mk
+
+
+# Add here any variable or target overrides you need.
diff --git a/debian/dd/source/format b/debian/dd/source/format
new file mode 100644
index 0000000..163aaf8
--- /dev/null
+++ b/debian/dd/source/format
@@ -0,0 +1 @@
+3.0 (quilt)
diff --git a/debian/dd/watch.ex b/debian/dd/watch.ex
new file mode 100644
index 0000000..d883f04
--- /dev/null
+++ b/debian/dd/watch.ex
@@ -0,0 +1,23 @@
+# Example watch control file for uscan
+# Rename this file to "watch" and then you can run the "uscan" command
+# to check for upstream updates and more.
+# See uscan(1) for format
+
+# Compulsory line, this is a version 3 file
+version=3
+
+# Uncomment to examine a Webpage
+# <Webpage URL> <string match>
+#http://www.example.com/downloads.php dfu-util-(.*)\.tar\.gz
+
+# Uncomment to examine a Webserver directory
+#http://www.example.com/pub/dfu-util-(.*)\.tar\.gz
+
+# Uncommment to examine a FTP server
+#ftp://ftp.example.com/pub/dfu-util-(.*)\.tar\.gz debian uupdate
+
+# Uncomment to find new files on sourceforge, for devscripts >= 2.9
+# http://sf.net/dfu-util/dfu-util-(.*)\.tar\.gz
+
+# Uncomment to find new files on GooglePages
+# http://example.googlepages.com/foo.html dfu-util-(.*)\.tar\.gz
diff --git a/doc/dfu-util.1 b/doc/dfu-util.1
index 69563e3..e286cf2 100644
--- a/doc/dfu-util.1
+++ b/doc/dfu-util.1
@@ -104,10 +104,8 @@ Please see
.B http://wiki.openmoko.org/wiki/Dfu-util
for some limitations and bugs in the current dfu-util code.
.PP
-Please report any further bugs at
-.B http://bugzilla.openmoko.org
-or on the openmoko-kernel mailing list at
-.BR openmoko-kernel@lists.openmoko.org .
+Please report any further bugs at on the openmoko mailing list at
+.BR openmoko@lists.openmoko.org .
.SH LICENCE
.B dfu-util
is covered by the GNU General Public License (GPL), version 2 or later.
diff --git a/src/Makefile.am b/src/Makefile.am
index 7f9c211..0674413 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -7,5 +7,7 @@ dfu_util_SOURCES = main.c \
dfu.c \
dfu.h \
usb_dfu.h \
+ dfu_file.c \
+ dfu_file.h \
quirks.c \
quirks.h
diff --git a/src/Makefile.in b/src/Makefile.in
index ca7a582..e3fba40 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -46,7 +46,7 @@ CONFIG_CLEAN_VPATH_FILES =
am__installdirs = "$(DESTDIR)$(bindir)"
PROGRAMS = $(bin_PROGRAMS)
am_dfu_util_OBJECTS = main.$(OBJEXT) dfu_load.$(OBJEXT) dfu.$(OBJEXT) \
- quirks.$(OBJEXT)
+ dfu_file.$(OBJEXT) quirks.$(OBJEXT)
dfu_util_OBJECTS = $(am_dfu_util_OBJECTS)
dfu_util_LDADD = $(LDADD)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
@@ -174,6 +174,8 @@ dfu_util_SOURCES = main.c \
dfu.c \
dfu.h \
usb_dfu.h \
+ dfu_file.c \
+ dfu_file.h \
quirks.c \
quirks.h
@@ -259,6 +261,7 @@ distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dfu.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dfu_file.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dfu_load.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/quirks.Po@am__quote@
diff --git a/src/dfu.c b/src/dfu.c
index c1d2fcd..e473784 100644
--- a/src/dfu.c
+++ b/src/dfu.c
@@ -21,18 +21,9 @@
*/
#include <stdio.h>
-#include <usb.h>
+#include <libusb.h>
#include "dfu.h"
-/* DFU commands */
-#define DFU_DETACH 0
-#define DFU_DNLOAD 1
-#define DFU_UPLOAD 2
-#define DFU_GETSTATUS 3
-#define DFU_CLRSTATUS 4
-#define DFU_GETSTATE 5
-#define DFU_ABORT 6
-
#define INVALID_DFU_TIMEOUT -1
static int dfu_timeout = INVALID_DFU_TIMEOUT;
@@ -79,15 +70,15 @@ void dfu_debug( const int level )
*
* returns 0 or < 0 on error
*/
-int dfu_detach( struct usb_dev_handle *device,
+int dfu_detach( libusb_device_handle *device,
const unsigned short interface,
const unsigned short timeout )
{
if( 0 != dfu_verify_init(__FUNCTION__) )
return -1;
- return usb_control_msg( device,
- /* bmRequestType */ USB_ENDPOINT_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
+ return libusb_control_transfer( device,
+ /* bmRequestType */ LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE,
/* bRequest */ DFU_DETACH,
/* wValue */ timeout,
/* wIndex */ interface,
@@ -108,10 +99,10 @@ int dfu_detach( struct usb_dev_handle *device,
*
* returns the number of bytes written or < 0 on error
*/
-int dfu_download( struct usb_dev_handle *device,
+int dfu_download( libusb_device_handle *device,
const unsigned short interface,
const unsigned short length,
- char* data )
+ unsigned char* data )
{
int status;
@@ -135,8 +126,8 @@ int dfu_download( struct usb_dev_handle *device,
return -2;
}
- status = usb_control_msg( device,
- /* bmRequestType */ USB_ENDPOINT_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
+ status = libusb_control_transfer( device,
+ /* bmRequestType */ LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE,
/* bRequest */ DFU_DNLOAD,
/* wValue */ transaction++,
/* wIndex */ interface,
@@ -144,9 +135,9 @@ int dfu_download( struct usb_dev_handle *device,
/* wLength */ length,
dfu_timeout );
if( status < 0 ) {
- fprintf( stderr, "%s: usb_control_msg returned %d: %s\n",
+ fprintf( stderr, "%s: libusb_control_transfer returned %d\n",
__FUNCTION__,
- status, usb_strerror() );
+ status);
}
return status;
@@ -164,10 +155,10 @@ int dfu_download( struct usb_dev_handle *device,
*
* returns the number of bytes received or < 0 on error
*/
-int dfu_upload( struct usb_dev_handle *device,
+int dfu_upload( libusb_device_handle *device,
const unsigned short interface,
const unsigned short length,
- char* data )
+ unsigned char* data )
{
int status;
@@ -183,8 +174,8 @@ int dfu_upload( struct usb_dev_handle *device,
return -1;
}
- status = usb_control_msg( device,
- /* bmRequestType */ USB_ENDPOINT_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
+ status = libusb_control_transfer( device,
+ /* bmRequestType */ LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE,
/* bRequest */ DFU_UPLOAD,
/* wValue */ transaction++,
/* wIndex */ interface,
@@ -192,9 +183,9 @@ int dfu_upload( struct usb_dev_handle *device,
/* wLength */ length,
dfu_timeout );
if( status < 0 ) {
- fprintf( stderr, "%s: usb_control_msg returned %d: %s\n",
+ fprintf( stderr, "%s: libusb_control_msg returned %d\n",
__FUNCTION__,
- status, usb_strerror() );
+ status);
}
return status;
@@ -210,11 +201,11 @@ int dfu_upload( struct usb_dev_handle *device,
*
* return the number of bytes read in or < 0 on an error
*/
-int dfu_get_status( struct usb_dev_handle *device,
+int dfu_get_status( libusb_device_handle *device,
const unsigned short interface,
struct dfu_status *status )
{
- char buffer[6];
+ unsigned char buffer[6];
int result;
if( 0 != dfu_verify_init(__FUNCTION__) )
@@ -226,8 +217,8 @@ int dfu_get_status( struct usb_dev_handle *device,
status->bState = STATE_DFU_ERROR;
status->iString = 0;
- result = usb_control_msg( device,
- /* bmRequestType */ USB_ENDPOINT_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
+ result = libusb_control_transfer( device,
+ /* bmRequestType */ LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE,
/* bRequest */ DFU_GETSTATUS,
/* wValue */ 0,
/* wIndex */ interface,
@@ -257,14 +248,14 @@ int dfu_get_status( struct usb_dev_handle *device,
*
* return 0 or < 0 on an error
*/
-int dfu_clear_status( struct usb_dev_handle *device,
+int dfu_clear_status( libusb_device_handle *device,
const unsigned short interface )
{
if( 0 != dfu_verify_init(__FUNCTION__) )
return -1;
- return usb_control_msg( device,
- /* bmRequestType */ USB_ENDPOINT_OUT| USB_TYPE_CLASS | USB_RECIP_INTERFACE,
+ return libusb_control_transfer( device,
+ /* bmRequestType */ LIBUSB_ENDPOINT_OUT| LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE,
/* bRequest */ DFU_CLRSTATUS,
/* wValue */ 0,
/* wIndex */ interface,
@@ -285,17 +276,17 @@ int dfu_clear_status( struct usb_dev_handle *device,
*
* returns the state or < 0 on error
*/
-int dfu_get_state( struct usb_dev_handle *device,
+int dfu_get_state( libusb_device_handle *device,
const unsigned short interface )
{
int result;
- char buffer[1];
+ unsigned char buffer[1];
if( 0 != dfu_verify_init(__FUNCTION__) )
return -1;
- result = usb_control_msg( device,
- /* bmRequestType */ USB_ENDPOINT_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
+ result = libusb_control_transfer( device,
+ /* bmRequestType */ LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE,
/* bRequest */ DFU_GETSTATE,
/* wValue */ 0,
/* wIndex */ interface,
@@ -321,14 +312,14 @@ int dfu_get_state( struct usb_dev_handle *device,
*
* returns 0 or < 0 on an error
*/
-int dfu_abort( struct usb_dev_handle *device,
+int dfu_abort( libusb_device_handle *device,
const unsigned short interface )
{
if( 0 != dfu_verify_init(__FUNCTION__) )
return -1;
- return usb_control_msg( device,
- /* bmRequestType */ USB_ENDPOINT_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
+ return libusb_control_transfer( device,
+ /* bmRequestType */ LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE,
/* bRequest */ DFU_ABORT,
/* wValue */ 0,
/* wIndex */ interface,
diff --git a/src/dfu.h b/src/dfu.h
index cd4b06c..6d2347a 100644
--- a/src/dfu.h
+++ b/src/dfu.h
@@ -21,7 +21,7 @@
#ifndef __DFU_H__
#define __DFU_H__
-#include <usb.h>
+#include <libusb.h>
#include "usb_dfu.h"
/* DFU states */
@@ -56,6 +56,24 @@
#define DFU_STATUS_ERROR_UNKNOWN 0x0e
#define DFU_STATUS_ERROR_STALLEDPKT 0x0f
+/* DFU commands */
+#define DFU_DETACH 0
+#define DFU_DNLOAD 1
+#define DFU_UPLOAD 2
+#define DFU_GETSTATUS 3
+#define DFU_CLRSTATUS 4
+#define DFU_GETSTATE 5
+#define DFU_ABORT 6
+
+/* DFU interface */
+#define DFU_IFF_DFU 0x0001 /* DFU Mode, (not Runtime) */
+#define DFU_IFF_VENDOR 0x0100
+#define DFU_IFF_PRODUCT 0x0200
+#define DFU_IFF_CONFIG 0x0400
+#define DFU_IFF_IFACE 0x0800
+#define DFU_IFF_ALT 0x1000
+#define DFU_IFF_DEVNUM 0x2000
+#define DFU_IFF_PATH 0x4000
/* This is based off of DFU_GETSTATUS
*
@@ -72,27 +90,42 @@ struct dfu_status {
unsigned char iString;
};
+struct dfu_if {
+ u_int16_t vendor;
+ u_int16_t product;
+ u_int8_t configuration;
+ u_int8_t interface;
+ u_int8_t altsetting;
+ int bus;
+ u_int8_t devnum;
+ const char *path;
+ unsigned int flags;
+ unsigned int count;
+ libusb_device *dev;
+ libusb_device_handle *dev_handle;
+};
+
void dfu_init( const int timeout );
void dfu_debug( const int level );
-int dfu_detach( struct usb_dev_handle *device,
+int dfu_detach( libusb_device_handle *device,
const unsigned short interface,
const unsigned short timeout );
-int dfu_download( struct usb_dev_handle *device,
+int dfu_download( libusb_device_handle *device,
const unsigned short interface,
const unsigned short length,
- char* data );
-int dfu_upload( struct usb_dev_handle *device,
+ unsigned char* data );
+int dfu_upload( libusb_device_handle *device,
const unsigned short interface,
const unsigned short length,
- char* data );
-int dfu_get_status( struct usb_dev_handle *device,
+ unsigned char* data );
+int dfu_get_status( libusb_device_handle *device,
const unsigned short interface,
struct dfu_status *status );
-int dfu_clear_status( struct usb_dev_handle *device,
+int dfu_clear_status( libusb_device_handle *device,
const unsigned short interface );
-int dfu_get_state( struct usb_dev_handle *device,
+int dfu_get_state( libusb_device_handle *device,
const unsigned short interface );
-int dfu_abort( struct usb_dev_handle *device,
+int dfu_abort( libusb_device_handle *device,
const unsigned short interface );
char* dfu_state_to_string( int state );
diff --git a/src/dfu_file.c b/src/dfu_file.c
new file mode 100644
index 0000000..b6a190f
--- /dev/null
+++ b/src/dfu_file.c
@@ -0,0 +1,190 @@
+/*
+ * Checks for and parses a DFU suffix
+ *
+ * (C) 2011 Tormod Volden <debian.tormod@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+#include "dfu_file.h"
+
+unsigned long crc32_table[] = {
+ 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
+ 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
+ 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
+ 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
+ 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
+ 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
+ 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,
+ 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
+ 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,
+ 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
+ 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106,
+ 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
+ 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d,
+ 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
+ 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
+ 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
+ 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7,
+ 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
+ 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa,
+ 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
+ 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,
+ 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
+ 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84,
+ 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
+ 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
+ 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
+ 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e,
+ 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
+ 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,
+ 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
+ 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28,
+ 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
+ 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,
+ 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
+ 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
+ 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
+ 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,
+ 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
+ 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc,
+ 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
+ 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
+ 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
+ 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d};
+
+uint32_t crc32_byte(uint32_t accum, uint8_t delta)
+{
+ return crc32_table[(accum ^ delta) & 0xff] ^ (accum >> 8);
+}
+
+/* reads the fd and name member, fills in all others
+ returns 0 if no DFU suffix
+ returns positive if valid DFU suffix
+ returns negative on file read error */
+int parse_dfu_suffix(struct dfu_file *file)
+{
+ int ret;
+ int i;
+ struct stat st;
+ uint32_t crc = 0xffffffff;
+ /* supported suffices are at least 16 bytes */
+ unsigned char dfusuffix[16];
+ unsigned char *firmware = NULL;
+
+ file->size = 0;
+ /* default values, if no valid suffix is found */
+ file->dwCRC = 0;
+ file->suffixlen = 0;
+ file->bcdDFU = 0;
+ file->idVendor = 0xffff; /* wildcard value */
+ file->idProduct = 0xffff; /* wildcard value */
+ file->bcdDevice = 0xffff; /* wildcard value */
+
+ ret = fstat(file->fd, &st);
+ if (ret < 0) {
+ perror(file->name);
+ return ret;
+ }
+
+ file->size = st.st_size;
+ if (file->size < sizeof(dfusuffix)) {
+ fprintf(stderr, "File too short for DFU suffix\n");
+ return 0;
+ }
+
+ firmware = malloc(file->size);
+ if (!firmware) {
+ fprintf(stderr, "Unable to allocate file buffer for firmware.\n");
+ exit(1);
+ }
+
+ ret = read(file->fd, firmware, file->size);
+ if (ret < 0) {
+ fprintf(stderr, "Could not read file\n");
+ perror(file->name);
+ return ret;
+ }
+
+ for (i = 0; i < file->size - 4; i++)
+ crc = crc32_byte(crc, firmware[i]);
+
+ free(firmware);
+
+ ret = lseek(file->fd, -sizeof(dfusuffix), SEEK_END);
+ if (ret < 0) {
+ fprintf(stderr, "Could not seek to DFU suffix\n");
+ perror(file->name);
+ goto rewind;
+ }
+
+ ret = read(file->fd, dfusuffix, sizeof(dfusuffix));
+ if (ret < 0) {
+ fprintf(stderr, "Could not read DFU suffix\n");
+ perror(file->name);
+ goto rewind;
+ } else if (ret < sizeof(dfusuffix)) {
+ fprintf(stderr, "Could not read whole DFU suffix\n");
+ ret = -EIO;
+ goto rewind;
+ }
+
+ if (dfusuffix[10] != 'D' ||
+ dfusuffix[9] != 'F' ||
+ dfusuffix[8] != 'U') {
+ fprintf(stderr, "No valid DFU suffix signature\n");
+ ret = 0;
+ goto rewind;
+ }
+
+ file->dwCRC = (dfusuffix[15] << 24) +
+ (dfusuffix[14] << 16) +
+ (dfusuffix[13] << 8) +
+ dfusuffix[12];
+
+ if (file->dwCRC != crc) {
+ fprintf(stderr, "DFU CRC does not match\n");
+ goto rewind;
+ }
+
+ file->bcdDFU = (dfusuffix[7] << 8) + dfusuffix[6];
+ printf("Dfu suffix version %x\n", file->bcdDFU);
+
+ file->suffixlen = dfusuffix[11];
+ if (file->suffixlen < sizeof(dfusuffix)) {
+ fprintf(stderr, "Unsupported DFU suffix length %i\n",
+ file->suffixlen);
+ ret = 0;
+ goto rewind;
+ }
+
+ file->idVendor = (dfusuffix[5] << 8) + dfusuffix[4];
+ file->idProduct = (dfusuffix[3] << 8) + dfusuffix[2];
+ file->bcdDevice = (dfusuffix[1] << 8) + dfusuffix[0];
+
+rewind:
+ lseek(file->fd, 0, SEEK_SET);
+ return ret;
+}
+
diff --git a/src/dfu_file.h b/src/dfu_file.h
new file mode 100644
index 0000000..8c33665
--- /dev/null
+++ b/src/dfu_file.h
@@ -0,0 +1,20 @@
+
+#ifndef _DFU_FILE_H
+#define _DFU_FILE_H
+
+struct dfu_file {
+ const char *name;
+ int fd;
+ off_t size;
+ /* From DFU suffix fields */
+ u_int32_t dwCRC;
+ unsigned char suffixlen;
+ u_int16_t bcdDFU;
+ u_int16_t idVendor;
+ u_int16_t idProduct;
+ u_int16_t bcdDevice;
+};
+
+int parse_dfu_suffix(struct dfu_file *file);
+
+#endif
diff --git a/src/dfu_load.c b/src/dfu_load.c
index 3a4f382..85da452 100644
--- a/src/dfu_load.c
+++ b/src/dfu_load.c
@@ -26,38 +26,29 @@
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
-#include <fcntl.h>
#include <errno.h>
#include <string.h>
-#include <usb.h>
+#include <libusb.h>
#include "config.h"
#include "dfu.h"
#include "usb_dfu.h"
+#include "dfu_file.h"
#include "dfu_load.h"
#include "quirks.h"
-/* ugly hack for Win32 */
-#ifndef O_BINARY
-#define O_BINARY 0
-#endif
+extern int verbose;
-int dfuload_do_upload(struct usb_dev_handle *usb_handle, int interface,
- int xfer_size, const char *fname)
+int dfuload_do_upload(struct dfu_if *dif, int xfer_size, struct dfu_file file)
{
- int ret, fd, total_bytes = 0;
- char *buf = malloc(xfer_size);
+ int total_bytes = 0;
+ unsigned char *buf;
+ int ret;
+ buf = malloc(xfer_size);
if (!buf)
return -ENOMEM;
- fd = open(fname, O_WRONLY|O_CREAT|O_EXCL, 0644);
- if (fd < 0) {
- perror(fname);
- ret = fd;
- goto out_free;
- }
-
printf("bytes_per_hash=%u\n", xfer_size);
printf("Copying data from DFU device to PC\n");
printf("Starting upload: [");
@@ -65,17 +56,17 @@ int dfuload_do_upload(struct usb_dev_handle *usb_handle, int interface,
while (1) {
int rc, write_rc;
- rc = dfu_upload(usb_handle, interface, xfer_size, buf);
+ rc = dfu_upload(dif->dev_handle, dif->interface, xfer_size, buf);
if (rc < 0) {
ret = rc;
- goto out_close;
+ goto out_free;
}
- write_rc = write(fd, buf, rc);
+ write_rc = write(file.fd, buf, rc);
if (write_rc < rc) {
fprintf(stderr, "Short file write: %s\n",
strerror(errno));
ret = total_bytes;
- goto out_close;
+ goto out_free;
}
total_bytes += rc;
if (rc < xfer_size) {
@@ -91,93 +82,85 @@ int dfuload_do_upload(struct usb_dev_handle *usb_handle, int interface,
printf("] finished!\n");
fflush(stdout);
-out_close:
- close(fd);
out_free:
free(buf);
+ if (verbose)
+ printf("Received a total of %i bytes\n", total_bytes);
return ret;
}
#define PROGRESS_BAR_WIDTH 50
-int dfuload_do_dnload(struct usb_dev_handle *usb_handle, int interface,
- int xfer_size, const char *fname)
+int dfuload_do_dnload(struct dfu_if *dif, int xfer_size, struct dfu_file file)
{
- int ret, fd, bytes_sent = 0;
+ int bytes_sent = 0;
unsigned int bytes_per_hash, hashes = 0;
- char *buf = malloc(xfer_size);
- struct stat st;
+ unsigned char *buf;
struct dfu_status dst;
+ int ret;
+ buf = malloc(xfer_size);
if (!buf)
return -ENOMEM;
- fd = open(fname, O_RDONLY|O_BINARY);
- if (fd < 0) {
- perror(fname);
- ret = fd;
- goto out_free;
- }
-
- ret = fstat(fd, &st);
- if (ret < 0) {
- perror(fname);
- goto out_close;
- }
-
- if (st.st_size <= 0 /* + DFU_HDR */) {
- fprintf(stderr, "File seems a bit too small...\n");
- ret = -EINVAL;
- goto out_close;
- }
-
- bytes_per_hash = st.st_size / PROGRESS_BAR_WIDTH;
+ bytes_per_hash = (file.size - file.suffixlen) / PROGRESS_BAR_WIDTH;
if (bytes_per_hash == 0)
bytes_per_hash = 1;
printf("bytes_per_hash=%u\n", bytes_per_hash);
#if 0
- read(fd, DFU_HDR);
+ read(file.fd, DFU_HDR);
#endif
printf("Copying data from PC to DFU device\n");
printf("Starting download: [");
fflush(stdout);
- while (bytes_sent < st.st_size /* - DFU_HDR */) {
+ while (bytes_sent < file.size - file.suffixlen) {
int hashes_todo;
-
- ret = read(fd, buf, xfer_size);
+ int bytes_left;
+ int chunk_size;
+
+ bytes_left = file.size - file.suffixlen - bytes_sent;
+ if (bytes_left < xfer_size)
+ chunk_size = bytes_left;
+ else
+ chunk_size = xfer_size;
+ ret = read(file.fd, buf, chunk_size);
if (ret < 0) {
- perror(fname);
- goto out_close;
+ perror(file.name);
+ goto out_free;
}
- ret = dfu_download(usb_handle, interface, ret, ret ? buf : NULL);
+ ret = dfu_download(dif->dev_handle, dif->interface, ret, ret ? buf : NULL);
if (ret < 0) {
fprintf(stderr, "Error during download\n");
- goto out_close;
+ goto out_free;
}
bytes_sent += ret;
do {
- ret = dfu_get_status(usb_handle, interface, &dst);
+ ret = dfu_get_status(dif->dev_handle, dif->interface, &dst);
if (ret < 0) {
fprintf(stderr, "Error during download get_status\n");
- goto out_close;
+ goto out_free;
}
+
+ if (dst.bState == DFU_STATE_dfuDNLOAD_IDLE ||
+ dst.bState == DFU_STATE_dfuERROR)
+ break;
+
/* Wait while device executes flashing */
if (quirks & QUIRK_POLLTIMEOUT)
usleep(DEFAULT_POLLTIMEOUT * 1000);
else
usleep(dst.bwPollTimeout * 1000);
- } while (dst.bState != DFU_STATE_dfuDNLOAD_IDLE &&
- dst.bState != DFU_STATE_dfuERROR);
+ } while (1);
if (dst.bStatus != DFU_STATUS_OK) {
printf(" failed!\n");
printf("state(%u) = %s, status(%u) = %s\n", dst.bState,
dfu_state_to_string(dst.bState), dst.bStatus,
dfu_status_to_string(dst.bStatus));
ret = -1;
- goto out_close;
+ goto out_free;
}
hashes_todo = (bytes_sent / bytes_per_hash) - hashes;
@@ -188,21 +171,23 @@ int dfuload_do_dnload(struct usb_dev_handle *usb_handle, int interface,
}
/* send one zero sized download request to signalize end */
- ret = dfu_download(usb_handle, interface, 0, NULL);
+ ret = dfu_download(dif->dev_handle, dif->interface, 0, NULL);
if (ret < 0) {
fprintf(stderr, "Error sending completion packet\n");
- goto out_close;
+ goto out_free;
}
printf("] finished!\n");
fflush(stdout);
+ if (verbose)
+ printf("Sent a total of %i bytes\n", bytes_sent);
get_status:
/* Transition to MANIFEST_SYNC state */
- ret = dfu_get_status(usb_handle, interface, &dst);
+ ret = dfu_get_status(dif->dev_handle, dif->interface, &dst);
if (ret < 0) {
fprintf(stderr, "unable to read DFU status\n");
- goto out_close;
+ goto out_free;
}
printf("state(%u) = %s, status(%u) = %s\n", dst.bState,
dfu_state_to_string(dst.bState), dst.bStatus,
@@ -224,14 +209,13 @@ get_status:
}
#if 0
printf("Resetting USB...\n");
- if (usb_reset(usb_handle) < 0) {
+ if (usb_reset(dif->dev_handle) < 0) {
fprintf(stderr, "error resetting after download: %s\n",
usb_strerror());
}
#endif
printf("Done!\n");
-out_close:
- close(fd);
+
out_free:
free(buf);
diff --git a/src/dfu_load.h b/src/dfu_load.h
index 8955696..ba50506 100644
--- a/src/dfu_load.h
+++ b/src/dfu_load.h
@@ -1,9 +1,7 @@
#ifndef _SAM7DFU_H
#define _SAM7DFU_H
-int dfuload_do_upload(struct usb_dev_handle *usb_handle, int interface,
- int xfer_size, const char *fname);
-int dfuload_do_dnload(struct usb_dev_handle *usb_handle, int interface,
- int xfer_size, const char *fname);
+int dfuload_do_upload(struct dfu_if *dif, int xfer_size, struct dfu_file file);
+int dfuload_do_dnload(struct dfu_if *dif, int xfer_size, struct dfu_file file);
#endif
diff --git a/src/main.c b/src/main.c
index e9f4ef3..1d03704 100644
--- a/src/main.c
+++ b/src/main.c
@@ -26,11 +26,13 @@
#include <unistd.h>
#include <string.h>
#include <getopt.h>
-#include <usb.h>
+#include <libusb.h>
#include <errno.h>
+#include <fcntl.h>
#include "dfu.h"
#include "usb_dfu.h"
+#include "dfu_file.h"
#include "dfu_load.h"
#include "quirks.h"
#ifdef HAVE_CONFIG_H
@@ -41,6 +43,14 @@
#include <usbpath.h>
#endif
+/* ugly hack for Win32 */
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
+int debug;
+int verbose = 0;
+
/* define a portable function for reading a 16bit little-endian word */
unsigned short get_int16_le(const void *p)
{
@@ -49,63 +59,27 @@ unsigned short get_int16_le(const void *p)
return ( cp[0] ) | ( ((unsigned short)cp[1]) << 8 );
}
-int debug;
-static int verbose = 0;
-
-#define DFU_IFF_DFU 0x0001 /* DFU Mode, (not Runtime) */
-#define DFU_IFF_VENDOR 0x0100
-#define DFU_IFF_PRODUCT 0x0200
-#define DFU_IFF_CONFIG 0x0400
-#define DFU_IFF_IFACE 0x0800
-#define DFU_IFF_ALT 0x1000
-#define DFU_IFF_DEVNUM 0x2000
-#define DFU_IFF_PATH 0x4000
-
-struct usb_vendprod {
- u_int16_t vendor;
- u_int16_t product;
-};
-
-struct dfu_if {
- u_int16_t vendor;
- u_int16_t product;
- u_int8_t configuration;
- u_int8_t interface;
- u_int8_t altsetting;
- int bus;
- u_int8_t devnum;
- const char *path;
- unsigned int flags;
- struct usb_device *dev;
-
- struct usb_dev_handle *dev_handle;
-};
-
-static int _get_first_cb(struct dfu_if *dif, void *v)
+/* Find DFU interfaces in a given device.
+ * Iterate through all DFU interfaces and their alternate settings
+ * and call the passed handler function on each setting until handler
+ * returns non-zero. */
+static int find_dfu_if(libusb_device *dev,
+ int (*handler)(struct dfu_if *, void *),
+ void *v)
{
- struct dfu_if *v_dif = v;
-
- memcpy(v_dif, dif, sizeof(*v_dif)-sizeof(struct usb_dev_handle *));
-
- /* return a value that makes find_dfu_if return immediately */
- return 1;
-}
-
-/* Find a DFU interface (and altsetting) in a given device */
-static int find_dfu_if(struct usb_device *dev, int (*handler)(struct dfu_if *, void *), void *v)
-{
- struct usb_config_descriptor *cfg;
- struct usb_interface_descriptor *intf;
- struct usb_interface *uif;
+ struct libusb_device_descriptor desc;
+ struct libusb_config_descriptor *cfg;
+ const struct libusb_interface_descriptor *intf;
+ const struct libusb_interface *uif;
struct dfu_if _dif, *dfu_if = &_dif;
int cfg_idx, intf_idx, alt_idx;
int rc;
memset(dfu_if, 0, sizeof(*dfu_if));
-
- for (cfg_idx = 0; cfg_idx < dev->descriptor.bNumConfigurations;
+ libusb_get_device_descriptor(dev, &desc);
+ for (cfg_idx = 0; cfg_idx < desc.bNumConfigurations;
cfg_idx++) {
- cfg = &dev->config[cfg_idx];
+ libusb_get_config_descriptor(dev, cfg_idx, &cfg);
/* in some cases, noticably FreeBSD if uid != 0,
* the configuration descriptors are empty */
if (!cfg)
@@ -124,10 +98,11 @@ static int find_dfu_if(struct usb_device *dev, int (*handler)(struct dfu_if *, v
intf->bInterfaceSubClass == 1) {
dfu_if->dev = dev;
dfu_if->vendor =
- dev->descriptor.idVendor;
+ desc.idVendor;
dfu_if->product =
- dev->descriptor.idProduct;
- dfu_if->configuration = cfg_idx;
+ desc.idProduct;
+ dfu_if->configuration = cfg->
+ bConfigurationValue;
dfu_if->interface =
intf->bInterfaceNumber;
dfu_if->altsetting =
@@ -144,32 +119,90 @@ static int find_dfu_if(struct usb_device *dev, int (*handler)(struct dfu_if *, v
}
}
}
+
+ libusb_free_config_descriptor(cfg);
}
return 0;
}
+static int _get_first_cb(struct dfu_if *dif, void *v)
+{
+ struct dfu_if *v_dif = v;
+
+ /* Copy everything except the device handle.
+ * This depends heavily on this member being last! */
+ memcpy(v_dif, dif, sizeof(*v_dif)-sizeof(libusb_device_handle *));
+
+ /* return a value that makes find_dfu_if return immediately */
+ return 1;
+}
+
+/* Fills in dif with the first found DFU interface */
static int get_first_dfu_if(struct dfu_if *dif)
{
return find_dfu_if(dif->dev, &_get_first_cb, (void *) dif);
}
+static int _check_match_cb(struct dfu_if *dif, void *v)
+{
+ struct dfu_if *v_dif = v;
+
+ if (v_dif->flags & DFU_IFF_IFACE &&
+ dif->interface != v_dif->interface)
+ return 0;
+ if (v_dif->flags & DFU_IFF_ALT &&
+ dif->altsetting != v_dif->altsetting)
+ return 0;
+ return _get_first_cb(dif, v);
+}
+
+/* Fills in dif from the matching DFU interface/altsetting */
+static int get_matching_dfu_if(struct dfu_if *dif)
+{
+ return find_dfu_if(dif->dev, &_check_match_cb, (void *) dif);
+}
+
+static int _count_match_cb(struct dfu_if *dif, void *v)
+{
+ struct dfu_if *v_dif = v;
+
+ if (v_dif->flags & DFU_IFF_IFACE &&
+ dif->interface != v_dif->interface)
+ return 0;
+ if (v_dif->flags & DFU_IFF_ALT &&
+ dif->altsetting != v_dif->altsetting)
+ return 0;
+ v_dif->count++;
+ return 0;
+}
+
+/* Count matching DFU interface/altsetting */
+static int count_matching_dfu_if(struct dfu_if *dif)
+{
+ dif->count = 0;
+ find_dfu_if(dif->dev, &_count_match_cb, (void *) dif);
+ return dif->count;
+}
+
#define MAX_STR_LEN 64
static int print_dfu_if(struct dfu_if *dfu_if, void *v)
{
- struct usb_device *dev = dfu_if->dev;
+ libusb_device *dev = dfu_if->dev;
+ struct libusb_config_descriptor *cfg;
int if_name_str_idx;
- char name[MAX_STR_LEN+1] = "UNDEFINED";
+ unsigned char name[MAX_STR_LEN+1] = "UNDEFINED";
- if_name_str_idx = dev->config[dfu_if->configuration]
- .interface[dfu_if->interface]
+ libusb_get_config_descriptor_by_value(dev, dfu_if->configuration, &cfg);
+
+ if_name_str_idx = cfg->interface[dfu_if->interface]
.altsetting[dfu_if->altsetting].iInterface;
if (if_name_str_idx) {
if (!dfu_if->dev_handle)
- dfu_if->dev_handle = usb_open(dfu_if->dev);
+ libusb_open(dfu_if->dev, &dfu_if->dev_handle);
if (dfu_if->dev_handle)
- usb_get_string_simple(dfu_if->dev_handle,
+ libusb_get_string_descriptor_ascii(dfu_if->dev_handle,
if_name_str_idx, name,
MAX_STR_LEN);
}
@@ -177,32 +210,54 @@ static int print_dfu_if(struct dfu_if *dfu_if, void *v)
printf("Found %s: [0x%04x:0x%04x] devnum=%u, cfg=%u, intf=%u, "
"alt=%u, name=\"%s\"\n",
dfu_if->flags & DFU_IFF_DFU ? "DFU" : "Runtime",
- dev->descriptor.idVendor, dev->descriptor.idProduct,
- dev->devnum, dfu_if->configuration, dfu_if->interface,
+ dfu_if->vendor, dfu_if->product, dfu_if->devnum,
+ dfu_if->configuration, dfu_if->interface,
dfu_if->altsetting, name);
+ libusb_free_config_descriptor(cfg);
+ return 0;
+}
+
+/* Walk the device tree and print out DFU devices */
+static int list_dfu_interfaces(void)
+{
+ libusb_device **list;
+ libusb_device *dev;
+ ssize_t num_devs, i;
+
+ num_devs = libusb_get_device_list(NULL, &list);
+
+ for (i = 0; i < num_devs; ++i) {
+ dev = list[i];
+ find_dfu_if(dev, &print_dfu_if, NULL);
+ }
+
+ libusb_free_device_list(list, 1);
return 0;
}
static int alt_by_name(struct dfu_if *dfu_if, void *v)
{
- struct usb_device *dev = dfu_if->dev;
+ libusb_device *dev = dfu_if->dev;
+ struct libusb_config_descriptor *cfg;
int if_name_str_idx;
- char name[MAX_STR_LEN+1] = "UNDEFINED";
+ unsigned char name[MAX_STR_LEN+1] = "UNDEFINED";
- if_name_str_idx =
- dev->config[dfu_if->configuration].interface[dfu_if->interface].
- altsetting[dfu_if->altsetting].iInterface;
+ libusb_get_config_descriptor_by_value(dev, dfu_if->configuration, &cfg);
+
+ if_name_str_idx = cfg->interface[dfu_if->interface]
+ .altsetting[dfu_if->altsetting].iInterface;
if (!if_name_str_idx)
return 0;
if (!dfu_if->dev_handle)
- dfu_if->dev_handle = usb_open(dfu_if->dev);
+ libusb_open(dfu_if->dev, &dfu_if->dev_handle);
if (!dfu_if->dev_handle)
return 0;
- if (usb_get_string_simple(dfu_if->dev_handle, if_name_str_idx, name,
- MAX_STR_LEN) < 0)
+ if (libusb_get_string_descriptor_ascii(dfu_if->dev_handle,
+ if_name_str_idx, name,
+ MAX_STR_LEN) < 0)
return 0; /* should we return an error here ? */
- if (strcmp(name, v))
+ if (strcmp((char *)name, v))
return 0;
/*
* Return altsetting+1 so that we can use return value 0 to indicate
@@ -221,7 +276,7 @@ static int _count_cb(struct dfu_if *dif, void *v)
}
/* Count DFU interfaces within a single device */
-static int count_dfu_interfaces(struct usb_device *dev)
+static int count_dfu_interfaces(libusb_device *dev)
{
int num_found = 0;
@@ -233,39 +288,49 @@ static int count_dfu_interfaces(struct usb_device *dev)
/* Iterate over all matching DFU capable devices within system */
static int iterate_dfu_devices(struct dfu_if *dif,
- int (*action)(struct usb_device *dev, void *user), void *user)
+ int (*action)(struct libusb_device *dev, void *user), void *user)
{
- struct usb_bus *usb_bus;
- struct usb_device *dev;
+ struct libusb_device_descriptor desc;
+ struct libusb_device *dev;
+ libusb_device **list;
+ ssize_t num_devs, i;
+
+ dev = NULL;
+ num_devs = libusb_get_device_list(NULL, &list); // FIXME set context
/* Walk the tree and find our device. */
- for (usb_bus = usb_get_busses(); NULL != usb_bus;
- usb_bus = usb_bus->next) {
- for (dev = usb_bus->devices; NULL != dev; dev = dev->next) {
- int retval;
-
- if (dif && (dif->flags &
- (DFU_IFF_VENDOR|DFU_IFF_PRODUCT)) &&
- (dev->descriptor.idVendor != dif->vendor ||
- dev->descriptor.idProduct != dif->product))
- continue;
- if (dif && (dif->flags & DFU_IFF_DEVNUM) &&
- (atoi(usb_bus->dirname) != dif->bus ||
- dev->devnum != dif->devnum))
- continue;
- if (!count_dfu_interfaces(dev))
- continue;
-
- retval = action(dev, user);
- if (retval)
- return retval;
+ for (i = 0; i < num_devs; ++i) {
+ uint8_t bnum = libusb_get_bus_number(list[i]);
+ uint8_t dnum = libusb_get_device_address(list[i]);
+
+ int retval;
+ dev = list[i];
+ libusb_get_device_descriptor(list[i], &desc);
+
+ if (dif && (dif->flags & DFU_IFF_VENDOR) &&
+ desc.idVendor != dif->vendor)
+ continue;
+ if (dif && (dif->flags & DFU_IFF_PRODUCT) &&
+ desc.idProduct != dif->product)
+ continue;
+ if (dif && (dif->flags & DFU_IFF_DEVNUM) &&
+ (bnum != dif->bus || dnum != dif->devnum))
+ continue;
+ if (!count_dfu_interfaces(dev))
+ continue;
+
+ retval = action(dev, user);
+ if (retval) {
+ libusb_free_device_list(list, 0);
+ return retval;
}
}
+ libusb_free_device_list(list, 0);
return 0;
}
-static int found_dfu_device(struct usb_device *dev, void *user)
+static int found_dfu_device(struct libusb_device *dev, void *user)
{
struct dfu_if *dif = user;
@@ -281,7 +346,7 @@ static int get_first_dfu_device(struct dfu_if *dif)
}
-static int count_one_dfu_device(struct usb_device *dev, void *user)
+static int count_one_dfu_device(struct libusb_device *dev, void *user)
{
int *num = user;
@@ -300,40 +365,17 @@ static int count_dfu_devices(struct dfu_if *dif)
}
-static int list_dfu_interfaces(void)
-{
- struct usb_bus *usb_bus;
- struct usb_device *dev;
-
- /* Walk the tree and find our device. */
- for (usb_bus = usb_get_busses(); NULL != usb_bus;
- usb_bus = usb_bus->next ) {
- for (dev = usb_bus->devices; NULL != dev; dev = dev->next) {
- find_dfu_if(dev, &print_dfu_if, NULL);
- }
- }
- return 0;
-}
-
-static int parse_vendprod(struct usb_vendprod *vp, const char *str)
+static void parse_vendprod(u_int16_t *vendor, u_int16_t *product,
+ const char *str)
{
- unsigned long vend, prod;
const char *colon;
+ *vendor = strtoul(str, NULL, 16);
colon = strchr(str, ':');
- if (!colon || strlen(colon) < 2)
- return -EINVAL;
-
- vend = strtoul(str, NULL, 16);
- prod = strtoul(colon+1, NULL, 16);
-
- if (vend > 0xffff || prod > 0xffff)
- return -EINVAL;
-
- vp->vendor = vend;
- vp->product = prod;
-
- return 0;
+ if (colon)
+ *product = strtoul(colon + 1, NULL, 16);
+ else
+ *product = 0;
}
@@ -366,25 +408,41 @@ static int resolve_device_path(struct dfu_if *dif)
#endif /* !HAVE_USBPATH_H */
-/* Look for descriptor in the configuration descriptor output */
-static int usb_get_extra_descriptor(usb_dev_handle *udev, unsigned char type,
+/* Look for descriptor in the configuration descriptor hierarchy */
+static int usb_get_extra_descriptor(struct dfu_if *dfu_if, unsigned char type,
unsigned char index, void *resbuf, int size)
{
- char *cbuf;
- int desclen, conflen, smallest;
+ unsigned char *cbuf;
+ int conflen;
int ret;
int p = 0;
int foundlen = 0;
+ struct libusb_config_descriptor *config;
+
+ /* Get the total length of the configuration descriptors */
+ ret = libusb_get_active_config_descriptor(dfu_if->dev, &config);
+ if (ret) {
+ fprintf(stderr, "Error: failed "
+ "libusb_get_active_config_descriptor()\n");
+ return -1;
+ }
+ conflen = config->wTotalLength;
+ libusb_free_config_descriptor(config);
- conflen = (usb_device(udev))->config->wTotalLength;
+ /* Suck in the whole configuration descriptor list */
cbuf = malloc(conflen);
- ret = usb_get_descriptor(udev, USB_DT_CONFIG, index, cbuf, conflen);
+ ret = libusb_get_descriptor(dfu_if->dev_handle, LIBUSB_DT_CONFIG,
+ index, cbuf, conflen);
if (ret < conflen) {
- fprintf(stderr, "Warning: failed to retrieve complete"
+ fprintf(stderr, "Warning: failed to retrieve complete "
"configuration descriptor\n");
conflen = ret;
}
+
+ /* Iterate through the descriptors */
while (p + 1 < conflen) {
+ int desclen, smallest;
+
desclen = (int) cbuf[p];
if (cbuf[p + 1] == type) {
smallest = desclen < size ? desclen : size;
@@ -395,10 +453,13 @@ static int usb_get_extra_descriptor(usb_dev_handle *udev, unsigned char type,
p += desclen;
}
free(cbuf);
+ /* A descriptor is at least 2 bytes long */
if (foundlen > 1)
return foundlen;
+
/* try to retrieve it through usb_get_descriptor directly */
- return usb_get_descriptor(udev, type, index, resbuf, size);
+ return libusb_get_descriptor(dfu_if->dev_handle, type, index, resbuf,
+ size);
}
static void help(void)
@@ -406,6 +467,7 @@ static void help(void)
printf("Usage: dfu-util [options] ...\n"
" -h --help\t\t\tPrint this help message\n"
" -V --version\t\t\tPrint the version number\n"
+ " -v --verbose\t\t\tPrint verbose debug statements\n"
" -l --list\t\t\tList the currently attached DFU capable USB devices\n"
" -d --device vendor:product\tSpecify Vendor/Product ID of DFU device\n"
" -p --path bus-port. ... .port\tSpecify path to DFU device\n"
@@ -452,7 +514,6 @@ enum mode {
int main(int argc, char **argv)
{
- struct usb_vendprod vendprod;
struct dfu_if _rt_dif, _dif, *dif = &_dif;
int num_devs;
int num_ifs;
@@ -462,7 +523,8 @@ int main(int argc, char **argv)
enum mode mode = MODE_NONE;
struct dfu_status status;
struct usb_dfu_func_descriptor func_dfu;
- char *filename = NULL;
+ libusb_context *ctx;
+ struct dfu_file file;
char *alt_name = NULL; /* query alt name if non-NULL */
char *end;
int final_reset = 0;
@@ -475,11 +537,13 @@ int main(int argc, char **argv)
host_page_size = getpagesize();
memset(dif, 0, sizeof(*dif));
+ file.name = NULL;
- usb_init();
- //usb_set_debug(255);
- usb_find_busses();
- usb_find_devices();
+ ret = libusb_init(&ctx);
+ if (ret) {
+ fprintf(stderr, "unable to initialize libusb: %i\n", ret);
+ return EXIT_FAILURE;
+ }
while (1) {
int c, option_index = 0;
@@ -499,7 +563,7 @@ int main(int argc, char **argv)
break;
case 'v':
if (verbose) {
- usb_set_debug(255);
+ libusb_set_debug(ctx, 255);
}
verbose = 1;
break;
@@ -508,15 +572,13 @@ int main(int argc, char **argv)
exit(0);
break;
case 'd':
- /* Parse device */
- if (parse_vendprod(&vendprod, optarg) < 0) {
- fprintf(stderr, "unable to parse `%s' as a vendor:product\n", optarg);
-
- exit(2);
- }
- dif->vendor = vendprod.vendor;
- dif->product = vendprod.product;
- dif->flags |= (DFU_IFF_VENDOR | DFU_IFF_PRODUCT);
+ /* Parse device ID */
+ parse_vendprod(&dif->vendor, &dif->product, optarg);
+ printf("Filter on vendor = 0x%04x product = 0x%04x\n", dif->vendor, dif->product);
+ if (dif->vendor)
+ dif->flags |= DFU_IFF_VENDOR;
+ if (dif->product)
+ dif->flags |= DFU_IFF_PRODUCT;
break;
case 'p':
/* Parse device path */
@@ -555,11 +617,11 @@ int main(int argc, char **argv)
break;
case 'U':
mode = MODE_UPLOAD;
- filename = optarg;
+ file.name = optarg;
break;
case 'D':
mode = MODE_DOWNLOAD;
- filename = optarg;
+ file.name = optarg;
break;
case 'R':
final_reset = 1;
@@ -576,7 +638,7 @@ int main(int argc, char **argv)
exit(2);
}
- if (!filename) {
+ if (!file.name) {
fprintf(stderr, "You need to specify a filename to -D or -U\n");
help();
exit(2);
@@ -601,12 +663,12 @@ int main(int argc, char **argv)
if (!get_first_dfu_device(dif))
exit(3);
- /* We have exactly one device. Its usb_device is now in dif->dev */
+ /* We have exactly one device. Its libusb_device is now in dif->dev */
printf("Opening DFU USB device... ");
- dif->dev_handle = usb_open(dif->dev);
+ libusb_open(dif->dev, &dif->dev_handle);
if (!dif->dev_handle) {
- fprintf(stderr, "Cannot open device: %s\n", usb_strerror());
+ fprintf(stderr, "Cannot open device \n");
exit(1);
}
@@ -620,30 +682,27 @@ int main(int argc, char **argv)
/* find set of quirks for this device */
set_quirks(_rt_dif.vendor, _rt_dif.product);
- if (!_rt_dif.flags & DFU_IFF_DFU) {
+ if (!(_rt_dif.flags & DFU_IFF_DFU)) {
/* In the 'first round' during runtime mode, there can only be one
* DFU Interface descriptor according to the DFU Spec. */
/* FIXME: check if the selected device really has only one */
printf("Claiming USB DFU Runtime Interface...\n");
- if (usb_claim_interface(_rt_dif.dev_handle, _rt_dif.interface) < 0) {
- fprintf(stderr, "Cannot claim interface %d: %s\n",
- _rt_dif.interface,
- usb_strerror());
+ if (libusb_claim_interface(_rt_dif.dev_handle, _rt_dif.interface) < 0) {
+ fprintf(stderr, "Cannot claim interface %d\n",
+ _rt_dif.interface);
exit(1);
}
- if (usb_set_altinterface(_rt_dif.dev_handle, 0) < 0) {
- fprintf(stderr, "Cannot set alt interface: %s\n",
- usb_strerror());
+ if (libusb_set_interface_alt_setting(_rt_dif.dev_handle, _rt_dif.interface, 0) < 0) {
+ fprintf(stderr, "Cannot set alt interface\n");
exit(1);
}
printf("Determining device status: ");
if (dfu_get_status(_rt_dif.dev_handle, _rt_dif.interface, &status ) < 0) {
- fprintf(stderr, "error get_status: %s\n",
- usb_strerror());
+ fprintf(stderr, "error get_status\n");
exit(1);
}
printf("state = %s, status = %d\n",
@@ -658,25 +717,23 @@ int main(int argc, char **argv)
"detach request...\n");
if (dfu_detach(_rt_dif.dev_handle,
_rt_dif.interface, 1000) < 0) {
- fprintf(stderr, "error detaching: %s\n",
- usb_strerror());
+ fprintf(stderr, "error detaching\n");
exit(1);
break;
}
+ libusb_release_interface(_rt_dif.dev_handle,
+ _rt_dif.interface);
printf("Resetting USB...\n");
- ret = usb_reset(_rt_dif.dev_handle);
- if (ret < 0 && ret != -ENODEV)
- fprintf(stderr,
- "error resetting after detach: %s\n",
- usb_strerror());
+ ret = libusb_reset_device(_rt_dif.dev_handle);
+ if (ret < 0 && ret != LIBUSB_ERROR_NOT_FOUND)
+ fprintf(stderr, "error resetting after detach\n");
sleep(2);
break;
case DFU_STATE_dfuERROR:
printf("dfuERROR, clearing status\n");
if (dfu_clear_status(_rt_dif.dev_handle,
_rt_dif.interface) < 0) {
- fprintf(stderr, "error clear_status: %s\n",
- usb_strerror());
+ fprintf(stderr, "error clear_status\n");
exit(1);
break;
}
@@ -687,10 +744,13 @@ int main(int argc, char **argv)
goto dfustate;
break;
}
+ libusb_release_interface(_rt_dif.dev_handle,
+ _rt_dif.interface);
+ libusb_close(_rt_dif.dev_handle);
/* now we need to re-scan the bus and locate our device */
- if (usb_find_devices() < 2)
- printf("not at least 2 device changes found ?!?\n");
+// if (usb_find_devices() < 2)
+// printf("not at least 2 device changes found ?!?\n");
if (dif->flags & DFU_IFF_PATH) {
ret = resolve_device_path(dif);
@@ -721,10 +781,9 @@ int main(int argc, char **argv)
exit(3);
printf("Opening USB Device...\n");
- dif->dev_handle = usb_open(dif->dev);
+ libusb_open(dif->dev, &dif->dev_handle);
if (!dif->dev_handle) {
- fprintf(stderr, "Cannot open device: %s\n",
- usb_strerror());
+ fprintf(stderr, "Cannot open device\n");
exit(1);
}
} else {
@@ -749,51 +808,47 @@ dfustate:
dif->altsetting = n-1;
}
- print_dfu_if(dif, NULL);
-
- num_ifs = count_dfu_interfaces(dif->dev);
+ num_ifs = count_matching_dfu_if(dif);
if (num_ifs < 0) {
- fprintf(stderr, "No DFU Interface after RESET?!?\n");
+ fprintf(stderr, "No matching DFU Interface after RESET?!?\n");
exit(1);
- } else if (num_ifs == 1) {
- if (!get_first_dfu_if(dif)) {
- fprintf(stderr, "Can't find the single available "
- "DFU IF\n");
- exit(1);
- }
- } else if (num_ifs > 1 && !(dif->flags & (DFU_IFF_IFACE|DFU_IFF_ALT))) {
- fprintf(stderr, "We have %u DFU Interfaces/Altsettings, "
- "you have to specify one via --intf / --alt options\n",
- num_ifs);
+ } else if (num_ifs > 1 ) {
+ fprintf(stderr, "We have %u DFU Interfaces/Altsettings,"
+ " you have to specify one via --intf / --alt"
+ " options\n", num_ifs);
exit(1);
}
+ if (!get_matching_dfu_if(dif)) {
+ fprintf(stderr, "Can't find the matching DFU interface/"
+ "altsetting\n");
+ exit(1);
+ }
+ print_dfu_if(dif, NULL);
+
#if 0
printf("Setting Configuration %u...\n", dif->configuration);
- if (usb_set_configuration(dif->dev_handle, dif->configuration) < 0) {
- fprintf(stderr, "Cannot set configuration: %s\n",
- usb_strerror());
+ if (libusb_set_configuration(dif->dev_handle, dif->configuration) < 0) {
+ fprintf(stderr, "Cannot set configuration\n");
exit(1);
}
#endif
printf("Claiming USB DFU Interface...\n");
- if (usb_claim_interface(dif->dev_handle, dif->interface) < 0) {
- fprintf(stderr, "Cannot claim interface: %s\n",
- usb_strerror());
+ if (libusb_claim_interface(dif->dev_handle, dif->interface) < 0) {
+ fprintf(stderr, "Cannot claim interface\n");
exit(1);
}
printf("Setting Alternate Setting #%d ...\n", dif->altsetting);
- if (usb_set_altinterface(dif->dev_handle, dif->altsetting) < 0) {
- fprintf(stderr, "Cannot set alternate interface: %s\n",
- usb_strerror());
+ if (libusb_set_interface_alt_setting(dif->dev_handle, dif->interface, dif->altsetting) < 0) {
+ fprintf(stderr, "Cannot set alternate interface\n");
exit(1);
}
status_again:
printf("Determining device status: ");
if (dfu_get_status(dif->dev_handle, dif->interface, &status ) < 0) {
- fprintf(stderr, "error get_status: %s\n", usb_strerror());
+ fprintf(stderr, "error get_status\n");
exit(1);
}
printf("state = %s, status = %d\n",
@@ -810,8 +865,7 @@ status_again:
case DFU_STATE_dfuERROR:
printf("dfuERROR, clearing status\n");
if (dfu_clear_status(dif->dev_handle, dif->interface) < 0) {
- fprintf(stderr, "error clear_status: %s\n",
- usb_strerror());
+ fprintf(stderr, "error clear_status\n");
exit(1);
}
goto status_again;
@@ -820,8 +874,7 @@ status_again:
case DFU_STATE_dfuUPLOAD_IDLE:
printf("aborting previous incomplete transfer\n");
if (dfu_abort(dif->dev_handle, dif->interface) < 0) {
- fprintf(stderr, "can't send DFU_ABORT: %s\n",
- usb_strerror());
+ fprintf(stderr, "can't send DFU_ABORT\n");
exit(1);
}
goto status_again;
@@ -833,11 +886,11 @@ status_again:
if (!transfer_size) {
/* Obtain DFU functional descriptor */
- ret = usb_get_extra_descriptor(dif->dev_handle, USB_DT_DFU,
+ ret = usb_get_extra_descriptor(dif, USB_DT_DFU,
dif->interface, &func_dfu, sizeof(func_dfu));
if (ret < 0) {
fprintf(stderr, "Error obtaining DFU functional "
- "descriptor: %s\n", usb_strerror());
+ "descriptor\n");
} else {
transfer_size = get_int16_le(&func_dfu.wTransferSize);
printf("Device returned transfer size %i\n",
@@ -856,8 +909,10 @@ status_again:
printf("Limited transfer size to %i\n", transfer_size);
}
/* DFU specification */
- if (transfer_size < dif->dev->descriptor.bMaxPacketSize0) {
- transfer_size = dif->dev->descriptor.bMaxPacketSize0;
+ struct libusb_device_descriptor desc;
+ libusb_get_device_descriptor(dif->dev, &desc);
+ if (transfer_size < desc.bMaxPacketSize0) {
+ transfer_size = desc.bMaxPacketSize0;
printf("Adjusted transfer size to %i\n", transfer_size);
}
@@ -878,14 +933,44 @@ status_again:
switch (mode) {
case MODE_UPLOAD:
- if (dfuload_do_upload(dif->dev_handle, dif->interface,
- transfer_size, filename) < 0)
+ file.fd = open(file.name, O_WRONLY|O_CREAT|O_EXCL, 0644);
+ if (file.fd < 0) {
+ perror(file.name);
exit(1);
+ }
+ if (dfuload_do_upload(dif, transfer_size, file) < 0)
+ exit(1);
+ close(file.fd);
break;
case MODE_DOWNLOAD:
- if (dfuload_do_dnload(dif->dev_handle, dif->interface,
- transfer_size, filename) < 0)
+ file.fd = open(file.name, O_RDONLY|O_BINARY);
+ if (file.fd < 0) {
+ perror(file.name);
+ exit(1);
+ }
+ ret = parse_dfu_suffix(&file);
+ if (ret < 0)
+ exit(1);
+ if (ret == 0) {
+ fprintf(stderr, "Warning: File has no DFU suffix\n");
+ } else if (file.bcdDFU != 0x0100) {
+ fprintf(stderr, "Unsupported DFU file revision "
+ "%04x\n", file.bcdDFU);
+ exit(1);
+ }
+ if (file.idVendor != 0xffff &&
+ dif->vendor != file.idVendor) {
+ fprintf(stderr, "Warning: File vendor ID %04x does "
+ "not match device %04x\n", file.idVendor, dif->vendor);
+ }
+ if (file.idProduct != 0xffff &&
+ dif->product != file.idProduct) {
+ fprintf(stderr, "Warning: File product ID %04x does "
+ "not match device %04x\n", file.idProduct, dif->product);
+ }
+ if (dfuload_do_dnload(dif, transfer_size, file) < 0)
exit(1);
+ close(file.fd);
break;
default:
fprintf(stderr, "Unsupported mode: %u\n", mode);
@@ -894,16 +979,16 @@ status_again:
if (final_reset) {
if (dfu_detach(dif->dev_handle, dif->interface, 1000) < 0) {
- fprintf(stderr, "can't detach: %s\n", usb_strerror());
+ fprintf(stderr, "can't detach\n");
}
printf("Resetting USB to switch back to runtime mode\n");
- ret = usb_reset(dif->dev_handle);
- if (ret < 0 && ret != -ENODEV) {
- fprintf(stderr, "error resetting after download: %s\n",
- usb_strerror());
+ ret = libusb_reset_device(dif->dev_handle);
+ if (ret < 0 && ret != LIBUSB_ERROR_NOT_FOUND) {
+ fprintf(stderr, "error resetting after download\n");
}
}
+ libusb_close(dif->dev_handle);
exit(0);
}
diff --git a/src/usb_dfu.h b/src/usb_dfu.h
index 1f9799b..e803891 100644
--- a/src/usb_dfu.h
+++ b/src/usb_dfu.h
@@ -42,7 +42,7 @@ struct usb_dfu_func_descriptor {
#define USB_DT_DFU_SIZE 9
-#define USB_TYPE_DFU (USB_TYPE_CLASS|USB_RECIP_INTERFACE)
+#define USB_TYPE_DFU (LIBUSB_REQUEST_TYPE_CLASS|LIBUSB_RECIPIENT_INTERFACE)
/* DFU class-specific requests (Section 3, DFU Rev 1.1) */
#define USB_REQ_DFU_DETACH 0x00