Skip to content

Instantly share code, notes, and snippets.

@nidate
Last active August 7, 2022 08:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nidate/48818c520f49f8f0d883 to your computer and use it in GitHub Desktop.
Save nidate/48818c520f49f8f0d883 to your computer and use it in GitHub Desktop.
Raspberry Pi Zero

Raspberry PI ZERO を入手した

セットアップ

https://learn.adafruit.com/introducing-the-raspberry-pi-zero?view=all

の通り進めていけば良い。

基本的にRuspbianをダウンロードし、https://github.com/RayViljoen/Raspberry-PI-SD-Installer-OS-X でMicro SDに書き込めば起動できる状態になる。

パッケージダウンロード

Raspbianのオフィシャルダウンロードページが遅いのでミラーを使う。 https://www.raspbian.org/RaspbianMirrors

/etc/apt/sources.list もミラーを使うように直しておく。

#deb http://mirrordirector.raspbian.org/raspbian/ jessie main contrib non-free rpi
deb http://ftp.jaist.ac.jp/pub/Linux/raspbian-archive/raspbian/ jessie main contrib non-free rpi
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
#deb-src http://archive.raspbian.org/raspbian/ jessie main contrib non-free rpi
deb-src http://ftp.jaist.ac.jp/pub/Linux/raspbian-archive/raspbian/ jessie main contrib non-free rpi

Wi-Fiアダプタの設定

Planex GW-USNANO2AなどはRaspbianのデフォルトで認識するらしいが、アキバを数件見ても置いているところがなかった。(2015-12現在)

入手が容易だったIO-DATA WN-G150UM はデフォルトでは認識しない。

を参考に以下のように書き換えることで利用できる。

/etc/udev/rules.d/network_drivers.rules

ACTION=="add",SUBSYSTEMS=="usb",ATTRS{idVendor}=="04bb",ATTRS{idProduct}=="094c",RUN+="/sbin/modprobe -qba 8192cu"

/etc/modprobe.d/network_drivers.conf

install 8192cu /sbin/modprobe --ignore-install 8192cu $CMDLINE_OPTS; /bin/echo "04bb 094c" > /sys/bus/usb/drivers/rtl8192cu/new_id

/etc/modprobe.d/8192cu.conf

# Disable power management
options 8192cu rtw_power_mgnt=0 rtw_enusbss=0

2022-08現在 rtl8192cuドライバを使う。

/etc/udev/rules.d/network_drivers.rules

ACTION=="add",SUBSYSTEMS=="usb",ATTRS{idVendor}=="04bb",ATTRS{idProduct}=="094c",RUN+="/sbin/modprobe -qba rtl8192cu"

/etc/modprobe.d/network_drivers.conf

install rtl8192cu /sbin/modprobe --ignore-install rtl8192cu $CMDLINE_OPTS; /bin/echo "04bb 094c" > /sys/bus/usb/drivers/rtl8192cu/new_id

Wi-Fiパスワードの設定

wpa_passphrase コマンドを利用して、/etc/wpa_supplicant/wpa_supplicant.conf にパスフレーズを書き込む。 コメントで生パスワードが書かれるので消しておくこと。

$ sudo sh -c 'wpa_passphrase SSID PASSPHRASE >> /etc/wpa_supplicant/wpa_supplicant.conf'

ネットワーク設定

デフォルトのavahi(Zeroconf,Bonjour)に任せて ruspberrypi.local のホスト名で繋げられるようにした。

ヘッドレスで初期設定したい

Raspbian各種設定をする時、オフィシャルなドキュメントではUSBキーボードとHDMIの映るディスプレイをつなげて、通常コンソールから行うように書かれている。

インストール時に作成するSDカードをLinuxマシンでマウントし、/etc以下のWi-Fi設定などのファイルを書き換えてから起動させればヘッドレスで初期設定ができる。 本当はMac上で完結させたかったが、調べたところではOSXからext4を書き込むのは難しいようだ。

vfat fsの/bootパーティションを利用することで、容易に設定変更できるのではないかと思っている。 -> 2022-08現在では、Raspberry PI Imagerを使って設定できるようになっている。

キーボードの配列が違う

USBキーボードをつなげて101キーボードを使っているのに、2の上が@じゃない!おかしい!となったとき。

$ sudo dpkg-reconfigure keyboard-configuration
$ sudo service keyboard-setup restart

https://wiki.debian.org/Keyboard

Desktop

https://www.raspbian.org/RaspbianMate

sudo apt-get install mate-core mate-desktop-environment

~/.xinitrc に追加

exec mate-session

vnc

apt-get install vnc4server

を入れて、~/.vnc/xstartupの以下をコメントに従ってコメントアウト。

# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc

vncserverコマンドでサーバを立ち上げる。

OSXからはFinderの「サーバへ接続(Cmd+K)」でvnc://raspberrypi.local:5901に接続すれば使える。

日本語環境

http://www.mztn.org/rpi/rpi34.html

TODO

  • BT接続
    • キーボード
    • ネットワーク
  • iOSからのアクセス
    • 日本語
    • BTキーボードのコントロールキー問題
  • ケース、電源
  • クロスコンパイル
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment