STM32VLDicovery(ST-Link v1)にFlash書き込み

st-utilとarm-none-eabi-gdbとの組合せで書き込みできないっぽかったので
st-flash writeコマンドを使ってみる
https://github.com/texane/stlink

普通に書き込むとエラーが出る

$ st-flash write bin/main.bin 0x08000000 

2014-07-17T01:40:01 INFO src/stlink-common.c: Loading device parameters....
2014-07-17T01:40:01 INFO src/stlink-common.c: Device connected is: F1 Medium-density Value Line device, id 0x10016420
2014-07-17T01:40:01 INFO src/stlink-common.c: SRAM size: 0x2000 bytes (8 KiB), Flash: 0x3ffe800 bytes (65530 KiB) in pages of 1024 bytes
2014-07-17T01:40:01 INFO src/stlink-common.c: Attempting to write 7212 (0x1c2c) bytes to stm32 address: 134217728 (0x8000000)
Flash page at addr: 0x08001c00 erased
2014-07-17T01:40:01 INFO src/stlink-common.c: Finished erasing 8 pages of 1024 (0x400) bytes
2014-07-17T01:40:01 INFO src/stlink-common.c: Starting Flash write for VL/F0 core id
2014-07-17T01:40:01 INFO src/stlink-common.c: Successfully loaded flash loader in sram
  7/7 pages written
2014-07-17T01:40:02 INFO src/stlink-common.c: Starting verification of write complete
2014-07-17T01:40:02 ERROR src/stlink-common.c: Verification of flash failed at offset: 0
stlink_fwrite_flash() == -1

どうやらst-link v1とst-link v2で動作が異なるらしい。STM32VLDiscoveryはst-link v1とのこと。
v1オプションをつければいけるっぽい。
http://startingelectronics.com/tutorials/STM32-microcontrollers/programming-STM32-flash-in-Linux/

$ st-flash write v1 bin/main.bin 0x08000000

2014-07-17T01:41:27 INFO src/stlink-common.c: Loading device parameters....
2014-07-17T01:41:27 INFO src/stlink-common.c: Device connected is: F1 Medium-density Value Line device, id 0x10016420
2014-07-17T01:41:27 INFO src/stlink-common.c: SRAM size: 0x2000 bytes (8 KiB), Flash: 0x20000 bytes (128 KiB) in pages of 1024 bytes
2014-07-17T01:41:27 INFO src/stlink-sg.c: Successfully opened a stlink v1 debugger
2014-07-17T01:41:27 INFO src/stlink-common.c: Attempting to write 7212 (0x1c2c) bytes to stm32 address: 134217728 (0x8000000)
Flash page at addr: 0x08001c00 erased
2014-07-17T01:41:27 INFO src/stlink-common.c: Finished erasing 8 pages of 1024 (0x400) bytes
2014-07-17T01:41:27 INFO src/stlink-common.c: Starting Flash write for VL/F0 core id
2014-07-17T01:41:27 INFO src/stlink-common.c: Successfully loaded flash loader in sram
  7/7 pages written
2014-07-17T01:41:28 INFO src/stlink-common.c: Starting verification of write complete
2014-07-17T01:41:28 INFO src/stlink-common.c: Flash written and verified! jolly good!