Raspberry Pi OS – matoken's blog https://matoken.org/blog Is there no plan B? Tue, 30 Dec 2025 22:45:10 +0000 ja hourly 1 https://wordpress.org/?v=6.9.1 https://matoken.org/blog/wp-content/uploads/2025/03/cropped-1865f695c4eecc844385acef2f078255036adccd42c254580ea3844543ab56d9-32x32.jpeg Raspberry Pi OS – matoken's blog https://matoken.org/blog 32 32 Cloudflareの速度テストをTUIで https://matoken.org/blog/2025/12/31/cloudflare-speed-test-with-tui/ https://matoken.org/blog/2025/12/31/cloudflare-speed-test-with-tui/#respond Tue, 30 Dec 2025 22:45:08 +0000 https://matoken.org/blog/?p=5121

Cloudflare の速度計測サイトのspeed.cloudflare.com をTUI で計測できるcloudflare-speed-cli というものを知ったので試してみました.
cloudflare-speed-cli はRust 製でGPL-3.0 license です.

類似のもので,speedtest.net を計測できるspeedtest-cli をよく使っていますが,Cloudflare も使えると便利そうです.

cloudflare-speed-cli はGitHub Releases にはLinux x86_64, aarch64, macOS aarch64, x86_64, Windows x86_64 のバイナリがあります.しかし例によってRaspberry Pi bookworm armhf(Arm 32bit)でも試してみます.

Rust 関連はasciimena 3.0 をbuild したときに入れたものからrustup で1.92.0 にしたものを使います.

cargo install で時間が掛かりますが特につまづいたりせずbuild できました.

$ cargo --version
warning: `/home/matoken/.cargo/config` is deprecated in favor of `config.toml`
  |
  = help: if you need to support cargo 1.38 or earlier, you can symlink `config` to `config.toml`
cargo 1.92.0 (344c4567c 2025-10-21)
$ cargo install --git https://github.com/kavehtehrani/cloudflare-speed-cli --features tui
$ cloudflare-speed-cli --help
Cloudflare-based speed test with optional TUI

Usage: cloudflare-speed-cli [OPTIONS]

Options:
      --base-url <BASE_URL>
          Base URL for the Cloudflare speed test service [default: https://speed.cloudflare.com]
      --json
          Print JSON result and exit (no TUI)
      --text
          Print text summary and exit (no TUI)
      --download-duration <DOWNLOAD_DURATION>
          Download phase duration [default: 10s]
      --upload-duration <UPLOAD_DURATION>
          Upload phase duration [default: 10s]
      --idle-latency-duration <IDLE_LATENCY_DURATION>
          Idle latency probe duration (pre-test) [default: 2s]
      --concurrency <CONCURRENCY>
          Concurrency for download/upload workers [default: 6]
      --download-bytes-per-req <DOWNLOAD_BYTES_PER_REQ>
          Bytes per download request [default: 10000000]
      --upload-bytes-per-req <UPLOAD_BYTES_PER_REQ>
          Bytes per upload request [default: 5000000]
      --probe-interval-ms <PROBE_INTERVAL_MS>
          Probe interval in milliseconds [default: 250]
      --probe-timeout-ms <PROBE_TIMEOUT_MS>
          Probe timeout in milliseconds [default: 800]
      --experimental
          Enable experimental features (TURN fetch + UDP-like loss probe)
      --export-json <EXPORT_JSON>
          Export results as JSON
      --export-csv <EXPORT_CSV>
          Export results as CSV
      --auto-save <AUTO_SAVE>
          Use --auto-save true or --auto-save false to override (default: true) [default: true] [possible values: true, false]
      --interface <INTERFACE>
          Bind to a specific network interface (e.g., ens18, eth0)
      --source <SOURCE>
          Bind to a specific source IP address (e.g., 192.168.10.0)
      --certificate <CERTIFICATE>
          Path to a custom TLS certificate file (PEM or DER format)
  -h, --help
          Print help
  -V, --version
          Print version
$ cloudflare-speed-cli --version
cloudflare-speed-cli 0.3.1

早速試してみます.cloudflare-speed-cli をオプションなしで実行するとTUI で実行されます.起動してすぐに計測が始まり,既定値では計測結果が保存されます.tab key でHistory ページに遷移すると過去の計測結果を閲覧したりエクスポートしたりできます.

cloudflare speed cli TUI

--text オプションでcli モードですが,プログレスが大量に出てちょっと使いづらい感じです.

プロスレス部分はSTDERR なのでそれを捨ててしまってもいいかもしれません

$ cloudflare-speed-cli --text 2>/dev/null
IP/Colo/ASN: 133.106.160.49 / NRT / 138384 (-)
Download: 23.73 Mbps
Upload:   2.47 Mbps
Idle latency p50/p90/p99: 98.9/110.7/110.7 ms (loss 0.0%, jitter 10.2 ms)
Loaded latency (download) p50/p90/p99: 438.0/578.6/755.2 ms (loss 0.0%, jitter 130.1 ms)
Loaded latency (upload) p50/p90/p99: 654.8/794.1/794.1 ms (loss 45.5%, jitter 144.4 ms)

こんな感じで定期的に計測するのにも便利かもと思いましたが,cli モードでは既定値では結果を保存しないようです.

$ watch -n 3600 -- cloudflare-speed-cli --text

--auto-save true も追加すると結果が保存されます.

$ watch -n 3600 -- cloudflare-speed-cli --text --auto-save true

ただ,以下のようにTUI モードの計測時のログには --interface を指定してもInterface やAP 名は保存されないようです.

│ 3.   2025-12-31 06:30:11 +09:00  DL   20.69 Mbps  UL    4.66 Mbps  Idle p50  103.7 ms  -  (1)
│ 4.   2025-12-31 06:08:33 +09:00  DL   21.73 Mbps  UL    3.16 Mbps  Idle p50  100.7 ms  wlan0  TP-L13💻 (2)
  1. --text でcli モードで実行したときの結果

  2. TUI モードで実行したときの結果

SEE ALSO

$ speedtest-cli
Retrieving speedtest.net configuration...
Testing from Rakuten Mobile Network (133.106.160.42)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by GSL Networks (Tokyo) [0.26 km]: 60.882 ms
Testing download speed................................................................................
Download: 12.70 Mbit/s
Testing upload speed......................................................................................................
Upload: 2.69 Mbit/s
Speedtest CLI: Internet speed test for the command line ※Ookla公式だがプロプライエタリ
$ speedtest

   Speedtest by Ookla

      Server: IPA CyberLab 400G - Tokyo (id: 48463)
         ISP: Rakuten Mobile Network
Idle Latency:    50.15 ms   (jitter: 1.41ms, low: 48.98ms, high: 52.36ms)
    Download:    20.75 Mbps (data used: 19.9 MB)
                262.40 ms   (jitter: 71.32ms, low: 72.73ms, high: 398.26ms)
      Upload:     2.96 Mbps (data used: 1.6 MB)
                779.27 ms   (jitter: 95.79ms, low: 75.05ms, high: 1148.99ms)
 Packet Loss:     0.0%
  Result URL: https://www.speedtest.net/result/c/e1a349cf-53eb-4d63-b8f4-8550dabd772d
n8henrie/fastcli: Python3 speed test via Fast.com fast.com を使いcli で計測……2025-12-27にarchived されていた
$ python -m fastcli -v
Approximate download speed: 17.48 Mbps
]]>
https://matoken.org/blog/2025/12/31/cloudflare-speed-test-with-tui/feed/ 0
Raspberry Pi OS を buster から bullseye に dist-upgrade https://matoken.org/blog/2021/11/12/raspberry-pi-os-buster-to-bullseye-dist-upgrade/ https://matoken.org/blog/2021/11/12/raspberry-pi-os-buster-to-bullseye-dist-upgrade/#comments Thu, 11 Nov 2021 23:18:14 +0000 http://matoken.org/blog/?p=3430

Raspberry Pi OS bullseye がリリースされていたので手元のRaspberry Pi 3 model B のOS をbuster からbullseye にアップグレードしてみました.

今回の環境は以下のような感じです.

BOARD
Raspberry Pi 3 model B
OS
Raspberry Pi OS buster armhf
OS導入ストレージ
microSD 32GB
主なサービス
OpenSSH, samba
操作
ssh経由

バックアップ

/etc は etckeeper(git) で管理しているのでリモートにpush しておきます./home は手動でバックアップ.
その他必要に応じてバックアップ.

もしくはストレージをまるごとイメージでバックアップ.(SD Card Copier/dd等)

buster を最新にする

Raspberry Pi OS buster を最新の状態します.

$ sudo mount -o remount,rw /boot (1)
$ sudo apt update (2)
$ sudo apt upgrade (3)
$ sudo reboot (4)
  1. 読み取りファイルシステムを書き込み可能に
  2. パッケージ情報の更新
  3. パッケージを最新に
  4. 必要に応じて再起動

操作ログを取得する

script コマンドで操作ログをファイルに書き出すようにしておきます.何か合った時に参照します.(接続元の端末でも保存しておくと例えばdisk fullなどのときにも保存されるので安心)

$ script -a ~/buster2bullseye_$(date +%F-%T).log

パッケージの状態をチェックする

$ dpkg --audit (1)
$ dpkg --get-selections | grep 'hold
  1. エラーのあるパッケージがないか確認
  2. ホールド状態のパッケージがないか確認

APT source-list ファイルの準備

/etc/apt/sources.list を書き換えます.busterbullseye に変更.編集時には apt edit-sources コマンドを使うと文法チェックをしてくれる.

$ sudo apt edit-sources
$ cat /etc/apt/sources.list
deb http://raspbian.raspberrypi.org/raspbian/ bullseye main contrib non-free rpi
deb-src http://raspbian.raspberrypi.org/raspbian/ bullseye main contrib non-free rpi

/etc/apt/sources.list.d/ 以下も確認して,Raspberry Pi OS 以外のリポジトリはコメントアウトする.(apt edit-sources ${FILENAME} で編集可能)

パッケージ情報を更新する

$ sudo apt update

アップグレードに必要な容量があるか確認する

$ sudo apt -o APT::Get::Trivial-Only=true full-upgrade

読み込み専用ファイルシステムを書き込み可能にする

$ sudo mount -o remount,rw /boot

OpenSSH Server をアップグレードする

アップグレード中に新規の SSH 接続が出来ない ようなので前もってアップグレードしておく.(トラブルが起きなければ既存のセッションだけで問題ないはずだが念の為)

$ sudo apt install openssh-server

アップグレード後ssh 接続ができることを確認.

システムの最小アップグレード

$ sudo apt upgrade --without-new-pkgs

システムのアップグレード

$ sudo apt full-upgrade

手元の環境では full-upgrade 時に以下のような依存関係のエラーになりました.

