
Raspberry Pi 3 B+ を買ったらメイン PC が起動しなくなったので、Raspberry Piでデスクトップ環境な設定メモ。
いやしかし、デフォルトで日本語が使える環境が入ってるとか時代ですねぇ。漢字変換もそこそこ頭良さそう。FreeBSD でこの設定をできる気がしない。
ホスト名は GUI のメニューからポチポチっと Ras1 に短縮。VNC, SSH, I2C, 1-Wire をオン。Recommended Software も適当にポチポチっと。octave とかそういうやつ。
octave が 4.0.3 (2016-07-02 Release) なんやけど、最新は 5.1.0 (2019-03-01 Release) って何とかならんのかなぁ?古すぎるやろ。自前でビルドするしかないのかな?
octave (脱線?)
tx = ty = linspace (-8, 8, 400);
[xx, yy] = meshgrid (tx, ty);
r = sqrt (xx .^ 2 + yy .^ 2) + eps;
tz = sin (r) ./ r;
surfl (tx, ty, tz);
例にある 3D グラフを分割数を 400 にして描いてみましたがなかなか重いですね(^^;;; ぐりぐりしようとすると vcgencmd measure_temp の読みで 70度 ぐらいいっちゃいますね。
スクリーンショットは xwd コマンドとかないんですか。どうしたらいいのかな?xwd で撮って xv や ImageMagick で変換とかしか方法知らないや。
とか思ってたらメニューの「ファイル」から「名前をつけて保存」を選び、3D.jpg にすると (ghostscript 君がかなり頑張ってくれて) 保存できましたが、左上のちょっとだけしか保存できませんでしたorz ウィンドウサイズを変更したのが駄目だったみたい。
warning: print.m: epstool binary is not available.
っていうメッセージもあったので epstool も追加しましたが今度はモノクロに。
pdf のまま保存して ImageMagick で「convert -trim 3D.pdf 3D.jpg」が早くて良かったみたいです。

saveas(gcf,'3D-graph.png') とかやると直接 png に変換するみたいです。画面と見た目は変わりますが、きれいなグラフが欲しいときにはこっちですね。(拡張子を jpg にすると jpeg でも保存してくれますが、すごく遅いので eps なり、png なりで保存したあとに convert するのがおすすめです。)
jpeg で保存しようとすると
warning: print.m: fig2dev binary is not available.
warning: print.m: pstoedit binary is not available.
と言われるので
Ras1:~> sudo apt-get install fig2dev pstoedit
したんですが png 出力がうまく行かなくなったので削除。
Ras1:~> sudo apt-get remove fig2dev pstoedit ; sudo apt-get autoremove
プロットを表示する前後にちょっと書き加えるとグラフの画面を表示しなくなります。スクリプトでグラフが欲しいとき向けかな。
f_handle = figure('visible', 'off');
surfl (tx, ty, tz)
saveas(f_handle, 'image.eps')
アップデート & tcsh
ターミナルを起動したら bash だったので tcsh!
おまじない的に update しておいてから
pi@Ras1:~ $ sudo apt update
pi@Ras1:~ $ sudo apt upgrade
pi@Ras1:~ $ sudo rpi-update
sudo: ホスト Ras1 の名前解決ができません
*** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom
*** Performing self-update
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 13545 100 13545 0 0 42318 0 --:--:-- --:--:-- --:--:-- 42460
*** 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.14.98-v7+
#############################################################
WARNING: This update bumps to rpi-4.19.y linux tree
Be aware there could be compatibility issues with some drivers
Discussion here:
https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=224931
##############################################################
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 0 168 0 0 218 0 --:--:-- --:--:-- --:--:-- 218
100 58.2M 0 58.2M 0 0 1233k 0 --:--:-- 0:00:48 --:--:-- 449k
*** Updating firmware
*** Updating kernel modules
*** depmod 4.19.25-v7+
*** depmod 4.19.25+
*** 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 82f49d8dfd9c000a203fb1deae64a3eb87abf3c1
*** A reboot is needed to activate the new firmware
なんか色々アップデートされたっぽいので念の為、再起動
pi@Ras1:~ $ sudo apt-get install tcsh
pi@Ras1:~ $ sudo chsh -s `which tcsh` `whoami`
足りないものを追加
日本語フォント!
日本語がちゃんと表示されているみたいですが、IPAexフォント (IPA フォントの可変幅と固定幅を纏めた物) と、Adobe & google が共同で作成した noto フォントをインストール
「apt-cache search 〜」でパッケージ名を探してから「apt-get install 〜」する。
Ras1:~> sudo apt-cache search font ipaex
fonts-ipaexfont - Japanese OpenType font, all IPAex Fonts
fonts-ipaexfont-gothic - Japanese OpenType font, IPAex Gothic Font
fonts-ipaexfont-mincho - Japanese OpenType font, IPAex Mincho Font
fonts-ipamj-mincho - Japanese OpenType font, IPAmj Mincho Font
fonts-takao - Japanese TrueType font set, Takao Fonts
fonts-takao-gothic - Japanese TrueType font set, Takao Gothic Fonts
fonts-takao-mincho - Japanese TrueType font set, Takao Mincho Fonts
texlive-fonts-extra - TeX Live: Additional fonts
texlive-lang-japanese - TeX Live: Japanese
Ras1:~> sudo apt-get install fonts-ipaexfont
...
Ras1:~> sudo apt-cache search font noto
fonts-cabin - humanist sans serif font
fonts-noto - metapackage to pull in all Noto fonts
fonts-noto-cjk - "No Tofu" font families with large Unicode coverage (CJK)
fonts-noto-hinted - "No Tofu" font families with large Unicode coverage (hinted)
fonts-noto-mono - "No Tofu" monospaced font family with large Unicode coverage
fonts-noto-unhinted - "No Tofu" font families with large Unicode coverage (unhinted)
texlive-fonts-extra - TeX Live: Additional fonts
texlive-latex-extra - TeX Live: LaTeX additional packages
Ras1:~> sudo apt-get install fonts-noto
...
locate コマンドがない!
> sudo apt-get install mlocate
> sudo updatedb
見た感じ /etc/cron.daily の下で毎日 ionice -c3 して DB の更新が行われるみたいですね。ほんとかな?時々 /var/lib/mlocate/mlocate.db のタイムスタンプを確認してみましょう。
メモリ (swap) が足りない!chromium のタブとか何個か開くとすぐにメモリが足りずに固まりますね。
> sudo sed -i.bak -e 's/^\(CONF_SWAPSIZE=\).*/\14096/;s/^#\(CONF_MAXSWAP=\).*/\14096/' /etc/dphys-swapfile
> sudo systemctl stop dphys-swapfile
> sudo systemctl start dphys-swapfile
/etc/dphys-swapfile の中の CONF_MAXSWAP=100 で 100MB の swap が指定されているので =4096 と書き換えて 4GB の swap を確保。
無指定の場合、最大 2GB の sawp 容量しか確保されないので #CONF_MAXSWAP=2048 のコメントを外し上限を =4096 に書き換え。
swap ファイルを確保し直すようで暫く重くなります。しばらくするとこんな感じで、使われていないメモリーは swap out されていきます。
Ras1:~> free -h
total used free shared buff/cache available
Mem: 926M 601M 50M 56M 273M 262M
Swap: 4.0G 255M 3.8G
nslookup どこや! whois ないぞ。
Ras1:~> sudo apt-cache search nslookup
dnsutils - Clients provided with BIND
gresolver - graphical tool for performing DNS queries
knot-dnsutils - Clients provided with Knot DNS (kdig, knslookup, knsupdate)
libbot-basicbot-pluggable-perl - extended simple IRC bot for pluggable modules
libnet-nslookup-perl - simple DNS lookup module for perl
Ras1:~> sudo apt-get install dnsutils
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています
状態情報を読み取っています... 完了
提案パッケージ:
rblcheck
以下のパッケージが新たにインストールされます:
dnsutils
アップグレード: 0 個、新規インストール: 1 個、削除: 0 個、保留: 4 個。
281 kB のアーカイブを取得する必要があります。
...snip
Ras1:~> sudo apt-get install whois
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています
状態情報を読み取っています... 完了
以下のパッケージが新たにインストールされます:
whois
アップグレード: 0 個、新規インストール: 1 個、削除: 0 個、保留: 4 個。
68.4 kB のアーカイブを取得する必要があります。
この操作後に追加で 257 kB のディスク容量が消費されます。
取得:1 http://ftp.jaist.ac.jp/pub/Linux/raspbian-archive/raspbian stretch/main armhf whois armhf 5.2.17~deb9u1 [68.4 kB]
68.4 kB を 0秒 で取得しました (73.7 kB/s)
以前に未選択のパッケージ whois を選択しています。
(データベースを読み込んでいます ... 現在 100215 個のファイルとディレクトリがインストールされています。)
.../whois_5.2.17~deb9u1_armhf.deb を展開する準備をしています ...
whois (5.2.17~deb9u1) を展開しています...
whois (5.2.17~deb9u1) を設定しています ...
man-db (2.7.6.1-2) のトリガを処理しています ...
Ras1:~> whois yahoo.co.jp
[ JPRS database provides information on network administration. Its use is ]
[ restricted to network administration purposes. For further information, ]
[ use 'whois -h whois.jprs.jp help'. To suppress Japanese output, add'/e' ]
[ at the end of command, e.g. 'whois -h whois.jprs.jp xxx/e'. ]
Domain Information: [ドメイン情報]
a. [ドメイン名] YAHOO.CO.JP
e. [そしきめい] やふーかぶしきがいしゃ
f. [組織名] ヤフー株式会社
g. [Organization] Yahoo Japan Corporation
k. [組織種別] 株式会社
l. [Organization Type] Corporation
...snip
nslookup 入れたら bind 入れておこうかな。と search したらめっちゃでてくるやん。
ま、sudo apt-cache search bind domain で一番上に出てきてくれたので
Ras1:~> sudo apt-get install bind9 bind9-doc bind9utils
こういうパッケージシステムって、普通は 1つ入れたら全部入るものを細かく分割していて、何を入れていいのか分からなくなりますねぇ。
ということで、 メタルLAN, Key & mouse は USB, テレビに HDMI 接続の Raspberry Pi からの書き込みでした。
本当は 名刺サイズの超小型PC「ラズパイ」で遊ぶ 辺りとか、GPS レシーバーを繋いでタイムサーバーにしたり、ADS-B を受信して Flightradar24 へフィードしたりしようとか思ってたんですけどね。
ほかの OS は入らないの?
FreeBSD
Rasberry pi 向け FreeBSD のスナップショットもあります。make world や ports で新しいのを入れたい私向き?
FreeBSD on Raspberry Pi & STABLE Weekly SNAPSHOT
他のワンボードコンピュータ
こういう IoT 向けの 1chip コンピュータ は結構出てるみたいですね。
その昔、日立が出した EEPROM (電気的に消去可能なメモリ≒Flashメモリ) 内蔵 の 「H8/538F」 が初めての製品らしく、それまでのマスクROM (製造時にプログラムを焼いて変更不可能)、UV-EPROM (紫外線でメモリを消去し書き換え可能) のメモリに比べて遥かに扱いやすくなったそうです。
そういえば H8,(H16,H32), SH-3,4 シリーズも流行りましたねぇ。
https://pc.watch.impress.co.jp/docs/column/semicon/1133196.html
ROM の分類
マスクROM: mask Read Only Memory (製造時にデータを書き込みし、書き換え不能)
書き込み時に回路のヒューズを切って書き込みを行うため、書き換えは不可能。
PROM: Programmable ROM (書き込み可能な RON)
├ (書き込み不能な一般品 UV-PROM に消去窓がないものをこう呼ぶこともある)
└EPROM: Erasable Programmable ROM (書き込み & 消去可能な ROM)
├UV-EPROM: UV Erasable Programmable ROM (消去窓から紫外線を照射することで消去可能な PROM/日光だと 1年以上)
└EEPROM: Electrical Erasble ROM (電気的に消去可能な PROM)
この区分だと Flash メモリは EEPROM のように見えるが EEPROM の消去方法は通常動作と異なるため取り外して行う必要があるものが普通である。
ASUS の Raspberry Pi もどき、高性能版
Tinker Board S オンボードに 16GB eMMC (フラッシュメモリ) を搭載し microSD 無しで動作可能。
CPU Rockchip RK3288 (クアッドコア1.8GHz)
メインメモリ 2GB (LPDDR3)
GPU Mali™-T760
オーディオ 24bit/192kHz
ネットワーク Gbit LAN & Wifi 802.11 b/g/n
Raspberry Pi の GIGA LAN は速度出ませんが、こいつはちゃんと速度出ます。
Tinker Board S コンプリートスターターキット Amazon \15,980
SD は容量の大きい安いのを買ったらいいので付けなくても良いんですけどねぇ。Tinker Board S マルツオンライン \9,950+税 こちらはボードだけ。
SONY の Arduino
SONY SPRESENSE ARM Cortex-M4F 6コア 156MHz、RAM 1.5MB、GPS レシーバー、Class D アンプ内蔵の上、他社からアドオンボードもあり。I/O は 1.8V、拡張ボード経由で 3.3V, 5V へ変換。購入先 スイッチサイエンス \5,940 や Amazon \6,098 など。