BluePillシリーズはARM系のSTM32が載ったボードで
恐ろしく低価格なのに使いやすいというボードです。
RobotDyn STM32F103 Dev.BoardはそんなBluePillシリーズの一つ。
本家のサイト(海外)から調達すると、なんと2.5USD……どういうことなの(
RobotDyn本家のサイトより引用
$ cd Documents/Arduino/hardware/
ボード情報を追加。どうせなのでgitから取りましょう。
$ git clone https://github.com/rogerclarkmelbourne/Arduino_STM32.git
Arduino IDEを再起動してやり、ボードリストにSTM32系が追加されている事を確認。*1
ブートローダー導入
USBシリアル変換器を用意します。
私が使ったのはコレ。
FTDI USBシリアル変換アダプター(5V/3.3V切り替え機能付き)
- 出版社/メーカー: スイッチサイエンス(Switch Science)
- メディア: おもちゃ&ホビー
- この商品を含むブログを見る
RXはA9、TXはA10に、後電源系を該当するところにジャンパ線でつなぎます。
動作電圧は3.3Vなので、切り替えスイッチは指す前に確認してくださいね。
PCに戻り、ボード設定をします。
$ cd $ cd Documents/Arduino/hardware/Arduino_STM32/tools/macosx/stm32flash/
ブートローダー用バイナリを導入
$ curl -OL https://github.com/rogerclarkmelbourne/STM32duino-bootloader/raw/master/binaries/generic_boot20_pc13.bin
書き込み
$ ./stm32flash -w ./generic_boot20_pc13.bin -v -g 0x0 /dev/tty.usbserial-HOGEFUGA
実行すると、最終的にはこんな表示がでるはず。
stm32flash Arduino_STM32_0.9 http://github.com/rogerclarkmelbourne/arduino_stm32 Using Parser : Raw BINARY Interface serial_posix: 57600 8E1 Version : 0x22 Option 1 : 0x00 Option 2 : 0x00 Device ID : 0x0410 (Medium-density) - RAM : 20KiB (512b reserved by bootloader) - Flash : 128KiB (sector size: 4x1024) - Option RAM : 16b - System RAM : 2KiB Write to memory Erasing memory Wrote and verified address 0x08005294 (100.00%) Done. Starting execution at address 0x08000000... done.
Lチカ書き込み
ターゲットボードを"Generic STM32F103C board"と設定します。
ボードを読み込むとIDEからスケッチ例が呼び出せるようになります。
まぁまずは伝統のLチカ。
動いているか確認するため、少し手を加えます。
動作LEDは"PC13"に割当されているので、PB1をPC13に書き換え。
ついでに点滅周期をお好みで弄ります。
// the setup function runs once when you press reset or power the board void setup() { // Power LED is PC13. pinMode(PC13, OUTPUT); } // the loop function runs over and over again forever void loop() { digitalWrite(PC13, HIGH); // turn the LED on (HIGH is the voltage level) delay(2000); // wait for a second digitalWrite(PC13, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second }