Skip to content

Commit 0bc1c26

Browse files
committed
Update README.md
1 parent 501f1e2 commit 0bc1c26

File tree

1 file changed

+85
-2
lines changed

1 file changed

+85
-2
lines changed

README.md

+85-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,88 @@
11
# Spark STM32 Bootloader
22

3-
Careful! Low level dragons here!
3+
*Careful! Low level dragons here!*
44

5-
Real README content in the near future. ;-)
5+
* Really make sure you have a working programmer shield and an ST-link programmer.
6+
* Is this a brand new core from scratch (that you made? nice!) goto 1, or is it this a core that came from Spark - goto "unlocking your bootloader"
7+
8+
### Unlocking your bootloader
9+
10+
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.
11+
12+
* Grab the "unlocker" from here: (https://github.com/spark/bootloader/tree/master/tools (use "raw")
13+
* dfu that with a: `dfu-util -d 1d50:607f -a 0 -s 0x08005000:leave -D unlocker-firmware.bin`
14+
* Your core should restart, flash some lights, and end with a 'green' flash before wiping saved wifi profiles and resetting
15+
* Your bootloader is unlocked!
16+
17+
**1. Make sure you have st-flash installed, or have a copy of the ST-Link Utility software.**
18+
19+
* You can find the software on their site if you're using windows: http://www.st.com/web/catalog/tools/FM146/CL1984/SC724/SS1677/PF251168
20+
21+
* If you're on mac / linux grab "st-flash" you can grab and build a tool yourself:
22+
```
23+
git clone [email protected]:texane/stlink.git
24+
cd stlink
25+
./autogen.sh
26+
./configure
27+
make
28+
make install
29+
```
30+
31+
**2. Grab a copy of the latest bootloader from here:**
32+
33+
https://github.com/spark/bootloader/blob/master/build/bootloader.bin?raw=true5.) With your core in your programmer shield / st-link connected, lets re-flash some stuff!
34+
35+
* In the windows utility set device -> settings to "connect under reset" true! (if you can't find this that's okay)
36+
* 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.
37+
* Write your bootloader.bin back to 0x08000000
38+
* Congrats, you re-wrote your bootloader!
39+
40+
**3. Lock your bootloader back up! (Optional, but recommended)**
41+
42+
* Grab the locking firmware here: (https://github.com/spark/bootloader/tree/master/tools (use "raw")
43+
* dfu that to `dfu-util -d 1d50:607f -a 0 -s 0x08005000:leave -D locker-firmware.bin`
44+
* your core should reset, flash some lights, and flash 'red' when locked.
45+
46+
**4. Okay, lets keep going and update the radio driver on the CC3000**
47+
48+
* Grab the patch programmer from here: https://github.com/spark/cc3000-patch-programmer/blob/master/build/cc3000-patch-programmer.bin?raw=true
49+
* dfu it with: `dfu-util -d 1d50:607f -a 0 -s 0x08005000:leave -D cc3000-patch-programmer.bin`
50+
* 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.
51+
* 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
52+
53+
54+
### It's time to write some stuff to external flash!
55+
56+
**1. Lets make some keys (optional step if your keys have been fine):**
57+
58+
```
59+
openssl genrsa -out core.pem 1024
60+
openssl rsa -in core.pem -pubout -out core_public.pem
61+
openssl rsa -in core.pem -outform DER -out core_private.der
62+
```
63+
64+
**2. Flash your new private key:**
65+
66+
`dfu-util -d 1d50:607f -a 1 -s 0x00002000 -v -D core_private.der`
67+
68+
**3. Grab the server public key, and flash it:**
69+
https://s3.amazonaws.com/spark-website/cloud_public.der
70+
71+
`dfu-util -d 1d50:607f -a 1 -s 0x00001000 -v -D cloud_public.der`
72+
73+
**4. Grab the latest firmware and flash it**
74+
75+
https://github.com/spark/core-firmware/blob/spark_2/build/core-firmware.bin?raw=true
76+
77+
```
78+
# to the factory reset spot
79+
dfu-util -a 1 -s 0x00020000 -v -D core-firmware.bin
80+
81+
## to the main firmware spot
82+
dfu-util -a 0 -s 0x08005000:leave -D core-firmware.bin
83+
```
84+
85+
**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!**
86+
87+
*(Thanks to David for putting this together)*
88+
Ref: https://community.spark.io/t/st-link-programmer-shield-only-so-youve-decided-you-want-to-update-your-bootloader-and-everything/2355

0 commit comments

Comments
 (0)