$ sudo apt full-upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Error!
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libc6-dev : Breaks: libgcc-8-dev (< 8.4.0-2~) but 8.3.0-6+rpi1 is to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.

gcc-8-base パッケージを導入して再度 dist-upgrade を試みることで解決しました.

$ sudo apt install gcc-8-base libc6-dev
$ sudo apt full-upgrade

KMS video driver の設定

/boot/config.txt を編集します.ファイル内の dtoverlay=vc4-fkms-v3d 行をコメントアウトし,[all] セクション内に dtoverlay=vc4-kms-v3d を記述します.

[all]
#dtoverlay=vc4-fkms-v3d (1)
dtoverlay=vc4-kms-v3d (2)
  1. コメントアウト
  2. 追記

再起動したら大体終わり.

RaspberryPiOS bullseye

後はサードパーティのAPT source-list ファイルを修正したり,アプリケーションの設定をしたり,bullseyeでサポートされなくなったパッケージを確認したり,アップグレード時に削除されたパッケージを確認したり…….

一通り設定が終わったらここでもバックアップをしておく.

]]>
https://matoken.org/blog/2021/11/12/raspberry-pi-os-buster-to-bullseye-dist-upgrade/feed/ 2
Raspberry Pi OS armhfでWidevineDRMビデオを観られるようになったので試す https://matoken.org/blog/2021/03/21/watch-widevine-drm-video-on-raspberry-pi-os-armhf/ https://matoken.org/blog/2021/03/21/watch-widevine-drm-video-on-raspberry-pi-os-armhf/#respond Sat, 20 Mar 2021 22:05:39 +0000 http://matoken.org/blog/?p=3124

Raspberry Pi OS armhfに libwidevinecdm0 パッケージが入ったようです.Raspberry Pi 3 Model Bでも動作したのでメモしておきます.

libwidevinecdm0 パッケージはWidevineというDRM付きコンテンツを閲覧するためのパッケージです.

Widevineは結構あちこちで見かけます.siteには以下のようなサービスが載っていました.

libwidevinecdm0 services

まずWidevineに非対応な状態でNetflixのコンテンツを閲覧しようとするとこのようなエラーになります.

libwidevinecdm0 ng

Note
Netflixの会員じゃなくても次で試せます.
TV番組・ドラマを無料で視聴 | Netflix お試し無料配信

ここで libwidevinecdm0 パッケージを導入してChromiumを起動しなおせばOKなはずですがうまく行きません.
chrome://components/ を見ても Widevine が出てきません.

https://bitmovin.com/demos/drm にアクセスしてみると, Detected , using No DRM と表示されDRMが使えないようです.

Raspberry Pi 4 Model B/400以外の事例が見当たらないのでもしかして何らかの要件が足りなくてRaspberry Pi 4 より前のバージョンでは動かないのかな?とか思ったのですが,もう少し調べるとRaspberry Pi OSのChromiumには chromiumchromium-browser の2つのパッケージがあるようです.

chromium
$ apt show chromium
Package: chromium
Version: 88.0.4324.146-1~deb10u1
Priority: optional
Section: web
Maintainer: Debian Chromium Team <chromium@packages.debian.org>
Installed-Size: 114 MB
Provides: gnome-www-browser, www-browser
Depends: libasound2 (>= 1.0.16), libatk-bridge2.0-0 (>= 2.5.3), libatk1.0-0 (>= 2.2.0), libatomic1 (>= 4.8), libatspi2.0-0 (>= 2.9.90), libavcode
c58 (>= 7:4.0), libavformat58 (>= 7:4.1), libavutil56 (>= 7:4.0), libc6 (>= 2.28), libcairo2 (>= 1.6.0), libcups2 (>= 1.7.0), libdbus-1-3 (>= 1.9
.14), libdrm2 (>= 2.4.38), libevent-2.1-6 (>= 2.1.8-stable), libexpat1 (>= 2.0.1), libflac8 (>= 1.3.0), libfontconfig1 (>= 2.12.6), libfreetype6
(>= 2.3.9), libgbm1 (>= 17.1.0~rc2), libgcc1 (>= 1:4.0), libgdk-pixbuf2.0-0 (>= 2.22.0), libglib2.0-0 (>= 2.39.4), libgtk-3-0 (>= 3.19.12), libha
rfbuzz0b (>= 2.2.0), libicu63 (>= 63.1-1~), libjpeg62-turbo (>= 1.5.0), libjsoncpp1 (>= 1.7.4), liblcms2-2 (>= 2.2+git20110628), libminizip1 (>=
1.1), libnspr4 (>= 2:4.9-2~), libnss3 (>= 2:3.22), libopenjp2-7 (>= 2.2.0), libopus0 (>= 1.1), libpango-1.0-0 (>= 1.14.0), libpng16-16 (>= 1.6.2-
1), libpulse0 (>= 0.99.1), libre2-5 (>= 20160901), libsnappy1v5, libstdc++6 (>= 7), libvpx5 (>= 1.6.0), libwebp6 (>= 0.5.1), libwebpdemux2 (>= 0.
5.1), libwebpmux3 (>= 0.6.1-2), libx11-6 (>= 2:1.4.99.1), libxcb1 (>= 1.9.2), libxcomposite1 (>= 1:0.3-1), libxdamage1 (>= 1:1.1), libxext6, libx
fixes3, libxml2 (>= 2.7.4), libxrandr2, libxslt1.1 (>= 1.1.25), zlib1g (>= 1:1.2.2), chromium-common (= 88.0.4324.146-1~deb10u1)
Recommends: chromium-sandbox
Suggests: chromium-l10n, chromium-shell, chromium-driver
Conflicts: libgl1-mesa-swx11, libnettle4, libsecret-1-0 (<< 0.18)
Breaks: chromium-lwn4chrome (<= 1.0-2), chromium-tt-rss-notifier (<= 0.5.2-2)
Homepage: http://www.chromium.org/Home
Download-Size: 48.9 MB
APT-Sources: http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages
Description: web browser
 Web browser that aims to build a safer, faster, and more stable internet
 browsing experience.
 .
 This package contains the web browser component.
