Multiple software timers, how many?, third timer not triggering

Using Particle Electron 0.4.8-rc.6

Output indicated that timer03 never gets triggered.
If I change the timer.start() order it appears only the
first two timers are activated.

Are only 2 timers allowed?
Also changing the time delay does not appear to make a difference.

As per another help thread SYSTEM_THREAD(ENABLED); makes no
difference.

// THIS IS MY CODE

Timer timer01(1100, doTimer01); // 1.2 seconds
Timer timer02(3600, doTimer02); // 3.6 seconds
Timer timer03(5400, doTimer03); // 5.4 seconds

void setup() {
    Serial.begin(9600);
    delay(5000);
    Serial.printlnf("System version: %s", System.version().c_str());
    timer01.start();
    timer02.start();
    timer03.start();
}

void loop() {
    // do nothing
}

void doTimer01() {
    Serial.println("Timer 01");
}

void doTimer02() {
    Serial.println("Timer 02");
}

void doTimer03() {
    Serial.println("Timer 03");
}

I don’t think that we will be going to deep into outdated system versions.
0.6.0 (soon to come 0.6.1) is the current stable (not Release Candidate) version and I’d suggest you’d update the system version to a version that had a boatload of bug fixes done over time.

BTW, AFAIK you can have up to 10 Software Timers, but you need to consider that they are all running on the same thread.

Ok so I need to Update the firmware... so I run...

particle update
It updates but i still end up with the same version! 0.4.8-rc.6
How do I update to 0.6.0 please?

The docs state update , updates to the latest version!
I found 0.6.1 here...

But where is 0.6.0 ?

You need the most recent CLI (currently 1.19.4).
Also you need to re-target your application firmware to 0.6.0.

Can you post the output of

particle serial inspect

(in Listening Mode)

0.6.0 can be found here

Ok I managed to update over USB
Result was Flash Success for both parts but with warning
Invalid DFU suffix signature

I now can’t connect over USB and the D7 LED is lit blue but the mode light is not flashing for any known mode!

This is just an ignorable warning, but the dim D7 LED is not good.
This usually happening when there was a power issue during update or a brownout condition.

Can you still enter DFU or Safe Mode?

Ok first time was from CLI using
particle flash --usb system-part1-0.6.0-electron.bin
particle flash --usb system-part2-0.6.0-electron.bin

second try was using DFU
dfu-util -d 2b04:d00a -a 0 -s 0x8020000 -D system-part1-0.6.0-electron.bin
dfu-util -d 2b04:d00a -a 0 -s 0x8040000 -D system-part2-0.6.0-electron.bin

Result was…
File downloaded successfully

Still got the D7 LED on (very dim) no mode LED

Unable to put into safe mode, mode LED is magenta but not flashing.

How about DFU Mode and

particle flash --usb tinker

I did particle update so now I’m back where I started with 0.4.8
Maybe the file was corroupt or as you suggest a power issue.
Ill try again when I calm down.
Thoughts iI had bricked it :frowning:

Much thanks for your fast help ScruffR
Realise this is not quite on original topic now and is more a firmware update subject.

Can you check

particle --version

BTW, the 0.6.0 firmware for the Electron consists of three parts and when doing it manually, you should add an intermediate 0.5.3 update.

You will need this too
https://github.com/spark/firmware/releases/download/v0.6.0/system-part3-0.6.0-electron.bin

Yes I am on that road now…
Version CLI 1.11.0

I attempt npm update -g particle-cli@v1.18.0 but it appears to do nothing after a short pause.

As I said earlier

You either only do

npm update -g particle-cli

to get the most recent version or you first

npm uninstall -g particle-cli

and then reinstall

npm install -g particle-cli

or when you're on Windows, use the installer.

Ok I did npm update -g particle-cli
and got…
particle – version
1.19.4

Since documents state…
If you use DFU over USB, you can update to v0.6.0 directly, but make sure you have installed v1.18.0 of the CLI first.

I downloaded parts 1, 2 and 3 from

then ran
particle flash --usb system-part1-0.6.0-electron.bin
particle flash --usb system-part2-0.6.0-electron.bin
particle flash --usb system-part3-0.6.0-electron.bin
Got flash success for each part

Now got D7 led lit again and unable to enter DFU mode!
Mode light will not come on for any combination of mode / reset presses

I guess it’s BRICKED since I am unable to access it in DFU or OTA or change mode.
After uploading was I supposed to press reset? as that’s what I did I think!

Your device is not bricked, it is just not running any useful firmware if the D7 LED is on dimly and it doesn’t respond. If you have JTAG programmer or programmer shield you can fix it for sure. The ST Micro JTAG programmers can apparently be found on eBay for under $10. Here is a link to programmer shield:

If you have another Particle device, you may be able to use it as JTAG programmer and fix it but that has been running about 50/50.

Are you able to place the device in DFU mode?

@BDub, somehow the user got an electron bricked with the firmware upgrade.

Can you also try

particle flash --usb tinker

