[solved] "Fake" Firmware Download

I am having some issues that I have been trying to work through for the past two weeks and have not yet come to any conclusion. I built a BASIC led blink application that works perfectly on the Core. I took the syntax of that application and applied it to the application.cpp file for the Photon. I am able to do a successful local build and dfu download to the Photon with zero errors. The photon reboots but still does not work. I verified that the system-part1 and part2 as well as the user-part are downloading to the correct memory locations and i also verified that my application is being compiled as well. I seen somewhere on this form that there was a problem with a ā€œFakeā€ Firmware download where it would look like it downloaded but the firmware was rejected. That does not seem to be the problem as it does not do the quick green flash and another reboot after the firmware is downloaded. As of tonight i made sure i had the ā€œlatestā€ branch.

Are there any thoughts as to what I could possibly do?

Below is the build process of my app

C:\Particle\firmware\modules>make PLATFORM=photon all program-dfu
  C:/Particle/firmware/modules/photon/system-part1/makefile C:/Particle/firmware
/modules/photon/system-part2/makefile C:/Particle/firmware/modules/photon/user-p
art/makefile
make -C C:/Particle/firmware/modules/photon/system-part1/ all program-dfu  PLATF
ORM=photon
make[1]: Entering directory `C:/Particle/firmware/modules/photon/system-part1'
make -C ../../../communication
make[2]: Entering directory `C:/Particle/firmware/communication'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `C:/Particle/firmware/communication'
make -C ../../../hal-dynalib
make[2]: Entering directory `C:/Particle/firmware/hal-dynalib'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `C:/Particle/firmware/hal-dynalib'
make -C ../../../services
make[2]: Entering directory `C:/Particle/firmware/services'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `C:/Particle/firmware/services'
make -C ../../../platform
make[2]: Entering directory `C:/Particle/firmware/platform'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `C:/Particle/firmware/platform'
make -C ../../../hal
make[2]: Entering directory `C:/Particle/firmware/hal'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `C:/Particle/firmware/hal'
arm-none-eabi-size --format=berkeley ../../../build/target/system-part1/platform
-6-m/system-part1.elf
   text    data     bss     dec     hex filename
 249768     144     132  250044   3d0bc ../../../build/target/system-part1/platf
orm-6-m/system-part1.elf
Serial device PARTICLE_SERIAL_DEV : not available
Flashing using dfu:
dfu-util -d 0x2B04:0xD006 -a 0 -s 0x8020000 -D ../../../build/target/system-part
1/platform-6-m/system-part1.dfu
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

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 = 0x08020000, size = 249916
Download        [=========================] 100%       249916 bytes
Download done.
File downloaded successfully
make[1]: Leaving directory `C:/Particle/firmware/modules/photon/system-part1'
make -C C:/Particle/firmware/modules/photon/system-part2/ all program-dfu  PLATF
ORM=photon
make[1]: Entering directory `C:/Particle/firmware/modules/photon/system-part2'
make -C ../../../newlib_nano
make[2]: Entering directory `C:/Particle/firmware/newlib_nano'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `C:/Particle/firmware/newlib_nano'
make -C ../../../services-dynalib
make[2]: Entering directory `C:/Particle/firmware/services-dynalib'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `C:/Particle/firmware/services-dynalib'
make -C ../../../system
make[2]: Entering directory `C:/Particle/firmware/system'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `C:/Particle/firmware/system'
make -C ../../../wiring
make[2]: Entering directory `C:/Particle/firmware/wiring'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `C:/Particle/firmware/wiring'
make -C ../../../communication-dynalib
make[2]: Entering directory `C:/Particle/firmware/communication-dynalib'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `C:/Particle/firmware/communication-dynalib'
make -C ../../../hal
make[2]: Entering directory `C:/Particle/firmware/hal'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `C:/Particle/firmware/hal'
make -C ../../../platform
make[2]: Entering directory `C:/Particle/firmware/platform'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `C:/Particle/firmware/platform'
arm-none-eabi-size --format=berkeley ../../../build/target/system-part2/platform
-6-m/system-part2.elf
   text    data     bss     dec     hex filename
 179384    2044   38788  220216   35c38 ../../../build/target/system-part2/platf
