# Flash success but actually not

**URL:** <https://community.particle.io/t/flash-success-but-actually-not/27443>\
**Category:** Troubleshooting\
**Created:** [November 22, 2016, 1:03pm UTC](https://community.particle.io/t/flash-success-but-actually-not/27443 "2016-11-22T13:03:51Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhywu](https://avatars.discourse-cdn.com/v4/letter/z/6a8cbe/32.png) [@zhywu](https://community.particle.io/u/zhywu)\
**Post date:** [November 22, 2016, 1:03pm UTC](https://community.particle.io/t/flash-success-but-actually-not/27443/1 "2016-11-22T13:03:51Z")

</div>

I have an electron and an app compiled locally and flashed via serial port. The compilation finished successfully, however there is a problem with the flashing. After I issue the following command:

particle flash --serial firmware.bin

I get:

Flash success!

But the app is still functioning as it would with an older version. I did flash an older version into the electron a while ago. but suddenly I can’t flash any new build.

Anyone has this kind of things happened before?

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [November 22, 2016, 1:07pm UTC](https://community.particle.io/t/flash-success-but-actually-not/27443/2 "2016-11-22T13:07:56Z")

</div>

Try the more reliable

```nohighlight
particle flash --usb firmware.bin

```

in DFU Mode.

You can also do

```nohighlight
particle binary inspect firmware.bin

```

to see what kind of binary you’ve got there 😉

---

<div class="post-metadata">

**Author:** ![zhywu](https://avatars.discourse-cdn.com/v4/letter/z/6a8cbe/32.png) [@zhywu](https://community.particle.io/u/zhywu)\
**Post date:** [November 22, 2016, 1:17pm UTC](https://community.particle.io/t/flash-success-but-actually-not/27443/3 "2016-11-22T13:17:00Z")

</div>

Unfortunately the same, this is what I get from running the inspect:

firmware.bin  
CRC is ok (6fb6d674)  
Compiled for electron  
This is an application module number 1 at version 4  
It depends on a system module number 2 at version 21

Any problem with it?

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [November 22, 2016, 1:21pm UTC](https://community.particle.io/t/flash-success-but-actually-not/27443/4 "2016-11-22T13:21:50Z")

</div>

What was the output of `particle flash --usb firmware.bin`?  
What does `particle serial inspect` give you in Listening Mode?  
What does the RGB LED do after flashing?  
Can you try to flash another binary (e.g. simple blink)?

---

<div class="post-metadata">

**Author:** ![zhywu](https://avatars.discourse-cdn.com/v4/letter/z/6a8cbe/32.png) [@zhywu](https://community.particle.io/u/zhywu)\
**Post date:** [November 22, 2016, 1:47pm UTC](https://community.particle.io/t/flash-success-but-actually-not/27443/5 "2016-11-22T13:47:12Z")

</div>

I did an ota to push blink, the app did update. and then I did locally flash using:

particle flash --usb firmware.bin

output:

* * *

Found DFU device 2b04:d00a  
checking file /home/build/firmware.bin  
spawning dfu-util -d 2b04:d00a -a 0 -i 0 -s 0x08080000:leave -D /home/build/firmware.bin  
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](mailto:dfu-util@lists.gnumonks.org)

dfu-util: Invalid DFU suffix signature  
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!  
Opening DFU capable USB device…  
ID 2b04:d00a  
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 = 0x08080000, size = 5832  
Download [=========================] 100% 5832 bytes  
Download done.  
File downloaded successfully

Flash success!

* * *

The app did switch to my app, but it is an older version…

So I think there might be a problem with the build caching. I did run “make clean” and delete all the previous build files. Here is my script:

```
#!/bin/bash
echo
BUILD_TYPE="build"
FLASH_SERIAL="no"

if [[! -z "$1"]]; then
  BUILD_TYPE=$1
fi
if [["$2" == "flash"]]; then
  FLASH_SERIAL="yes"
fi
echo build type: $BUILD_TYPE
echo

BASE_DIR="$(cd "$(dirname "")"; pwd)"
APP_DIR="$BASE_DIR/src"
OUT_DIR="$BASE_DIR/build"
OUT_FIRMWARE_NAME="firmware"
echo output dir: $OUT_DIR
echo

CURRENT_DIR=$(pwd)
FIRMWARE_DIR=$BASE_DIR/firmware/main
echo change working dir to: $FIRMWARE_DIR
cd $FIRMWARE_DIR
echo

ERROR=0
continue_to() {
  if [["$ERROR" == "0"]]; then
    ($1)
    ERROR=$?
  fi
}
if [["$BUILD_TYPE" == "clean"]] || [["$BUILD_TYPE" == "rebuild"]]; then
  continue_to "make clean"
  continue_to "rm -rf $OUT_DIR/*"
fi
if [["$BUILD_TYPE" == "build"]] || [["$BUILD_TYPE" == "rebuild"]]; then
  continue_to "make PLATFORM=electron APPDIR=$APP_DIR TARGET_DIR=$OUT_DIR TARGET_NAME=$OUT_FIRMWARE_NAME"
fi
if [["$FLASH_SERIAL" == "yes"]]; then
  continue_to "particle flash --usb $OUT_DIR/$OUT_FIRMWARE_NAME.bin"
fi
echo change working back to: $CURRENT_DIR
if [["$ERROR" != "0"]]; then
  echo build error
fi
cd $CURRENT_DIR

```

I ran

```
./build.sh rebuild flash

```

Is there any command that I missed to clean up build?

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [November 22, 2016, 2:01pm UTC](https://community.particle.io/t/flash-success-but-actually-not/27443/6 "2016-11-22T14:01:12Z")

</div>

You should use the Particle `make` files.

```nohighlight
make clean

```

would be the cleanup command

---

<div class="post-metadata">

**Author:** ![zhywu](https://avatars.discourse-cdn.com/v4/letter/z/6a8cbe/32.png) [@zhywu](https://community.particle.io/u/zhywu)\
**Post date:** [November 22, 2016, 2:04pm UTC](https://community.particle.io/t/flash-success-but-actually-not/27443/7 "2016-11-22T14:04:01Z")

</div>

I did… the md5sum of the firmware.bin is always the same no matter how I change my code.

Sorry, I know I sound silly now

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [November 22, 2016, 2:14pm UTC](https://community.particle.io/t/flash-success-but-actually-not/27443/8 "2016-11-22T14:14:51Z")

</div>

Have read through the docu here?

> <https://github.com/particle-iot/firmware/blob/develop/docs/build.md>

  
You need to put your app code in a designated directory or reference the path correctly and you need to execute the command from the _correct_ folder too.

---

<div class="post-metadata">

**Author:** ![zhywu](https://avatars.discourse-cdn.com/v4/letter/z/6a8cbe/32.png) [@zhywu](https://community.particle.io/u/zhywu)\
**Post date:** [November 22, 2016, 2:25pm UTC](https://community.particle.io/t/flash-success-but-actually-not/27443/9 "2016-11-22T14:25:35Z")

</div>

I did read it.

It seems that the build.mk doesn’t detect source files outside of the folder. While I can do:

```
make APPDIR=/path/to/application/source [TARGET_DIR=/path/to/applications/output] [TARGET_FILE=basename]

```

to target my source files. But the “make clean” doesn’t delete the build/target folder under the firmware root folder probably doesn’t make sense.

After deleting the firware/build/target folder I can see something else now. My code builds but there is a make error. probably I should start another thread.