again?
This should usually be done after a modular update (particle update wouldn't need that AFAIK).

This is why I usually write something like: "... CLI vX.Y.Z (or later) ..." or "... use the latest version (currently vX.Y.Z) ..."

It's stated this way to ensure if you want 0.6.0, you will get 0.6.0. Updating to the latest CLI may be the latest version and won't necessarily be 0.6.0 anymore. It just so happens that the latest CLI does also still contain 0.6.0 firmware. So either will work, but you should always be able to follow the documentation and it be correct.

If you updated firmware via particle flash --usb for system parts, you would have to press reset after the firmware transfer completed. The RGB LED would have still been flashing yellow. If you have the correct CLI version, you can also just run particle update and it will flash all 3 images for you (for 0.6.0 electron) and reset the device for you after it completes.

Try to remove ALL power sources for a few minutes, and connect just the USB while holding the MODE button down. Does the RGB flash magenta, then yellow again?

If not, please contact https://support.particle.io about this latest issue and reference this thread.

Can you remember exactly the point in time when the unit was working, vs. not. Was it transferring via DFU, completed transfer, still flashing yellow, then you pressed RESET and immediately after D7 was dimly lit for good? Did you have the battery plugged in at that time and was it charging or fully charged? Good USB power source? We might not be able to determine exactly what went wrong here but I'd like to ask for as much detail as you can provide to help us solve this issue.

Ok just tried it again…
USB power applied while holding down MODE, no battery connected.
The RGB LED failed to light any colour, just the dim D7 on and flashing red battery led.

I remember after flashing via USB the RGB LED was flashing or steady yellow.
The CLI reported that all 3 code blocks had flash success.
Then I am sure I pressed reset and that is when the D7 LED came on.
The battery was connected and charging but I am also quite certain it was nowhere near flat since battery and USB were connected for several hours while attempting to update the CLI and Firmware.
I do have a GPS sensor and XYZ sensor connected to the 3.3V pin
The GPS consumes 40mA and the XYZ about 400uA.
I had an LED connected via 220 Ohm R from Pin D1 to GND
GPS Serial out to Pin USART1-RX
XYZ OUT to Pins A0, A1 and A2

I am using WindowsXP and DOS Command Window to run the CLI
Still unable to put into DFU Mode.
Now looking at JTAG programmers on eBay to see what damage I can do with that!

Thank you all for your help.

Thanks for the extra details @BrianMoreau! You’ll definitely be able to restore things with a JTAG tool. I recommend these (search “ST-Link” on eBay or Amazon): [eBay] [Amazon] I purchased from the seller on eBay and they worked great. Amazon is a faster option if you have a Prime account, for not that much more.

Restore instructions:

Windows

  1. Purchase something like this (search “ST-Link” on eBay or Amazon): [eBay] [Amazon]
  2. Download this tool: STSW-LINK004 and install
  3. Download this driver: STSW-LINK009, unzip into a folder. Run the stlink_winusb_install.bat file by double-clicking on it.
  4. Download this firmware file combined-v0.4.8-rc.6-electron and save to a known location.
  5. Plug in your mini ST-Link. The driver install should succeed.
  6. Connect the mini ST-Link to your Electron as shown in this diagram
  7. Plug your Electron into USB power using a USB cable.
  8. Put your Electron into DFU Mode. Not a required step but you may need to press and release the reset button on the device just as you start to perform any operation on the chip.
  9. Open the STM32 ST-Link UTILITY application in Windows
  10. Open the TARGET menu then click SETTINGS, make sure the PORT is set to SWD mode.
  11. Open the TARGET menu and click CONNECT. You should be connected to the target. (the data window should populate)
  12. Now open the TARGET menu, then OPTION BYTES. Un-select all sectors (there is a button at the bottom to do this), and APPLY. This will un-writeprotect your flash.
  13. Now do a full erase. Open the TARGET menu and click ERASE CHIP
  14. Once complete reprogram the device. Open the TARGET menu and click PROGRAM. Select the bootloader file downloaded earlier (combined-v0.4.8-rc.6-electron.bin). Make sure, at the next popup the address is 0x08000000 (the default address). Program the device
  15. Once complete the unit should eventually start blinking blue. Open up a command terminal and run the command particle identify. Make a note of the returned Device ID (you will need it later). You will need the Particle CLI installed to do this.
  16. Run the command particle setup wifi and follow the onscreen prompts. Once complete the unit will continue to blink blue. This is a known bug. Disconnect the ST-Link and then disconnect the USB cable from the Electron. Give it a moment then plug the USB cable back into the Electron (do not re-connect the ST-Link).
  17. The unit should boot up. Eventually, you will get a cyan flashing with red blip due to handshake error. Run this CLI command to fix the keys: particle keys doctor YOUR_DEVICE_ID

Mac / Linux

  1. Purchase something like this (search “ST-Link” on eBay or Amazon): [eBay] [Amazon]
  2. (if on a Mac) Install the st-flash utility using the these commands (if on a Linux system) follow the steps in this article
  3. Download this firmware file combined-v0.4.8-rc.6-electron and save to a known location.
  4. Plug in your mini ST-Link.
  5. Connect the mini ST-Link to your Electron as shown in this diagram
  6. Plug your Electron into USB power using a USB cable.
  7. Put your Electron into DFU Mode. Not a required step but you may need to press and release the reset button on the device just as you start to perform any operation on the chip.
  8. Open up a terminal and navigate to folder with the bootloader file in it
  9. Run this command st-flash write v1 combined-v0.4.8-rc.6-electron.bin 0x08000000. If you get an error message, then try using sudo in front of the above command or try rebooting the system.
  10. Once complete the unit should eventually start blinking blue. Run the command particle identify. Make a note of the returned Device ID (you will need it later). You will need the Particle CLI installed to do this.
  11. Run the command particle setup wifi and follow the onscreen prompts. Once complete the unit will continue to blink blue. This is a known bug. Disconnect the ST-Link and then disconnect the USB cable from the Electron. Give it a moment then plug the USB cable back into the Electron (do not re-connect the ST-Link).
  12. The unit should boot up. Eventually, you will get a cyan flashing with red blip due to handshake error. Run this CLI command to fix the keys: particle keys doctor YOUR_DEVICE_ID
3 Likes