Hardware : BCM2835
Revision : d03114
Serial : 1000000066323307
Model : Raspberry Pi 4 Model B Rev 1.4
我が家においてたRaspi3はB+じゃなくBだった件。
ずっとB+だと思ってた。
cat /proc/cpuinfo
Hardware : BCM2835
Revision : a32082
Serial : 0000000098ace381
Model : Raspberry Pi 3 Model B Rev 1.2
あー。
rPi 3は、100Mbps
USBで、100Mbpsなのでそれを使って、識別もできる。
takuya@raspi3:~$ ethtool eth0
Settings for eth0:
Supported ports: [ TP MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Supported pause frame use: No
Supports auto-negotiation: Yes
Supported FEC modes: Not reported
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Advertised pause frame use: Symmetric Receive-only
Advertised auto-negotiation: Yes
Advertised FEC modes: Not reported
Link partner advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Link partner advertised pause frame use: Symmetric Receive-only
Link partner advertised auto-negotiation: Yes
Link partner advertised FEC modes: Not reported
Speed: 100Mb/s
Duplex: Full
Port: MII
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
Cannot get wake-on-lan settings: Operation not permitted
Current message level: 0x00000007 (7)
drv probe link
Link detected: yes
usb 結果にも特徴がある。
takuya@raspi3:~$ lsusb
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
takuya@raspi3:~$
raspi4 の場合
takuya@raspi3:~$ lsusb
Bus 001 Device 004: ID 0781:5591 SanDisk Corp. Ultra Flair
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
takuya@raspi3:~$
これで、takuya ユーザーがssh ログイン後に mysql コマンドでユーザー名takuyaを使って、接続できるようになります。
takuya@:~$ mysql -p
Enter password:
ERROR 1045 (28000): Access denied for user 'takuya'@'localhost' (using password: NO)
takuya@:~$ mysql
ERROR 1045 (28000): Access denied for user 'takuya'@'localhost' (using password: NO)
takuya@:~$
takuya@:~$ mysql -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 98
Server version: 10.5.12-MariaDB-0+deb11u1 Debian 11
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
mycli からも接続できます。
mycli -u takuya
mycli は 2021-12-02 入れたバージョンでは、index out of range のエラーになります。
takuya@raspi-ubuntu:~$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 0525:a4a7 Netchip Technology, Inc. Linux-USB Serial Gadget (CDC ACM mode)
raspi から USBのOrange Pi へつなぐ
sudo screen /dev/ttyACM0 115200
これで、よくあるSSHを経由しない pi zero の管理ってやつができる。でも今回の目標はこれじゃない。
Orange Pi につながるのはいいけど、逆に、Raspiをリモートから読みたいよね。
単純に通信する。
agetty を使わずに、単純に通信する。
Orange Piの agetty を止める。
systemctl enable serial-getty@ttyGS0.service
systemctl stop serial-getty@ttyGS0.service
systemctl status serial-getty@ttyGS0.service
takuya@raspi-ubuntu:~$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 0525:a4a7 Netchip Technology, Inc. Linux-USB Serial Gadget (CDC ACM mode)
ttyACM0ができています。
takuya@raspi-ubuntu:~$ ls /dev/ttyA*
/dev/ttyACM0 /dev/ttyAMA0
takuya@raspi-ubuntu:~$ systemctl list-units -t device | grep -i serial
sys-devices-platform-scb-fd500000.pcie-pci0000:00-0000:00:00.0-0000:01:00.0-usb1-1\x2d1-1\x2d1.4-1\x2d1.4:2.0-tty-ttyACM0.device loaded active plugged Linux-USB Serial Gadget (CDC ACM mode)
sys-devices-platform-soc-fe201000.serial-tty-ttyAMA0.device loaded active plugged /sys/devices/platform/soc/fe201000.serial/tty/ttyAMA0
sys-devices-platform-soc-fe215040.serial-tty-ttyS0.device loaded active plugged /sys/devices/platform/soc/fe215040.serial/tty/ttyS0
いろいろ試したけど、ここまでする必要はないと思う。
まとめ
USB-OTGで、手軽にリモートアクセスできるシリアル通信を追加することができる。
今回、実験に使ったのはOrange Pi Zero ですが、USB-OTGでシリアルコンソールが可能です。Raspi Zero でも可能です。
Pi Zeroへログインする記事が多いですが、リッスンさせる agetty を起動する側次第で、Pi zero経由でログインもできるようになる事がわかりました。USBケーブル一本で、任意のPCにリモートコンソールが追加できてとても便利です。intel vPro のようにBIOSアクセスはできませんが、市販マザーボードではGRUB/initramfsへアクセスできるだけでも有益です。ネットワーク実験でいちいち設置場所に行かなくてもいいですしね。
RaspberryPi zero は SSH接続しなくても、USB接続でログインすることができます。
rPiで検索するとSSHばかりですが、pi zero に限りOTGが使えるので、USBではシリアル通信ができます。
世の中の記事は、pi zero へ ログインする話ばかりですが、'pi zero から'ログインする事もできます。「なんの意味があるのそれ」と思うかもしれませんが、リモートからSSH経由でpi zero にログインし、その先に接続したPCへログインし、テレワークのリモート管理に役立てることができるのです。
今回使った機器 / Orange Pi Zero
raspi -- raspi zero だと記事がわかりづらくなるので、あえて Orange Pi Zero を使っています。
Orange Pi Zero は日本のAmazonでも変えますがAliexpressなど中華サイトの通販のほうがいいかもしれませんね。
mkdir working
cd working
wget https://pecl.php.net/get/rar-4.2.0.tgz
tar zxvf rar-4.2.0.tgz
cd rar-4.2.0
## ビルド
phpize7.0
./configure
make
## インストール
make install
takuya@server:~$ sudo lsof +D /mnt
lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/116/gvfs
Output information may be incomplete.
lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1000/gvfs
Output information may be incomplete.
This message was generated by the smartd daemon running on:
host name: server
DNS domain: [Empty]
The following warning/error was logged by the smartd daemon:
Device: /dev/nvme0, number of Error Log entries increased from 0 to 2
Device info:
CT500P1SSD8, S/N:18XXXXX, FW:P3CR010
For details see host's SYSLOG.
You can also use the smartctl utility for further investigation.
Another message will be sent in 24 hours if the problem persists.
メッセージをみると、 , number of Error Log entries increased from 0 to 2 とエラーが出てるのがはっきりわかるのでsmartmontoolsはあてになるようです。死んだあとでメール来たので遅かったけど。