Firebase Functionsをnode8で動かす
Tips on developing Firebase
Technical knowledge base by pigmal, LLC
last update: 2018-12-26 00:00:00 +0000
tomuはUSBタイプAのポートにすっぽりとはまる、超小型のマイコンボードで、2つのボタン(タッチセンサ)と2つのLEDを搭載し、USBからの給電で動作します。
設計情報はすべてオープンソースで、PCBやケースを含めて12点の部品でできています。
USB DFU(Device Firmware Update)に対応しているので、専用ツールを必要とせずに、プログラムを書き込めます。
主なスペック
CPU: Silicon Labs Happy Gecko EFM32HG309
Clock: 25 MHz ARM Cortex-M0+
RAM: 8 KB
Flash: 64 KB フラッシュ
Interface:USB 2.0 FS
ボタン: 2
LED: 2 (赤 + 緑)
入手方法
国内ではスイッチサイエンスで販売しています。
https://www.switch-science.com/catalog/5254/
quick startに従って開発環境を構築していきます。プログラムをビルドしてtomuに書き込んで実行するには以下3つのツールが必要です。
An ARM toolchain
ARMの開発者向けページ( [GNU Toolchain | GNU Arm Embedded Toolchain – Arm Developer](https://developer.arm.com/open-source/gnu-toolchain/gnu-rm) )からDLするのが確実ですが、ここではpx4というオープンソースドローンのプロジェクトが公開しているformulaを使ってbrewでインストールする方法をご紹介します。 |
以下コマンドでインストールします。
$ brew tap PX4/homebrew-px4
$ brew update
$ brew install gcc-arm-none-eabi
Make
MakeはXCodeにバンドルされています。XCodeをインストールしていない場合はインストールして、以下のようにコマンドが実行出来ることを確認しておきます。
$ make -v
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
This program built for i386-apple-darwin11.3.0
dfu-utils
tomuはUSB DFU(Device Firemware Update)という標準仕様に準拠しているため、専用のツールを必要とせずに、DFU用の汎用ツールでファームウェアを書き込めます。
dfu-utilはbrewでインストールできます。
$ brew install dfu-util
エラーが出る場合は
$ brew doctor
を実行して、表示される指示に従います。
githubからサンプルコードを取得します。
$ git clone git@github.com:im-tomu/tomu-quickstart.git
$ cd tomu_quickstart
このリポジトリに以下サンプルが含まれています。
bare-minimum | Does nothing, forever, without crashing. |
miniblink | Blink the two LEDs using the SysTick timer. |
usb-hid | Emulate a USB mouse, and wiggle the cursor back and forth. |
usb-msc | Emulate a very small “USB Mass Storage” disk drive. |
usb-midi | Provide a USB MIDI device that continuously sends NoteOn and NoteOff events. |
usb-cdcacm | Communicate with Tomu over a virtual serial port. |
opticspy |
tomuをUSBポートに差し込み、任意のディレクトリ内でmakeし、dfu-utilでtomuに新しいファームウェアを書き込みます。
$ cd usb-hid-keyboard
$ make
$ dfu-util --download usb-hid-keyboard.dfu
Tomuは、ファームウェアの書き込みだけであれば、上記のような手順を踏まずに、WebUSB仕様に基づいて、ブラウザからファームウェア書き込みが出来ます。
TomuをUSBポートに差し込むと、bootloaderを認識したとポップアップメッセージが出るのでクリックすると、以下ページが開きます。
https://dfu.tomu.im/
こちらのWebUI上で、以下の手順でファームウェアを書き込みます。
dapboot DFU bootloader
を選択しconnect
ボタンをクリックTomu Bootloader
を選択してconnect
Choose file
ボタンを押して書き込む.dfuファイルを選択し、download
ボタンをクリックで書き込み開始