chromium-browser
$ apt show chromium-browser
Package: chromium-browser
Version: 88.0.4324.187-rpt1
Priority: optional
Section: web
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Installed-Size: 329 MB
Provides: chromium, chromium-browser-inspector, www-browser
Pre-Depends: dpkg (>= 1.15.6)
Depends: libasound2 (>= 1.0.16), libatk-bridge2.0-0 (>= 2.5.3), libatk1.0-0 (>= 2.2.0), libatspi2.0-0 (>= 2.9.90), libc6 (>= 2.18), libcairo2 (>=
 1.6.0), libcups2 (>= 1.7.0), libdbus-1-3 (>= 1.9.14), libdrm2 (>= 2.4.38), libexpat1 (>= 2.0.1), libgbm1 (>= 17.1.0~rc2), libgcc1 (>= 1:4.3), li
bgdk-pixbuf2.0-0 (>= 2.22.0), libglib2.0-0 (>= 2.39.4), libgtk-3-0 (>= 3.21.5), libnspr4 (>= 2:4.9-2~), libnss3 (>= 2:3.22), libpango-1.0-0 (>= 1
.14.0), libx11-6 (>= 2:1.4.99.1), libxcb1 (>= 1.9.2), libxcomposite1 (>= 1:0.3-1), libxdamage1 (>= 1:1.1), libxext6, libxfixes3, libxkbcommon0 (>
= 0.5.0), libxrandr2, libxtst6, bash (>= 4), xdg-utils, chromium-codecs-ffmpeg-extra (= 88.0.4324.187-rpt1) | chromium-codecs-ffmpeg (= 88.0.4324
.187-rpt1), libraspberrypi0, libgl1-mesa-dri
Recommends: chromium-browser-l10n
Suggests: webaccounts-chromium-extension, unity-chromium-extension, adobe-flashplugin
Conflicts: chromium, chromium-browser-inspector
Replaces: chromium, chromium-browser-inspector
Homepage: https://chromium.googlesource.com/chromium/src/
Download-Size: 103 MB
APT-Manual-Installed: no
APT-Sources: http://archive.raspberrypi.org/debian buster/main armhf Packages
Description: Chromium web browser, open-source version of Chrome
 An open-source browser project that aims to build a safer, faster, and more
 stable way for all Internet users to experience the web.

そしてうまく行かなかったのは chromium でした.
chromium-browser を入れて(排他なので chromim パッケージは削除される)再度試すと,chrome://components/Widevine が現れて,

libwidevinecdm0 componets

https://bitmovin.com/demos/drm にアクセスしてみると, Detected , using widevine と表示されるようになりNetflixのコンテンツも閲覧できました.

libwidevinecdm0 netflix

Note
攻殻機動隊 SAC_2045 より.なんだかOPがPortal感

ということで,Raspberry Pi 3 Model B + Raspberry Pi OS armhf でも libwidevinecdm0 パッケージと chromium-browser パッケージを導入することでWidevineのDRMコンテンツが観られるようになりました :)
(DRMなしで閲覧できたほうが嬉しいですが)

$ sudo apt update
$ sudo apt install chromium-browser libwidevinecdm0
$ chromium-browser &
環境
$ dpkg-query -W chromium-browser* libwidevinecdm0
chromium-browser        88.0.4324.187-rpt1
chromium-browser-inspector
chromium-browser-l10n   88.0.4324.187-rpt1
libwidevinecdm0 4.10.1679.0-1
$ lsb_release -dr
Description:    Raspbian GNU/Linux 10 (buster)
Release:        10
$ uname -m
armv7l
$ cat /proc/device-tree/model ;echo
Raspberry Pi 3 Model B Rev 1.2
]]>
https://matoken.org/blog/2021/03/21/watch-widevine-drm-video-on-raspberry-pi-os-armhf/feed/ 0
Raspberry Pi の温度管理をソフトウェアで頑張る https://matoken.org/blog/2020/12/07/do-your-best-to-control-the-temperature-of-raspberry-pi-with-softwar/ https://matoken.org/blog/2020/12/07/do-your-best-to-control-the-temperature-of-raspberry-pi-with-softwar/#respond Sun, 06 Dec 2020 15:02:07 +0000 http://matoken.org/blog/?p=2881

この記事は日本Androidの会秋葉原支部ロボット部 Advent Calendar 2020 の12/07分の記事です.

内容は 日本Androidの会秋葉原支部ロボット部 第96回勉強会 で発表した内容を加筆修正したものです.

はじめに

Raspberry Pi という英国発の教育向けとして2012年に発売された安価なシングルボードコンピュータがあります.教育向けとして発売されましたが趣味にもよく使われています.OSは標準ではLinux(DebianベースのRaspberry Pi OS)が採用されています.

私はもっぱら省電力のLinuxマシンとして使うことが多いです.

トラブル

今夏空調のない部屋の自宅サーバの横でRaspberry Pi 3 model B + Raspberry Pi OS arm64(β)で計算をさせていたのですが,しばらく動かしていると固まるようになりました.

