ttt90
2024年2月15日 10時07分
お世話になります。
Bluetoothドングルを用いたシリアル通信を実装しようとしています。
下記の投稿を参考に作業を進めたところ”systemctl ”を使用した時点で、エラーが出ました。
https://armadillo.atmark-techno.com/blog/615/3697
[エラー]
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
エラー内容をもとに下記の記事を参照すると、/bin/bash 対話実行する場合はsystemdが使用できないと見受けられました。
https://armadillo.atmark-techno.com/forum/armadillo/18066
実際に記事の内容を実施してみると/sbin/initをコマンドとして実行するとエラーはでませんが、
/bin/bash 対話実行した場合は対策前と同じく下記エラーが表示されました。
[エラー]
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
/bin/bash 対話実行ではsystemdを使用することはできないのでしょうか。
また、Bluetoothシリアル通信確認について他に方法があればご教授お願い致します。
コメント
ttt90
2024年2月15日 13時19分
at_shinya.koga
2024年2月15日 13時51分
アットマークテクノの古賀です。
ttt90さん:
>お察しの通り、Debianコンテナを使用しています。
>
>ご質問のコンテナ生成ですが以下のpodman run コマンドで生成しています。
>podman run --name=ble_test --systemd=true -it localhost/blescanner:latest /bin/bash
了解しました。これですと、podman start でコンテナを起動した際、一番最初に /bin/bash が実行されますね。
>生成・起動時にsystemdを実行というのは、shファイルを用意して起動時に実行するということでしょうか。
podman run の末尾引数に指定している /bin/bash を、/etc/init にするか(※/sbin/init が systemd へのシンボリックリンクとして存在する場合)、または、/lib/systemd/systemd を指定してください。
その後に podman exec -it ble_test /bin/bash を実行して、/bin/bash から systemctl を実行してみてください。
>ブログURL添付ありがとうございます。参考にします。
紹介した当社ブログでは、/etc/atmark/containers/ に配置するコンテナの .conf ファイルの set_command 行で /lib/systemd/systemd を指定しています。
その設定で、ABOS の podman_start でコンテナを生成・起動すると、podman run の末尾引数に /lib/systemd/systemd を指定してコンテナを生成・起動したのと同様な振る舞いになります。
ttt90
2024年2月15日 15時08分
アットマークテクノ
古賀様
ありがとうございます。
教えていただいた通り、コマンドを/lib/systemd/systemdに変更することで
おそらくsystemdを起動できたのですが、
下記のような表示になり、ログインが求められます。
systemd 247.3-7+deb11u4 running in system mode. (+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +ZSTD +SECCOMP +BLKID +ELFUTILS +KMOD +IDN2 -IDN +PCRE2 default-hierarchy=unified) Detected virtualization podman. Detected architecture arm64. Failed to create symlink /sys/fs/cgroup/net_prio: File exists Failed to create symlink /sys/fs/cgroup/net_cls: File exists Failed to create symlink /sys/fs/cgroup/cpuacct: File exists Failed to create symlink /sys/fs/cgroup/cpu: File exists Welcome to Debian GNU/Linux 11 (bullseye)! Set hostname to <e9912053cd00>. Queued start job for default target Graphical Interface. system-getty.slice: unit configures an IP firewall, but the local system does not support BPF/cgroup firewalling. (This warning is only shown for the first unit using IP firewalling.) -.slice: Failed to migrate controller cgroups from /libpod_parent/libpod-e9912053cd00b63003efe595ebfccd146bd464646eb307ae793806387eba2144, ignoring: No such file or directory [ OK ] Created slice system-getty.slice. [ OK ] Created slice system-modprobe.slice. [ OK ] Created slice User and Session Slice. [ OK ] Started Dispatch Password …ts to Console Directory Watch. [ OK ] Started Forward Password R…uests to Wall Directory Watch. [ OK ] Reached target Local Encrypted Volumes. [ OK ] Reached target Paths. [ OK ] Reached target Remote File Systems. [ OK ] Reached target Slices. [ OK ] Reached target Swap. [ OK ] Listening on initctl Compatibility Named Pipe. [ OK ] Listening on Journal Socket (/dev/log). [ OK ] Listening on Journal Socket. Starting Journal Service... Starting Remount Root and Kernel File Systems... [ OK ] Finished Remount Root and Kernel File Systems. Starting Create System Users... [ OK ] Started Journal Service. Starting Flush Journal to Persistent Storage... [ OK ] Finished Flush Journal to Persistent Storage. [ OK ] Finished Create System Users. Starting Create Static Device Nodes in /dev... [ OK ] Finished Create Static Device Nodes in /dev. [ OK ] Reached target Local File Systems (Pre). [ OK ] Reached target Local File Systems. Starting Create Volatile Files and Directories... [ OK ] Finished Create Volatile Files and Directories. [ OK ] Reached target System Time Set. [ OK ] Reached target System Time Synchronized. Starting Update UTMP about System Boot/Shutdown... [ OK ] Finished Update UTMP about System Boot/Shutdown. [ OK ] Reached target System Initialization. [ OK ] Started Daily apt download activities. [ OK ] Started Daily apt upgrade and clean activities. [ OK ] Started Periodic ext4 Onli…ata Check for All Filesystems. [ OK ] Started Daily Cleanup of Temporary Directories. [ OK ] Reached target Timers. [ OK ] Listening on D-Bus System Message Bus Socket. [ OK ] Reached target Sockets. [ OK ] Reached target Basic System. [ OK ] Started blescanner daemon. Starting Bluetooth service... [ OK ] Started D-Bus System Message Bus. Starting User Login Management... Starting Permit User Sessions... [ OK ] Finished Permit User Sessions. [ OK ] Started Console Getty. [ OK ] Reached target Login Prompts. [ OK ] Started Bluetooth service. [ OK ] Reached target Bluetooth. [ OK ] Started User Login Management. [ OK ] Reached target Multi-User System. [ OK ] Reached target Graphical Interface. Starting Update UTMP about System Runlevel Changes... [ OK ] Finished Update UTMP about System Runlevel Changes. Debian GNU/Linux 11 e9912053cd00 console e9912053cd00 login: Welcome to Debian GNU/Linux 11 (bullseye)! Debian GNU/Linux 11 e9912053cd00 console e9912053cd00 login:
ArmadilloのログインID、パスワードを入力しても
ログインできませんでした。
何のログインID、パスワード入力すればよいのでしょうか。
よろしくお願いいたします。
ttt90
2024年2月15日 16時47分
アットマークテクノ
古賀様
修正してrunしたところ、問題なく実行され、
systemctlが使用できることを確認しました。
ありがとうございます。
立て続けになるのですが、Bluetoothの起動の際、
systemctl restart bluetoothを実行すると下記のエラーが出ます。
Job for bluetooth.service failed because the control process exited with error code. See "systemctl status bluetooth.service" and "journalctl -xe" for details.
systemctl status bluetooth.serviceを実行すると下記のように実行に失敗しています。
root@0c335e3f30f9:/# systemctl status bluetooth.service ● bluetooth.service - Bluetooth service Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Thu 2024-02-15 07:42:40 UTC; 1min 26s ago Docs: man:bluetoothd(8) Process: 361 ExecStart=/usr/libexec/bluetooth/bluetoothd --compat (code=exited, status=1/FAILURE) Main PID: 361 (code=exited, status=1/FAILURE) Status: "Starting up" Feb 15 07:42:40 0c335e3f30f9 systemd[1]: Starting Bluetooth service... Feb 15 07:42:40 0c335e3f30f9 bluetoothd[361]: Bluetooth daemon 5.55 Feb 15 07:42:40 0c335e3f30f9 bluetoothd[361]: src/adapter.c:adapter_init() Failed to access management interface Feb 15 07:42:40 0c335e3f30f9 bluetoothd[361]: src/main.c:main() Adapter handling initialization failed Feb 15 07:42:40 0c335e3f30f9 systemd[1]: bluetooth.service: Main process exited, code=exited, status=1/FAILURE Feb 15 07:42:40 0c335e3f30f9 systemd[1]: bluetooth.service: Failed with result 'exit-code'. Feb 15 07:42:40 0c335e3f30f9 systemd[1]: Failed to start Bluetooth service.
これは、Bluetoothドングルが認識できていないのでしょうか。
ttt90
2024年2月15日 17時03分
アットマークテクノ
古賀様
連投になって申し訳ありません。
現在、下記リンクのBluetoothドングルを使用しているのですが、
このドングルでシリアル通信することは可能でしょうか。
https://www.amazon.co.jp/dp/B07TJHK1RW/?tag=a8-affi-159040-22&a8=lvjryv…
もしよろしければ、ArmadilloIoT-G4でシリアル通信の実績のあるBluetoothドングルを教えていただけますでしょうか。
よろしくお願いいたします。
at_shinya.koga
2024年2月15日 17時25分
アットマークテクノの古賀です。
以下の件ですが、コンテナ内部から Bluetooth デバイスにアクセスするためには、コンテナに権限を与えないといけないのです。
このことは、マニュアルの「BT デバイスを使用する」で説明しています。ご覧になってみてください:
https://manual.atmark-techno.com/armadillo-iot-g4/armadillo-iotg-g4_pro…
また、最初のコメントで紹介した弊社のブログでも、「コンテナ実行」の項で、.conf ファイルで権限設定する手順を説明しています:
https://armadillo.atmark-techno.com/blog/10899/18234
ttt90さん:
>立て続けになるのですが、Bluetoothの起動の際、
>systemctl restart bluetoothを実行すると下記のエラーが出ます。
Job for bluetooth.service failed because the control process exited with error code. See "systemctl status bluetooth.service" and "journalctl -xe" for details.
>
>systemctl status bluetooth.serviceを実行すると下記のように実行に失敗しています。
>
root@0c335e3f30f9:/# systemctl status bluetooth.service ... Feb 15 07:42:40 0c335e3f30f9 systemd[1]: Starting Bluetooth service... Feb 15 07:42:40 0c335e3f30f9 bluetoothd[361]: Bluetooth daemon 5.55 Feb 15 07:42:40 0c335e3f30f9 bluetoothd[361]: src/adapter.c:adapter_init() Failed to access management interface Feb 15 07:42:40 0c335e3f30f9 bluetoothd[361]: src/main.c:main() Adapter handling initialization failed Feb 15 07:42:40 0c335e3f30f9 systemd[1]: bluetooth.service: Main process exited, code=exited, status=1/FAILURE Feb 15 07:42:40 0c335e3f30f9 systemd[1]: bluetooth.service: Failed with result 'exit-code'. Feb 15 07:42:40 0c335e3f30f9 systemd[1]: Failed to start Bluetooth service.
>
>これは、Bluetoothドングルが認識できていないのでしょうか。
ということで、Debian コンテナ内で動いている bluetoothd が、Bluetooth デバイスにアクセスする権限がないために、認識できずにエラーしている状況だと思います。
podman run の引数に、'--cap-add=NET_ADMIN --network=host' を追加してコンテナを起動・生成してみてください:
https://docs.podman.io/en/latest/markdown/podman-run.1.html
ttt90
2024年2月19日 6時14分
アットマークテクノ
古賀様
お世話になっております。
https://armadillo.atmark-techno.com/blog/615/4246
上記のブログを参考にBluetoothのシリアル通信を実現しようとしているのですが、
” rfcomm listen /dev/rfcomm0 22 &”を実行後、
ペアリング済みのPCからTeratermで接続しようとすると、
下記エラーが出ます。
[エラー]
Can't create RFCOMM TTY: Address already in use
”systemctl daemon-reload”をした後に”systemctl restart bluetooth”をしても効果はありませんでした。
ModemManagerの無効化もしております。
こちらの解決方法をお教えいただけますでしょうか。
よろしくお願いいたします。
at_shinya.koga
2024年2月15日 10時36分
アットマークテクノの古賀です。
ttt90さん:
>下記の投稿を参考に作業を進めたところ”systemctl ”を使用した時点で、エラーが出ました。
>https://armadillo.atmark-techno.com/blog/615/3697
>
>[エラー]
>System has not been booted with systemd as init system (PID 1). Can't operate.
>Failed to connect to bus: Host is down
>
>エラー内容をもとに下記の記事を参照すると、/bin/bash 対話実行する場合はsystemdが使用できないと見受けられました。
>https://armadillo.atmark-techno.com/forum/armadillo/18066
>
>実際に記事の内容を実施してみると/sbin/initをコマンドとして実行するとエラーはでませんが、
>/bin/bash 対話実行した場合は対策前と同じく下記エラーが表示されました。
>[エラー]
>System has not been booted with systemd as init system (PID 1). Can't operate.
>Failed to connect to bus: Host is down
>
>/bin/bash 対話実行ではsystemdを使用することはできないのでしょうか。
お使いの製品が Armadillo-IoT G4 であることと、ご質問の内容から、ABOS 上で Debian コンテナをお使いなのだと思います。
その前提でコメントしますが、もし違いましたら、お知らせください。
お使いの Debian コンテナですが、podman run コマンドで生成された場合は、生成時のコマンド引数を教えてくださいませ。
/etc/atmark/containers/ に配置する .conf ファイルを使い、ABOS の podman_start コマンドで生成・始動していらっしゃる場合は、.conf ファイルの記載内容のうち、set_command の行の内容を教えてください。
お使いのコンテナが、生成・起動時に systemd (: /sbin/init) を最初のプロセスとして実行するようになっていれば、コンテナ起動後に、podman exec -it で /bin/bash 対話実行した時に、bash から systemctl を実行してもエラーにならないはずです。
コンテナ内で systemd を利用する手順の例は、こちらのブログも参考にしてみてください:
Armadillo Base OS:Debianコンテナ内のアプリケーションをsystemdで管理する
https://armadillo.atmark-techno.com/blog/10899/18234