2024-05-15

【Raspberry Piメモ・1】機材準備、Raspbianインストール、SSH接続
続きです。
1、etcバックアップとパッケージアップデート
いろいろいじる前に、初回ログイン直後にやるのは表題の作業です。
sudo -s cd / cp -Rp etc etc.default # 初期値バックアップ cat /etc/debian_version 10.4 # 現バージョン確認 apt update apt -y upgrade apt -y dist-upgrade sync reboot # 再起動 cat /etc/debian_version 10.4 # バージョンが上がってる場合あり apt --purge autoremove # 不要パッケージのクリーンアップ
2、raspi-config 基礎情報の設定
raspi-config
目的によって異なるが、当方は以下のような感じで設定
3 Boot Options -> B2 Wait for Network boot -> No 4 Localisation Options -> I2 Change Timezone -> Asia Tokyo -> I4 Change Wi-fi Country -> JP 5 Interfacing Options -> P1 Camera -> No -> P2 SSH -> Yes -> P3 VNC -> No -> P4 SPI -> No -> P5 I2C -> Yes -> P6 Serial -> Yes -> P7 1-Wire -> No -> P8 Remote GPIO -> No 6 Overclock -> 設定不要 7 Advanced Options -> A1 Expand Filesystem を選択 これで、SDカードの残り容量がフルで使えるようになる -> A2 Overscan -> No -> A3 Memory Split -> 16 を入力(64は不要と思われる) -> A4 Audio -> 0 Auto -> A5 Resolution -> Default -> A6 Screen Blanking -> No -> A7 Pixel Doubling -> No -> A8 GL Driver -> 設定不要 -> A9 Compositor -> No -> AA Pi 4 Video Output -> 設定不要 -> AB Overlay FS -> No -> No Finish で再起動
3、ファームウェア更新
rpi-update
*** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom
*** Performing self-update
*** Relaunching after update
*** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom
*** We're running for the first time
*** Backing up files (this will take a few minutes)
*** Backing up firmware
*** Backing up modules 4.19.97-v7+
#############################################################
WARNING: This update bumps to rpi-5.4.y linux tree
See: https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=269769
'rpi-update' should only be used if there is a specific
reason to do so - for example, a request by a Raspberry Pi
engineer or if you want to help the testing effort
and are comfortable with restoring if there are regressions.
DO NOT use 'rpi-update' as part of a regular update process.
##############################################################
Would you like to proceed? (y/N)
*** Downloading specific firmware revision (this will take a few minutes)
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 168 100 168 0 0 1302 0 --:--:-- --:--:-- --:--:-- 1312
100 114M 0 114M 0 0 1200k 0 --:--:-- 0:01:37 --:--:-- 160k
*** Updating firmware
*** Updating kernel modules
*** depmod 5.4.35-v7+
*** depmod 5.4.35-v7l+
*** depmod 5.4.35+
*** depmod 5.4.35-v8+
*** Updating VideoCore libraries
*** Using HardFP libraries
*** Updating SDK
*** Running ldconfig
*** Storing current firmware revision
*** Deleting downloaded files
*** Syncing changes to disk
*** If no errors appeared, your firmware was successfully updated to 8d64ec7016906fb1f2bbe937dd7401705c5acf33
*** A reboot is needed to activate the new firmware
sync
reboot
4、/boot/config.txtの直接編集
raspi-configでは操作できない設定は、/boot/config.txtを直接編集します。
設定可能項目は、/boot/overlays/READMEに記載されています。
たとえばBluetooth、WiFiがらみの設定に何があるか調べるには
sudo -s
cd /boot
cat overlays/README | grep bt
See: github.com/notro/fbtft/wiki/FBTFT-on-Raspian
Name: disable-bt
Load: dtoverlay=disable-bt
Name: miniuart-bt
Load: dtoverlay=miniuart-bt
Name: pi3-disable-bt
Info: This overlay has been renamed disable-bt, keeping pi3-disable-bt as an
Name: pi3-miniuart-bt
Info: This overlay has been renamed miniuart-bt, keeping pi3-miniuart-bt as
Info: Overlay for SH1106 OLED via SPI using fbtft staging driver.
Info: Overlay for SSD1306 OLED via SPI using fbtft staging driver.
Info: Overlay for SSD1351 OLED via SPI using fbtft staging driver.
cat overlays/README | grep wifi
Name: disable-wifi
Load: dtoverlay=disable-wifi
Name: pi3-disable-wifi
Info: This overlay has been renamed disable-wifi, keeping pi3-disable-wifi as
などとすればおおまかにわかります。
試しに、オンボードBluetooth、Wi-Fiを無効に、オンボードLEDの点灯点滅を無効にする設定をしてみます。
以下のようにconfig.txtの先頭に書きます。(当方の環境では末尾の[all]ブロック後への記述では設定が効かなかった)
vi /boot/config.txt # For more options and information see # http://rpf.io/configtxt # Some settings may impact device functionality. See link above for details # Disable onboard controllers dtoverlay=disable-wifi dtoverlay=disable-bt # LED off settings dtparam=pwr_led_trigger=none,pwr_led_activelow=off # POWER (RED) LED off dtparam=act_led_trigger=none,act_led_activelow=off # SD ACCESS (GREEN) LED off dtparam=eth_led0=14 # ETHER LED off dtparam=eth_led1=14 # ETHER LED off
rebootして、ifconfigにwlanが居ない、hciconfigの出力が無い、状態であれば、Wi-Fi、Bluetoothを無効にした設定が効いています。
pi@raspberrypi:~ $ ifconfig
eth0: flags=4163<up> mtu 1500
inet 192.168.1.4 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 2408:210:cd41:4600:1ce9:184f:a64e:9b19 prefixlen 64 scopeid 0x0<global>
inet6 fe80::d104:d11f:2495:1f60 prefixlen 64 scopeid 0x20<link>
ether b8:27:eb:fb:cf:a3 txqueuelen 1000 (Ethernet)
RX packets 276 bytes 25033 (24.4 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 188 bytes 25181 (24.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<up> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
pi@raspberrypi:~ $ hciconfig
pi@raspberrypi:~ $
</host></up></global></up>
Raspberry Pi固有の初期設定はこれくらいで、あとは普通のDebianサーバーですので、同じように設定します。
・【Debian】タイムゾーン設定と時刻同期【FreeBSD】
・【Debian初期設定1】CD Insatall,Network,apt Kernel/Package Update【Buster】
・【Debian初期設定2】group、passwd、sudo、sshログインルール
・【Debian初期設定3】bash系シェル初期設定ファイル
・【Debian初期設定4】LDロードパスに/usr/local/libを常時加える
・【Debian】Sambaインストール/アンインストールメモ【FreeBSD】
・DebianにウェブサーバーApache2をセットアップ
・DebianにメールサーバーPostfixをセットアップ
こんなところでしょうか。ラズベリーパイを外部公開サーバーにする予定があるなら、ユーザー名pi変更と↑sshログインルール付与は必須です。
次回以降で、GPIOにアナログDACとスピーカつないでラジオにした記録、iOS SwiftとNode.js使ってBLEの操作をした記録など書いていきたいと思います。
※本記事内容の無断転載を禁じます。
ご連絡は以下アドレスまでお願いします★
Wav2Lipのオープンソース版を改造して外部から呼べるAPI化する
Wav2Lipのオープンソース版で静止画の口元のみを動かして喋らせる
【iOS】アプリアイコン・ロゴ画像の作成・設定方法
オープンソースリップシンクエンジンSadTalkerをAPI化してアプリから呼ぶ【2】
オープンソースリップシンクエンジンSadTalkerをAPI化してアプリから呼ぶ【1】
【Xcode】iPhone is not available because it is unpairedの対処法
【Let's Encrypt】Failed authorization procedure 503の対処法
【Debian】古いバージョンでapt updateしたら404 not foundでエラーになる場合
ファイアウォール内部のWindows11 PCにmacOS Sequoiaからリモートデスクトップする
Windows11+WSL2でUbuntuを使う【2】ブリッジ接続+固定IPの設定
進研ゼミチャレンジタッチをAndroid端末化する
VirtualBoxの仮想マシンをWindows起動時に自動起動し終了時に自動サスペンドする
Windows11のコマンドプロンプトでテキストをコピーする
Androidホームで左にスワイプすると出てくるニュース共を一切表示させない方法
Googleスプレッドシートを編集したら自動で更新日時を入れる
Node.jsからPostgreSQLサーバに接続・操作する
【Apache】サーバーに同時接続可能なクライアント数を調整する
【C++】staticメンバ変数がundefined referenceとエラーになる場合