Help with flushing a Photon with dfu-util

Hi,
I got the local toolchain and I think I got it all the way to produce a firmware file (.bin and .dfu).
I cannot make it to flush using dfu-util.

PS C:\Eli\Photon\firmware\build> **dfu-util -l**
dfu-util 0.8

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2014 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to dfu-util@lists.gnumonks.org

Found DFU: [2b04:d006] ver=0200, devnum=5, cfg=1, intf=0, alt=1, name="@DCT Flash   /0x00000000/01*016Kg", serial="00000000010C"
Found DFU: [2b04:d006] ver=0200, devnum=5, cfg=1, intf=0, alt=0, name="@Internal Flash   /0x08000000/03*016Ka,01*016Kg,01*064Kg,07*128Kg", serial="00000000010C"

Then my command line is: dfu-util -d 2b04:d006 -a 0 -s 0x08005000:leave -D core-firmware.dfu
Note that I changed the vendor ID to 2b04:d006, which is what dfu-util -l reports. the documentation and makefiles uses 1d50:607f, which I guess should be for the Core and not the Photon (right?).

The result:

Opening DFU capable USB device...
ID 2b04:d006
Run-time device DFU version 011a
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 4096
DfuSe interface name: "Internal Flash   "
Downloading to address = 0x08005000, size = 79560
Download        [                         ]   0%            **0 bytesPage at 0x08005000 is not writeable**

The Photon is flashing yellow. Any idea what the problem can be?
Thanks a lot,
Eli

You are flashing to the wrong address. Might want to consider particle-cli instead :slight_smile:

Ok, Thanks. What address should I use? more generally, where (or how) can I get a memory map for the Photon?
I will also look at particle-cli…

Eli

if you are building locally, add the goal program-dfu to the make command line and this will flash the binary to the correct address.

Hi,
I think I got it now. For the sake of others, and so you can comment if I got it wrong in the (long) way, here is what I found:

  • First, the instructions in the develop branch (https://github.com/spark/firmware/tree/develop) look like the one in Master, and do not talk specifically for Photon. Hence, I suggest you change the line:
    : git clone https://github.com/spark/firmware.git
    to
    : git clone -b develop https://github.com/spark/firmware.git

  • I am using Windows. It is not clear which shell do you recommend for development. In the last couple of nights, I tried Cigwin, PowerShell, MInGW (bash) and God forbid cmd.exe. Oh and git bash at some point (they were very long nights). Eventually I got it to work from MinGW bash, but I don’t know if that is the best option. Do you have a recommendation?

  • You should point out that “make” will assume you are working on Core. If your thing (like mine) is photon, then “make PLATFORM=photon”. Pretty sure there is a better way though… Anyway you should add a comment.

  • Finally, the last 5 hours were on chasing a problem in the file firmware/build/module.mk. You use the expression " if [ -s $@.pre_crc ];" which, apparently, it is a very bashy thing to do. Unless you do something strange, make will use /bin/sh, in which [-s filename] does not exist. The closest one is -e (file exists), or -r (file exist and readable). I changed it and it works. Please take a look and, if it make sense to you, change it.

By the way, if you prefer, I can do the changes. (fork and pull request). Please let me know. And also tell me if I got it right: the last time I fought makefiles was fifteen years ago…

Greetings,
Eli

Hi Eli,

These are all valid points, some of them already documented - I'll point out where the documentation is in case you missed it.

  • regarding the develop branch, this is very much a transient state where we expect to be working from master. Anyone going to master now will see this warning in the first paragraph:

Photon users: This firmware branch is not yet updated for the Photon; For the latest (0.4.0) firmware that is compatible with the Photon, please switch to the develop branch.

  • the choice of shell is MinGW on Windows, as mentioned in the list of dependencies, although we can make that dependency more prominent if that makes it clearer.

  • You're correct that the core is the default build, and is that way for backwards compatibility since there are many people still building for the Core. The paragraph that follows the description of using make to build in the frontpage readme.md is a pointer for building other platforms:

The makefile documentation describes the build options supported and how to target platforms other than the Core.

  • setting PLATFORM=photon is the correct approach. You can also define PLATFORM as an environment variable so that it's always used without having to be specified each time.

  • Please let me know what the issue was you were fixing in the makefile so I can try to reproduce it. I'm surprised you're seeing a problem with that particular line since it's been tested on Windows, OS X and linux, although your local setup may be different from ours if you were uncertain about which shell to use.

I hope this helps and that the pointers to our online resources save you time in future.

Cheers,
mat.

1 Like