再起動すればしばらく動きますがしばらくするとやはり固まります.これをどうにか出来ないかと調べてみました.

ログの取得

まずはログを録ってみます.

crontabで1分毎に情報を記録
* * * * *       printf "`date +\%s`,`cat /sys/class/thermal/thermal_zone0/temp`,`echo "obase=2; ibase=16; \`vcgencmd get_throttled | cut -f2 -dx\`" | bc`,`vcgencmd measure_clock arm|cut -f2 -d=`\n" >> ~/.temp.log

内容はこんな感じです.(外気温度も録ればよかった)

UNIX Time
date +%s
SoC温度
/sys/class/thermal/thermal_zone0/temp
スロットリング周りのフラグ
vcgencmd get_throttled
arm周波数
vcgencmd measure_clock arm

ログがファイルに書かれる間にフリーズしてデータが失われるのを防ぐために /etc/fstab のマウントオプションに sync オプションも付けておきます.(再起動かremountで反映)

ログを取得している状態で負荷を掛けます.今回は /dev/urandom をcatすることで計算させました.今回のRaspberry Pi 3 model Bは4coreあるので4つ動かしています.

今回のテストで使った負荷(いつもはvanity address/vttとかとか)
$ cat /dev/urandom > /dev/null &
$ cat /dev/urandom > /dev/null &
$ cat /dev/urandom > /dev/null &
$ cat /dev/urandom > /dev/null &

熱が原因?

しばらく動かしてRaspberry Piが固まった後にログを確認してみます.
SoCの温度が85度を何度か記録した後に固まっているようです.
85度というのはRaspberry Pi OSでの標準のSoC制限温度のようです.この温度の5度前(標準では80度)からサーマルスロットリングが始まるようです.

サーマルスロットリングでクロックが下がって温度が下がれば問題無さそうだけど80度からクロックが下がっても85度を超えて固まってしまっているようです.
ベータ版のRaspberry Pi OS amd64を使っているせいかもしれないと思い,標準のRaspberry Pi OS armhf(32bit)版に変更して同様に試してみましたが同様の動きのようです.

正攻法としてはヒートシンク,ファンの増設や空調を入れるとよさそうですが,金欠なのでとりあえずソフトだけでどうにか出来ないかと試しました.

SoC制限温度を下げる

まずSoCの制限温度ですが,公式フォーラムで70度以下にしたほうがいいという書き込みを見かけました.逆に100度でも大丈夫という人も居るのですが安全側の70度にしてみます.

この設定は /boot/config.txt でパラメータを設定できます.以下は70度に設定たときの例です.この状態で再起動すると反映されます.

temp_limit=70

再起動後以下のコマンドで設定が反映されているか確認が出来ます.

$ vcgencmd get_config int | grep ^temp_limit=
temp_limit=70

この状態で負荷を掛けると70度を越えるくらいで固まりました.やはり制限温度を越えると固まってい舞うようです.

SoCの最大周波数を下げてみる

Raspberry Pi 3 model B のSoCは最大周波数1.2GHzです.これを下げてみます.

/boot/config.txtarm_freq= で設定できます.以下は800MHzに設定したときの例です.再起動で反映されます.

arm_freq=800

再起動後に設定が反映されているか確認します.

$ vcgencmd get_config int | grep ^arm_freq=
arm_freq=800

この状態で負荷を掛けるとやはり固まります.まあサーマルスロットリングが効いても固まるので仕方がない感じです.

SoCの最小周波数を下げてみる(これが効くのでは?)

次にSoC最小周波数を下げてみます.既定値は600MHzで,サーマルスロットリングでもここまで下がっているのでこれを更に下げると温度が下がりそうな気がします.

/boot/config.txtarm_freq_min= で設定できます.以下は400MHzに設定したときの例です.再起動で反映されます.

arm_freq_min=400

しかし再起動後に確認してみると600MHzより下には設定できないみたいで600MHzになってしまいます.

$ vcgencmd get_config int | grep ^arm_freq_min=
arm_freq_min=600

この状態で負荷を掛けるとやはり600Mhzまでしか下がらず固まります.

残念ながらRaspberry Pi のスロットリングでは無理そうです.

maxcpusでコアを制限してみる

Linuxのブートパラメータで maxcpus を指定することでコアを制限できます.Raspberry Pi の場合は /boot/cmdline.txt で設定できます.

設定後以下のコマンドで確認できます.

$ grep -o -E 'maxcpus=.{0,9} ' /proc/cmdline
maxcpus=1
$ grep ^processor /proc/cpuinfo | wc -l
1

これでCPU core1津で動作しています.しかし最大周波数を600MHzかつ1coreでも同様にフリーズしてしまいました.

cpufreqでクロック制御

IntelCPUのNotePCなどではcoufreqを使ってこのあたりの制御をするのですが,これでも600mHzより下には下げられないようで駄目でした.

LimitCPUで指定プロセスの制限を行う

LimitCPUは指定プロセスを監視し,CPU利用率や%で制限するプログラムです.Linux, MacOS, *BSDなどのUNIX-Likesystemで利用できます.
Raspberry Pi OSではcpulimitパッケージとしてパッケージングされており,コマンドもcoulimitです.

cpulimitの導入
$ sudo apt install cpulimit

cpulimitコマンドに制限したいプロセスIDやプロセス名と制限を指定することで動作します.

cat からはじまるプロセスを50%に制限
$ pgrep ^cat | xargs -n1 -I{} sh -c "cpulimit -p {} -l 50 -v &"

