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.
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
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)?
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
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?
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.
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.