I managed to make a few baby steps. I messed up (bricked?) two devices to the point where I wasn’t able to connect to them via the stm32 link utility.
I managed to bring one device back by using openOCD. If anyone will be having the same problems, try to follow this thread:
https://github.com/spark/firmware/issues/31
There is one difference however. Change the content of your .cfg file:
source [find interface/stlink-v2.cfg]
source [find target/stm32f2x.cfg]
reset_config srst_only srst_nogate
Since the P1 has the STM32F205 120Mhz ARM Cortex M3 inside of it, you have to use “stm32f2x.cfg” and I removed this line:
set WORKAREASIZE 0x5000
Since I didn’t really know what it does (I have to google it as soon as my nervous breakdown is over) and it didn’t really make a difference.
Once you run this command:
openocd -f p1.cfg -c "init;reset init"
and you don’t get any errors, you can run puTTY and connect to openOCD via telnet and port 4444.
To Erase the chip, I had to halt the ship, unlock it and erase all the sectors. After that I was able to connect to the P1 via the stm32 link utility again.
The second device is a little more problematic. When trying to connect via openOCD I get the following errors:
Examination failed, GDB will be halted. Polling again in 100ms
Info : Previous state query failed, trying to reconnect
Error: jtag status contains invalid mode value - communication failure
I would really like to know if this is a software or hardware failure since even while the device was OK, I wasn’t always able to connect via JTag (I had to wiggle it a little, I think the pin quality on our custom board is not the best). I am also worried that this device is beyond repair.
Is it even possible to brick the P1 with user code? After I flashed the firmware I checked the sectors, the important ones were write protected so I doubt I was able to mess up the bootloader or firmware.
Also, is it normal, that the P1 flashes white for some time after I flash the bootloader and firmware? This happened with every device I flashed, sometimes I had to reset and even flash it several times before it went into listening mode.
I learned more about chip developing in the last few days than I am confortable with 