cpulimitで50%に制限してみたt頃温度が下がるのを確認できました.数日動かしても固まらなくなったようです.
定期的にSoCの温度を確認して制限を変更していくと良さそうでうs.

LimitCPUはCPUlimitの開発が止まった後のフォークですが,その後CPUlimitが新しく開発が始まっているようです.詳細は以下のページを参照してください.

cgroupでCPUリソース制限(未確認)

LimitCPUが効いたので恐らくcgroupでのCPUリソース制限でも大丈夫そうです.(未確認)

おわりに

現在は気温も下がり制限などしなくても問題ありません.でもきっと来夏にまた起こると思うのでそこでまた確認するつもりです.

しかし,今回の解決方法はCPUのリソースを制限して温度を下げて居るので計算量は減っています.空調を入れたりCPUファンを導入するのが正攻法になるのかなと思います.
CPUファンはサードパーティーから各種発売されているのでそれらを使うかDIYする感じになると思います.

そういえば最近Raspberry Pi OSの設定コマンドの raspi-config の中に Set behaviour of GPIO fan というメニューが出来たり,Raspberry Pi 4には公式のCPUファンが発売されているのでこれらを使うのが良さそうです.

]]>
https://matoken.org/blog/2020/12/07/do-your-best-to-control-the-temperature-of-raspberry-pi-with-softwar/feed/ 0
Raspberry Pi Model Bの8GB RAM版の発売とRaspberry Pi OS https://matoken.org/blog/2020/05/30/8gb-ram-version-of-raspberry-pi-model-b-launched-and-raspberry-pi-os/ https://matoken.org/blog/2020/05/30/8gb-ram-version-of-raspberry-pi-model-b-launched-and-raspberry-pi-os/#respond Sat, 30 May 2020 14:03:11 +0000 http://matoken.org/blog/?p=2754

Raspberry Pi 4 Model Bの8GB RAM版が発表.同時に発売され,日本も同時発売になったようです.

日本だと今はこのあたりでしょうか.

RAM が8GB あるとデスクトップ用途がRAM を気にせず使えるようになりそうですね.後は例えばビデオミーティングアプリのJitsi Meet をRaspberry Pi でホストしている人がいたりしますが,現在は設定を少し変えて省エネ設定で動かしていますが規定値の設定で動きそうです.
そして8GBもあると気になるのが標準OSのRaspbianがarmhf(32bit)にしか対応していないところ.
別のディストリビューションを使えばarm64(b4bit)は利用できますが標準OSが非対応なのはちょっと悲しいです.

私はDebian をよく使います.

これも今回発表がありました.64bit版のベータがリリースされました.

Not to be left out, today we’ve released an early beta of our own 64-bit operating system image.

Raspbianの名前も変わり,Raspberry Pi OS と改められるようです.

Both our 32-bit and 64-bit operating system images have a new name: Raspberry Pi OS.

新しい64bitの Raspberry Pi OS は以下から入手できます.

ダウンロードサイトのディレクトリもraspiosが出来ています.これまでの32bitは raspios_armhf になるようです.

$ w3m -dump https://downloads.raspberrypi.org/ | grep -E 'raspbian|raspios'
[DIR] raspbian/                         2020-02-25 16:50    -
[DIR] raspbian_full/                    2020-02-14 13:52    -
[DIR] raspbian_lite/                    2020-02-14 13:49    -
[DIR] raspios_arm64/                    2020-05-28 04:38    -
[DIR] raspios_armhf/                    2020-05-28 05:27    -
[DIR] raspios_full_armhf/               2020-05-28 05:28    -
[DIR] raspios_lite_armhf/               2020-05-28 05:27    -
[ ]   wp-slice-raspbian                 2020-05-28 07:46 1.0K

armhfのリリースノートを観るとこれまでのものに今回のバージョンが追記されていました.(64biには未だ存在しない)

$ w3m -dump https://downloads.raspberrypi.org/raspios_armhf/release_notes.txt | grep ^2020-05-27:$ -A 33
2020-05-27:
  * Added Bookshelf application
  * Added Raspberry Pi Diagnostics application
  * Added magnifier plugin to taskbar - needs magnifier application installed from Recommended Software to enable
  * Added Magnifier application to Recommended Software
  * Added marketing questionnaire as initial Chromium tab
  * Version 0.25 of Scratch 2 included - uses external application to access IMU on SenseHAT
  * Version 1.0.5 of Scratch 3 included - uses external application to access IMU on SenseHAT
  * Version 32.0.0.371 of Flash player included
  * Version 1.0.6 of Node-RED included
  * Version 6.7.1 of VNC Server included
  * Version 6.20.113 of VNC Client included
  * Internal audio outputs enabled as separate ALSA devices
  * MagPi preinstall removed and replaced with Beginner’s Guide
  * MagPi weblink removed from main menu
  * Chromium made default application for PDF files
  * Common icon loading code for lxpanel plugins used
  * Italian translations added
  * Initial move of mouse pointer to menu button disabled
  * Padding at left of menu button removed
  * Focus behaviour changed so that focus moves to desktop if no windows are opened - improves reliability of Orca screen reader
  * Bug fix - focus bug in volume plugin
  * Bug fix - keyboard repeat interval bug in Mouse & Keyboard Settings
  * Bug fix - battery detection bug in battery plugin
  * Bug fix - spurious active areas on taskbar when plugins are hidden
  * Bug fix - occasional crash in file manager on file selection
  * Disk ID is now regenerated on first boot
  * Updated udev rules
    - Remove unused argon rule
    - Add vcsm-cma to video group
    - Add pwm to gpio group
  * i2cprobe: More flexible I2C/SPI alias mapping
  * Raspberry Pi firmware 21e1fe3477ffb708a5736ed61a924fd650031136
  * Linux kernel 4.19.118