orm-6-m/system-part2.elf
Serial device PARTICLE_SERIAL_DEV : not available
Flashing using dfu:
dfu-util -d 0x2B04:0xD006 -a 0 -s 0x8060000 -D ../../../build/target/system-part
2/platform-6-m/system-part2.dfu
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

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 = 0x08060000, size = 181428
Download        [=========================] 100%       181428 bytes
Download done.
File downloaded successfully
make[1]: Leaving directory `C:/Particle/firmware/modules/photon/system-part2'
make -C C:/Particle/firmware/modules/photon/user-part/ all program-dfu  PLATFORM
=photon
make[1]: Entering directory `C:/Particle/firmware/modules/photon/user-part'
make -C ../../../user
make[2]: Entering directory `C:/Particle/firmware/user'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `C:/Particle/firmware/user'
make -C ../../../hal-dynalib
make[2]: Entering directory `C:/Particle/firmware/hal-dynalib'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `C:/Particle/firmware/hal-dynalib'
make -C ../../../services-dynalib
make[2]: Entering directory `C:/Particle/firmware/services-dynalib'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `C:/Particle/firmware/services-dynalib'
make -C ../../../system-dynalib
make[2]: Entering directory `C:/Particle/firmware/system-dynalib'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `C:/Particle/firmware/system-dynalib'
make -C ../../../rt-dynalib
make[2]: Entering directory `C:/Particle/firmware/rt-dynalib'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `C:/Particle/firmware/rt-dynalib'
make -C ../../../wiring
make[2]: Entering directory `C:/Particle/firmware/wiring'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `C:/Particle/firmware/wiring'
make -C ../../../communication-dynalib
make[2]: Entering directory `C:/Particle/firmware/communication-dynalib'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `C:/Particle/firmware/communication-dynalib'
make -C ../../../platform
make[2]: Entering directory `C:/Particle/firmware/platform'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `C:/Particle/firmware/platform'
make -C ../../../wiring_globals
make[2]: Entering directory `C:/Particle/firmware/wiring_globals'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `C:/Particle/firmware/wiring_globals'
arm-none-eabi-size --format=berkeley ../../../build/target/user-part/platform-6-
m/user-part.elf
   text    data     bss     dec     hex filename
   2996      52     368    3416     d58 ../../../build/target/user-part/platform
-6-m/user-part.elf
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.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

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 = 3048
Download        [=========================] 100%         3048 bytes
Download done.
File downloaded successfully
make[1]: Leaving directory `C:/Particle/firmware/modules/photon/user-part'
make: Nothing to be done for `program-dfu'.

C:\Particle\firmware\modules>

In what subdirectory of C:\Particle\firmware\user\applications\ have you put your application.cpp?

Can you try

C:\Particle\firmware\modules>make clean all PLATFORM=photon APP=<yourSubDir> program-dfu

What version GCC are you running?


BTW: The issue you linked there was in connection with OTA flashing. Other similar issues were connected to a node.js problem not downloading the bin file correctly from the remote build farm, but mostly itā€™s in connection with actually building the wrong firmware (e.g. via Dev or local toolchain not selecting the correct project path - working on a file thatā€™s not part of the project being built and/or not saving/commiting changes).

@andrewhanisch can you share the output from putting your Photon in Listening Mode and typing s and v? Thanks!

the application.cpp file that i am working on is located here ā€œC:\Particle\firmware\user\srcā€

The GCC release notes are below. Looks to be version 4.9

Release notes for


GNU Tools for ARM Embedded Processors 4.9
- Q2 2015


This release includes the following items:

  • Bare metal EABI pre-built binaries for running on a Windows host
  • Bare metal EABI pre-built binaries for running on a Linux host
  • Bare metal EABI pre-built binaries for running on a Mac OS X host
  • Source code package (together with build scripts and instructions to setup
    build environment), composed of:

The photon does not show up as a serial device either. I followed the steps needed to install the driver via zadig. It is only showing up as a usb device ā€œPhoton with WiFiā€ I cannont get it to show up as a com port

The Zadig step will install DFU drivers. The Serial driver is separate and can be found as part of this tutorial: [Particle Official] Windows 10 Full CLI and DFU Setup

Ah ok. Sorry. Here is what I get.

Thanks for that! So it looks like you have the latest bootloader and system parts.

I always advise a clean build, especially if you are changing anything in the system filesā€¦ but itā€™s also a good idea so you donā€™t forget to clean build when you do change system files.

C:\Particle\firmware\modules>make clean all PLATFORM=photon -s program-dfu

What have you changed application.cpp to contain?

Try this and see if you get tinker to run:
C:\Particle\firmware\modules>make clean all PLATFORM=photon APP=tinker -s program-dfu

It would be advisable to put your own projects into

C:\Particle\firmware\user\applications\<yourProject>

and build using

C:\Particle\firmware\modules>make clean all PLATFORM=photon APP=<yourProject> -s program-dfu

Iā€™ve been putting my apps in a directory outside of the firmware directory so that they donā€™t clutter up my github untracked files view:

C:\Particle\fw-apps\myproject

and build usingā€¦
C:\Particle\firmware\modules> make clean all PLATFORM=photon APPDIR=C:\Particle\fw-apps\myproject -s program-dfu

1 Like

Thatā€™s the even better PRO advice :sunglasses:

1 Like

I will move my application source. Thatā€™s a good idea. I installed the com driver last night and did another compile and download and IT WORKS! Iā€™m honestly not sure why installing that driver would make any difference. I also added a 6 to the PRODUCT_ID that is at the top of the application.cpp file as well as I noticed that it was not populated.

