Showing posts with label Particle. Show all posts
Showing posts with label Particle. Show all posts

Friday, 19 January 2018

How to Downgrade Particle System Firmware


Particle sometimes rushes to release their newest system firmware but your applications could stop working or some unexpected things happen for some reason.
So here is how to downgrade the system firmware.

Step 1: check the current system fw on the device
- connect your device to your computer with a USB cable
- press the SETUP button for 3 seconds to enter setup mode.
- using a serial monitor such as PuTTY (Windows) or screen (linux/OSX), to connect to the device
press 'v' - this prints the "system version, e.g. 0.6.3".

I'm using Linux so my command is:
                                screen /dev/ttyACM0

Step 2: download the target system fw
Say I want go back to 0.6.3, I can down load the system-part1 and part2 .bin file from this link.
https://github.com/particle-iot/firmware/releases/tag/v0.6.3

Step 3: flashing
particle flash YOUR_DEVICE_NAME system-part1-0.6.3-p1.bin particle flash YOUR_DEVICE_NAME system-part2-0.6.3-p1.bin particle flash YOUR_DEVICE_NAME tinker (NOT optional)

NOTE THAT THE LAST STEP, FLASHING TINKER, IS NOT OPTIONAL.

I think the device might have to handshake with the particle cloud at some point. If you don't do this, you can check the system fw with step 1, and you might see it's still showing you the old version number.


ref:
https://community.particle.io/t/determining-the-version-of-system-firmware-on-a-photon-p1/13324
https://github.com/particle-iot/firmware/releases/tag/v0.6.3
https://community.particle.io/t/particle-firmware-updates-thread/14378/25

Tuesday, 19 September 2017

Particle Installation Troubleshooting

If you see such things like:

node-pre-gyp ERR! Pre-built binaries not found for serialport@4.0.7 and node@4.2.1 (node-v46 ABI) (falling back to source compile with node-gyp)
gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/4.2.1"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/particle-cli/node_modules/serialport/.node-gyp"
make: Entering directory '/usr/local/lib/node_modules/particle-cli/node_modules/serialport/build'
make: *** No rule to make target '../.node-gyp/4.2.1/include/node/common.gypi', needed by 'Makefile'. Stop.
make: Leaving directory '/usr/local/lib/node_modules/particle-cli/node_modules/serialport/build'
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:270:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess.handle.onexit (internal/childprocess.js:200:12)
gyp ERR! System Linux 4.9.24+
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/usr/local/lib/node_modules/particle-cli/node_modules/serialport/build/Release/serialport.node" "--module_name=serialport" "--module_path=/usr/local/lib/node_modules/particle-cli/node_modules/serialport/build/Release"
gyp ERR! cwd /usr/local/lib/node_modules/particle-cli/node_modules/serialport
gyp ERR! node -v v4.2.1
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/usr/local/lib/node_modules/particle-cli/node_modules/serialport/build/Release/serialport.node --module_name=serialport --module_path=/usr/local/lib/node_modules/particle-cli/node_modules/serialport/build/Release' (1)
node-pre-gyp ERR! stack at ChildProcess. (/usr/local/lib/node_modules/particle-cli/node_modules/serialport/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at emitTwo (events.js:87:13)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:172:7)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:818:16)
node-pre-gyp ERR! stack at Process.ChildProcess.handle.onexit (internal/childprocess.js:211:5)
node-pre-gyp ERR! System Linux 4.9.24+
node-pre-gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/particle-cli/node_modules/serialport/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /usr/local/lib/node_modules/particle-cli/node_modules/serialport
node-pre-gyp ERR! node -v v4.2.1
node-pre-gyp ERR! node-pre-gyp -v v0.6.32
node-pre-gyp ERR! not ok
Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/usr/local/lib/node_modules/particle-cli/node_modules/serialport/build/Release/serialport.node --module_name=serialport --module_path=/usr/local/lib/node_modules/particle-cli/node_modules/serialport/build/Release' (1)
npm ERR! Linux 4.9.24+
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "particle-cli"
npm ERR! node v4.2.1
npm ERR! npm v2.14.7
npm ERR! code ELIFECYCLE
npm ERR! serialport@4.0.7 install: node-pre-gyp install --fallback-to-build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the serialport@4.0.7 install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! This is most likely a problem with the serialport package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-pre-gyp install --fallback-to-build
npm ERR! You can get their info via:
npm ERR! npm owner ls serialport
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/pi/npm-debug.log


This is a known but relatively undocumented bug with the particle-cli installation process. The following should work:

           $ sudo npm install -g --unsafe-perm node-pre-gyp npm serialport particle-cli

ref:
https://community.particle.io/t/connecting-particle-photon-to-local-server-on-raspberry-pi-zero-w/32227
https://community.particle.io/t/new-cli-on-os-x-10-11-el-capitan-solved/28802/8



Tuesday, 27 June 2017

Change Particle Photon SSID