Raspberry Pi の Download ページを観るとここもアップデートされていました.

Raspberry Pi OS (previously called Raspbian) is our official operating system for all models of the Raspberry Pi.

この64bit beta版はRaspberry Pi 3 と 4 で動作するようです.(2 v1.2でも多分動く)

Note, the 64bit OS is only install-able on the Pi 3 and Pi 4 devices

ということでRaspberry Pi 3 なら持ってる!ということでダウンロードしてみました.

$ wget https://downloads.raspberrypi.org/raspios_arm64/images/raspios_arm64-2020-05-28/2020-05-27-raspios-buster-arm64.zip https://downloads.raspberrypi.org/raspios_arm64/images/raspios_arm64-2020-05-28/2020-05-27-raspios-buster-arm64.zip.sha256 https://downloads.raspberrypi.org/raspios_arm64/images/raspios_arm64-2020-05-28/2020-05-27-raspios-buster-arm64.zip.sig
$ sha256sum -c 2020-05-27-raspios-buster-arm64.zip.sha256
2020-05-27-raspios-buster-arm64.zip: OK
$ gpg --verify ./2020-05-27-raspios-buster-arm64.zip.sig
gpg: assuming signed data in './2020-05-27-raspios-buster-arm64.zip'
gpg: Signature made Thu 28 May 2020 01:05:10 PM JST
gpg:                using RSA key 54C3DD610D9D1B4AF82A37758738CD6B956F460C
gpg: Good signature from "Raspberry Pi Downloads Signing Key" [expired]
gpg: Note: This key has expired!
Primary key fingerprint: 54C3 DD61 0D9D 1B4A F82A  3775 8738 CD6B 956F 460C

署名の確認をすると期限切れのようです.新しい鍵を貰ってきてインポートして再度署名確認します.(ダウンロードページあたりにリンクして欲しい)

$ wget https://www.raspberrypi.org/raspberrypi_downloads.gpg.key
$ gpg ./raspberrypi_downloads.gpg.key
gpg: WARNING: no command supplied.  Trying to guess what you mean ...
pub   rsa2048 2017-04-10 [SC] [expires: 2021-04-21]
      54C3DD610D9D1B4AF82A37758738CD6B956F460C
uid           Raspberry Pi Downloads Signing Key
sub   rsa2048 2017-04-10 [E] [expires: 2021-04-21]
$ gpg --import ./raspberrypi_downloads.gpg.key
gpg: key 8738CD6B956F460C: 1 signature not checked due to a missing key
gpg: key 8738CD6B956F460C: "Raspberry Pi Downloads Signing Key" 3 new signatures
gpg: Total number processed: 1
gpg:         new signatures: 3
  :
$ gpg --verify ./2020-05-27-raspios-buster-arm64.zip.sig
gpg: assuming signed data in './2020-05-27-raspios-buster-arm64.zip'
gpg: Signature made Thu 28 May 2020 01:05:10 PM JST
gpg:                using RSA key 54C3DD610D9D1B4AF82A37758738CD6B956F460C
gpg: Good signature from "Raspberry Pi Downloads Signing Key" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.

とりあえず良さそうです.

sd card等に書き込みます.今回dd で書きましたが,公式のRaspberry Pi Imager を使ったほうがいいかもですね.

$ time zcat ./2020-05-27-raspios-buster-arm64.zip | pv | sudo dd of=/dev/sdz bs=16M conv=fdatasync
3.46GiB 0:02:34 [22.9MiB/s] [                                                                                                                                 <=>               ]
0+92723 records in
0+92723 records out
3711959040 bytes (3.7 GB, 3.5 GiB) copied, 212.594 s, 17.5 MB/s

real    3m32.613s
user    0m30.584s
sys     2m12.420s
$ sync

これを使って起動してみると普通に起動します.

