昨日はyottaのことを書いたが、mbed OSを使ったアプリを作ってみた方がよいんじゃないかと思った。
いきなり海に飛び込んで、足が吊ったのと同じようになっているからだ。
Getting Started Guides
一番上に、mbed-driversというのがあるから、それを試してみよう。
mbed-drivers
昨日Windowsにインストールしたyottaを立ち上げ、適当にディレクトリを作って、
(workspace) E:\Prog\mbed\mbed-drivers>yotta install mbed-drivers
info: get versions for mbed-drivers
info: download mbed-drivers@0.11.2 from the public module registry
info: get versions for win
error: could not install target win at for win
error: win does not exist in the targets registry. Check that the name is correct, and that it has been published.
インストールする前にターゲットの切替をするのね。。。
昨日はFreescaleのを選んだけど、もっとふさわしいのはないかねぇ。
とかやっている間に、もっとチュートリアルっぽいのがないか探したところ、こちらが見つかった。
Running your first mbed OS application
Step 2
(workspace) E:\Prog\mbed>cd blinky
(workspace) E:\Prog\mbed\blinky>yotta init
Enter the module name: <blinky>
Enter the initial version: <0.0.0>
Is this an executable (instead of a re-usable library module)? <no> yes
Short description: LED blink test
Author: hiro99ma
What is the license for this project (Apache-2.0, ISC, MIT etc.)? <Apache-2.0>
最初に入力を求められるmodule nameは、デフォルトはフォルダ名になるみたい。
あとは、適当だ。
生成したファイルを見ると、blinkyってのがない。
ヘッダが入るらしいフォルダらしいのだが、まああとで考えよう。
Step 3
次は、targetの検索。
そうそう、これが知りたかったのだ。
今朝の時点では、こうだった(2015/11/07 10:27)。
(workspace) E:\Prog\mbed\blinky>yotta search --limit 1000 target
test-target-dep 0.0.2:
Test Target Test Dependencies
autopulated
st-nucleo-f401re-gcc 0.1.0:
Official mbed build target for the mbed st-nucleo-f401re development board.
mbed-target:nucleo-f401re, mbed-official, nucleo-f401re, gcc
bbc-microbit-classic-armcc 0.1.0:
Official mbed build target for the microbit, using the armcc toolchain.
mbed-target:nrf51822, mbed-official, nrf51822, nordic, armcc, microbit
stm32f429i-disco-gcc 0.0.16:
Official mbed build target for the mbed stm32f429i-disco development board.
mbed-target:discovery-f429zi, mbed-official, stm32f429i-disco, gcc
nordic-nrf51822-16k-gcc 0.0.11:
Official mbed build target for the mbed nrf51822 development board, using the armgcc toolchain.
mbed-target:nrf51822, mbed-official, nrf51822, nordic, gcc
target-onsemi-ncs36510-gcc 0.1.0:
Official mbed build target for .
mbed-official, mbed, onsemi, ncs36510, gcc
st-stm32f439zi-gcc 0.0.4:
Official mbed build target for the st stm32f439zi microcontroller.
mbed-target:nucleo-f439zi, mbed-official, stm32f439i, gcc
nordic-nrf51822-32k-gcc 0.0.8:
Official mbed build target for the nrf51822 32KB chip.
mbed-target:nrf51822, mbed-official, nrf51822, nordic, gcc
stm32f411re-nucleo-gcc 0.1.0:
Official mbed build target for the mbed st-nucleo-f411re development board.
mbed-target:nucleo-f411re, mbed-official, stm32f411re-nucleo, gcc
nordic-nrf51822-16k-armcc 0.0.11:
Official mbed build target for the mbed nrf51822 development board, using the armcc toolchain.
mbed-target:nrf51822, mbed-official, nrf51822, nordic, armcc
bbc-microbit-classic-gcc-nosd 0.1.2:
Official mbed build target for the BBC micro:bit, using the armgcc toolchain, without Softdevice.
mbed-target:nrf51822, mbed-official, nrf51822, nordic, gcc
nrf51dk-gcc 0.0.4:
Official mbed build target for the nRF51-DK 32KB platform.
mbed-official, mbed-target:nrf51_dk, gcc
efm32gg-stk-gcc 0.3.4:
Official mbed build target for the mbed EFM32GG STK3700 development board, using the GCC toolchain.
mbed-target:efm32gg-stk, mbed-official, efm32gg, efm32gg-stk, gcc
nrf51dk-armcc 0.0.4:
Official mbed build target for the nRF51-DK 32KB platform.
mbed-official, mbed-target:nrf51_dk, armcc
bbc-microbit-classic-armcc-nosd 0.1.0:
Official mbed build target for the microbit, using the armcc toolchain, without soft device.
mbed-target:nrf51822, mbed-official, nrf51822, nordic, armcc, microbit
x86-linux-native 1.0.0:
Build target for programs compiled natively for Linux
linux, native
mbed-gcc 0.1.3:
base mbed build target for gcc toolchain
mbed-official, gcc
x86-osx-native 0.0.7:
Build target for programs compiled natively for OS X
libc 0.0.3:
libc shim module: pulls in the platform libc when compiling for nostdlib targets
libc
James Crosby <james.crosby@arm.com>
x86-linux-native-coverage 0.0.3:
Build target for programs compiled natively for Linux with gcov
linux, native, coverage
ublox-odin-w2-gcc 0.0.4:
Official mbed build target for the ublox odin-w2 module.
ublox-odin-w2, mbed-official, odin-w2, gcc
kinetis-k64-armcc 1.0.0:
Official mbed build target for Freescale Kinetis K64 family chips, using the
armcc toolchain.
mbed-official, mbed, kinetis, kinetis-k64, freescale, mk64f, mk64fn1m0vll12, armcc
ublox-c029-gcc 0.0.3:
Official mbed build target for the mbed ublox c029 development board.
ublox-c029, mbed-official, c029, gcc
blenano-gcc 0.0.2:
Unofficial mbed build target for the RedBearLab BLE Nano board
mbed-official, gcc
mkit-gcc 0.0.4:
Official mbed build target for the nrf51822 16KB chip.
mbed-official, gcc
seeedtinyble-gcc 0.0.2:
Official mbed build target for the nrf51822 16KB chip.
nxp-lpc111x-gcc 0.1.1:
Community member maintained build target for the NXP LPC111x using GCC
nxp, lpc1114, lpc111x, lpc11cxx, gcc
Scott Tsai <scottt.tw@gmail.com>
mkit-armcc 0.0.4:
Official mbed build target for the mkit nrf51822 16KB chip.
mbed-official, armcc
mkit-classic-armcc 0.0.1:
mbed classic build target for nrf51822 mkit.
mingw 0.0.1:
Build target for programs compiled natively for Windows via MinGW
bbc-microbit-gcc 0.0.2:
Official mbed build target for the BBC micro:bit chip.
gcc, mbed-official
bbc-microbit-armcc 0.0.2:
Official mbed build target for the BBC micro:bit chip.
armcc, mbed-official
おお、stm32f411re-nucleo-gccというのがあるではないか!
(workspace) E:\Prog\mbed\blinky>yotta target stm32f411re-nucleo-gcc
info: get versions for stm32f411re-nucleo-gcc
info: download stm32f411re-nucleo-gcc@0.1.0 from the public module registry
info: get versions for mbed-gcc
info: download mbed-gcc@0.1.3 from the public module registry
armccとか買えるような身分でもないから、gccでよいのだ。
Step 4
ここで、mbed-driversをインストールするみたいだ。
依存しているもののインストールらしいので、mbed-driversは単独で動くものじゃなくて、文字通りドライバに相当するものということか。
(workspace) E:\Prog\mbed\blinky>yotta install mbed-drivers
info: get versions for mbed-drivers
info: download mbed-drivers@0.11.2 from the public module registry
info: dependency mbed-drivers: ~0.11.2 written to module.json
info: get versions for mbed-hal
info: download mbed-hal@1.0.5 from the public module registry
info: get versions for cmsis-core
info: download cmsis-core@1.0.1 from the public module registry
info: get versions for ualloc
info: download ualloc@1.0.2 from the public module registry
info: get versions for minar
info: download minar@1.0.1 from the public module registry
info: get versions for core-util
info: download core-util@1.0.1 from the public module registry
info: get versions for compiler-polyfill
info: download compiler-polyfill@1.1.1 from the public module registry
info: get versions for mbed-hal-st
info: download mbed-hal-st@1.0.0 from the public module registry
info: get versions for mbed-hal-st-stm32f4
info: download mbed-hal-st-stm32f4@1.0.3 from the public module registry
info: get versions for uvisor-lib
info: download uvisor-lib@1.0.6 from the public module registry
info: get versions for mbed-hal-st-stm32cubef4
info: download mbed-hal-st-stm32cubef4@1.0.2 from the public module registry
info: get versions for cmsis-core-st
info: download cmsis-core-st@1.0.0 from the public module registry
info: get versions for cmsis-core-stm32f4
info: download cmsis-core-stm32f4@1.0.2 from the public module registry
info: get versions for dlmalloc
info: download dlmalloc@1.0.0 from the public module registry
info: get versions for minar-platform
info: download minar-platform@1.0.0 from the public module registry
info: get versions for minar-platform-mbed
info: download minar-platform-mbed@1.0.0 from the public module registry
yotta_modulesというフォルダにいろいろ入ってきた。
Step 5
sourceフォルダにapp.cppというファイルを作って、アプリを書く。
エントリポイントは、main()ではなくapp_start()とのこと。
#include "mbed-drivers/mbed.h"
namespace {
void blinky()
{
static DigitalOut led(LED2);
led = !led;
printf("LED = %d\r\n", led.read());
}
}
void app_start(int argc, char** argv)
{
minar::Scheduer::postCallback(blinky).period(minar::milliseconds(500));
}
Step 6
ビルド!
(workspace) E:\Prog\mbed\blinky>yotta build
(中略)
In file included from E:/Prog/mbed/blinky/yotta_modules/cmsis-core/cmsis-core/cmsis_nvic.h:35:0,
from E:/Prog/mbed/blinky/yotta_modules/uvisor-lib/uvisor-lib/uvisor-lib.h:23,
from E:/Prog/mbed/blinky/yotta_modules/uvisor-lib/source/unsupported.cpp:17:
E:/Prog/mbed/blinky/yotta_modules/cmsis-core-stm32f4/cmsis-core-stm32f4/cmsis.h:
35:23: fatal error: stm32f4xx.h: No such file or directory
#include "stm32f4xx.h"
^
おーーーい!!
以下を、blinky\yotta_modules\cmsis-core-stm32f4\cmsis-core-stm32f4にコピーすると、進んだ。
mbed/stm32f4xx.h at master · mbedmicro/mbed
mbed/stm32f411xe.h at master · mbedmicro/mbed
mbed/stm32f4xx_hal_conf.h at master · mbedmicro/mbed
が、今度はこんなエラーが。
E:/Prog/mbed/blinky/yotta_modules/mbed-drivers/mbed-drivers/platform.h:21:20: fatal error: device.h: No such file or directory
#include "device.h"
^
これは、NUCLEOって感じね。
FRDM-K64Fだと、yotta_modules\mbed-hal-frdm-k64f\mbed-hal-frdm-k64fに揃っていた。
mbedのコンパイルサイトで見てみると、mbed-src/targets/hal/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F411REに中にあるものがそれっぽい。

