Spark not accepting new firmware

Ive got a spark core that ive been trying to program lately. Using the web IDE Ive flashed the blink example to my spark. It tells me that its flashing code… the spark led flashes magenta and the web IDE tells me its successfully flashed.

I then check the device info in the through the restful api and the functions exposed is still the old codes functions and variables.

I sometimes get the failed to flash firmware message as well.

Ive tried 2 sparks over 2 networks. I hard reset one of them but that did not seem to help at all

Not sure what im doing wrong. Ive programmed them before admittedly a few months ago but it just doesnt seem to be working for me now

1 Like

I’m facing the same problem!!!

I’m fairly sure it is code related - even though the programs compile with no errors.

I’ve resorted to having to alternate the D7 LED between HIGH and LOW each time i flash a new version of the program – just to make sure its not one of those “fake” flashes which doesn’t actually accept the new firmware. :angry:

I’m actually just in the middle of trying to provide an extremely simple program that does this consistently – so the Spark peoples can debug it. Brb.

cya
R

PS - Tinker (via the phone) always flashes correctly.

However, a few times after a ‘factory reset’, i enter the Wifi password, and then the spark just goes to breathing cyan (without ‘shouting rainbows’) - whilst i haven’t even clicked “OKAY” on the spark naming screen in the app yet.

We definitely have the same issue then

This is the code I’m currently struggling to flash successfully!! (Have stripped it down to the bare minimum). Can upload a video of what the Spark Core goes through when flashing, if required.

String publishString = "hello";

void setup() {
    pinMode(D7, OUTPUT);
}

void loop() {

    Spark.publish("Uptime",publishString);
    digitalWrite(D7, HIGH);
          
    delay(1000);
}

@Devin - can you try this code and see if it flashes successfully (the D7 LED wil come on)?

NOTE: As soon as i comment out the following line, it flashes just fine:

       Spark.publish("Uptime",publishString);

Is there a coding error somewhere that ‘Verify’ isn’t catching?

Thanks,
R

When you perform an OTA, the core will blink magenta while downloading and eventually read solid magenta before quick flashing magenta and eventually reset.

Can you check if this is happening? :slight_smile:

Hi Kenneth, I guess I’m going to have to provide a video to be clearer.

This time it flashed successfully (but took forever) :
00:00 - 01:42 : flashing magenta
01:42 - 01:49 : fast magenta flickering
01:50 - 01:55 : green/white etc - i couldn’t keep track
01:55 - 01:57 : cyan flashing
01:57 - onward : cyan breathing

Now, i just changed “LOW” to “HIGH” on the LED line and re-flashed, and it didn’t work! There was a bit of RED flashing in there too. I didn’t make note of the exact colour/pattern.

Also, occasionally the Spark will be breathing cyan, and there will be a few rapid cyan flashes, and then it goes back to breathing.

I flashed the example Rehaan gave and it went through the process of flashing magenta, then resetting and still the old code is present.

1 Like

Im not sure if I got you correct. How is the checking of old code done?

Using the restful api. I check which functions and variables are exposed.

1 Like

^ Or just check if the D7 LED is on or off - to see if the new code has taken effect…

Also with this particular piece of code, it will be breathing cyan & publishing() events just fine - but will not go magenta when new code is flashed to it.

(This might be because I’m using delay(1000) in the code?)

Thanks,
R

Yes, the delay() will cause the core not to enter OTA properly for sure.

2 Likes

Here’s the updated code, without the use of delay(1000).

Still facing the original problem of the core seeming like its flashing this code, but at the end of it all, its still running what was originally on it (Tinker). Are you able to replicate this @kennethlimcp ?

unsigned long lastTime = 0UL;

void setup() {
    pinMode(D7, OUTPUT);
}

void loop() {

    digitalWrite(D7, HIGH);
    
    unsigned long now = millis();
    
    if (now-lastTime>5000UL) // Do this every 5 seconds 
    {
        lastTime = now;
    
        Spark.publish("Uptime","Hello");
    }
}

Thanks,
R

So I tried the original code with delay(1000) and that was a problem for me. I think @zachary said they are aware of a problem with fast publishing interfering with OTA updates–maybe he can comment here. You are publishing at the maximum allowable rate at 1 per second.

After the problem, I had to do a factory reset to be able to successfully flash new code.

I then changed the delay to 5 seconds and things are much better. So after a factory reset and changing to delay(5000); it works fine for me.

2 Likes

Hey guys!

I’ve noticed that when I have code that compiles, but has some other bug (like I’m not setting pinMode), the Spark will try to run my firmware and then fail back to the previous working copy. As a workaround right now, I recommend adding something like:

#define my_app_version 1

void setup() {
    Spark.publish("my_app_version", String(my_app_version), 60, PRIVATE);
}

and then subscribing to your event stream with spark subscribe mine (using the CLI https://github.com/spark/spark-cli ). I’m hoping we can add nice wrappers for this, but for now this workaround has been helping me during development. :smile:

Thanks!
David

1 Like

I still cant get code to flash properly.

Ive tried simple code

 int temperature = 9;

void setup() {
    Spark.variable("temperature", &temperature, INT);
}

void loop() {

    
}

still doesnt flash? not sure if I can make it more basic without possibilities of errors

1 Like

Thanks @bko — the publish-during-update bug was fixed a little while back—end of April—and made it into firmware v0.2.2 as mentioned in the change log.

1 Like

@Devin I’d recommend you apply the CC3000 patch if you haven’t. Use the ti-patch-1.13.7 branch (bin file download), and follow the Quick Deploy instructions in the README.

1 Like

thanks i will give that a try

1 Like

@bko - IIRC, i was having the same issue with the non-delay code in my last post (after a factory/hard reset). I might be wrong though.

@Dave - that’s my amateur-hunch too (non-detected errors), but i don’t see any above (eg. in Devin’s last post).

@Devin - Were you trying to flash the above program after doing a hard-reset? I guess the consensus is that the issue can be just as much related to the program currently on your spark core, as the new one you’re trying to flash. Always best to test after a hard-reset.

Either way, things seem to be running smoothly for me now! (Even the programs that weren’t flashing earlier!) - so i’m happy :smile:

@zachary - am i correct to assume that everytime my spark successfully flashes via the cloud, it gets the latest firmware?

Thanks for the help guys!