Raspberry PiにSTM32F411REを繋いでLED点滅させる

Raspberry PiにSTM32F411REを繋ぎ、mbedオンラインコンパイラコンパイルしてできた.binを書き込み、LED点滅させるまでにやったこと。
※STM32F411REに電源供給すれば、あらかじめ書き込まれているプログラムが実行されてLED点滅する。

Raspberry PiのUSBポートにSTM32F411REを接続すれば自動認識される。

$ dmesg
<snip>
[    3.386473] usb 1-1.2: Product: STM32 STLink
[    3.393662] usb 1-1.2: Manufacturer: STMicroelectronics
[    3.400817] usb 1-1.2: SerialNumber: 0673FF514951775087035535
[    3.466354] usb-storage 1-1.2:1.1: USB Mass Storage device detected
[    3.489401] scsi0 : usb-storage 1-1.2:1.1
<snip>
[    4.490367] scsi 0:0:0:0: Direct-Access     MBED     microcontroller  1.0  PQ: 0 ANSI: 2
<snip>
. It is not a modem.
[    7.146527] cdc_acm 1-1.2:1.2: ttyACM0: USB ACM device

USBデバイス一覧の中に確認できる。

$ lsusb
<snip>
Bus 001 Device 004: ID 0483:374b SGS Thomson Microelectronics

マウントもされている。

$ df
Filesystem     1K-blocks    Used Available Use% Mounted on
rootfs          15104000 1865976  12588232  13% /
/dev/root       15104000 1865976  12588232  13% /
devtmpfs          219744       0    219744   0% /dev
tmpfs              44784     264     44520   1% /run
tmpfs               5120       0      5120   0% /run/lock
tmpfs              89560       0     89560   0% /run/shm
/dev/mmcblk0p1     57288    9904     47384  18% /boot
/dev/sda              16      16         0 100% /media/NUCLEO

オンラインコンパイラコンパイルしてできたプログラム(.bin)をコピーしたら失敗。

$ cp Nucleo_blink_led_NUCLEO_F411RE.bin /media/NUCLEO/
cp: writing `/media/NUCLEO/Nucleo_blink_led_NUCLEO_F411RE.bin': No space left on device
cp: failed to extend `/media/NUCLEO/Nucleo_blink_led_NUCLEO_F411RE.bin': No space left on device

下記ページを参考にして、firmwareのアップデートとST-Linkドライバのインストールを試みる。
Preparing the STM32 Nucleo Board - | mbed

$ unzip stlinkupgradev2j23m6.zip
Archive:  stlinkupgradev2j23m6.zip
   creating: STLinkUpgradeV2J23/
  inflating: STLinkUpgradeV2J23/ST-LinkUpgrade.exe
  inflating: STLinkUpgradeV2J23/STLinkUSBDriver.dll
pi@raspberrypi ~/stm32 $ unzip stlinknucleodriversigned.zip
Archive:  stlinknucleodriversigned.zip
  inflating: STLinkNucleoDriverSigned/dpinst_amd64.exe
  inflating: STLinkNucleoDriverSigned/dpinst_x86.exe
<snip>

Windows環境でないとダメそうなので、あきらめて別の方法を探して有益な情報にたどりつく。
Uploading .bin files to STM32 Nucleo in Linux. | mbed
Programming STM32 Microcontroller Flash in Linux

1. libusbをインストール

$ sudo apt-get install libusb-1.0.0-dev
<snip>

2. stlinkをインストール

$ git clone https://github.com/texane/stlink stlink.git
もしくは
$ wget https://github.com/texane/stlink/archive/master.zip
<snip>
$ unzip master.zip
<snip>
$ cd stlink-master/
$ ./autogen.sh 
autoreconf: Entering directory `.'
<snip>
$ ./configure
checking for a BSD-compatible install... /usr/bin/install -c
<snip>
$ make 
Making all in .
<snip>
$sudo make install
Making install in .
<snip>
$ sudo cp *.rules /etc/udev/

3. st-flashコマンドで書き込む

$ sudo st-flash write Nucleo_blink_led_NUCLEO_F411RE.bin 0x8000000
2015-01-04T16:36:21 INFO src/stlink-common.c: Loading device parameters....
2015-01-04T16:36:21 INFO src/stlink-common.c: Device connected is: F4 device (low power) - stm32f411re, id 0x10006431
2015-01-04T16:36:21 INFO src/stlink-common.c: SRAM size: 0x20000 bytes (128 KiB), Flash: 0x80000 bytes (512 KiB) in pages of 16384 bytes
2015-01-04T16:36:21 INFO src/stlink-common.c: Attempting to write 13408 (0x3460) bytes to stm32 address: 134217728 (0x8000000)
EraseFlash - Sector:0x0 Size:0x4000
Flash page at addr: 0x08000000 erased
2015-01-04T16:36:21 INFO src/stlink-common.c: Finished erasing 1 pages of 16384 (0x4000) bytes
2015-01-04T16:36:21 INFO src/stlink-common.c: Starting Flash write for F2/F4
2015-01-04T16:36:21 INFO src/stlink-common.c: Successfully loaded flash loader in sram
size: 13408
2015-01-04T16:36:21 INFO src/stlink-common.c: Starting verification of write complete
2015-01-04T16:36:21 INFO src/stlink-common.c: Flash written and verified! jolly good!

4. ピカピカ。やったね。

プログラムが反映されなければ、STM32F411RE上のRESETボタン(黒いスイッチ)を押してみたり。
尚、./autogenを実行したときに"autoreconfがないよ"って言われたら、autoconfをインストールする。

$ ./autogen.sh
./autogen.sh: 2: ./autogen.sh: autoreconf: not found
$ sudo apt-get install autoconf
<snip>