Can I change factory reset firmware?

Can I make my own factory reset firmware with my own default wifi credentials?
Would be handy during debug experiments

@ryotsuke did you try the spark-cli?

It allows you to compile your code into a .bin file and you can use it to replace the factory-reset firmware through dfu-util

And what code should I use to set default wifi credentials? So I still could set other ones with mode button and Smart Config

This isn’t really exposed yet but you can look somewhere around:

You possibly misunderstood. I want to change the firmware that sparks resets to.
Spark-cli “spark flash firmware core-firmware.bin” is used to flash new firmware, but it is not replacing default one, that appears on board after reset.
Code you’ve provided allows to set new credentials, but I want to store default ones directly inside.
So basically I want my frimware with my settings appear directly after factory reset with no further actions required.
Setting default credentials so no need to set them again after factory reset is main purpose.

Use case:


  1. Flash firmware from cloud, core hangs
  2. Factory Reset
  3. Attach to PC
  4. Use serial client to set credentials
  5. Detach core
  6. Wait to connect to cloud

I want (for now):

  1. Flash firmware from cloud, core hangs
  2. Factory Reset
  3. Wait to connect to cloud

Potential later use:

  1. Core hangs
  2. Factory reset
  3. Core connects to my wifi defaults, than updates itself from local cloud with preconfigured firmware name

Last one will be increadibly handy for updating lot of cores in some enterprise environment.

I believe i need to change something like this

and set data here:

But i’m not sure what will happen to this data after firmware from cloud updates.
Also I dont know how to make this factory firmware (if it is possible at all)

1 Like

You said ‘factory reset firmware’ earlier. core-firmware.bin doesn’t change the factory reset firmware.

That’s the user-code firmware. Oh wells :slight_smile:

So I’ve explained now what I would like to have?
Is it possible?

English is not my native, perhaps I sound confusing

Create a firmware with the WiFi credentials you want, use the local build tools to compile a bin and use dfu-util to replace the Factory Reset bin.

dfu-util can write to any area of internal or or external SPI flash (which is where the factory reset firmware is located). See the Memory Map in the Spark Docs. (I’d get you a link but I’m posting from my phone.)

So if I write anything to
0x20000 Factory Reset Firmware Location 128 KB max
It becomes factory reset firmware. Great :smile:

What about hard coding credentials. If I just override variables like _ssid[] core will connect, but after OTA these variables will have values from cloud version. I need to write values to same place connect_callback(ssid, password, security_type) does, but do that only once per factory reset (not per reset) so they can be changed with mode button (I assume we don’t change anything more in default firmware at the moment)

1 Like

Hi @ryotsuke,

Yes! Writing any firmware to 0x20000 will replace the firmware the core loads during a factory reset. You can manually set the credentials the firmware will use every time with the “WLAN_MANUAL_CONNECT” process you outlined above, but if you want these credentials to persist after flashing different firmware (provided you don’t include the default creds in all your flashed snippets), you would need to save a wifi profile on the cc3000.

You could add something like this to your setup:

void wifi_add_profile_callback(const char *ssid, const char *password, unsigned long security_type);

Though you would probably want some extra logic to make sure you’re not adding too many profiles, etc, etc. :smile:


so setup should be

void setup() {
    wifi_add_profile_callback("my ssid", "my password", WPA2);

Still confusing:

  1. Will this work with recent firmware changes that init WLAN before static constructors and setup methods?
  2. I use mode button, enter other credentials and gotcha - they are resetted by setup() again

Exactly, so you could do something like have it in a class constructor before setup (#1). #2 is a little harder, honestly it sounds like the ‘better’ solution for you would be to tweak the bootloader slightly so that it doesn’t clear wifi profiles during a factory reset.

May be I just need a way to read credentials and set them if they are completely empty. Is there anything like that?
If factory reset itself cleanups wifi credentials, that will be a solution

Hmm, I’m not aware of a way to read profiles back out, but there certainly could be.

Alternatively, you could also modify the connection policy on the CC3000 to default to connect to open access points, by setting “should_connect_to_open_ap”

extern long wlan_ioctl_set_connection_policy(
               unsigned long should_connect_to_open_ap,
               unsigned long should_use_fast_connect,
               unsigned long ulUseProfiles);

Sorry for the request. But I am a newbie…

Is there like a step by step tutorial someone is willing to drop here to make my code become the default Firmware, and make sure it does not become bigger in size than the default factory firmware (allowed size)?


I hope I got your question right. The default factory reset firmware is a Tinker App like what you get with a new :spark: core.

I can post the code in the default Tinker app and you can paste in a new App I WebIDE but any new code you add will make the size larger.

What’s your concern? Running out of memory?

No. My concern is that I want my app to be able to be flashed with the default factory reset instead of the Tinker App. And as I read in this thread, there is a size limit for this app in order to be ref lashed correctly to the right place in memory.

I am not concerned about memory at all. Its a fairly small program, but I just want to make sure I understand the limits right.

Now … Once I replace in the webIDE the Tinker App… What’s next steps to set this new (my) app as the default APP for any factory reset operation instead of the Tinker App? (IE: Mode Button for 10 secs with Reset Tap).

Thanks for the help!

I can’t get your question somehow…

You want to replace the Factory Reset Firmware with your own firmware which loads every time you perform a factory reset?

There’s not too much of a limit for the Factory reset and it stays in the External flash from 0x20000 to 0x3FFFF if i’m not wrong.

Take a look at:

I have a tutorial to replace the default factory firmware if i got your question correct :wink: