Author Topic: Error : An error occurred while flashing the device:  (Read 17241 times)

exeng

  • Sr. Member
  • ****
  • Posts: 452
Error : An error occurred while flashing the device:
« on: August 09, 2016, 12:32:16 am »
Has anyone definitively solved or can explain the following error during upload.

Quote
 
Sending file to cloud, to flash OAK_GD (Device ID: d9XXXXXXXXXXXXXXXXXXXX)

Error : An error occurred while flashing the device:

Recently decided to update to 1.0.5 repo and did a factory restore and firmware update via the normal instructions. At the 3 blink state but cannot upload any sketches. Consistently see the prior quoted error message. Oak is claimed and viable on Particle.io and selected for flash via CLI.

I'm about to rip my hair out and wished I never decided to update. My Oak was running just fine for months before this.

Sorry if this has been previously discussed but I didn't see that anyone solved this... just that it went away. So far not for me.

PeterF

  • Hero Member
  • *****
  • Posts: 883
Re: Error : An error occurred while flashing the device:
« Reply #1 on: August 09, 2016, 12:51:23 am »
This is getting weird... think you're the second or third person to have this problem. Although, since yours is still in the triple-blink state, it seems like yours is at least claiming it's waiting to be programmed, so that sounds more like the state that kh's was in.

Did you do the OakRestore OTA style update, or did you manually flash the latest firmware on? Does Particle say it's online/in config mode with no user rom?

exeng

  • Sr. Member
  • ****
  • Posts: 452
Re: Error : An error occurred while flashing the device:
« Reply #2 on: August 09, 2016, 08:44:04 am »
Pete,
Installed 1.0.5
Did the restore to factory via my FTDI friend.
Then did the OTA Soft AP update to get to the 3 blink state and device claimed.
As describe, can't load a sketch.

Particle shows it active in the device screen but I don't see it come online in the log when connected. So frustrating. I haven't messed with my Oaks for quite awhile and wanted to get to 1.0.5 since by all indications (i.e. forum) it seemed stable.

I have one new Oak that I may that hasn't been ever configured. Maybe it's time to try bringing it into the fold. I'm very reluctant to touch any of my other Oaks that running just fine at 1.0.0.

exeng (feeling like a noob again)

kh

  • Jr. Member
  • **
  • Posts: 64
  • OakTerm developer
Re: Error : An error occurred while flashing the device:
« Reply #3 on: August 09, 2016, 05:33:03 pm »
...so that sounds more like the state that kh's was in.

Yes, it does sound like this.

I just checked all of my Oaks and found they are currently working fine. Last time this happened, it affected a few people simultaneously. We don't seem to have this situation yet, but perhaps you're just the first unlucky one this time exeng. My gut feeling is that this issue is separate to the problems fixed in 1.0.3 to 1.0.5 and we haven't gotten to the bottom of it yet.

Probably the best confirmation that this is the issue is to serial upload the OakSystem sketch with DEBUG_SETUP defined. The serial debug messages will show whether the Oak is successfully handshaking with the Particle Cloud.

To do this, follow steps 4-10 in my post here, but also define DEBUG_SETUP and make the change on line 128 of OakSystem.ino described in this post. Afterwards, to go back to the release firmware, follow the forced serial update procedure.

(Don't compile a user sketch with DEBUG_SETUP defined as it will cause a fatal exception. I haven't found the cause of this yet).
« Last Edit: August 09, 2016, 05:35:37 pm by kh »

exeng

  • Sr. Member
  • ****
  • Posts: 452
Re: Error : An error occurred while flashing the device:
« Reply #4 on: August 09, 2016, 05:40:44 pm »
Well it's like a nightmare... It just keeps getting worse.

Did the restore again and OTA firmware update (1.0.5). Device ID looks good. System version 10. Can see it on my wireless net and connect to it. At 3 blinking state but both OakCLI and Particle do not see it and cannot manual claim.

So frustrating.

kh, was typing when you posted. Thanks. I will try your suggestion if I can manage it.

exeng

  • Sr. Member
  • ****
  • Posts: 452
Re: Error : An error occurred while flashing the device:
« Reply #5 on: August 09, 2016, 08:27:54 pm »
OK trying the OakSystem sketch install steps but down a rat hole with respect to Python. I've not used nor am I Python savvy so bare with me.

Installed Python 2.7 but when trying to do the OakSystem upload step I get the following message:
Quote
  File "C:\Users\Stephen\AppData\Roaming\Arduino15\packages\digistump\hardware\oak\1.0.5/tools//esptool.py", line 22, in <module>
    import serial
ImportError: No module named serial

I'll try to figure it out as I would prefer to understand it but any guidance would help.

exeng

  • Sr. Member
  • ****
  • Posts: 452
Re: Error : An error occurred while flashing the device:
« Reply #6 on: August 09, 2016, 08:41:19 pm »
Python error fixed. Just needed to install the python serial package:
https://pypi.python.org/pypi/pyserial/2.7