Raspberry Pi 3 Model B Rev 1.2で試しました
$ cat /proc/device-tree/model ;echo
Raspberry Pi 3 Model B Rev 1.2
aarch64 kernelです
$ uname -a
Linux raspberrypi 5.4.42-v8+ #1319 SMP PREEMPT Wed May 20 14:18:56 BST 2020 aarch64 GNU/Linux
パッケージもarm64
$ LC_ALL=C dpkg-architecture --print-set
DEB_BUILD_ARCH=arm64; DEB_BUILD_ARCH_ABI=base; DEB_BUILD_ARCH_BITS=64; DEB_BUILD_ARCH_CPU=arm64; DEB_BUILD_ARCH_ENDIAN=little; DEB_BUILD_ARCH_LIBC=gnu; DEB_BUILD_ARCH_OS=linux;
DEB_BUILD_GNU_CPU=aarch64; DEB_BUILD_GNU_SYSTEM=linux-gnu; DEB_BUILD_GNU_TYPE=aarch64-linux-gnu; DEB_BUILD_MULTIARCH=aarch64-linux-gnu; DEB_HOST_ARCH=arm64; DEB_HOST_ARCH_ABI=ba
se; DEB_HOST_ARCH_BITS=64; DEB_HOST_ARCH_CPU=arm64; DEB_HOST_ARCH_ENDIAN=little; DEB_HOST_ARCH_LIBC=gnu; DEB_HOST_ARCH_OS=linux; DEB_HOST_GNU_CPU=aarch64; DEB_HOST_GNU_SYSTEM=li
nux-gnu; DEB_HOST_GNU_TYPE=aarch64-linux-gnu; DEB_HOST_MULTIARCH=aarch64-linux-gnu; DEB_TARGET_ARCH=arm64; DEB_TARGET_ARCH_ABI=base; DEB_TARGET_ARCH_BITS=64; DEB_TARGET_ARCH_CPU
=arm64; DEB_TARGET_ARCH_ENDIAN=little; DEB_TARGET_ARCH_LIBC=gnu; DEB_TARGET_ARCH_OS=linux; DEB_TARGET_GNU_CPU=aarch64; DEB_TARGET_GNU_SYSTEM=linux-gnu; DEB_TARGET_GNU_TYPE=aarch
64-linux-gnu; DEB_TARGET_MULTIARCH=aarch64-linux-gnu; export DEB_BUILD_ARCH DEB_BUILD_ARCH_ABI DEB_BUILD_ARCH_BITS DEB_BUILD_ARCH_CPU DEB_BUILD_ARCH_ENDIAN DEB_BUILD_ARCH_LIBC D
EB_BUILD_ARCH_OS DEB_BUILD_GNU_CPU DEB_BUILD_GNU_SYSTEM DEB_BUILD_GNU_TYPE DEB_BUILD_MULTIARCH DEB_HOST_ARCH DEB_HOST_ARCH_ABI DEB_HOST_ARCH_BITS DEB_HOST_ARCH_CPU DEB_HOST_ARCH
_ENDIAN DEB_HOST_ARCH_LIBC DEB_HOST_ARCH_OS DEB_HOST_GNU_CPU DEB_HOST_GNU_SYSTEM DEB_HOST_GNU_TYPE DEB_HOST_MULTIARCH DEB_TARGET_ARCH DEB_TARGET_ARCH_ABI DEB_TARGET_ARCH_BITS DE
B_TARGET_ARCH_CPU DEB_TARGET_ARCH_ENDIAN DEB_TARGET_ARCH_LIBC DEB_TARGET_ARCH_OS DEB_TARGET_GNU_CPU DEB_TARGET_GNU_SYSTEM DEB_TARGET_GNU_TYPE DEB_TARGET_MULTIARCH
導入パッケージ数(ヘッダ5行を除いて1303個)
$ dpkg-query -l|wc -l
1308
パッケージリスト(dpkg-query -l)

https://gist.github.com/6215f11e53ee668b04246ecd1d08f3db

ディスク利用量は3GB程
$ df -m
Filesystem     1M-blocks  Used Available Use% Mounted on
/dev/root          29938  2840     25832  10% /
devtmpfs             329     0       329   0% /dev
tmpfs                457     0       457   0% /dev/shm
tmpfs                457     1       457   1% /run
tmpfs                  5     1         5   1% /run/lock
tmpfs                457     0       457   0% /sys/fs/cgroup
/dev/mmcblk0p1       253    54       200  22% /boot
tmpfs                 92     0        92   0% /run/user/1000
有線/無線LAN認識
$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether b8:27:eb:46:60:13 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.182/24 brd 192.168.1.255 scope global dynamic noprefixroute eth0
       valid_lft 258810sec preferred_lft 226410sec
    inet6 fe80::2979:45f7:e3bf:a4d9/64 scope link
       valid_lft forever preferred_lft forever
3: wlan0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
    link/ether b8:27:eb:13:35:46 brd ff:ff:ff:ff:ff:ff
Bluetooth
$ bluetoothctl
Agent registered
[bluetooth]# list
Controller B8:27:EB:EC:CA:B9 raspberrypi [default]
[bluetooth]# quit
raspi-config等もある
Raspberry Pi 3 Model B Rev 1.2


┌─────────┤ Raspberry Pi Software Configuration Tool (raspi-config) ├──────────┐
│                                                                              │
│  1 Change User Password Change password for the 'pi' user                    │
│  2 Network Options      Configure network settings                           │
│  3 Boot Options         Configure options for start-up                       │
│  4 Localisation Options Set up language and regional settings to match your  │
│  5 Interfacing Options  Configure connections to peripherals                 │
│  6 Overclock            Configure overclocking for your Pi                   │
│  7 Advanced Options     Configure advanced settings                          │
│  8 Update               Update this tool to the latest version               │
│  9 About raspi-config   Information about this configuration tool            │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                     <Select>                     <Finish>                    │
│                                                                              │
└──────────────────────────────────────────────────────────────────────────────┘
screenfetch(Raspbian logoじゃなくDebian logoになった)

RasPiOS screenfetch 20200530 23:05:27 2909997

pfetch
$ pfetch/pfetch
  _____      pi@raspberrypi
 /  __ \     os     Debian GNU/Linux 10 (buster)
|  /    |    host   Raspberry Pi 3 Model B Rev 1.2
|  \___-     kernel 5.4.42-v8+
-_           uptime 52m
  --_        pkgs   1313
             memory 203M / 913M

て感じで試し始めました.
しばらく使ってみようかと思います.

あ,余ったRaspberry Pi があったらください :p

もし問題が見つかったら以下を確認して報告すると直るかもしれません.

]]>
https://matoken.org/blog/2020/05/30/8gb-ram-version-of-raspberry-pi-model-b-launched-and-raspberry-pi-os/feed/ 0