This is for building a IoT product with Particle Photon and you want the users to see the SSID of your company's name rather than Photon-WXYZ.

System.set(SYSTEM_CONFIG_SOFTAP_PREFIX, "YourCompanyName");
System.set(SYSTEM_CONFIG_SOFTAP_SUFFIX, "xxxx");

Note that it won't go back to default after being updated!!!

ref:
https://community.particle.io/t/change-photon-ssid/13737/26
https://community.particle.io/t/particle-app-cannot-setup-photon/14201

Tuesday, 14 March 2017

Particle Takes a Long Timer to Connect to Cloud on Startup (Breathing White for a long time)


When not AUTOMATIC, do particle.connect() at the top!


ref:
https://community.particle.io/t/solved-photon-stuck-breathing-white/16510/6

Wednesday, 8 March 2017

Particle Device Setup -- Android




ref:
https://bintray.com/particle/android/devicesetup/
https://github.com/spark/spark-setup-android

Monday, 13 February 2017

I2C Competing Error

I've already made those I2C devices lined up with delays but there is still a chance they migh fail ending it: getting return = 1 from Wire.endTransmission();

The solution is when ever catched a non-zero return from Wire.endTransmission(); just Wire.begin() again to re-initialize the I2C bus. 

ref:
https://community.particle.io/t/i2c-connection-randomly-fails-on-p1-photon/13865/4      !!!!!!!
https://community.particle.io/t/strange-i2c-bus-issues-with-photon/13875
https://community.particle.io/t/photon-i2c-bus-issues/13416/18



Saturday, 17 December 2016

Particle Photon Setup Problem: Flashing Cyan with a Quick Red Burst(Bad Key Issue)

Just didn't know why the Photon cannot connect to the cloud and keeps flashing cyan (with some very quick red burst sometimes). But the Particle team has been really helpful! Check this topic:

https://community.particle.io/t/photon-setup-flashing-cyan-with-a-quick-red-burst-now-orange-burst-solved/12118/70

To sum up:

particle keys new particle keys load device.pem particle keys send <device_id> device.pub.pem // grab this file https://s3.amazonaws.com/spark-website/cloud_public.der particle keys server cloud_public.der

Then try to put the device into Safe Mode and it CAN finally connected to the cloud again!!!
(Dec 17 2016)

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

This shit happened again Apr. 20 2017!!!!!!!!!

This time I fixed this with a easier way:

(1) Put the device into DFU

(2) particle keys doctor DEVICE_ID

Found DFU device 2b04:d008
Found DFU device 2b04:d008
New Key Created!
Found DFU device 2b04:d008
Found DFU device 2b04:d008
Saved!
spawning dfu-util -d 2b04:d008 -a 1 -i 0 -s 34:leave -D XXXYYYZZZDeviceID_rsa_new.der
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

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:d008
Run-time device DFU version 011a
Claiming USB DFU Interface...
Setting Alternate Setting #1 ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 011a
Device returned transfer size 4096
DfuSe interface name: "DCT Flash   "
Downloading to address = 0x00000022, size = 608
Download [=========================] 100%          608 bytes
Download done.
File downloaded successfully
Saved!
attempting to add a new public key for device XXXYYYZZZDeviceID
submitting public key succeeded!
Okay!  New keys in place, your device should restart.


(3) particle keys server

Found DFU device 2b04:d008
spawning dfu-util -d 2b04:d008 -a 1 -i 0 -s 2082 -D /usr/local/lib/node_modules/particle-cli/keys/rsa.pub.der
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

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:d008
Run-time device DFU version 011a
Claiming USB DFU Interface...
Setting Alternate Setting #1 ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 011a
Device returned transfer size 4096
DfuSe interface name: "DCT Flash   "
Downloading to address = 0x00000822, size = 512
Download [=========================] 100%          512 bytes
Download done.
File downloaded successfully
Okay!  New keys in place, your device will not restart.


(4) particle flash --usb tinker

Found DFU device 2b04:d008
spawning dfu-util -d 2b04:d008 -a 0 -i 0 -s 0x080A0000:leave -D /usr/local/lib/node_modules/particle-cli/binaries/p1_tinker.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

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:d008
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

Flash success!

ref:
https://community.particle.io/t/solved-photon-fast-blinking-cyan-with-a-random-red-burst/14359
https://community.particle.io/t/photon-setup-flashing-cyan-with-a-quick-red-burst-now-orange-burst-solved/12118/75
https://community.particle.io/t/photon-flashing-cyan-with-red-bursts-solved/25113/3


Thursday, 1 December 2016

Compiling Using Particle CLI with Subfolders

I always like to keep things tidy and neat so I keep many things in subfolders such as ./sensors/xxxTemperature.cpp and #include them in the same way with relative directories. However, problems come after I updated my particle cli this morning (didn't happen before). The compiler started to tell me:
fatal error: No such file or directory ../build/target/user/platform-6xxxx

I tried with just one directory with everything in it and it worked, although I HATE it because it looks so fatty. "Stupid Particle" I said...