Looks like I now have OakSystem per kh's instruction... On to the next step.

exeng

  • Sr. Member
  • ****
  • Posts: 452
Re: Error : An error occurred while flashing the device:
« Reply #7 on: August 09, 2016, 09:20:16 pm »
OK couldn't get any output after installing the OakSystem via serial. Mostly likely my misunderstanding of the steps required. However, in the process I learned that one can update over serial and I uploaded a sketch that was previously running just fine on this Oak that wirelessly speaks to Thinkspeak, Particle, and Blynk. Particle looks like a bust at this point and it was never critical to my app; just a curiousity. Haven't verified Bylnk yet but Thinkspeak is working just fine. Now that I know I can serial upload sketches I'm right on the edge of bailing on Particle OTA. If my Blynk functions work, that might be the nail in the coffin. I don't need the Particle headache right now. Two days, spent trying to figure out why it broke. But there is a very big part of me that wants to know why and would like it to work.

OakCLI and Particle don't see this Oak but yet my sketch can get to Thingspeak and I can see the Oak as a client it on my router.

Arrrgggh!

exeng

  • Sr. Member
  • ****
  • Posts: 452
Re: Error : An error occurred while flashing the device:
« Reply #8 on: August 09, 2016, 10:21:48 pm »
Update: Well did another restore and OTA of the latest firmware fully intending to do only serial uploads from now until the issue with "error occurred while flashing the device" is understood and/or resolved. And low and behold, OakCLI and Particle can see the Oak and it is claimed. And yet I still cannot upload a sketch. What a circus! So frustrating not knowing what gremlins are causing this very unstable unrepeatable behavior.

So... I wonder is Particle will see events from this Oak if I load my sketch via serial?

kh

  • Jr. Member
  • **
  • Posts: 64
  • OakTerm developer
Re: Error : An error occurred while flashing the device:
« Reply #9 on: August 09, 2016, 10:36:49 pm »
Sorry, I know this is very frustrating.

So... I wonder is Particle will see events from this Oak if I load my sketch via serial?

This is a great way to confirm the source of your problem. Send an event and then print a message to the serial port or blink the led to confirm it's sent. If it doesn't show up on the Particle Console or OakTerm, then it's pretty clear the Particle Cloud is not passing on your events, which is the problem I and others had. You can see the bare minimum test sketches I used for this in my post on the Particle forums.
 

Also, here are some thoughts on your previous message, if you still need to get the serial debug messages working...

OK couldn't get any output after installing the OakSystem via serial.