これをexportして、解凍したファイルから適当に見繕って、yotta_modules\mbed-hal-st-stm32f4にコピーした。
E:/Prog/mbed/blinky/yotta_modules/minar-platform-mbed/minar-platform/minar_platform_types.h:29:17: error: 'MINAR_PLATFORM_TIME_BASE' was not declared in this scope
Time_Base = MINAR_PLATFORM_TIME_BASE,
^
これは、mbed-drivers\yotta_modules\mbed-hal-frdm-k64f\mbed-hal-frdm-k64f\target_config.hにあるんだけど、値の意味がわからん。
mbed-hal-st-stm32f429zi/mbed-hal-st-stm32f429zi at master · ARMmbed/mbed-hal-st-stm32f429zi
ここはSTM32F429ZIなんだけど、これだとdevice.hとかtarget_config.hなんかもある。
https://github.com/ARMmbed?utf8=%E2%9C%93&query=stm
検索しても、STM32F411はないなぁ。
もしかして、yotta buildする最初のメッセージの「unsupported platform」がすべての原因なのか?
*******************************************************************
* WARNING (uvisor-lib): unsupported platform; your code will still
* work but no security feature is provided;
* UVISOR_DISABLED is set by default
*******************************************************************
試しに、
(workspace) E:\Prog\mbed\blinky>yotta target stm32f429i-disco-gccしてからyotta buildすると、そういうメッセージは出ない。
でも、ビルドはやはりうまく行かない。
objects.hとか、その辺が関係しそうだ。。。
https://github.com/ARMmbed/mbed-hal
ここに、移植の際の説明が書かれている。
- mbed-hal
- mbed-hal-<vendor>
- mbed-hal-<vendor>-<chip family>
- mbed-hal-<vendor>-<chip>
- mbed-hal-<vendor>-<target>
が基本的な階層らしい。
いま私が使っている構成を見ると、こうなっている。
- mbed-hal
- mbed-hal-st
- mbed-hal-st-stm32f4
mbed-hal-st-stm32cubef4
うん、<target>に相当するものがないですね。
それに、さっきコピーしたPeripheralNames.hなんかは<chip-family>にあるべきもの。
それがmbed-hal-st-stm32f4に入っていなかったことからすると、まだこの辺はSTM32向けには整備されてないのかもしれない。
よし、今回は断念だ!