STM32が結構使えるよ、という話を聞いたので、しばらく前にAliexpress でSTM32F103C8が載ったボードとST-LINK V2を注文してみました。
デバッグ用?のST-LINK V2とボード2枚で送料込みで$5を切る価格だったと思います。
開発環境はとりあえず Core2 Quad 6600 + メモリ4GB + LinuxMint19 MATE 64bit にArduino環境を突っ込みます。
Arduino 1.8.9 64bit 版をホームディレクトリに展開して
~/arduino-1.8.9$ sudo ./install.sh ~/arduino-1.8.9$ ./arduino-linux-setup.sh $USER
とします。デスクトップへのショートカット作成には失敗してしまいますが、メニューには追加成功するので、そこからデスクトップにショートカットを追加しました。
Arduino IDEを起動したら、ファイル⇒環境設定で「追加のボードマネージャのURL」に
https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json
を追加したあと、ボードマネージャで「STM32 Cores by STMicroelectronics」をインストールします。
完了したら、スケッチ例で Blink を開きます。
ボードに合わせてGeneric STM32F1 Seriesを選択します。選択後、細かい設定ができるようになっていますので、以下のようにしてみました。
ST-LINK V2と基板の各端子を接続して、ST-LINK V2をPCに接続すると予め書き込まれているプログラムが起動するのか、緑のLED(PC13)が点滅します。
ここで、Blinkスケッチの LED_BUILDIN をすべて PC13 に書き換えます。
ビルドしようとすると・・・
Arduino:1.8.9 (Linux), ボード:"Generic STM32F1 series, BluePill F103C8, STM32CubeProgrammer (SWD), Enabled (generic 'Serial'), None, Low/Full Speed, Smallest (-Os default), Newlib Nano (default)" /home/tom/arduino-1.8.9/arduino-builder -dump-prefs -logger=machine -hardware /home/tom/arduino-1.8.9/hardware -hardware /home/tom/.arduino15/packages -tools /home/tom/arduino-1.8.9/tools-builder -tools /home/tom/arduino-1.8.9/hardware/tools/avr -tools /home/tom/.arduino15/packages -built-in-libraries /home/tom/arduino-1.8.9/libraries -libraries /home/tom/Arduino/libraries -fqbn=STM32:stm32:GenF1:pnum=BLUEPILL_F103C8,upload_method=swdMethod,xserial=generic,usb=none,xusb=FS,opt=osstd,rtlib=nano -ide-version=10809 -build-path /tmp/arduino_build_288179 -warnings=none -build-cache /tmp/arduino_cache_521720 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arm-none-eabi-gcc.path=/home/tom/.arduino15/packages/STM32/tools/arm-none-eabi-gcc/8.2.1-1.7 -prefs=runtime.tools.arm-none-eabi-gcc-8.2.1-1.7.path=/home/tom/.arduino15/packages/STM32/tools/arm-none-eabi-gcc/8.2.1-1.7 -prefs=runtime.tools.STM32Tools.path=/home/tom/.arduino15/packages/STM32/tools/STM32Tools/1.3.0 -prefs=runtime.tools.STM32Tools-1.3.0.path=/home/tom/.arduino15/packages/STM32/tools/STM32Tools/1.3.0 -prefs=runtime.tools.CMSIS.path=/home/tom/.arduino15/packages/STM32/tools/CMSIS/5.5.1 -prefs=runtime.tools.CMSIS-5.5.1.path=/home/tom/.arduino15/packages/STM32/tools/CMSIS/5.5.1 -verbose /tmp/arduino_modified_sketch_654796/Blink.ino /home/tom/arduino-1.8.9/arduino-builder -compile -logger=machine -hardware /home/tom/arduino-1.8.9/hardware -hardware /home/tom/.arduino15/packages -tools /home/tom/arduino-1.8.9/tools-builder -tools /home/tom/arduino-1.8.9/hardware/tools/avr -tools /home/tom/.arduino15/packages -built-in-libraries /home/tom/arduino-1.8.9/libraries -libraries /home/tom/Arduino/libraries -fqbn=STM32:stm32:GenF1:pnum=BLUEPILL_F103C8,upload_method=swdMethod,xserial=generic,usb=none,xusb=FS,opt=osstd,rtlib=nano -ide-version=10809 -build-path /tmp/arduino_build_288179 -warnings=none -build-cache /tmp/arduino_cache_521720 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arm-none-eabi-gcc.path=/home/tom/.arduino15/packages/STM32/tools/arm-none-eabi-gcc/8.2.1-1.7 -prefs=runtime.tools.arm-none-eabi-gcc-8.2.1-1.7.path=/home/tom/.arduino15/packages/STM32/tools/arm-none-eabi-gcc/8.2.1-1.7 -prefs=runtime.tools.STM32Tools.path=/home/tom/.arduino15/packages/STM32/tools/STM32Tools/1.3.0 -prefs=runtime.tools.STM32Tools-1.3.0.path=/home/tom/.arduino15/packages/STM32/tools/STM32Tools/1.3.0 -prefs=runtime.tools.CMSIS.path=/home/tom/.arduino15/packages/STM32/tools/CMSIS/5.5.1 -prefs=runtime.tools.CMSIS-5.5.1.path=/home/tom/.arduino15/packages/STM32/tools/CMSIS/5.5.1 -verbose /tmp/arduino_modified_sketch_654796/Blink.ino Using board 'GenF1' from platform in folder: /home/tom/.arduino15/packages/STM32/hardware/stm32/1.6.1 Using core 'arduino' from platform in folder: /home/tom/.arduino15/packages/STM32/hardware/stm32/1.6.1 bash -c "[ -f /tmp/arduino_modified_sketch_654796/build_opt.h ] || (mkdir -p /tmp/arduino_build_288179/sketch && touch /tmp/arduino_build_288179/sketch/build_opt.h)" Detecting libraries used... /home/tom/.arduino15/packages/STM32/tools/arm-none-eabi-gcc/8.2.1-1.7/bin/arm-none-eabi-g++ -mcpu=cortex-m3 -mthumb @/tmp/arduino_build_288179/sketch/build_opt.h -c -Os -w -std=gnu++14 -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -I/tmp/arduino_modified_sketch_654796 -I/home/tom/.arduino15/packages/STM32/hardware/stm32/1.6.1/cores/arduino/avr -I/home/tom/.arduino15/packages/STM32/hardware/stm32/1.6.1/cores/arduino/stm32 -I/home/tom/.arduino15/packages/STM32/hardware/stm32/1.6.1/cores/arduino/stm32/LL -I/home/tom/.arduino15/packages/STM32/hardware/stm32/1.6.1/cores/arduino/stm32/usb -I/home/tom/.arduino15/packages/STM32/hardware/stm32/1.6.1/cores/arduino/stm32/usb/hid -I/home/tom/.arduino15/packages/STM32/hardware/stm32/1.6.1/cores/arduino/stm32/usb/cdc -I/home/tom/.arduino15/packages/STM32/hardware/stm32/1.6.1/system/Drivers/STM32F1xx_HAL_Driver/Inc/ -I/home/tom/.arduino15/packages/STM32/hardware/stm32/1.6.1/system/Drivers/STM32F1xx_HAL_Driver/Src/ -I/home/tom/.arduino15/packages/STM32/hardware/stm32/1.6.1/system/STM32F1xx/ -I/home/tom/.arduino15/packages/STM32/hardware/stm32/1.6.1/system/Middlewares/ST/STM32_USB_Device_Library/Core/Inc -I/home/tom/.arduino15/packages/STM32/hardware/stm32/1.6.1/system/Middlewares/ST/STM32_USB_Device_Library/Core/Src -w -x c++ -E -CC -DSTM32F1xx -DARDUINO=10809 -DARDUINO_BLUEPILL_F103C8 -DARDUINO_ARCH_STM32 "-DBOARD_NAME=\"BLUEPILL_F103C8\"" -DSTM32F103xB -DHAL_UART_MODULE_ENABLED -I/home/tom/.arduino15/packages/STM32/tools/CMSIS/5.5.1/CMSIS/Core/Include/ -I/home/tom/.arduino15/packages/STM32/hardware/stm32/1.6.1/system/Drivers/CMSIS/Device/ST/STM32F1xx/Include/ -I/home/tom/.arduino15/packages/STM32/hardware/stm32/1.6.1/system/Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/ -I/home/tom/.arduino15/packages/STM32/hardware/stm32/1.6.1/cores/arduino -I/home/tom/.arduino15/packages/STM32/hardware/stm32/1.6.1/variants/PILL_F103XX /tmp/arduino_build_288179/sketch/Blink.ino.cpp -o /dev/null Error while detecting libraries included by /tmp/arduino_build_288179/sketch/Blink.ino.cpp Generating function prototypes... /home/tom/.arduino15/packages/STM32/tools/arm-none-eabi-gcc/8.2.1-1.7/bin/arm-none-eabi-g++ -mcpu=cortex-m3 -mthumb @/tmp/arduino_build_288179/sketch/build_opt.h -c -Os -w -std=gnu++14 -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -I/tmp/arduino_modified_sketch_654796 -I/home/tom/.arduino15/packages/STM32/hardware/stm32/1.6.1/cores/arduino/avr -I/home/tom/.arduino15/packages/STM32/hardware/stm32/1.6.1/cores/arduino/stm32 -I/home/tom/.arduino15/packages/STM32/hardware/stm32/1.6.1/cores/arduino/stm32/LL -I/home/tom/.arduino15/packages/STM32/hardware/stm32/1.6.1/cores/arduino/stm32/usb -I/home/tom/.arduino15/packages/STM32/hardware/stm32/1.6.1/cores/arduino/stm32/usb/hid -I/home/tom/.arduino15/packages/STM32/hardware/stm32/1.6.1/cores/arduino/stm32/usb/cdc -I/home/tom/.arduino15/packages/STM32/hardware/stm32/1.6.1/system/Drivers/STM32F1xx_HAL_Driver/Inc/ -I/home/tom/.arduino15/packages/STM32/hardware/stm32/1.6.1/system/Drivers/STM32F1xx_HAL_Driver/Src/ -I/home/tom/.arduino15/packages/STM32/hardware/stm32/1.6.1/system/STM32F1xx/ -I/home/tom/.arduino15/packages/STM32/hardware/stm32/1.6.1/system/Middlewares/ST/STM32_USB_Device_Library/Core/Inc -I/home/tom/.arduino15/packages/STM32/hardware/stm32/1.6.1/system/Middlewares/ST/STM32_USB_Device_Library/Core/Src -w -x c++ -E -CC -DSTM32F1xx -DARDUINO=10809 -DARDUINO_BLUEPILL_F103C8 -DARDUINO_ARCH_STM32 "-DBOARD_NAME=\"BLUEPILL_F103C8\"" -DSTM32F103xB -DHAL_UART_MODULE_ENABLED -I/home/tom/.arduino15/packages/STM32/tools/CMSIS/5.5.1/CMSIS/Core/Include/ -I/home/tom/.arduino15/packages/STM32/hardware/stm32/1.6.1/system/Drivers/CMSIS/Device/ST/STM32F1xx/Include/ -I/home/tom/.arduino15/packages/STM32/hardware/stm32/1.6.1/system/Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/ -I/home/tom/.arduino15/packages/STM32/hardware/stm32/1.6.1/cores/arduino -I/home/tom/.arduino15/packages/STM32/hardware/stm32/1.6.1/variants/PILL_F103XX /tmp/arduino_build_288179/sketch/Blink.ino.cpp -o /tmp/arduino_build_288179/preproc/ctags_target_for_gcc_minus_e.cpp /home/tom/.arduino15/packages/STM32/tools/arm-none-eabi-gcc/8.2.1-1.7/bin/arm-none-eabi-g++: error while loading shared libraries: libiconv.so.2: cannot open shared object file: No such file or directory exit status 127 ボードGeneric STM32F1 seriesに対するコンパイル時にエラーが発生しました。
ということで、「libiconv.so.2」がない、というエラーになってしまいます。
・・・・・うーむ。
(参考)
https://github.com/stm32duino/Arduino_Core_STM32