Instructions how to build dfu-util on OS X

You probably figured it out, but just to clear this up: The upload command generates a raw memory dump from the device, which probably got written over your original dfu file. BTW, the latest git version should refuse to overwrite an existing file, but I am not sure what you have. So if you tried later to download this file it would have no dfu or dfuse header information and you will see a “signature” error.

When you specify an address for downloading, you force it into “raw” download mode instead of dfuse file mode. So if you in this case use a dfu file, the dfu/dfuse header information in the file will be copied over as well, which will break. The “real” firmware code will be shifted and all addresses will be wrong.

For future versions, I think dfu-util should be able to detect whether it is talking to a dfuse device, and then switch automatically to dfuse communication mode and expect a dfuse file (unless an advanced user wants to download a raw binary file to it). So –dfuse default will not be needed, and –dfuse address might be renamed to avoid confusion.

PS. I can tell you that you are not the first one to get confused by upload/download on microcontrollers :slight_smile:

Nice that you managed to find the issue =)

Yeah I had figured out that part, but I am still losing.
delete all copies of 3.32 redownload the commands seem to work after several tries.

Unfortunately Lib splash screen shows up with mangled App version, and runtime is a grayed line on the right with 3 tiny yellow dots, and one larger yellow blotch on the 2 chat position from the bottom. no graphing no characters, no lines. other than the grid lines. Also about the same height from the bottom is a grayed line the size of a text line that goes from left to almost the right. I have reloaded both several times and see the same result.

DSO%20BenF%20Firmware%20v3 rich$ dfu-util --dfuse default -d 0x0483:0xdf11 -a 0 -D DSO\ BenF\ APP\ v3.32.dfu
dfu-util - © 2007-2008 by OpenMoko Inc.
© 2010 Tormod Volden (experimental DfuSe support)
This program is Free Software and has ABSOLUTELY NO WARRANTY

dfu-util does currently only support DFU version 1.0

