Photon won't *finish* flash with dfu-util

Just received my Photon, claimed it via Android, its flashable via the web IDE.

Local build - well, release/0.4.4 , develop and latest branches won’t flash. If I cd into firmware/modules and run “make clean all program-dfu PLATFORM=photon” it seems to flash bits of the firmware but then falls over towards the end:

arm-none-eabi-objcopy -O ihex ../../../build/target/user-part/platform-6-m/user-part.elf ../../../build/target/user-part/platform-6-m/user-part.hex
arm-none-eabi-size --format=berkeley ../../../build/target/user-part/platform-6-m/user-part.elf
   text       data        bss        dec        hex    filename
   4636        104        332       5072       13d0    ../../../build/target/user-part/platform-6-m/user-part.elf
arm-none-eabi-objdump -h -S ../../../build/target/user-part/platform-6-m/user-part.elf > ../../../build/target/user-part/platform-6-m/user-part.lst
dfu-suffix -v 2B04 -p D006 -a ../../../build/target/user-part/platform-6-m/user-part.dfu
dfu-suffix (dfu-util) 0.7

Copyright 2011-2012 Stefan Schmidt, 2013-2014 Tormod Volden
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to dfu-util@lists.gnumonks.org

Suffix successfully added to file
Serial device PARTICLE_SERIAL_DEV : not available
Flashing using dfu:
dfu-util -d 0x2B04:0xD006 -a 0 -s 0x80A0000:leave -D ../../../build/target/user-part/platform-6-m/user-part.dfu
dfu-util 0.7

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

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 = 0x080a0000, size = 4740
Download    [=========================] 100%         4740 bytes
Download done.
File downloaded successfully
dfu-util: Error during download get_status
../../../build/module.mk:64: recipe for target 'program-dfu' failed
make[1]: *** [program-dfu] Error 74
make[1]: Leaving directory '/data3/useful_software/arduino/sparkcore/firmware/modules/photon/user-part'
makefile:84: recipe for target '/data3/useful_software/arduino/sparkcore/firmware/modules/photon/user-part/makefile' failed
make: *** [/data3/useful_software/arduino/sparkcore/firmware/modules/photon/user-part/makefile] Error 2

btw its dfu-util 0.8, i just didn’t change the version string. oh and auto-dfu mode (PARTICLE_SERIAL_DEV) doesn’t work on Linux due to an invalid -f flag to stty, did you mean -F (capital)?:

man stty
....
       -F, --file=DEVICE
              open and use the specified DEVICE instead of stdin

my spark core flashes fine.

Despite the error, the download has actually happened just fine.

You know, this is a long standing issue, present on the Core and the Photon. I was told it’s a bug in dfu-util so didn’t think to investigate further, but having seen how much confusion this makes, and that it continually crops up here on the forum, I gave it some time today.

I can affirm an issue with dfu-util, or at least some lack of clarity in the DFU protocol spec. But
I’m glad to say I managed to fix it! :tada: The fix will be released as part of 0.4.5.

For those interested, the details are https://github.com/spark/firmware/issues/599.

2 Likes

@mdma, sounds great! But an interesting question: How is a fix for the bootloader applied to the Photon? The procedure with locking/unlocking etc. seems to be not for all people…

On the photon, the latest bootloader is included in the system firmware, so it’s updated automatically.

Okay, that’s great and what I hoped for. But I just flashed the newest version including the fix and still get the error. That’s why I asked.

How did you flash the newest version? From where?

I used the 0.4.5.rc2 branch and flashed it as usual from within the modules directory.

yeah i’m still getting an error with release/v0.4.5-rc.2

File downloaded successfully
dfu-util: Error during download get_status
../../../build/module.mk:69: recipe for target 'program-dfu' failed
make[1]: *** [program-dfu] Error 74
make[1]: Leaving directory '/data3/useful_software/arduino/sparkcore/firmware/modules/photon/user-part'
makefile:81: recipe for target '/data3/useful_software/arduino/sparkcore/firmware/modules/photon/user-part/makefile' failed
make: *** [/data3/useful_software/arduino/sparkcore/firmware/modules/photon/user-part/makefile] Error 2

it does seem to be flashing though, as it had blink, its now got tinker

did you update your system modules? You’ll also have to flash the bootloader manually since I’m not increasing the IDs, since we only do this on each actual release. (So if you’ve already flashed system modules from v0.4.5-rc.1 then the bootloader won’t update.)

I updated the whole branch, did a clean and then flashed it. I switched to the 0.4.5-rc.2 from the develop branch without going through rc1. Not sure if that uses the same ID…

same here. straight from 0.4.4 release to 0.4.5-rc2 “make clean all”, develop gives the same result

sorry to be a pain, but i noticed this issue got closed and merged into latest, but its still not fixed for me (and @Stevie) even though it flashes ok, it still errors.

Yes and know :smile:. Some of my Photons still have the problem, some don’t. Those I did not touch for a while do not have the problem anymore after flashing the 0.4.5 release. I guess @mdma is right that for those which still exhibit the problem a manual update of the bootloader would be required - but I have no idea how to do that. The procedure in the docs is - apparently - for the Core and not the Photon. On the other hand, it is really not too important. My assumption is that starting 0.4.6 the problem would be gone for good.

weird!

i’ve updated via “make clean all program-dfu PLATFORM=photon” from the latest branch which i assume gets the new bootloader now its been merged, and also via the web ide which now lists 0.4.5, and via “particle update” but still get the dfu error.

You need to manually flash the bootloader using jtag if you’ve already build from a relatively recent version of develop. Flashing the firmware alone wont do it since your bootloader will already have the same version ID (it was bumped a couple of weeks ago.)

This is why we try to discourage anyone without the full developer setup (including jtag) from using the develop branch, since we are not incrementing version IDs for each change, but for each release.

so without a jtag the fix is to leave it alone until 0.4.6 gets a version bump?

yes. and build from latest rather than develop. The warning is there for a reason! :smile:

well yeah, i can’t remember if i ever actually flashed with develop, i must have i guess.

any guides on how to manually flash the bootloader via jtag, i may just buy an st-link v2, although the pin names on that don’t seem to match the ones in the photon datasheet

https://docs.particle.io/datasheets/photon-datasheet/#jtag

found it:

or maybe I can change the code so that it flashes the bootloader if it’s the same version but different? At least that helps solve this issue. But this one will go in develop… :wink:

Well, I do have a JTAG programmer. But I just upgraded the Photon with the intermediate version to the official version without using it. So it is possible, if not convenient.