Continuing the discussion from Won’t connect to internet - rapid green flashing:
This maybe goes without saying, but I’ll say it anyway: These instructions (*which you probably don’t need to try, and maybe shouldn’t do unless you are okay breaking things *) tell you how to remove and replace the bootloader on your core. This is pretty safe and easy if you have the right tools, but really please don’t do it unless you have a ST-Link programmer and a programmer shield, and you can confidently recover from an erased bootloader (a “bricked core”).
#So you’ve decided to reflash everything anyway,
##despite what @Dave literally just warned me about a second ago:
###Let’s do this:
1.) Really make sure you have a working programmer shield and an ST-link programmer.
2.) Is this a brand new core from scratch (that you made? nice!) goto 3, or is it this a core that came from Spark - goto “unlocking your bootloader”
##Unlocking your bootloader
Welcome! The bootloader on the stm32 is protected by a “write protect” flag that helps prevent accidental “bricking” of a core for those without a programmer shield / st-link programmer. But that’s not you, you want to fully erase your core, or re-write your bootloader, and you’re not scared of “bricking” anything.
A.) Grab the "unlocker" from here: (https://github.com/spark/bootloader/tree/master/tools (use "raw") B.) dfu that with a: dfu-util -d 1d50:607f -a 0 -s 0x08005000:leave -D unlocker-firmware.bin C.) your core should restart, flash some lights, and end with a 'green' flash before wiping saved wifi profiles and resetting D.) your bootloader is unlocked!
3.) Make sure you have st-flash installed, or have a copy of the ST-Link Utility software
- You can find the software on their site if you’re using windows:
If you’re on mac / linux grab “st-flash” you can grab and build a tool yourself:
git clone email@example.com:texane/stlink.git cd stlink ./autogen.sh ./configure make make install
4.) Grab a copy of the latest bootloader from here: https://github.com/spark/bootloader/blob/master/build/bootloader.bin?raw=true
5.) With your core in your programmer shield / st-link connected, lets re-flash some stuff!
A.) In the windows utility set device -> settings to "connect under reset" true! (if you can't find this that's okay) B.) do a full erase of your core, do this a few times, if you're in the windows utility, view the memory and make sure it's zero-ed out. C.) write your bootloader.bin back to 0x08000000 D.) congrats, you re-wrote your bootloader!
6.) Lock your bootloader back up! (Optional, but recommended)
A.) grab the locking firmware here: (https://github.com/spark/bootloader/tree/master/tools (use "raw") B.) dfu that to dfu-util -d 1d50:607f -a 0 -s 0x08005000:leave -D locker-firmware.bin C.) your core should reset, flash some lights, and flash 'red' when locked.
Okay, lets keep going and update the radio driver on the CC3000
1.) Grab the patch programmer from here: https://github.com/spark/cc3000-patch-programmer/blob/master/build/cc3000-patch-programmer.bin?raw=true
2.) dfu it with: dfu-util -d 1d50:607f -a 0 -s 0x08005000:leave -D cc3000-patch-programmer.bin
3.) hold down the mode button for 3+ seconds until the light starts blinking, let your core sit for 20-60 seconds after the light stops blinking.
4.) At this point you can erase your core with the st-link programmer (did you lock your bootloader?), to get it back into dfu mode
It’s time to write some stuff to external flash!
1.) Lets make some keys (optional step if your keys have been fine):
openssl genrsa -out core.pem 1024 openssl rsa -in core.pem -pubout -out core_public.pem openssl rsa -in core.pem -outform DER -out core_private.der
2.) Flash your new private key:
dfu-util -d 1d50:607f -a 1 -s 0x00002000 -v -D core_private.der
3.) Grab the server public key, and flash it:
https://s3.amazonaws.com/spark-website/cloud_public.der dfu-util -d 1d50:607f -a 1 -s 0x00001000 -v -D cloud_public.der
4.) Grab the latest firmware and flash it
https://github.com/spark/core-firmware/blob/spark_4/build/core-firmware.bin?raw=true ## to the factory reset spot dfu-util -a 1 -s 0x00020000 -v -D core-firmware.bin ## to the main firmware spot dfu-util -a 0 -s 0x08005000:leave -D core-firmware.bin
5.) If you made new keys, be sure to send someone at Spark your new public key, along with your core id, otherwise your core won’t connect to the cloud again!
I think that’s it!