Opening USB Device 0x0483:0xdf11…
Claiming USB DFU Runtime Interface…
Determining device status: state = dfuDNLOAD-IDLE, status = 0
WARNING: Runtime device already in DFU state ?!?
Found Runtime: [0x0483:0xdf11] devnum=4, cfg=0, intf=0, alt=0, name="@Internal Flash /0x08000000/12001Ka,116001Kg"
Claiming USB DFU Interface…
Setting Alternate Setting #0
Determining device status: state = dfuDNLOAD-IDLE, status = 0
aborting previous incomplete transfer
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
Transfer Size = 0x0400
file contains 1 DFU images
parsing DFU image 1
image for alternate setting 0, (2 elements, total size = 28363)
parsing element 1, address = 0x0800c000, size = 25850
Erasing page at address 0x0800c000, 1k page starting at 0x0800c000
Setting address pointer to 0x0800c000
Wrote 1024 bytes at 0x0800c000
Erasing page at address 0x0800c400, 1k page starting at 0x0800c400
Setting address pointer to 0x0800c400
Wrote 1024 bytes at 0x0800c400
Erasing page at address 0x0800c800, 1k page starting at 0x0800c800
Setting address pointer to 0x0800c800
Wrote 1024 bytes at 0x0800c800
Erasing page at address 0x0800cc00, 1k page starting at 0x0800cc00
Setting address pointer to 0x0800cc00
Wrote 1024 bytes at 0x0800cc00
Erasing page at address 0x0800d000, 1k page starting at 0x0800d000
Setting address pointer to 0x0800d000
Wrote 1024 bytes at 0x0800d000
Erasing page at address 0x0800d400, 1k page starting at 0x0800d400
Setting address pointer to 0x0800d400
Wrote 1024 bytes at 0x0800d400
Erasing page at address 0x0800d800, 1k page starting at 0x0800d800
Setting address pointer to 0x0800d800
Wrote 1024 bytes at 0x0800d800
Erasing page at address 0x0800dc00, 1k page starting at 0x0800dc00
Setting address pointer to 0x0800dc00
Wrote 1024 bytes at 0x0800dc00
Erasing page at address 0x0800e000, 1k page starting at 0x0800e000
Setting address pointer to 0x0800e000
Wrote 1024 bytes at 0x0800e000
Erasing page at address 0x0800e400, 1k page starting at 0x0800e400
Setting address pointer to 0x0800e400
Wrote 1024 bytes at 0x0800e400
Erasing page at address 0x0800e800, 1k page starting at 0x0800e800
Setting address pointer to 0x0800e800
Wrote 1024 bytes at 0x0800e800
Erasing page at address 0x0800ec00, 1k page starting at 0x0800ec00
Setting address pointer to 0x0800ec00
Wrote 1024 bytes at 0x0800ec00
Erasing page at address 0x0800f000, 1k page starting at 0x0800f000
Setting address pointer to 0x0800f000
Wrote 1024 bytes at 0x0800f000
Erasing page at address 0x0800f400, 1k page starting at 0x0800f400
Setting address pointer to 0x0800f400
Wrote 1024 bytes at 0x0800f400
Erasing page at address 0x0800f800, 1k page starting at 0x0800f800
Setting address pointer to 0x0800f800
Wrote 1024 bytes at 0x0800f800
Erasing page at address 0x0800fc00, 1k page starting at 0x0800fc00
Setting address pointer to 0x0800fc00
Wrote 1024 bytes at 0x0800fc00
Erasing page at address 0x08010000, 1k page starting at 0x08010000
Setting address pointer to 0x08010000
Wrote 1024 bytes at 0x08010000
Erasing page at address 0x08010400, 1k page starting at 0x08010400
Setting address pointer to 0x08010400
Wrote 1024 bytes at 0x08010400
Erasing page at address 0x08010800, 1k page starting at 0x08010800
Setting address pointer to 0x08010800
Wrote 1024 bytes at 0x08010800
Erasing page at address 0x08010c00, 1k page starting at 0x08010c00
Setting address pointer to 0x08010c00
Wrote 1024 bytes at 0x08010c00
Erasing page at address 0x08011000, 1k page starting at 0x08011000
Setting address pointer to 0x08011000
Wrote 1024 bytes at 0x08011000
Erasing page at address 0x08011400, 1k page starting at 0x08011400
Setting address pointer to 0x08011400
Wrote 1024 bytes at 0x08011400
Erasing page at address 0x08011800, 1k page starting at 0x08011800
Setting address pointer to 0x08011800
Wrote 1024 bytes at 0x08011800
Erasing page at address 0x08011c00, 1k page starting at 0x08011c00
Setting address pointer to 0x08011c00
Wrote 1024 bytes at 0x08011c00
Erasing page at address 0x08012000, 1k page starting at 0x08012000
Setting address pointer to 0x08012000
Wrote 1024 bytes at 0x08012000
Erasing page at address 0x08012400, 1k page starting at 0x08012400
Setting address pointer to 0x08012400
Wrote 250 bytes at 0x08012400
parsing element 2, address = 0x080124fc, size = 2497
Setting address pointer to 0x080124fc
Wrote 1024 bytes at 0x080124fc
Erasing page at address 0x080128fc, 1k page starting at 0x08012800
Setting address pointer to 0x080128fc
Wrote 1024 bytes at 0x080128fc
Erasing page at address 0x08012cfc, 1k page starting at 0x08012c00
Setting address pointer to 0x08012cfc
Wrote 449 bytes at 0x08012cfc
DSO%20BenF%20Firmware%20v3 rich$

DSO%20BenF%20Firmware%20v3 rich$ dfu-util --dfuse default -d 0x0483:0xdf11 -a 0 -D DSO\ BenF\ LIB\ v3.30.dfu
dfu-util - © 2007-2008 by OpenMoko Inc.
© 2010 Tormod Volden (experimental DfuSe support)
This program is Free Software and has ABSOLUTELY NO WARRANTY

dfu-util does currently only support DFU version 1.0

Opening USB Device 0x0483:0xdf11…
Claiming USB DFU Runtime Interface…
Determining device status: state = dfuIDLE, status = 0
WARNING: Runtime device already in DFU state ?!?
Found Runtime: [0x0483:0xdf11] devnum=4, cfg=0, intf=0, alt=0, name="@Internal Flash /0x08000000/12001Ka,116001Kg"
Claiming USB DFU Interface…
Setting Alternate Setting #0
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
Transfer Size = 0x0400
file contains 1 DFU images
parsing DFU image 1
image for alternate setting 0, (1 elements, total size = 13740)
parsing element 1, address = 0x08004000, size = 13732
Erasing page at address 0x08004000, 1k page starting at 0x08004000
Setting address pointer to 0x08004000
Wrote 1024 bytes at 0x08004000
Erasing page at address 0x08004400, 1k page starting at 0x08004400
Setting address pointer to 0x08004400
Wrote 1024 bytes at 0x08004400
Erasing page at address 0x08004800, 1k page starting at 0x08004800
Setting address pointer to 0x08004800
Wrote 1024 bytes at 0x08004800
Erasing page at address 0x08004c00, 1k page starting at 0x08004c00
Setting address pointer to 0x08004c00
Wrote 1024 bytes at 0x08004c00
Erasing page at address 0x08005000, 1k page starting at 0x08005000
Setting address pointer to 0x08005000
Wrote 1024 bytes at 0x08005000
Erasing page at address 0x08005400, 1k page starting at 0x08005400
Setting address pointer to 0x08005400
Wrote 1024 bytes at 0x08005400
Erasing page at address 0x08005800, 1k page starting at 0x08005800
Setting address pointer to 0x08005800
Wrote 1024 bytes at 0x08005800
Erasing page at address 0x08005c00, 1k page starting at 0x08005c00
Setting address pointer to 0x08005c00
Wrote 1024 bytes at 0x08005c00
Erasing page at address 0x08006000, 1k page starting at 0x08006000
Setting address pointer to 0x08006000
Wrote 1024 bytes at 0x08006000
Erasing page at address 0x08006400, 1k page starting at 0x08006400
Setting address pointer to 0x08006400
Wrote 1024 bytes at 0x08006400
Erasing page at address 0x08006800, 1k page starting at 0x08006800
Setting address pointer to 0x08006800
Wrote 1024 bytes at 0x08006800
Erasing page at address 0x08006c00, 1k page starting at 0x08006c00
Setting address pointer to 0x08006c00
Wrote 1024 bytes at 0x08006c00
Erasing page at address 0x08007000, 1k page starting at 0x08007000
Setting address pointer to 0x08007000
Wrote 1024 bytes at 0x08007000
Erasing page at address 0x08007400, 1k page starting at 0x08007400
Setting address pointer to 0x08007400
Wrote 420 bytes at 0x08007400
DSO%20BenF%20Firmware%20v3 rich$

Rich, I don’t think you have the latest git version. “git log -1” should list “commit e8e91cb4af4565f5dd1d1a154f21e8a9bd519ce0”.

This has now happened, and I have updated garden.seeedstudio.com/index.php?title=Dfu-util with the new syntax. As you can see there, the new code uses libusb 1.0. It would be nice if someone on Mac OS X can confirm that the build instructions are correct.

BTW, this code will soon go into the official dfu-tool version 0.5, so that it will be available through normal distributions.

I’ll give it a shot as soon as my Mac comes back from the repairman. Not even a Apple laptop survives a cup of tea poured over it :blush:

Firstly the Java Developer Package doesn’t seem to be needed any more on Lion (10.7).

Also I had to install these packages:

sudo port install libusb-devel libusb-compat git-core

Either the project still uses the old libusb api or the detection script doesn’t do the right thing.

Other than that everything works fine, but I did get this message at the end of flashing:

[code]$ dfu-util -a 0 -D ~/Hack/DSO\ NANO/DSO\ BenF\ Firmware\ v3.62/DSO\ BenF\ APP\ v3.62.dfu
dfu-util - © 2005-2008 by Weston Schmidt, Harald Welte and OpenMoko Inc.
© 2010 Tormod Volden (experimental DfuSe support)
This program is Free Software and has ABSOLUTELY NO WARRANTY

dfu-util does currently only support DFU version 1.0