Since you're successfully uploading sketches via serial, you must have almost everything right. Here are a few things to check...

  • Make sure you edit particle_globals.h to uncomment the #define OAK_SYSTEM_ROM... and #define DEBUG_SETUP, and also comment out line 128 of OakSystem.ino (Serial.println("LOOP")) before compiling and uploading the sketch via the Arduino IDE.
  • Also, before uploading the sketch, make sure you rerun the "python esptool.py ..." step 7 here. Serial upload always uploads to the first ROM slot, but if you do cloud uploads, it may upload to other slots and make those the boot default.
  • After uploading, open the Arduino IDE serial monitor and set the baud rate to 115200. Then power cycle your Oak to restart the sketch (it doesn't restart automatically upon opening the serial monitor like it does for a traditional Arduino). You should see the LED triple blinking (3 fast blinks, pause, repeat) indicating the Oak is in config mode. Even if you don't have the debug messages correctly turned on, you should still see a few lines printed from the OakBoot bootloader.
  • If you still don't see anything, set the baud rate in the serial monitor to 74880 and power cycle again. At this baud rate, you should see the initial boot message from the ESP8266's internal bootloader, which should look something like "ets Jan 8 2013,rst cause:2, boot mode:(1,7)" (the numbers may be different). If you don't see this, you must have an error with your FTDI connections, but that's very unlikely since you've been able to upload sketches.

OakCLI and Particle don't see this Oak but yet my sketch can get to Thingspeak and I can see the Oak as a client it on my router.

Just to clarify here...OakCLI communicates with your Oak via the Particle Cloud, so if Particle doesn't work, neither will OakCLI.
« Last Edit: August 09, 2016, 10:42:44 pm by kh »

exeng

  • Sr. Member
  • ****
  • Posts: 452
Re: Error : An error occurred while flashing the device:
« Reply #10 on: August 09, 2016, 10:59:50 pm »
kh, Thanks for sticking in there with me.

I feel like I'm chasing a moving target. I don't want to give up (not my nature) but this is beating me to a pulp. Too squishy and constantly changing behavior is the problem. Repeatable behavior is easier when debugging.  It could be me thrashing but I'm trying to be somewhat methodical. There has got to be some simple stupid bug somewhere but when you are coming at it as black box it's difficult to figure out.

OK enough venting. I need to set it aside for now and come back fresh to try your latest suggestions. Thanks for the info and insights. They are not lost on me yet.

The whole motivation for updating to 1.0.5 was that I was not seeing Particle updates (events) anymore and I knew that Bylnk had moved on, so I wanted to bring everything up to the latest revs.
1.0.0 was working just fine for me OTA updates and all before this.

Thanks,
exeng

PeterF

  • Hero Member
  • *****
  • Posts: 883
Re: Error : An error occurred while flashing the device:
« Reply #11 on: August 10, 2016, 12:51:36 am »
So... I wonder is Particle will see events from this Oak if I load my sketch via serial?

If I understand your question to mean 'will Particle see events from an Oak if the sketch is loaded via serial?', then then answer should be yes. I just uploaded a sketch to my test subject after a quick forced firmware update (I really can't be bothered with OTA updating until that stabilises some more), as that resets things the same way anyway. It output the serial debug messages, and also published an event to Particle. I've included the code used below. If you're wondering why I use 74880 baud rate for Serial, it is because the bootloader uses the baud rate, so I might as well use that baud rate so I don't get garbage every time the Oak starts.

Code: [Select]
//defined back to front on the Oak
#define LED_BUILTIN BUILTIN_LED

// the setup function runs once when you press reset or power the board
void setup()
{
  Serial.begin(74880);
  Serial.println("Sketch starting: Blink v0.3");
  Particle.publish("oak/userrom/startup","Blink v0.3", 60, PRIVATE);
 
  // initialise digital pin 1 as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop()
{
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(500);                   // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(500);                   // wait for a second


exeng

  • Sr. Member
  • ****
  • Posts: 452
Re: Error : An error occurred while flashing the device:
« Reply #12 on: August 10, 2016, 10:29:43 am »
Pete, kh thanks.

It's a new day. I'm going to "Carpe Diem" and deal with this later (i.e. evening PST).

BTW, does anyone know where the "Error: An error occurred while flashing the device" message emanates from? Perhaps that would provide a clue...or not.
exeng

kh

  • Jr. Member
  • **
  • Posts: 64
  • OakTerm developer
Re: Error : An error occurred while flashing the device:
« Reply #13 on: August 10, 2016, 10:52:01 am »
BTW, does anyone know where the "Error: An error occurred while flashing the device" message emanates from? Perhaps that would provide a clue...or not.
exeng

It comes from OakCLI (see here). This error is printed if OakCLI receives an error from the SparkJS API "flash" call to program the device (Particle was formerly known as Spark, and their Cloud API was named SparkJS). Essentially, OakCLI is just relaying that it got an error from the Particle Cloud after sending it the compiled firmware image to program onto the Oak. It only tells us success/failure, no more detail about the error is provided.

exeng

  • Sr. Member
  • ****
  • Posts: 452
Re: Error : An error occurred while flashing the device:
« Reply #14 on: August 10, 2016, 07:18:56 pm »
kh, Ran through your suggested (4-10) steps again. After completing the OakSystem serial upload this is what I see on the serial monitor...
Quote
WIFI CONNECTED
PARTICLE CONNECT
AUTO CONNECT
START HANDSHAKE
SHAKE
4
BLRECV
40
SHAKE1
4
SHAKE2
BLSEND
256
0
SHAKE3
SHAKE4
BLRECV
SET KEY
SEND HELLO
GET HELLO RESPONSE
BLSEND
18
0
WAIT FOR SERVER HELLO
HRM1
BLRECV
HM1
0
Hanshake: completed
END HANDSHAKE
SEND EVENTS
BLSEND
50
0
BLSEND
50
0
SEND SUBS
BLSEND
18
0
BLSEND
18
0
SEND TIME REQ
BLSEND
18
0
LOOP
HRM1
BLRECV
HM1
13
HRM1
BLRECV
HM1
13
HRM1
BLRECV
HM1
13
HRM1
BLRECV
HM1
13
HRM1
BLRECV
HM1
12
END AUTO CONNECT
BLSEND
50
0
BLSEND
50
0
AP ONLINE
START AP
STARTED
GOTO LOOP
HRM1
BLRECV
HM1
13
HRM1
BLRECV
HM1
13
HRM1
BLRECV
HM1
1
BLSEND
226
0
BLSEND
34
0
BLSEND
18
0
HRM1
BLRECV
HM1
13
BLSEND
18
0
HRM1
BLRECV
HM1
13... and so on

Oak is at 3 blink state.

Then I comment out #define OAK_SYSTEM_ROM_4F616B 82 and switch OTA of a blink test sketch. OTA upload fails as before. No new serial output (expect a refresh that blanks the serial monitor). 3 blink state remains. Serial output continues with the BLSEND pattern.

Particle.io does seem to see the Oak. At least according to the flashing dot on the devices screen.

So I'm still left wondering why I can't do an OTA upload. Wished I could see the exchange with Particle.