過去に以下のようなブログを書いてみました。 https://users.atmark-techno.com/blog/750/774 上記ブログと同じことを、Armadillo-840のカーネルバージョン3.4で動作できるかどうか試してみたいと思います。 -------------------------------------------------------------------------------------------------------------- 1. ATDE5をダウンロード -------------------------------------------------------------------------------------------------------------- Armadillo-IoTの開発環境であるATDE5を以下からダウンロードします。 http://armadillo.atmark-techno.com/armadillo-iot/downloads [開発環境] -- [ATDE] ATDE5の起動方法は以下を参照してください。 http://manual.atmark-techno.com/armadillo-iot/armadillo-iotg-std_product_manual_ja-2.0.0/ch04.html#sct.before-work.setup-atde5 -------------------------------------------------------------------------------------------------------------- 2. ソースコードのダウンロードと展開 -------------------------------------------------------------------------------------------------------------- 2.1 Armadillo-840のソースコードをダウンロードします。 atmark@atde5:~$ wget http://armadillo.atmark-techno.com/files/downloads/armadillo-840/source/linux-3.4-at15.tar.gz atmark@atde5:~$ wget http://armadillo.atmark-techno.com/files/downloads/armadillo-840/source/atmark-dist-20150727.tar.gz 2.2 ソースコードを展開します。 atmark@atde5:~$ tar zxf atmark-dist-20150727.tar.gz atmark@atde5:~$ tar zxf linux-3.4-at15.tar.gz atmark@atde5:~$ ln -s atmark-dist-20150727 atmark-dist atmark@atde5:~$ cd atmark-dist atmark@atde5:~/atmark-dist$ ln -s ../linux-3.4-at15 ./linux-3.x -------------------------------------------------------------------------------------------------------------- 3. カーネルのカスタマイズ -------------------------------------------------------------------------------------------------------------- 3.1 make menuconfigでvendor/Productを指定します atmark@atde5:~/atmark-dist$ make menuconfig Main Menu Vendor/Product Selection ---> (AtmarkTechno) Vendor (Armadillo-840) AtmarkTechno Products 3.2 カーネルコンフィギュレーションでBluetoothを有効にします Linux Kernel Configuration [*] Networking support ---> --- Bluetooth subsystem support <*> RFCOMM protocol support  ←チェックをつける [*] RFCOMM TTY support   ←チェックをつける <*> BNEP protocol support ←チェックをつける [*] Multicast filter support ←チェックをつける [*] Protocol filter support ←チェックをつける <*> HIDP protocol support ←チェックをつける Bluetooth device drivers ---> <*> HCI USB driver ←チェックをつける -------------------------------------------------------------------------------------------------------------- 4. ビルドを実行 -------------------------------------------------------------------------------------------------------------- 4.1 ビルドを実行します。 atmark@atde5:~/atmark-dist$ make -------------------------------------------------------------------------------------------------------------- 5. Bluezをビルド -------------------------------------------------------------------------------------------------------------- 5.1 Bluez 5.33をダウンロードして展開します。(2015.8.24時点での最新は5.33です) atmark@atde5:~$ wget http://www.kernel.org/pub/linux/bluetooth/bluez-5.33.tar.xz atmark@atde5:~$ tar Jxf bluez-5.33.tar.xz 5.2 libicalのクロスパッケージをインストールします atmark@atde5:~$ wget http://ftp.jp.debian.org/debian/pool/main/libi/libical/libical0_0.48-2_armhf.deb atmark@atde5:~$ dpkg-cross -v --build --arch armhf libical0_0.48-2_armhf.deb atmark@atde5:~$ sudo dpkg -i libical0-armhf-cross_0.48-2_all.deb atmark@atde5:~$ wget http://ftp.jp.debian.org/debian/pool/main/libi/libical/libical-dev_0.48-2_armhf.deb atmark@atde5:~$ dpkg-cross -v --build --arch armhf libical-dev_0.48-2_armhf.deb atmark@atde5:~$ sudo dpkg -i libical-dev-armhf-cross_0.48-2_all.deb 5.3 configureを実行します atmark@atde5:~$ cd bluez-5.33/ atmark@atde5:~/bluez-5.33$ ./configure --build=i686 --host=arm-linux-gnueabihf --disable-udev --disable-systemd --prefix=/usr 5.4 makeを実行します atmark@atde5:~/bluez-5.33$ make 5.5 make installを実行します。 DESTDIRには手順4でビルドした後に生成されるAtmark Distのromfsフォルダを指定してください。 atmark@atde5:~/bluez-5.33$ make install DESTDIR=/home/atmark/atmark-dist/romfs/ 5.6 不要なファイルを削除します。 atmark@atde5:~/bluez-5.33$ rm -rf /home/atmark/atmark-dist/romfs/usr/share/man/ 5.7 gatttoolを手動でインストールします。 atmark@atde5:~/bluez-5.33$ cp attrib/gatttool /home/atmark/atmark-dist/romfs/usr/bin/ -------------------------------------------------------------------------------------------------------------- 6. D-busをatmark distにインストール -------------------------------------------------------------------------------------------------------------- 6.1 DebianパッケージのD-busをダウンロードします atmark@atde5:~/bluez-5.32$ cd atmark@atde5:~$ wget http://security.debian.org/debian-security/pool/updates/main/d/dbus/dbus_1.6.8-1+deb7u6_armhf.deb 6.2 D-busパッケージをatmark distのROMイメージディレクトリに展開します atmark@atde5:~$ dpkg -x dbus_1.6.8-1+deb7u6_armhf.deb atmark-dist/romfs/ 6.3 不要なドキュメントファイルなどを削除します atmark@atde5:~$ rm -rf atmark-dist/romfs/usr/share/doc atmark@atde5:~$ rm -rf atmark-dist/romfs/usr/share/man 6.4 D-busが必要とするinit-funcionsをatmark distのROMイメージディレクトリに展開します atmark@atde5:~$ wget http://ftp.jp.debian.org/debian/pool/main/l/lsb/lsb-base_4.1+Debian8+deb7u1_all.deb atmark@atde5:~$ dpkg -x lsb-base_4.1+Debian8+deb7u1_all.deb atmark-dist/romfs/ atmark@atde5:~$ rm -rf atmark-dist/romfs/usr/share/doc 6.5 D-busデーモンを実行するユーザ/グループを追加します atmark@atde5:~$ vi atmark-dist/vendors/AtmarkTechno/Armadillo-840/etc/passwd ファイル末尾に以下の行を追加します messagebus:x:101:105::/var/run/dbus:/bin/false atmark@atde5:~$ vi atmark-dist/vendors/AtmarkTechno/Armadillo-840/etc/group ファイル末尾に以下の行を追加します messagebus:x:105: -------------------------------------------------------------------------------------------------------------- 7. イメージを再作成して、カーネル/ユーザーランドをArmadilloに書き込みます -------------------------------------------------------------------------------------------------------------- atmark@atde5:~$ cd atmark-dist atmark@atde5:~/atmark-dist$ make romfs atmark@atde5:~/atmark-dist$ make image Armadilloへの書き込み方法は以下のマニュアルを参照してください。 http://manual.atmark-techno.com/armadillo-840/armadillo-840_product_manual_ja-1.6.0/ch12.html -------------------------------------------------------------------------------------------------------------- 8. BLEデバイスからのアドバタイズパケットを受信してみます。 -------------------------------------------------------------------------------------------------------------- 8.1 今回使用するBluetoothモジュールは以下になります USBドングル : http://www.princeton.co.jp/product/ptmubt7.html BLEデバイス : http://www.logitec.co.jp/products/bluetooth/lbtmpvru02/ 9.2 USBドングルを認識しているか確認します [root@armadillo840-0 (ttySC2) ~]# hciconfig hci0: Type: BR/EDR Bus: USB BD Address: 00:1B:DC:06:C0:41 ACL MTU: 310:10 SCO MTU: 64:8 DOWN RX bytes:467 acl:0 sco:0 events:18 errors:0 TX bytes:317 acl:0 sco:0 commands:18 errors:0 9.3 USBドングルを有効にします [root@armadillo840-0 (ttySC2) ~]# hciconfig hci0 up 9.4 BLEデバイスを検索します [root@armadillo-iotg (ttymxc1) ~]# hcitool lescan LE Scan ... 44:13:19:05:A8:5B LBT-VRU0234 44:13:19:05:A8:5B (unknown) (Ctrl-Cで停止) BLEデバイスが検索できていることがわかります。 9.5 BLEデバイスの検索をバックグラウンドで動かします。 [root@armadillo840-0 (ttySC2) ~]# hcitool lescan 2>&1 > /dev/null & 9.6 アドバタイズパケットを受信した内容をダンプしてみます。 [root@armadillo840-0 (ttySC2) ~]# hcidump HCI sniffer - Bluetooth packet analyzer ver 5.33 device: hci0 snap_len: 1500 filter: 0xffffffff > HCI Event: LE Meta Event (0x3e) plen 36 LE Advertising Report ADV_NONCONN_IND - Non connectable undirected advertising (3) bdaddr 32:22:11:3F:7B:77 (Public) Flags: 0x05 Unknown type 0xff with 6 bytes data Complete local name: 'BLECAST_BL.' RSSI: -76 > HCI Event: LE Meta Event (0x3e) plen 38 LE Advertising Report ADV_IND - Connectable undirected advertising (0) bdaddr 44:13:19:05:A8:5B (Public) Flags: 0x06 Complete service classes: 0x1803 0x1802 0x1804 0x180f Complete local name: 'LBT-VRU0234' RSSI: -58 > HCI Event: LE Meta Event (0x3e) plen 12 LE Advertising Report SCAN_RSP - Scan Response (4) bdaddr 44:13:19:05:A8:5B (Public) RSSI: -58 > HCI Event: LE Meta Event (0x3e) plen 38 LE Advertising Report ADV_IND - Connectable undirected advertising (0) bdaddr 44:13:19:05:A8:5B (Public) Flags: 0x06 Complete service classes: 0x1803 0x1802 0x1804 0x180f Complete local name: 'LBT-VRU0234' RSSI: -64 以上