diff options
author | Uwe Hermann <uwe@debian.org> | 2010-12-31 22:32:52 +0100 |
---|---|---|
committer | Andrej Shadura <andrewsh@debian.org> | 2010-12-31 22:32:52 +0100 |
commit | b6239ac999cedf98c54cb1283df8c36e1c86c39e (patch) | |
tree | f0db0be7f241b5a2d69f992ebae610b34ce69cf0 | |
parent | 7050c76b6e97ccac5b5e20ebc73a9b1b095648d4 (diff) |
Import Upstream version 0.3
-rw-r--r-- | ChangeLog | 25 | ||||
-rw-r--r-- | Makefile.in | 2 | ||||
-rw-r--r-- | README | 22 | ||||
-rw-r--r-- | TODO | 9 | ||||
-rw-r--r-- | aclocal.m4 | 62 | ||||
-rwxr-xr-x | configure | 393 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | doc/Makefile.in | 2 | ||||
-rw-r--r-- | src/Makefile.am | 27 | ||||
-rw-r--r-- | src/Makefile.in | 58 | ||||
-rw-r--r-- | src/dfu-version.h | 3 | ||||
-rw-r--r-- | src/dfu.c | 8 | ||||
-rw-r--r-- | src/dfu_load.c (renamed from src/sam7dfu.c) | 65 | ||||
-rw-r--r-- | src/dfu_load.h (renamed from src/sam7dfu.h) | 4 | ||||
-rw-r--r-- | src/main.c | 115 | ||||
-rw-r--r-- | src/quirks.c | 30 | ||||
-rw-r--r-- | src/quirks.h | 17 | ||||
-rw-r--r-- | src/usb_dfu.h | 13 |
18 files changed, 518 insertions, 339 deletions
@@ -1,3 +1,28 @@ +0.3: + o quirks: Add OpenOCD to the poll timeout quirk table. + +2010-12-22: Stefan Schmidt <stefan@datenfreihafen.org> + +0.2: + o Fix some typos on the website and the README (Antonio Ospite, Uwe + Hermann) + o Remove build rule for a static binary. We can use autotools for this. + (Mike Frysinger) + o Fix infinite loop in download error path (C. Scott Ananian) + o Break out to show the 'finished' in upload (C. Scott Ananian) + o Add GPLv2+ headers (Harald Welte) + o Remove dead code (commands.[ch]) remnescent of dfu-programmer (Harald + Welte) + o Simple quirk system with Openmoko quirk for missing bwPollTimeout (Tormod Volden) + o New default (1024) and clamping of transfer size (Tormod Volden) + o Verify sending of completion packet (Tormod Volden) + o Look for DFU functional descriptor among all descriptors (Tormod + Volden) + o Print out in which direction we are transferring data + o Abort in upload if the file already exists + +2010-11-17 Stefan Schmidt <stefan@datenfreihafen.org> + 0.1: Initial release diff --git a/Makefile.in b/Makefile.in index f45b323..d0e11aa 100644 --- a/Makefile.in +++ b/Makefile.in @@ -148,6 +148,8 @@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ @@ -1,11 +1,19 @@ Dfu-util - Device Firmware Upgrade Utilities -Dfu-util is the host side implementation of the DFU 1.0 [1] specification of the USB -forum. DFU is intended to download and upload firmware to devices connected over +Dfu-util is the host side implementation of the DFU 1.0 [1] specification of +the USB forum. + +DFU is intended to download and upload firmware to devices connected over USB. It ranges from small devices like micro-controller boards up to mobile -phones. With dfu-util you are able to download firmware to your device or upload -firmware from it. Most tests have been done with the Openmoko Neo1973 and -Freerunner so far but other devices have been reported working and is being -worked on. +phones. With dfu-util you are able to download firmware to your device or +upload firmware from it. + +Most tests have been done with the Openmoko Neo1973 and Freerunner so far but +other devices have been reported working and is being worked on. + +[1] DFU spec: http://www.usb.org/developers/devclass_docs/usbdfu10.pdf + +The official website is: + + http://dfu-util.gnumonks.org/ -[1] DUF spec: http://www.usb.org/developers/devclass_docs/usbdfu10.pdf @@ -1,12 +1,17 @@ Core: - DFU suffix handling -- Real timeout handling - DFU 1.1 support +- Port to libusb 1.0 API CLI: - Status bar end marker or percentage values +Devices: +- Research iPhone/iPod/iPad support +- Test against Niftylights + Non-Code: - Make sure distros pick up the releases -- List with suported devices / bootloaders +- List with supported devices / bootloaders - Logo +- Re-License as LGPL for usage as library? @@ -13,13 +13,14 @@ m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.65],, -[m4_warning([this file was generated for autoconf 2.65. +m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.67],, +[m4_warning([this file was generated for autoconf 2.67. 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'.])]) # pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- +# serial 1 (pkg-config-0.24) # # Copyright © 2004 Scott James Remnant <scott@netsplit.com>. # @@ -47,7 +48,10 @@ 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)?$]) -AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl +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]) + if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) fi @@ -60,7 +64,6 @@ if test -n "$PKG_CONFIG"; then AC_MSG_RESULT([no]) PKG_CONFIG="" fi - fi[]dnl ])# PKG_PROG_PKG_CONFIG @@ -69,34 +72,31 @@ fi[]dnl # Check to see whether a particular set of modules exists. Similar # to PKG_CHECK_MODULES(), but does not set variables or print errors. # -# -# Similar to PKG_CHECK_MODULES, make sure that the first instance of -# this or PKG_CHECK_MODULES is called, or make sure to call -# PKG_CHECK_EXISTS manually +# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) +# only at the first occurence in configure.ac, so if the first place +# it's called might be skipped (such as if it is within an "if", you +# have to call PKG_CHECK_EXISTS manually # -------------------------------------------------------------- AC_DEFUN([PKG_CHECK_EXISTS], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl if test -n "$PKG_CONFIG" && \ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then - m4_ifval([$2], [$2], [:]) + m4_default([$2], [:]) m4_ifvaln([$3], [else $3])dnl fi]) - # _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) # --------------------------------------------- m4_define([_PKG_CONFIG], -[if test -n "$PKG_CONFIG"; then - if test -n "$$1"; then - pkg_cv_[]$1="$$1" - else - PKG_CHECK_EXISTS([$3], - [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`], - [pkg_failed=yes]) - fi -else - pkg_failed=untried +[if test -n "$$1"; then + 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_failed=yes]) + else + pkg_failed=untried fi[]dnl ])# _PKG_CONFIG @@ -138,16 +138,17 @@ and $1[]_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details.]) 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 --errors-to-stdout --print-errors "$2"` + $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$2" 2>&1` else - $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"` + $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$2" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD - ifelse([$4], , [AC_MSG_ERROR(dnl + m4_default([$4], [AC_MSG_ERROR( [Package requirements ($2) were not met: $$1_PKG_ERRORS @@ -155,25 +156,24 @@ $$1_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. -_PKG_TEXT -])], - [AC_MSG_RESULT([no]) - $4]) +_PKG_TEXT])[]dnl + ]) elif test $pkg_failed = untried; then - ifelse([$4], , [AC_MSG_FAILURE(dnl + AC_MSG_RESULT([no]) + m4_default([$4], [AC_MSG_FAILURE( [The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. _PKG_TEXT -To get pkg-config, see <http://pkg-config.freedesktop.org/>.])], - [$4]) +To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl + ]) else $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS $1[]_LIBS=$pkg_cv_[]$1[]_LIBS AC_MSG_RESULT([yes]) - ifelse([$3], , :, [$3]) + $3 fi[]dnl ])# PKG_CHECK_MODULES @@ -1,11 +1,11 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.65 for dfu-util 0.1. +# Generated by GNU Autoconf 2.67 for dfu-util 0.3. # # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. +# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software +# Foundation, Inc. # # # This configure script is free software; the Free Software Foundation @@ -316,7 +316,7 @@ $as_echo X"$as_dir" | test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p @@ -356,19 +356,19 @@ else fi # as_fn_arith -# as_fn_error ERROR [LINENO LOG_FD] -# --------------------------------- +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with status $?, using 1 if that was 0. +# script with STATUS, using 1 if that was 0. as_fn_error () { - as_status=$?; test $as_status -eq 0 && as_status=1 - if test "$3"; then - as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi - $as_echo "$as_me: error: $1" >&2 + $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error @@ -530,7 +530,7 @@ test -n "$DJDIR" || exec 7<&0 </dev/null exec 6>&1 # Name of the host. -# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` @@ -549,8 +549,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='dfu-util' PACKAGE_TARNAME='dfu-util' -PACKAGE_VERSION='0.1' -PACKAGE_STRING='dfu-util 0.1' +PACKAGE_VERSION='0.3' +PACKAGE_STRING='dfu-util 0.3' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -599,6 +599,8 @@ GREP CPP USB_LIBS USB_CFLAGS +PKG_CONFIG_LIBDIR +PKG_CONFIG_PATH PKG_CONFIG am__fastdepCC_FALSE am__fastdepCC_TRUE @@ -698,6 +700,8 @@ LDFLAGS LIBS CPPFLAGS PKG_CONFIG +PKG_CONFIG_PATH +PKG_CONFIG_LIBDIR USB_CFLAGS USB_LIBS CPP' @@ -763,8 +767,9 @@ do fi case $ac_option in - *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; - *) ac_optarg=yes ;; + *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *=) ac_optarg= ;; + *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. @@ -809,7 +814,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid feature name: $ac_useropt" + as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -835,7 +840,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid feature name: $ac_useropt" + as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1039,7 +1044,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid package name: $ac_useropt" + as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1055,7 +1060,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid package name: $ac_useropt" + as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1085,8 +1090,8 @@ do | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; - -*) as_fn_error "unrecognized option: \`$ac_option' -Try \`$0 --help' for more information." + -*) as_fn_error $? "unrecognized option: \`$ac_option' +Try \`$0 --help' for more information" ;; *=*) @@ -1094,7 +1099,7 @@ Try \`$0 --help' for more information." # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) - as_fn_error "invalid variable name: \`$ac_envvar'" ;; + as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; @@ -1112,13 +1117,13 @@ done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` - as_fn_error "missing argument to $ac_option" + as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; - fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;; + fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi @@ -1141,7 +1146,7 @@ do [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac - as_fn_error "expected an absolute directory name for --$ac_var: $ac_val" + as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' @@ -1155,8 +1160,8 @@ target=$target_alias if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe - $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. - If a cross compiler is detected then cross compile mode will be used." >&2 + $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used" >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi @@ -1171,9 +1176,9 @@ test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || - as_fn_error "working directory cannot be determined" + as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || - as_fn_error "pwd does not report name of working directory" + as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. @@ -1212,11 +1217,11 @@ else fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." - as_fn_error "cannot find sources ($ac_unique_file) in $srcdir" + as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( - cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg" + cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then @@ -1242,7 +1247,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.1 to adapt to many kinds of systems. +\`configure' configures dfu-util 0.3 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1256,7 +1261,7 @@ Configuration: --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit - -q, --quiet, --silent do not print \`checking...' messages + -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files @@ -1308,7 +1313,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of dfu-util 0.1:";; + short | recursive ) echo "Configuration of dfu-util 0.3:";; esac cat <<\_ACEOF @@ -1332,6 +1337,10 @@ Some influential environment variables: CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if you have headers in a nonstandard directory <include dir> PKG_CONFIG path to pkg-config utility + PKG_CONFIG_PATH + directories to add to pkg-config's search path + PKG_CONFIG_LIBDIR + path overriding pkg-config's built-in search path USB_CFLAGS C compiler flags for USB, overriding pkg-config USB_LIBS linker flags for USB, overriding pkg-config CPP C preprocessor @@ -1402,10 +1411,10 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -dfu-util configure 0.1 -generated by GNU Autoconf 2.65 +dfu-util configure 0.3 +generated by GNU Autoconf 2.67 -Copyright (C) 2009 Free Software Foundation, Inc. +Copyright (C) 2010 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF @@ -1521,7 +1530,7 @@ $as_echo "$ac_try_echo"; } >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } >/dev/null && { + test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : @@ -1587,10 +1596,10 @@ fi ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + if eval "test \"\${$3+set}\"" = set; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : +if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 @@ -1626,7 +1635,7 @@ if ac_fn_c_try_cpp "$LINENO"; then : else ac_header_preproc=no fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } @@ -1653,7 +1662,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 { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : +if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" @@ -1675,7 +1684,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 { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : +if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -1706,7 +1715,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 { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : +if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else eval "$3=no" @@ -1759,7 +1768,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 { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : +if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -1821,8 +1830,8 @@ 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.1, which was -generated by GNU Autoconf 2.65. Invocation command line was +It was created by dfu-util $as_me 0.3, which was +generated by GNU Autoconf 2.67. Invocation command line was $ $0 $@ @@ -1932,11 +1941,9 @@ trap 'exit_status=$? { echo - cat <<\_ASBOX -## ---------------- ## + $as_echo "## ---------------- ## ## Cache variables. ## -## ---------------- ## -_ASBOX +## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( @@ -1970,11 +1977,9 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; ) echo - cat <<\_ASBOX -## ----------------- ## + $as_echo "## ----------------- ## ## Output variables. ## -## ----------------- ## -_ASBOX +## ----------------- ##" echo for ac_var in $ac_subst_vars do @@ -1987,11 +1992,9 @@ _ASBOX echo if test -n "$ac_subst_files"; then - cat <<\_ASBOX -## ------------------- ## + $as_echo "## ------------------- ## ## File substitutions. ## -## ------------------- ## -_ASBOX +## ------------------- ##" echo for ac_var in $ac_subst_files do @@ -2005,11 +2008,9 @@ _ASBOX fi if test -s confdefs.h; then - cat <<\_ASBOX -## ----------- ## + $as_echo "## ----------- ## ## confdefs.h. ## -## ----------- ## -_ASBOX +## ----------- ##" echo cat confdefs.h echo @@ -2064,7 +2065,12 @@ _ACEOF ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then - ac_site_file1=$CONFIG_SITE + # We do not want a PATH search for config.site. + case $CONFIG_SITE in #(( + -*) ac_site_file1=./$CONFIG_SITE;; + */*) ac_site_file1=$CONFIG_SITE;; + *) ac_site_file1=./$CONFIG_SITE;; + esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site @@ -2079,7 +2085,11 @@ do { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 - . "$ac_site_file" + . "$ac_site_file" \ + || { { $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 ; } fi done @@ -2155,7 +2165,7 @@ if $ac_cache_corrupted; then $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} - as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 + as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## @@ -2170,16 +2180,22 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_aux_dir= for ac_dir in m4 "$srcdir"/m4; do - for ac_t in install-sh install.sh shtool; do - if test -f "$ac_dir/$ac_t"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/$ac_t -c" - break 2 - fi - done + if test -f "$ac_dir/install-sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f "$ac_dir/install.sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f "$ac_dir/shtool"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi done if test -z "$ac_aux_dir"; then - as_fn_error "cannot find install-sh, install.sh, or shtool in m4 \"$srcdir\"/m4" "$LINENO" 5 + as_fn_error $? "cannot find install-sh, install.sh, or shtool in m4 \"$srcdir\"/m4" "$LINENO" 5 fi # These three variables are undocumented and unsupported, @@ -2297,11 +2313,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 @@ -2323,7 +2339,7 @@ if ( # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". - as_fn_error "ls -t appears to fail. Make sure there is not a broken + as_fn_error $? "ls -t appears to fail. Make sure there is not a broken alias in your environment" "$LINENO" 5 fi @@ -2333,7 +2349,7 @@ then # Ok. : else - as_fn_error "newly created file is older than distributed files! + as_fn_error $? "newly created file is older than distributed files! Check your system clock" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 @@ -2571,7 +2587,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 { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then : +if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\"" = set; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF @@ -2579,7 +2595,7 @@ SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF -# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +# GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; @@ -2613,7 +2629,7 @@ if test "`cd $srcdir && pwd`" != "`pwd`"; then am__isrc=' -I$(srcdir)' # test to see if srcdir already configured if test -f $srcdir/config.status; then - as_fn_error "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 + as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 fi fi @@ -2629,7 +2645,7 @@ fi # Define the identity of the package. PACKAGE=dfu-util - VERSION=0.1 + VERSION=0.3 cat >>confdefs.h <<_ACEOF @@ -3011,8 +3027,8 @@ 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; } +as_fn_error $? "no acceptable C compiler found in \$PATH +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 @@ -3126,9 +3142,8 @@ 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_set_status 77 -as_fn_error "C compiler cannot create executables -See \`config.log' for more details." "$LINENO" 5; }; } +as_fn_error 77 "C compiler cannot create executables +See \`config.log' for more details" "$LINENO" 5 ; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -3170,8 +3185,8 @@ done 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; } +as_fn_error $? "cannot compute suffix of executables: cannot compile and link +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 @@ -3228,9 +3243,9 @@ $as_echo "$ac_try_echo"; } >&5 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 run C compiled programs. +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 @@ -3281,8 +3296,8 @@ 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; } +as_fn_error $? "cannot compute suffix of object files: cannot compile +See \`config.log' for more details" "$LINENO" 5 ; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi @@ -3695,6 +3710,10 @@ fi # Checks for libraries. + + + + 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. @@ -3807,18 +3826,16 @@ $as_echo "yes" >&6; } $as_echo "no" >&6; } PKG_CONFIG="" fi - fi pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for USB" >&5 $as_echo_n "checking for USB... " >&6; } -if test -n "$PKG_CONFIG"; then - if test -n "$USB_CFLAGS"; then - pkg_cv_USB_CFLAGS="$USB_CFLAGS" - else - if test -n "$PKG_CONFIG" && \ +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 ac_status=$? @@ -3828,15 +3845,13 @@ if test -n "$PKG_CONFIG"; then else pkg_failed=yes fi - fi -else - pkg_failed=untried + else + pkg_failed=untried fi -if test -n "$PKG_CONFIG"; then - if test -n "$USB_LIBS"; then - pkg_cv_USB_LIBS="$USB_LIBS" - else - if test -n "$PKG_CONFIG" && \ +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 ac_status=$? @@ -3846,14 +3861,15 @@ if test -n "$PKG_CONFIG"; then else pkg_failed=yes fi - fi -else - pkg_failed=untried + else + pkg_failed=untried fi if test $pkg_failed = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes @@ -3861,24 +3877,24 @@ else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - USB_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "libusb >= 0.1.4"` + USB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "libusb >= 0.1.4" 2>&1` else - USB_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "libusb >= 0.1.4"` + USB_PKG_ERRORS=`$PKG_CONFIG --print-errors "libusb >= 0.1.4" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$USB_PKG_ERRORS" >&5 - { $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 >= 0.1.4 not installed ***" "$LINENO" 5 elif test $pkg_failed = untried; then - as_fn_error "*** Required libusb >= 0.1.4 not installed ***" "$LINENO" 5 + { $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 else USB_CFLAGS=$pkg_cv_USB_CFLAGS USB_LIBS=$pkg_cv_USB_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } - : + fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for usb_path2devnum in -lusbpath" >&5 @@ -3973,7 +3989,7 @@ else # Broken: fails on valid input. continue fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. @@ -3989,11 +4005,11 @@ else ac_preproc_ok=: break fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext +rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi @@ -4032,7 +4048,7 @@ else # Broken: fails on valid input. continue fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. @@ -4048,18 +4064,18 @@ else ac_preproc_ok=: break fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext +rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : 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; } +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5 ; } fi ac_ext=c @@ -4120,7 +4136,7 @@ esac done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then - as_fn_error "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP @@ -4186,7 +4202,7 @@ esac done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then - as_fn_error "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP @@ -4318,8 +4334,7 @@ do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " -eval as_val=\$$as_ac_Header - if test "x$as_val" = x""yes; then : +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF @@ -4333,8 +4348,7 @@ for ac_header in stdlib.h string.h stdio.h usbpath.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -eval as_val=\$$as_ac_Header - if test "x$as_val" = x""yes; then : +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF @@ -4664,6 +4678,7 @@ DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= +U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' @@ -4687,15 +4702,15 @@ else fi if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then - as_fn_error "conditional \"MAINTAINER_MODE\" was never defined. + as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then - as_fn_error "conditional \"AMDEP\" was never defined. + as_fn_error $? "conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then - as_fn_error "conditional \"am__fastdepCC\" was never defined. + as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi @@ -4845,19 +4860,19 @@ export LANGUAGE (unset CDPATH) >/dev/null 2>&1 && unset CDPATH -# as_fn_error ERROR [LINENO LOG_FD] -# --------------------------------- +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with status $?, using 1 if that was 0. +# script with STATUS, using 1 if that was 0. as_fn_error () { - as_status=$?; test $as_status -eq 0 && as_status=1 - if test "$3"; then - as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi - $as_echo "$as_me: error: $1" >&2 + $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error @@ -5053,7 +5068,7 @@ $as_echo X"$as_dir" | test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p @@ -5106,8 +5121,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.1, which was -generated by GNU Autoconf 2.65. Invocation command line was +This file was extended by dfu-util $as_me 0.3, which was +generated by GNU Autoconf 2.67. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -5172,11 +5187,11 @@ _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.1 -configured by $0, generated by GNU Autoconf 2.65, +dfu-util config.status 0.3 +configured by $0, generated by GNU Autoconf 2.67, with options \\"\$ac_cs_config\\" -Copyright (C) 2009 Free Software Foundation, Inc. +Copyright (C) 2010 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." @@ -5194,11 +5209,16 @@ ac_need_defaults=: while test $# != 0 do case $1 in - --*=*) + --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= + ac_shift=: + ;; *) ac_option=$1 ac_optarg=$2 @@ -5220,6 +5240,7 @@ do $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; @@ -5232,7 +5253,7 @@ do ac_need_defaults=false;; --he | --h) # Conflict between --help and --header - as_fn_error "ambiguous option: \`$1' + as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; @@ -5241,7 +5262,7 @@ Try \`$0 --help' for more information.";; ac_cs_silent=: ;; # This is an error. - -*) as_fn_error "unrecognized option: \`$1' + -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" @@ -5301,7 +5322,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 @@ -5339,7 +5360,7 @@ $debug || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") -} || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5 +} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. @@ -5356,7 +5377,7 @@ if test "x$ac_cr" = x; then fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then - ac_cs_awk_cr='\r' + ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi @@ -5370,18 +5391,18 @@ _ACEOF echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || - as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 -ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'` + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 +ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || - as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then - as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi @@ -5470,20 +5491,28 @@ if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then else cat fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ - || as_fn_error "could not setup config files machinery" "$LINENO" 5 + || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF -# VPATH may cause trouble with some makes, so we remove $(srcdir), -# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# VPATH may cause trouble with some makes, so we remove sole $(srcdir), +# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=/{ -s/:*\$(srcdir):*/:/ -s/:*\${srcdir}:*/:/ -s/:*@srcdir@:*/:/ -s/^\([^=]*=[ ]*\):*/\1/ + ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ +h +s/// +s/^/:/ +s/[ ]*$/:/ +s/:\$(srcdir):/:/g +s/:\${srcdir}:/:/g +s/:@srcdir@:/:/g +s/^:*// s/:*$// +x +s/\(=[ ]*\).*/\1/ +G +s/\n// s/^[^=]*=[ ]*$// }' fi @@ -5511,7 +5540,7 @@ for ac_last_try in false false :; do if test -z "$ac_t"; then break elif $ac_last_try; then - as_fn_error "could not make $CONFIG_HEADERS" "$LINENO" 5 + as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi @@ -5596,7 +5625,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 - as_fn_error "could not setup config headers machinery" "$LINENO" 5 + as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" @@ -5609,7 +5638,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 @@ -5637,7 +5666,7 @@ do [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || - as_fn_error "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'" @@ -5664,7 +5693,7 @@ $as_echo "$as_me: creating $ac_file" >&6;} case $ac_tag in *:-:* | *:-) cat >"$tmp/stdin" \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 ;; + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac @@ -5801,22 +5830,22 @@ 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 + || 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"; } && { $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 +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;} +which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$tmp/stdin" case $ac_file in -) cat "$tmp/out" && rm -f "$tmp/out";; *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; esac \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # @@ -5827,19 +5856,19 @@ which seems to be undefined. Please make sure it is defined." >&2;} $as_echo "/* $configure_input */" \ && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" } >"$tmp/config.h" \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$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" \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 + || 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" \ - || as_fn_error "could not create -" "$LINENO" 5 + || as_fn_error $? "could not create -" "$LINENO" 5 fi # Compute "$ac_file"'s index in $config_headers. _am_arg="$ac_file" @@ -5989,7 +6018,7 @@ _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || - as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5 + as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. @@ -6010,7 +6039,7 @@ if test "$no_create" != yes; then exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. - $ac_cs_success || as_fn_exit $? + $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 diff --git a/configure.ac b/configure.ac index a27784d..09a3a5c 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.1]) +AC_INIT([dfu-util],[0.3]) AC_CONFIG_AUX_DIR(m4) AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION) AM_CONFIG_HEADER([config.h]) diff --git a/doc/Makefile.in b/doc/Makefile.in index 70e080f..094affd 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -118,6 +118,8 @@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ diff --git a/src/Makefile.am b/src/Makefile.am index a9a7cb4..7f9c211 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,26 +1,11 @@ AM_CFLAGS = -Wall -dfu-version.h: - echo -e '#ifndef DFU_UTIL_VERSION' \ - '\n#define DFU_UTIL_VERSION "'`svnversion -n`'"' \ - '\n#endif' > dfu-version.h -BUILT_SOURCES = dfu-version.h - -bin_PROGRAMS = dfu-util dfu-util_static +bin_PROGRAMS = dfu-util dfu_util_SOURCES = main.c \ - sam7dfu.c \ - sam7dfu.h \ + dfu_load.c \ + dfu_load.h \ dfu.c \ dfu.h \ - usb_dfu.h - -dfu_util_static_SOURCES = main.c \ - sam7dfu.c \ - sam7dfu.h \ - dfu.c \ - dfu.h \ - usb_dfu.h - -dfu_util_static_LDFLAGS = -static - -EXTRA_DIST = dfu-version.h + usb_dfu.h \ + quirks.c \ + quirks.h diff --git a/src/Makefile.in b/src/Makefile.in index 40307f6..ca7a582 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -32,7 +32,7 @@ POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : -bin_PROGRAMS = dfu-util$(EXEEXT) dfu-util_static$(EXEEXT) +bin_PROGRAMS = dfu-util$(EXEEXT) subdir = src DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -45,15 +45,10 @@ CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(bindir)" PROGRAMS = $(bin_PROGRAMS) -am_dfu_util_OBJECTS = main.$(OBJEXT) sam7dfu.$(OBJEXT) dfu.$(OBJEXT) +am_dfu_util_OBJECTS = main.$(OBJEXT) dfu_load.$(OBJEXT) dfu.$(OBJEXT) \ + quirks.$(OBJEXT) dfu_util_OBJECTS = $(am_dfu_util_OBJECTS) dfu_util_LDADD = $(LDADD) -am_dfu_util_static_OBJECTS = main.$(OBJEXT) sam7dfu.$(OBJEXT) \ - dfu.$(OBJEXT) -dfu_util_static_OBJECTS = $(am_dfu_util_static_OBJECTS) -dfu_util_static_LDADD = $(LDADD) -dfu_util_static_LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(dfu_util_static_LDFLAGS) $(LDFLAGS) -o $@ DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/m4/depcomp am__depfiles_maybe = depfiles @@ -74,8 +69,8 @@ am__v_CCLD_0 = @echo " CCLD " $@; AM_V_GEN = $(am__v_GEN_$(V)) am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) am__v_GEN_0 = @echo " GEN " $@; -SOURCES = $(dfu_util_SOURCES) $(dfu_util_static_SOURCES) -DIST_SOURCES = $(dfu_util_SOURCES) $(dfu_util_static_SOURCES) +SOURCES = $(dfu_util_SOURCES) +DIST_SOURCES = $(dfu_util_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) @@ -122,6 +117,8 @@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ @@ -171,25 +168,16 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CFLAGS = -Wall -BUILT_SOURCES = dfu-version.h dfu_util_SOURCES = main.c \ - sam7dfu.c \ - sam7dfu.h \ + dfu_load.c \ + dfu_load.h \ dfu.c \ dfu.h \ - usb_dfu.h + usb_dfu.h \ + quirks.c \ + quirks.h -dfu_util_static_SOURCES = main.c \ - sam7dfu.c \ - sam7dfu.h \ - dfu.c \ - dfu.h \ - usb_dfu.h - -dfu_util_static_LDFLAGS = -static -EXTRA_DIST = dfu-version.h -all: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) all-am +all: all-am .SUFFIXES: .SUFFIXES: .c .o .obj @@ -263,9 +251,6 @@ clean-binPROGRAMS: dfu-util$(EXEEXT): $(dfu_util_OBJECTS) $(dfu_util_DEPENDENCIES) @rm -f dfu-util$(EXEEXT) $(AM_V_CCLD)$(LINK) $(dfu_util_OBJECTS) $(dfu_util_LDADD) $(LIBS) -dfu-util_static$(EXEEXT): $(dfu_util_static_OBJECTS) $(dfu_util_static_DEPENDENCIES) - @rm -f dfu-util_static$(EXEEXT) - $(AM_V_CCLD)$(dfu_util_static_LINK) $(dfu_util_static_OBJECTS) $(dfu_util_static_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) @@ -274,8 +259,9 @@ 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_load.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sam7dfu.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/quirks.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @@ -376,15 +362,13 @@ distdir: $(DISTFILES) fi; \ done check-am: all-am -check: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) check-am +check: check-am all-am: Makefile $(PROGRAMS) installdirs: for dir in "$(DESTDIR)$(bindir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done -install: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) install-am +install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am @@ -409,7 +393,6 @@ distclean-generic: maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." - -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) clean: clean-am clean-am: clean-binPROGRAMS clean-generic mostlyclean-am @@ -479,7 +462,7 @@ ps-am: uninstall-am: uninstall-binPROGRAMS -.MAKE: all check install install-am install-strip +.MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ clean-generic ctags distclean distclean-compile \ @@ -495,11 +478,6 @@ uninstall-am: uninstall-binPROGRAMS uninstall-am uninstall-binPROGRAMS -dfu-version.h: - echo -e '#ifndef DFU_UTIL_VERSION' \ - '\n#define DFU_UTIL_VERSION "'`svnversion -n`'"' \ - '\n#endif' > dfu-version.h - # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/src/dfu-version.h b/src/dfu-version.h deleted file mode 100644 index c6aac9b..0000000 --- a/src/dfu-version.h +++ /dev/null @@ -1,3 +0,0 @@ -#ifndef DFU_UTIL_VERSION -#define DFU_UTIL_VERSION "exported" -#endif @@ -1,7 +1,9 @@ /* - * dfu-programmer - * + * low-level DFU message sending routines, originally taken from * $Id: dfu.c,v 1.3 2006/06/20 06:28:04 schmidtw Exp $ + * (part of dfu-programmer). + * + * (C) 2005-2006 Weston Schmidt <weston_schmidt@alumni.purdue.edu> * * 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 @@ -395,7 +397,7 @@ static const char *dfu_status_names[] = { [DFU_STATUS_errPROG] = "Program memory function failed", [DFU_STATUS_errVERIFY] = - "Programmed emmory failed verification", + "Programmed memory failed verification", [DFU_STATUS_errADDRESS] = "Cannot program memory due to received address that is out of range", [DFU_STATUS_errNOTDONE] = diff --git a/src/sam7dfu.c b/src/dfu_load.c index 16330ad..3a4f382 100644 --- a/src/sam7dfu.c +++ b/src/dfu_load.c @@ -1,7 +1,24 @@ /* This is supposed to be a "real" DFU implementation, just as specified in the * USB DFU 1.0 Spec. Not overloaded like the Atmel one... * + * The code was originally intended to interface with a USB device running the + * "sam7dfu" firmware (see http://www.openpcd.org/) on an AT91SAM7 processor. + * * (C) 2007-2008 by Harald Welte <laforge@gnumonks.org> + * + * 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> @@ -17,13 +34,15 @@ #include "config.h" #include "dfu.h" #include "usb_dfu.h" +#include "dfu_load.h" +#include "quirks.h" /* ugly hack for Win32 */ #ifndef O_BINARY #define O_BINARY 0 #endif -int sam7dfu_do_upload(struct usb_dev_handle *usb_handle, int interface, +int dfuload_do_upload(struct usb_dev_handle *usb_handle, int interface, int xfer_size, const char *fname) { int ret, fd, total_bytes = 0; @@ -32,14 +51,15 @@ int sam7dfu_do_upload(struct usb_dev_handle *usb_handle, int interface, if (!buf) return -ENOMEM; - fd = creat(fname, 0644); + 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: ["); fflush(stdout); @@ -61,7 +81,7 @@ int sam7dfu_do_upload(struct usb_dev_handle *usb_handle, int interface, if (rc < xfer_size) { /* last block, return */ ret = total_bytes; - goto out_close; + break; } putchar('#'); fflush(stdout); @@ -75,13 +95,13 @@ out_close: close(fd); out_free: free(buf); - + return ret; } #define PROGRESS_BAR_WIDTH 50 -int sam7dfu_do_dnload(struct usb_dev_handle *usb_handle, int interface, +int dfuload_do_dnload(struct usb_dev_handle *usb_handle, int interface, int xfer_size, const char *fname) { int ret, fd, bytes_sent = 0; @@ -99,12 +119,11 @@ int sam7dfu_do_dnload(struct usb_dev_handle *usb_handle, int interface, ret = fd; goto out_free; } - + ret = fstat(fd, &st); if (ret < 0) { perror(fname); goto out_close; - perror(fname); } if (st.st_size <= 0 /* + DFU_HDR */) { @@ -120,6 +139,7 @@ int sam7dfu_do_dnload(struct usb_dev_handle *usb_handle, int interface, #if 0 read(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 */) { @@ -143,8 +163,14 @@ int sam7dfu_do_dnload(struct usb_dev_handle *usb_handle, int interface, fprintf(stderr, "Error during download get_status\n"); goto out_close; } - usleep(5000); - } while (dst.bState != DFU_STATE_dfuDNLOAD_IDLE); + /* 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); if (dst.bStatus != DFU_STATUS_OK) { printf(" failed!\n"); printf("state(%u) = %s, status(%u) = %s\n", dst.bState, @@ -163,9 +189,11 @@ int sam7dfu_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); - if (ret >= 0) - ret = bytes_sent; - + if (ret < 0) { + fprintf(stderr, "Error sending completion packet\n"); + goto out_close; + } + printf("] finished!\n"); fflush(stdout); @@ -176,9 +204,11 @@ get_status: fprintf(stderr, "unable to read DFU status\n"); goto out_close; } - printf("state(%u) = %s, status(%u) = %s\n", dst.bState, + printf("state(%u) = %s, status(%u) = %s\n", dst.bState, dfu_state_to_string(dst.bState), dst.bStatus, dfu_status_to_string(dst.bStatus)); + if (!(quirks & QUIRK_POLLTIMEOUT)) + usleep(dst.bwPollTimeout * 1000); /* FIXME: deal correctly with ManifestationTolerant=0 / WillDetach bits */ switch (dst.bState) { @@ -195,7 +225,7 @@ get_status: #if 0 printf("Resetting USB...\n"); if (usb_reset(usb_handle) < 0) { - fprintf(stderr, "error resetting after download: %s\n", + fprintf(stderr, "error resetting after download: %s\n", usb_strerror()); } #endif @@ -205,13 +235,12 @@ out_close: out_free: free(buf); - return ret; + return bytes_sent; } -void sam7dfu_init() +void dfuload_init() { dfu_debug( debug ); dfu_init( 5000 ); } - diff --git a/src/sam7dfu.h b/src/dfu_load.h index 8ebe5a2..8955696 100644 --- a/src/sam7dfu.h +++ b/src/dfu_load.h @@ -1,9 +1,9 @@ #ifndef _SAM7DFU_H #define _SAM7DFU_H -int sam7dfu_do_upload(struct usb_dev_handle *usb_handle, int interface, +int dfuload_do_upload(struct usb_dev_handle *usb_handle, int interface, int xfer_size, const char *fname); -int sam7dfu_do_dnload(struct usb_dev_handle *usb_handle, int interface, +int dfuload_do_dnload(struct usb_dev_handle *usb_handle, int interface, int xfer_size, const char *fname); #endif @@ -31,8 +31,8 @@ #include "dfu.h" #include "usb_dfu.h" -#include "sam7dfu.h" -#include "dfu-version.h" +#include "dfu_load.h" +#include "quirks.h" #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -102,7 +102,7 @@ static int find_dfu_if(struct usb_device *dev, int (*handler)(struct dfu_if *, v int rc; memset(dfu_if, 0, sizeof(*dfu_if)); - + for (cfg_idx = 0; cfg_idx < dev->descriptor.bNumConfigurations; cfg_idx++) { cfg = &dev->config[cfg_idx]; @@ -128,16 +128,14 @@ static int find_dfu_if(struct usb_device *dev, int (*handler)(struct dfu_if *, v dfu_if->product = dev->descriptor.idProduct; dfu_if->configuration = cfg_idx; - dfu_if->interface = + dfu_if->interface = intf->bInterfaceNumber; - dfu_if->altsetting = + dfu_if->altsetting = intf->bAlternateSetting; if (intf->bInterfaceProtocol == 2) - dfu_if->flags |= - DFU_IFF_DFU; + dfu_if->flags |= DFU_IFF_DFU; else - dfu_if->flags &= - ~DFU_IFF_DFU; + dfu_if->flags &= ~DFU_IFF_DFU; if (!handler) return 1; rc = handler(dfu_if, v); @@ -248,12 +246,12 @@ static int iterate_dfu_devices(struct dfu_if *dif, if (dif && (dif->flags & (DFU_IFF_VENDOR|DFU_IFF_PRODUCT)) && - (dev->descriptor.idVendor != dif->vendor || - dev->descriptor.idProduct != dif->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)) + (atoi(usb_bus->dirname) != dif->bus || + dev->devnum != dif->devnum)) continue; if (!count_dfu_interfaces(dev)) continue; @@ -368,6 +366,40 @@ 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, + unsigned char index, void *resbuf, int size) +{ + char *cbuf; + int desclen, conflen, smallest; + int ret; + int p = 0; + int foundlen = 0; + + conflen = (usb_device(udev))->config->wTotalLength; + cbuf = malloc(conflen); + ret = usb_get_descriptor(udev, USB_DT_CONFIG, index, cbuf, conflen); + if (ret < conflen) { + fprintf(stderr, "Warning: failed to retrieve complete" + "configuration descriptor\n"); + conflen = ret; + } + while (p + 1 < conflen) { + desclen = (int) cbuf[p]; + if (cbuf[p + 1] == type) { + smallest = desclen < size ? desclen : size; + memcpy(resbuf, &cbuf[p], smallest); + foundlen = smallest; + break; + } + p += desclen; + } + free(cbuf); + if (foundlen > 1) + return foundlen; + /* try to retrieve it through usb_get_descriptor directly */ + return usb_get_descriptor(udev, type, index, resbuf, size); +} static void help(void) { @@ -390,7 +422,7 @@ static void help(void) static void print_version(void) { - printf("dfu-util version %s\n", VERSION "+svn" DFU_UTIL_VERSION); + printf("dfu-util version %s\n", VERSION); } static struct option opts[] = { @@ -425,6 +457,8 @@ int main(int argc, char **argv) int num_devs; int num_ifs; unsigned int transfer_size = 0; + unsigned int default_transfer_size = 1024; + unsigned int host_page_size; enum mode mode = MODE_NONE; struct dfu_status status; struct usb_dfu_func_descriptor func_dfu; @@ -432,14 +466,14 @@ int main(int argc, char **argv) char *alt_name = NULL; /* query alt name if non-NULL */ char *end; int final_reset = 0; - int page_size = getpagesize(); int ret; - - printf("dfu-util - (C) 2007-2008 by OpenMoko Inc.\n" + + printf("dfu-util - (C) 2005-2008 by Weston Schmidt, Harald Welte and OpenMoko Inc.\n" "This program is Free Software and has ABSOLUTELY NO WARRANTY\n\n"); printf("dfu-util does currently only support DFU version 1.0\n\n"); + host_page_size = getpagesize(); memset(dif, 0, sizeof(*dif)); usb_init(); @@ -569,7 +603,7 @@ int main(int argc, char **argv) /* We have exactly one device. Its usb_device is now in dif->dev */ - printf("Opening USB Device 0x%04x:0x%04x...\n", dif->vendor, dif->product); + printf("Opening DFU USB device... "); dif->dev_handle = usb_open(dif->dev); if (!dif->dev_handle) { fprintf(stderr, "Cannot open device: %s\n", usb_strerror()); @@ -581,9 +615,14 @@ int main(int argc, char **argv) if (!get_first_dfu_if(&_rt_dif)) exit(1); + printf("ID %04x:%04x\n", _rt_dif.vendor, _rt_dif.product); + + /* find set of quirks for this device */ + set_quirks(_rt_dif.vendor, _rt_dif.product); + 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. */ + * DFU Interface descriptor according to the DFU Spec. */ /* FIXME: check if the selected device really has only one */ @@ -609,6 +648,8 @@ int main(int argc, char **argv) } printf("state = %s, status = %d\n", dfu_state_to_string(status.bState), status.bStatus); + if (!(quirks & QUIRK_POLLTIMEOUT)) + usleep(status.bwPollTimeout * 1000); switch (status.bState) { case DFU_STATE_appIDLE: @@ -757,6 +798,8 @@ status_again: } printf("state = %s, status = %d\n", dfu_state_to_string(status.bState), status.bStatus); + if (!(quirks & QUIRK_POLLTIMEOUT)) + usleep(status.bwPollTimeout * 1000); switch (status.bState) { case DFU_STATE_appIDLE: @@ -790,21 +833,33 @@ status_again: if (!transfer_size) { /* Obtain DFU functional descriptor */ - ret = usb_get_descriptor(dif->dev_handle, 0x21, dif->interface, - &func_dfu, sizeof(func_dfu)); + ret = usb_get_extra_descriptor(dif->dev_handle, USB_DT_DFU, + dif->interface, &func_dfu, sizeof(func_dfu)); if (ret < 0) { fprintf(stderr, "Error obtaining DFU functional " "descriptor: %s\n", usb_strerror()); - transfer_size = page_size; } else { transfer_size = get_int16_le(&func_dfu.wTransferSize); + printf("Device returned transfer size %i\n", + transfer_size); } } - - if (transfer_size > page_size) - transfer_size = page_size; - - printf("Transfer Size = 0x%04x\n", transfer_size); + /* if returned zero or not detected (and not user specified) */ + if (!transfer_size) { + transfer_size = default_transfer_size; + printf("Warning: Trying default transfer size %i\n", + transfer_size); + } + /* limitation of Linux usbdevio */ + if (transfer_size > host_page_size) { + transfer_size = host_page_size; + printf("Limited transfer size to %i\n", transfer_size); + } + /* DFU specification */ + if (transfer_size < dif->dev->descriptor.bMaxPacketSize0) { + transfer_size = dif->dev->descriptor.bMaxPacketSize0; + printf("Adjusted transfer size to %i\n", transfer_size); + } if (DFU_STATUS_OK != status.bStatus ) { printf("WARNING: DFU Status: '%s'\n", @@ -817,16 +872,18 @@ status_again: fprintf(stderr, "Error: %d\n", status.bStatus); exit(1); } + if (!(quirks & QUIRK_POLLTIMEOUT)) + usleep(status.bwPollTimeout * 1000); } switch (mode) { case MODE_UPLOAD: - if (sam7dfu_do_upload(dif->dev_handle, dif->interface, + if (dfuload_do_upload(dif->dev_handle, dif->interface, transfer_size, filename) < 0) exit(1); break; case MODE_DOWNLOAD: - if (sam7dfu_do_dnload(dif->dev_handle, dif->interface, + if (dfuload_do_dnload(dif->dev_handle, dif->interface, transfer_size, filename) < 0) exit(1); break; diff --git a/src/quirks.c b/src/quirks.c new file mode 100644 index 0000000..0350fb5 --- /dev/null +++ b/src/quirks.c @@ -0,0 +1,30 @@ +/* Simple quirk system for dfu-util + * Copyright 2010 Tormod Volden + * + * 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 "quirks.h" + +int quirks = 0; + +void set_quirks(unsigned long vendor, unsigned long product) +{ + /* Device returns bogus bwPollTimeout values */ + if (vendor == VENDOR_OPENMOKO || + vendor == VENDOR_FIC || + vendor == VENDOR_VOTI) + quirks |= QUIRK_POLLTIMEOUT; +} diff --git a/src/quirks.h b/src/quirks.h new file mode 100644 index 0000000..fb93fab --- /dev/null +++ b/src/quirks.h @@ -0,0 +1,17 @@ +#ifndef DFU_QUIRKS_H +#define DFU_QUIRKS_H + +#define VENDOR_OPENMOKO 0x1d50 /* Openmoko Freerunner / GTA02 */ +#define VENDOR_FIC 0x1457 /* Openmoko Freerunner / GTA02 */ +#define VENDOR_VOTI 0x16c0 /* OpenPCD Reader */ + +#define QUIRK_POLLTIMEOUT (1<<0) + +/* Fallback value, works for OpenMoko */ +#define DEFAULT_POLLTIMEOUT 5 + +extern int quirks; + +void set_quirks(unsigned long vendor, unsigned long product); + +#endif /* DFU_QUIRKS_H */ diff --git a/src/usb_dfu.h b/src/usb_dfu.h index 117d73c..1f9799b 100644 --- a/src/usb_dfu.h +++ b/src/usb_dfu.h @@ -8,6 +8,19 @@ * This ought to be compliant to the USB DFU Spec 1.0 as available from * http://www.usb.org/developers/devclass_docs/usbdfu10.pdf * + * 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 <sys/types.h> |