OK. So I got the ST-Link/V2 working nicely yesterday with st-util
and st-flash
on my Mac (see two posts back.) Then I go to bed, wake up, brush my teeth, take a shower etc, only to find that it no longer works, at all. I have changed NOTHING.
Even stranger, my Olimex ARM-USB-OCD that was giving me all kinds of grief until I purchased the ST-Link/V2 to fix all that, is now working without a glitch!! WTF?! So confused.
[emotional-rant]
I have never in my 20 odd years of playing with microcontrollers ever had such random, unreliability with programmers and debuggers (Intel 8051, Microchip PIC 8/16/32 bit, Atmel AVR) as I have since starting to play with ST ARM chips. It's very frustrating and difficult to understand what is going on. Am I the only one? Is there some conspiracy that I don't know about? 
[/emotional-rant]
The first clue that something was wrong was the difference seen in the following two examples. The first is from yesterday, thanks to not closing the terminal window and being able to scroll back. Note the Flash size being reported by st-util
...
Yesterday ...
$ st-util
2014-04-18T17:07:58 INFO src/stlink-usb.c: -- exit_dfu_mode
2014-04-18T17:07:58 INFO src/stlink-common.c: Loading device parameters....
2014-04-18T17:07:58 INFO src/stlink-common.c: Device connected is: F1 Medium-density device, id 0x20036410
2014-04-18T17:07:58 INFO src/stlink-common.c: SRAM size: 0x5000 bytes (20 KiB), Flash: 0 bytes (0 KiB) in pages of 1024 bytes
Chip ID is 00000410, Core ID is 1ba01477.
Target voltage is 3217 mV.
Listening at *:4242...
And today ...
$ ./st-util
2014-04-15T19:48:52 INFO src/stlink-usb.c: -- exit_dfu_mode
2014-04-15T19:48:52 INFO src/stlink-common.c: Loading device parameters....
2014-04-15T19:48:52 INFO src/stlink-common.c: Device connected is: F1 Medium-density device, id 0x20036410
2014-04-15T19:48:52 INFO src/stlink-common.c: SRAM size: 0x5000 bytes (20 KiB), Flash: 0x20000 bytes (128 KiB) in pages of 1024 bytes
Chip ID is 00000410, Core ID is 1ba01477.
Target voltage is 3229 mV.
Listening at *:4242...
The next and arguably more serious sign that things were not right came when running GDB and noting the initial (corrupted) PC address ...
$ arm-none-eabi-gdb -x gdb-st.rc ../build/core-firmware.elf
GNU gdb (GNU Tools for ARM Embedded Processors) 7.6.0.20131129-cvs
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-apple-darwin10 --target=arm-none-eabi".
For bug reporting instructions, please see:
http://www.gnu.org/software/gdb/bugs/...
Reading symbols from /Users/bryan/sparkcore/core-firmware/build/core-firmware.elf...done.
0x8a3442ba in ?? ()
Nope. That just aint right at all.
FWIW, here's what OpenOCD had to say, using the Olimex ARM-USB-OCD ...
$ openocd -f interface/ftdi/olimex-arm-usb-ocd.cfg -f target/stm32f1x.cfg
Open On-Chip Debugger 0.8.0-rc1 (2014-04-13-19:52)
Licensed under GNU GPL v2
For bug reports, read
OpenOCD: Bug Reporting
Info : only one transport option; autoselect 'jtag'
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
jtag_ntrst_delay: 100
cortex_m reset_config sysresetreq
Info : clock speed 1000 kHz
Info : JTAG tap: stm32f1x.cpu tap/device found: 0x3ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x3)
Info : JTAG tap: stm32f1x.bs tap/device found: 0x16410041 (mfg: 0x020, part: 0x6410, ver: 0x1)
Info : stm32f1x.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : accepting 'gdb' connection from 3333
Info : device id = 0x20036410
Info : flash size = 128kbytes
undefined debug reason 7 - target needs reset
Info : JTAG tap: stm32f1x.cpu tap/device found: 0x3ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x3)
Info : JTAG tap: stm32f1x.bs tap/device found: 0x16410041 (mfg: 0x020, part: 0x6410, ver: 0x1)
And the related, successful GDB session ...
$ arm-none-eabi-gdb -x gdb.rc ../build/core-firmware.elf
GNU gdb (GNU Tools for ARM Embedded Processors) 7.6.0.20131129-cvs
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-apple-darwin10 --target=arm-none-eabi".
For bug reporting instructions, please see:
http://www.gnu.org/software/gdb/bugs/...
Reading symbols from /Users/bryan/sparkcore/core-firmware/build/core-firmware.elf...done.
0x00000000 in ?? ()
JTAG tap: stm32f1x.cpu tap/device found: 0x3ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x3)
JTAG tap: stm32f1x.bs tap/device found: 0x16410041 (mfg: 0x020, part: 0x6410, ver: 0x1)
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x0800010c msp: 0x20005000
(gdb) break main
Breakpoint 1 at 0x80057ec: file ../src/main.cpp, line 156.
(gdb) c
Continuing.
Note: automatically using hardware breakpoints for read-only addresses.
Breakpoint 1, main () at ../src/main.cpp:156
156 {
(gdb) c
Continuing.
Much better.
So, you tell me. Everyone is saying the ST-Link/V2 is THE way to go with the Sparkcore. But I cannot even get mine to work at all under its intended Windows environment -- and although it worked for a day yesterday on my Mac, today it does not. I suppose it could be faulty, somehow. Perhaps I'll buy another one, just to try and get to the bottom of this. Thankfully, they're not too expensive.