The first reference inspired me that Particle is actually making its compiler "smart" enough to search through all subfolders and we don't have to manually setup the relative directories. For example, if we have ./sensors/xxxTemperature.h, we usually write the include code:
#include "./sensors/xxxTemperature.h"

Now you can just (no...ONLY) follow the smart way by writing:
                                                   #include "xxxTemperature.h"

And the Particle Compiler could automatically search for it.

ref:
https://community.particle.io/t/subdirectories-not-compiling-in-cli-fixed/9283/5   (helped me.)
https://community.particle.io/t/compiling-using-cli-with-multiple-directories/24273
https://community.particle.io/t/multiple-folders-in-the-dev-ide-compile-errors-go-to-blank-file/18876




Friday, 14 October 2016

[Important] static variable and static global variable


There might be a time, that you DID assigned some value to an static variable, but in a function somewhere else, the change cannot be detected. For example, I met this problem when using Software Timers (Particle) whose callback functions don't take any input parameters and return values. Therefore, global/static variables are the only way of communication to the callback functions.

Here is the reason:

(1) Global variables are stored in static region.(2*) Non-static global variable and static global variable are different where non-static global variable (just defined without keyword static) can be seen in all project source files while static global variable can only be seen in the source file where it is defined. 

So if I want some variables to be static and global, I should not put "static" in front of the definition otherwise functions in other source files cannot see it.

///////////////////////////////////////////////////////////////////////////////////////////////////////////

More, if coping with c++ objects...here are some tips.

(1) Dealing with Class/Object pointers:

First, variables declared as external must be defined. So you need to have
Logger *log;
in Logger.cpp. You can also initialize it there like this:
Logger *log = new Logger();
Second, you don't need any more declarations, that is you just need to include Logger.h, no need to declare another Logger variable in Foo.h, just use log from Logger.h.
(2) Dealing with objects

In .h file:
extern Timer _timerXXX;
extern Timer _timerYYY;
extern Timer _timerZZZ;

In .cpp file:
// give inputs to the constructors
Timer _timerXXX(x1, x2); 
Timer _timerYYY(y2, y2);
Timer _timerZZZ(z1, z2);

ref:
http://www.cnblogs.com/sideandside/archive/2007/03/29/692559.html
http://blog.csdn.net/ymangu666/article/details/22277673

ref more:
http://stackoverflow.com/questions/8362679/extern-pointer-initialization



Saturday, 1 October 2016

permissions denied on serial port /dev/ttyACM0

Serial port is very commonly used when developing embedded systems such as Arduino or Particle core.

But we might encounter the following problem when trying to open the serial monitor:

                   Permission denied, cannot open /dev/ttyACM0

Many suggest to do:

              sudo chmod 666 /dev/ttyACM0

I don't know them but it did NOT work for me. This DID:

sudo usermod -a -G dialout boris

in which boris is my username.
And call:
      groups boris
to check.

Maybe you gotta login again.


Ref:
http://askubuntu.com/questions/616517/dev-ttyacm0-permission-denied-error
http://askubuntu.com/questions/58119/changing-permissions-on-serial-port

Tuesday, 13 September 2016

Particle Photon Getting Started


Step 1:
To install Node.js, type the following command in your terminal:
Then install the Node package manager, npm:
Create a symbolic link for node, as many Node.js tools use this name to execute.
Now we should have both the Node and npm commands working:
$ npm install -g particle-cli
Step 2:
sudo npm install -g particle-cli


Ref:
http://www.hostingadvice.com/how-to/install-nodejs-ubuntu-14-04/#ubuntu-package-manager
https://docs.particle.io/guide/tools-and-features/cli/photon/


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Trouble shooting, after an particle-cli upgrade, I am getting two errors look like:

        /usr/local/lib/node_modules/particle-cli/commands/Key Commands.js:213 

and the other similar one.

This is because the node version is too old. So we have to (1) upgrade node (2) remove particle-cli (3) re-install particle-cli again.

(1) in order to install the latest node
   1 Install npm:
sudo apt-get install npm
  1. Install n
sudo npm install n -g
  1. Get latest version of node
sudo n latest

(2) remove and re-install particle-cli
sudo npm remove -g particle-cli
sudo npm install -g particle-cli


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

I setup a brand new computer again.

Step 1:
sudo apt-get install nodejs-legacy
sudo apt-get install npm
You wont get the latest version but we are going to upgrade them in a minute.

Step 2:
Update them.
sudo npm cache clean -f
sudo npm install -g n
sudo n latest

Step 3:
bash <( curl -sL https://particle.io/install-cli )
Wait a while and that's IT!!!


ref:
https://github.com/spark/particle-cli/issues/176
http://stackoverflow.com/questions/34974535/install-latest-nodejs-version-in-ubuntu-14-04
http://www.hostingadvice.com/how-to/update-node-js-latest-version/
https://docs.particle.io/guide/tools-and-features/cli/photon/