The serial driver should not have changed anything. Perhaps you tried the clean build?

This is also not required, and only needed if you are trying to manage devices via the Particle Dashboard.

PRODUCT_ID in your user app is different than PLATFORM_ID in the make command, and only PLATFORM_ID=6 or PLATFORM=photon is required in the make command to compile firmware for the Photon.

1 Like

@BDub

Hi, I am trying to just build the firmware from https://github.com/spark/firmware/tree/photon_043, without making any local changes. I have installed all dependencies, and run (from modules/) ā€œmake clean all PLATFORM=photon APP=tinker program-dfuā€

The response is
make: Nothing to be done for clean'. make: Nothing to be done forallā€™.
make: Nothing to be done for `program-dfuā€™.

Iā€™ve also tried this with the tip of the firmware ā€˜developā€™ branch. Same symptom. (ā€œmake --versionā€ yields
"GNU Make 3.81"). Any help is appreciated! Thanks.

Any reason why you want to build for this ancient version?
We currently are at 0.5.2

make sure you are in the firmware/modules/ directory.

@BDub @ScruffR
I just did a fresh checkout of the release/0.6.0 version (15 commits behind ā€˜developā€™ tip). Same symptom as before. Yes, I am running the command from firmware/modules/ directory. I added ā€˜-nā€™ argument to ā€˜makeā€™, and I get the following:

C:\Users\steve\Google Drive\Documents\hacker\firmware\modules>make clean all PLATFORM=photon APP=tinker program-dfu -n
process_begin: CreateProcess(NULL, ā€œā€, ā€¦) failed.
process_begin: CreateProcess(NULL, ā€œā€, ā€¦) failed.
process_begin: CreateProcess(NULL, ā€œā€, ā€¦) failed.

make: Nothing to be done for clean'. make: Nothing to be done forallā€™.
make: Nothing to be done for `program-dfuā€™.

Any chance the space character in the file path is causing ā€˜makeā€™ some issues?
Thanks!

@BDub @ScruffR
Fixed! ā€˜makeā€™ doesnā€™t like spaces in the path, so I moved the code elsewhere.

Now the building begins, but fails after a couple minutes with the following output (ā€˜latestā€™ branch):
make clean all PLATFORM=photon APP=tinker program-dfu

/bin/sh: line 3: xxd: command not found
/bin/sh: line 3: test: 0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20280078563412: unary operator expected
make[1]: *** [ā€¦/build/module.mk:176: ā€¦/build/target/bootloader/platform-6-lto/bootloader.bin] Error 2
make[1]: Leaving directory '/cygdrive/c/Users/steve/Documents/firmware/bootloaderā€™
make: *** [build/recurse.mk:12: bootloader] Error 2

And on ā€˜developā€™ branch, I get:
make clean all PLATFORM=photon PARTICLE_DEVELOP=1 APP=tinker program-dfu

src/main.c: In function ā€˜mainā€™:
MCU/STM32F2xx/STM32_USB_OTG_Driver/src/usb_core.c:301:27: error: iteration 6 invokes undefined behavior [-Werror=aggressive-loop-optimizations]
MCU/STM32F2xx/STM32_USB_OTG_Driver/src/usb_core.c:299:3: note: containing loop
MCU/STM32F2xx/STM32_USB_OTG_Driver/src/usb_core.c:307:25: error: iteration 6 invokes undefined behavior [-Werror=aggressive-loop-optimizations]
MCU/STM32F2xx/STM32_USB_OTG_Driver/src/usb_core.c:305:3: note: containing loop
lto1.exe: all warnings being treated as errors
lto-wrapper: C:\Program Files (x86)\GNU Tools ARM Embedded\4.9 2015q3\bin\arm-none-eabi-g++.exe returned 1 exit status
c:/program files (x86)/gnu tools arm embedded/4.9 2015q3/bin/ā€¦/lib/gcc/arm-none-eabi/4.9.3/ā€¦/ā€¦/ā€¦/ā€¦/arm-none-eabi/bin/ld.exe: lto-wrapper failed
collect2.exe: error: ld returned 1 exit status
make[1]: *** [ā€¦/build/module.mk:219: ā€¦/build/target/bootloader/platform-6-lto/bootloader.elf] Error 1
make[1]: Leaving directory '/cygdrive/c/Users/steve/Documents/firmware/bootloaderā€™
make: *** [build/recurse.mk:12: bootloader] Error 2

Any help is appreciated! Thanks.

1 Like

Just for the record, in case anyone has the ā€œMCU/STM32F2xx/STM32_USB_OTG_Driver/src/usb_core.c:301:27: error: iteration 6 invokes undefined behavior [-Werror=aggressive-loop-optimizations]ā€ error. You might forgot change directory to ā€œmodulesā€ before running make.