Opening DFU USB device… ID 0483:df11
Claiming USB DFU Runtime Interface…
Determining device status: state = dfuIDLE, status = 0
WARNING: Runtime device already in DFU state ?!?
Found Runtime: [0x0483:0xdf11] devnum=4, cfg=0, intf=0, alt=0, name="@Internal Flash /0x08000000/12001Ka,116001Kg"
Claiming USB DFU Interface…
Setting Alternate Setting #0
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
Device returned transfer size 1024
bytes_per_hash=705
Copying data from PC to DFU device
Starting download: [##################################################] finished!
state(7) = dfuMANIFEST, status(0) = No error condition is present
unable to read DFU status[/code]

Thanks for testing!

No, this must be wrong. The new code uses libusb-1.0 and can not use the old API and the libusb-compat library from macports is not needed. Please make sure you check out the dfuse-libusb-1.0 branch and that it is up to date.

Right, I forgot to checkout the correct branch :blush:

However I now get compiler errors:

$ ./configure --libdir=/opt/local/lib --includedir=/opt/local/include checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... m4/install-sh -c -d checking for gawk... no checking for mawk... no checking for nawk... no checking for awk... awk checking whether make sets $(MAKE)... yes checking whether to enable maintainer-specific portions of Makefiles... no checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking for style of include used by make... GNU checking dependency style of gcc... gcc3 checking for pkg-config... /opt/local/bin/pkg-config checking pkg-config is at least version 0.9.0... yes checking for USB... yes checking for usb_path2devnum in -lusbpath... no checking how to run the C preprocessor... gcc -E checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking for stdlib.h... (cached) yes checking for string.h... (cached) yes checking stdio.h usability... yes checking stdio.h presence... yes checking for stdio.h... yes checking usbpath.h usability... no checking usbpath.h presence... no checking for usbpath.h... no checking for an ANSI C-conforming const... yes checking for size_t... yes checking for stdlib.h... (cached) yes checking for GNU libc compatible malloc... yes checking for working memcmp... yes checking for memset... yes configure: creating ./config.status config.status: creating Makefile config.status: creating src/Makefile config.status: creating doc/Makefile config.status: creating config.h config.status: executing depfiles commands $ make make all-recursive Making all in src CC main.o CC dfu_load.o CC dfuse.o CC dfuse_mem.o dfuse_mem.c:22:20: error: malloc.h: No such file or directory dfuse_mem.c: In function ‘add_segment’: dfuse_mem.c:33: warning: implicit declaration of function ‘malloc’ dfuse_mem.c:33: warning: incompatible implicit declaration of built-in function ‘malloc’ dfuse_mem.c: In function ‘free_segment_list’: dfuse_mem.c:72: warning: implicit declaration of function ‘free’ dfuse_mem.c: In function ‘parse_memory_layout’: dfuse_mem.c:95: warning: unknown conversion type character ‘m’ in format dfuse_mem.c:95: warning: format ‘%n’ expects type ‘int *’, but argument 3 has type ‘char **’ dfuse_mem.c:95: warning: too many arguments for format dfuse_mem.c:95: warning: unknown conversion type character ‘m’ in format dfuse_mem.c:95: warning: format ‘%n’ expects type ‘int *’, but argument 3 has type ‘char **’ dfuse_mem.c:95: warning: too many arguments for format dfuse_mem.c:111: warning: unknown conversion type character ‘m’ in format dfuse_mem.c:111: warning: format ‘%n’ expects type ‘int *’, but argument 6 has type ‘char **’ dfuse_mem.c:111: warning: too many arguments for format dfuse_mem.c:111: warning: unknown conversion type character ‘m’ in format dfuse_mem.c:111: warning: format ‘%n’ expects type ‘int *’, but argument 6 has type ‘char **’ dfuse_mem.c:111: warning: too many arguments for format make[2]: *** [dfuse_mem.o] Error 1 make[1]: *** [all-recursive] Error 1 make: *** [all] Error 2

Fixing the malloc issue was easy, just change the included headers to:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include “dfuse_mem.h”

But the sscanf issue is harder to solve since it doesn’t support m as a conversion specifier.

So you replaced malloc.h by stdlib.h. I will fix that, it is probably the correct way on Linux as well.
EDIT: And the delimiters of course, fixed, thanks.

Can you try using the “a” modifier where I had used the “m” modifier?

Thanks a lot for investigating these issues!

PS: According to the scanf man page, “a” and “m” are GNU C library extensions, but “m” should be included in POSIX.1. But until Mac OS X catches up with POSIX.1 we might have to allocate a buffer ourselves.

Huh, a means floating point. I think it is best to change this to a strchr call and then a manual malloc.

“a[” is different from “a” :slight_smile: Anyway, I have changed it to simple “[” and manual allocation. Please find the fix in git.

Sorry, forgot to post that it works just hunky-dory!

dfu-util 0.4

(C) 2005-2008 by Weston Schmidt, Harald Welte and OpenMoko Inc.
(C) 2010-2011 Tormod Volden (DfuSe support)
This program is Free Software and has ABSOLUTELY NO WARRANTY

dfu-util does currently only support DFU version 1.0

Opening DFU USB device... ID 0483:df11
Run-time device DFU version 011a
Claiming USB DFU Runtime Interface...
Determining device status: state = dfuERROR, status = 10
dfuERROR, clearing status
Opening USB Device...
Found Runtime: [0483:df11] devnum=0, cfg=1, intf=0, alt=0, name="@Internal Flash  /0x08000000/12*001Ka,116*001Kg"
Claiming USB DFU Interface...
Setting Alternate Setting #0 ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 011a
Device returned transfer size 1024
Dfu suffix version 11a
Warning: File product ID 0000 does not match device df11
DfuSe interface name: "Internal Flash  "
file contains 1 DFU images
parsing DFU image 1
image for alternate setting 0, (2 elements, total size = 34967)
parsing element 1, address = 0x0800c000, size = 32330
parsing element 2, address = 0x08013e4c, size = 2621
done parsing DfuSe file

Greetings,

Trying to install BenF from OSX, followed the instructions from the first post on this page. Worked fine through:

./autogen.sh
./configure --libdir=/opt/local/lib --includedir=/opt/local/include
make

When I tried to make, I got:
make: *** No targets specified and no makefile found. Stop.

Here’s a listing of the directory:

Base:dfuse-dfu-util martin$ ls
COPYING TODO configure.ac
ChangeLog aclocal.m4 doc
DEVICES.txt autogen.sh m4
Makefile.am autom4te.cache src
Makefile.in config.h.in www
README config.log
SPEC-differences.txt configure

I loaded the apple XCode package and the command line toolkits before installing macports.

I’m not a total unix/linux newbie, but by no means a veteran. Any help appreciated. Or would it just be easier to find someone with a PC and use their machine for the firmware upgrade?

Regards,
Martin

Try the instructions here:
seeedstudio.com/wiki/index.p … e=Dfu-util
Verified working just now.

This thread is obsolete now that the code changes have ben upstreamed.

Tomwid,

I tried the instructions there, followed them as close to the letter as I could. One small issue, on the:

sudo port install libusb-devel
I got a message saying “Please do not install this port as it has been replaced by libusb.”

So I installed the libusb port (as well as git-core), and everything seemed to go fine until the make command. Here’s the last part of my output:
(whitespace added after paste here for ease of reading.)

Base:dfu-util martin$ ./configure --libdir=/opt/local/lib --includedir=/opt/local/include
checking for a BSD-compatible install… /usr/bin/install -c
checking whether build environment is sane… yes
checking for a thread-safe mkdir -p… m4/install-sh -c -d
checking for gawk… no
checking for mawk… no
checking for nawk… no
checking for awk… awk
checking whether make sets $(MAKE)… yes
checking whether to enable maintainer-specific portions of Makefiles… no
checking for gcc… gcc
checking for C compiler default output file name… a.out
checking whether the C compiler works… yes
checking whether we are cross compiling… no
checking for suffix of executables…
checking for suffix of object files… o
checking whether we are using the GNU C compiler… yes
checking whether gcc accepts -g… yes
checking for gcc option to accept ISO C89… none needed
checking for style of include used by make… GNU
checking dependency style of gcc… gcc3
./configure: line 3332: syntax error near unexpected token USB,' ./configure: line 3332: PKG_CHECK_MODULES(USB, libusb-1.0 >= 1.0.0,’

Base:dfu-util martin$ ls -1
COPYING
ChangeLog
DEVICES.txt
Makefile.am
Makefile.in
README
SPEC-differences.txt
TODO
aclocal.m4
autogen.sh
autom4te.cache
config.h.in
config.log
configure
configure.ac
device-logs
doc
m4
src
www

Base:dfu-util martin$ make
make: *** No targets specified and no makefile found. Stop.
Base:dfu-util martin$

I don’t know how to proceed - my suspicion is that it’s some small fiddly bit I need to set/unset properly, but I don’t know where to start looking. Perhaps one of you local experts can either tell me what’s up, or ask me for output/directories/etc., to figure out what the problem is.

Regards,
Martin

Are you using the latest code from cgit.openezx.org/dfu-util/ ? The last commit is a fix for libusb detection on Mac OS X. It was obviously not needed some time ago, I am not sure what has changed. If it breaks for you /with/ this change, try without (use the 0.6 source instead).

Tormod,

Not sure how to answer that question. I followed the instructions at <http://www.seeedstudio.com/wiki/index.p … e=Dfu-util>, including the line:

git clone git://git.openezx.org/dfu-util

I assume this would call up the latest version. How would I modify the git command to get the 0.6 source? The only differences from the seedstudio wiki were that libusb-devel seems to have been replaced by libusb. Don’t know if this would break anything.

I’m gonna try this all on my laptop instead of my older desktop machine. Perhaps that will help. If not, perhaps we should take this discussion to e-mail (unless you all think having it here might help someone else down the line.)

Regards,
Martin

In your existing git repository, run “git checkout v0.6”. To get back to latest git again, run “git checkout master”.

Please report back here. You are most probably not the only one who will experience this issue :slight_smile: