RetroBSD & LiteBSDのご紹介
2016年07月29日(金) NetBSDのご紹介 at OSC2016 Kyoto
それは… 2015年12月の一つの記事からはじまった(?)
RetroBSDとは?
- 2.11BSDベース: PDP11で動いていたもの
- PIC32MX用OS(MIPS M4Kアーキテクチャ, 32bit): MMUなし
- 組み込み用ボード向け
- ネットワークは、w5100に対応しているみたい(?)
たけおかさんの発表も参考にして下さい(_O_)
RetroBSD対応ハードウエア
ボード選択のポイント
- 使い勝手: USBシリアル内蔵? (kernel用)writerは必要?
- I/O: すぐに使えるI/Oがあるか?
- 値段: できるだけ安いほうが良いよね?
むとうのおすすめ
Olimex PIC32-RetroBSD ボード
- Olimexで19.95 EUR (Pinguno-Microは12.95 EUR)
- 主なI/O: USBシリアル / writer / スイッチx1 / LEDx2
DIGILENT chipKIT Max32 + SD Cardシールド類
- 秋月で5400円、 SDシールド類は1000円ぐらいから
- 主なI/O: USBシリアル / writer / LEDx1
デモ: RetroBSDブート(1/2) at MAX32
2.11 BSD Unix for PIC32, revision G488 build 1:
Compiled 2016-01-24 by root@goa.vak.ru:
/website/retrobsd/build/retrobsd-sources/sys/pic32/max32
cpu: 795F512L 80 MHz, bus 80 MHz
oscillator: XT crystal, PLL div 1:2 mult x20
spi2: pins sdi=RG7/sdo=RG8/sck=RG6
uart1: pins rx=RF2/tx=RF8, interrupts 26/27/28, console
uart2: pins rx=RF4/tx=RF5, interrupts 40/41/42
uart4: pins rx=RD14/tx=RD15, interrupts 67/68/69
sd0: port SPI2, pin cs=RC14
gpio0: portA, pins ii---ii-iiiioiii
gpio1: portB, pins iiiiiiiiiiiiiiii
gpio2: portC, pins i-ii-------iiii-
gpio3: portD, pins --iiiiiiiiiiiiii
gpio4: portE, pins ------iiiiiiiiii
gpio5: portF, pins --ii--------i-ii
gpio6: portG, pins iiii--i-----iiii
デモ: RetroBSDブート(2/2) at MAX32
adc: 15 channels
pwm: 5 channels
sd0: function groups 3/1/1/1/1/1, max current 200 mA
sd0: type SDHC, size 1966080 kbytes, speed 20 Mbit/sec
sd0a: partition type b7, sector 2, size 102400 kbytes
sd0b: partition type b8, sector 204802, size 2048 kbytes
sd0c: partition type b7, sector 208898, size 102400 kbytes
phys mem = 128 kbytes
user mem = 96 kbytes
root dev = (0,1)
swap dev = (0,2)
root size = 102400 kbytes
swap size = 2048 kbytes
/dev/sd0a: 1447 files, 12070 used, 89929 free
Starting daemons: update cron
2.11 BSD UNIX (pic32) (console)
login:
デモ: RetroBSDブート at PIC32-RetroBSD
2.11 BSD Unix for PIC32, revision G290 build 7:
Compiled 2015-07-14 by chris@olimex:
/home/chris/retrobsd/sys/pic32/pinguino-micro
cpu: 795F512H 80 MHz, bus 80 MHz
oscillator: HS crystal, PLL div 1:2 mult x20
console: ttyUSB0 (7,0)
sd0: port SPI2, select pin B13
sd0: type SDHC, size 7565312 kbytes, speed 13 Mbit/sec
phys mem = 128 kbytes
user mem = 96 kbytes
root dev = rd0a (0,1)
root size = 102400 kbytes
swap dev = rd0b (0,2)
swap size = 2048 kbytes
/dev/sd0a: 1451 files, 12149 used, 89850 free
Starting daemons: update cron
2.11 BSD UNIX (pic32) (console)
login:
デモ: RetroBSDコマンド入力 at PIC32-RetroBSD
- BSDなので、manも/games/もあります;-)
% w
10:29am up 1 min, 1 user, load averages: 0.03, 0.00, 0.00
User tty login@ idle JCPU PCPU what
root console 10:29am -
% ps alx
F S UID PID PPID CPU PRI NICE ADDR SZ WCHAN TTY TIME COMMAND
3 S 0 0 0 21 0 0 0x6800 3 runout ? 0:02 swapper
200 S 0 1 0 1 30 0 0x50 33 proc ? 0:00 init -
200 S 0 10 1 0 40 0 0xd 7 u ? 0:00 update
200 S 0 12 1 0 26 0 0xa 52 selwait ? 0:00 cron
200 S 0 13 1 0 30 0 0x19 39 proc USB 0:00 -sh
1 R 0 16 13 13 50 0 0x7400 38 USB 0:00 ps alx
% df -i
Filesystem 1K-blocks Used Avail Capacity iused ifree %iused Mounted on
/dev/sd0a 101999 12151 89848 11% 1453 4947 22% /
デモ: RetroBSD manコマンド at PIC32-RetroBSD
% man echo
ECHO(1) ECHO(1)
NAME
echo - echo arguments
SYNOPSIS
echo [ -n ] [ arg ] ...
DESCRIPTION
Echo writes its arguments separated by blanks and terminated by a new-
line on the standard output. If the flag -n is used, no newline is
added to the output.
Echo is useful for producing diagnostics in shell programs and for
writing constant data on pipes. To send diagnostics to the standard
error file, do `echo ... 1>&2'.
7th Edition April 29, 1985 ECHO(1)
デモ: RetroBSD /games/ at PIC32-RetroBSD
% ls /games/
aclock bcd factor morse rain trek
adventure boggle fish number robots worm
arithmetic btlgammon fortune pig rogue worms
atc caesar hangman pom sail wump
backgammon canfield lib ppt snake
banner cfscores mille primes snscore
battlestar cribbage monop quiz teachgammon
% /games/hangman
______
| |
| O Guessed: abfgilnqs
| /|\
| | Word #: 1
| / \ Current Average: 9.000
__|_____ Overall Average: 0.000
| |___
|_________|
Word: --g--a--
Guess:
Sorry, the word was "vegetate"
Another word?
GPIO (General Purpose Input/Output)
- ディジタルの入出力が可能な汎用バス
- RetroBSDでは、制御用に/dev/conf*を、アクセス用に/dev/port*を使う
設定
% cat /dev/confe
------iiiiiiiiii
% echo --------iiiioooo > /dev/confe
% cat /dev/confe
------iiiiiioooo
入出力
% cat /dev/porte
--------11111000
% echo --------00000000 > /dev/porte
% echo --------11111111 > /dev/porte
ADC (Analogue-to-Digital Converter)
- アナログ入力データを、デジタル値としてコンピュータに入力
- RetroBSDでは、/dev/adc*を入力として使う(値を出し続ける)
% cat /dev/adc0|head -1
1023
% adc-demo
adc0 722 ============================================
adc1 538 ================================
adc2 880 ======================================================
adc3 332 ===================
…
デモ: GPIO at PIC32-RetroBSD
MAX32
PIC32-RetroBSD
デモ: ADC at PIC32-RetroBSD
- 4つの可変抵抗値(adc0-3)と1つのCdSの値(adc4)を入力
% cat /dev/adc0|head -1
681
% adc-demo
adc0 682 =========================================
adc1 379 ======================
adc2 278 ================
adc3 921 ========================================================
adc4 11
adc5 0
adc6 5
adc7 8
adc8 17
adc9 0
adc10 0
adc11 0
adc12 0
adc13 1023 ==============================================================
adc14 419 =========================
adc15 1023 ==============================================================
LiteBSDとは?
- 4.4BSD-Liteベース
- PIC32MZ(MIPS M5150, 32bit)用OS: MMUあり
- TCP/IPサポートあり (有線: SMSC LAN8720A, LAN8740A, 無線: MRF24WG(開発中))
- GPIOはRetroBSDと同じように使える (ADCは無し)
DIGILENT chipKIT Wi-FIRE board
- 主なI/O
- 無線LANがある (mrf0): ドライバは完成していない
- USBシリアル / writer / LEDx4 / スイッチx2 / ポテンショメータ
- $79
Olimex EMZ64 board
- Olimexで24.95 EUR
- 主なI/O
- Ethernet 100M / OLED128x64 / LEDx3 / スイッチx3
- 3.3Vシリアル変換必要, kernel書込にPICkit2が必要
デモ: LiteBSDブート(1/3) at chipKIT Wi-FIRE
Copyright (c) 1982, 1986, 1989, 1991, 1993
The Regents of the University of California. All rights reserved.
4.4BSD-Lite build 0 compiled 2016-01-03
root@goa.vak.ru:litebsd-sources/sys/compile/WIFIRE.pic32
cpu: PIC32MZ2048EFG100 rev A1, 200 MHz
oscillator: system PLL div 1:6 mult x50
cache: 16/4 kbytes
real mem = 512 kbytes
avail mem = 344 kbytes
using 18 buffers containing 73728 bytes of memory
spi1 at pins sdi=RD14/sdo=RC1/sck=RD1
spi2 at pins sdi=RF0/sdo=RD11/sck=RG6
spi3 at pins sdi=RB10/sdo=RC4/sck=RB14
spi4 at pins sdi=RF5/sdo=RG0/sck=RD10
uart1 at pins rx=RF1/tx=RD15, interrupts 112/113/114
uart4 at pins rx=RF2/tx=RF8, interrupts 170/171/172, console
デモ: LiteBSDブート(2/3) at chipKIT Wi-FIRE
sd0 at port spi3, pin cs=RC3
gpio0 at portA, pins -i---ii-iiiiiiii
gpio1 at portB, pins i---i-iiiiiiiiii
gpio2 at portC, pins iiii---------i--
gpio3 at portD, pins --ii------iiii-i
gpio4 at portE, pins ------iiiiiiiiii
gpio5 at portF, pins --ii--------i---
gpio6 at portG, pins iiii--iii-------
mrf0 at port spi4, pins cs=RD9, irq=RA15, reset=RF4, hibernate=RG1
mrf0: MRF24WG version 31.c, MAC address 00:1e:c0:1a:41:5d
bpf: mrf0 attached
sd0: function groups 1/1/1/1/1/3, max current 200 mA
sd0: type SDHC, size 1966080 kbytes, speed 50 Mbit/sec
sd0a: partition type b7, sector 2, size 204800 kbytes
sd0b: partition type b8, sector 409602, size 32768 kbytes
sd0c: partition type b7, sector 475138, size 102400 kbytes
デモ: LiteBSDブート(3/3) at chipKIT Wi-FIRE
bpf: sl0 attached
bpf: lo0 attached
WARNING: preposterous clock chip time -- CHECK AND RESET THE DATE!
starting file system checks.
/dev/rsd0a: 2317 files, 16799 blocks used, 33416 free
/dev/rsd0a: MARKING FILE SYSTEM CLEAN
starting network
clearing /tmp
standard daemons: update cron.
Sun Apr 17 09:37:57 PDT 2016
4.4BSD-Lite (bsd.net) (console)
login:
デモ: LiteBSDコマンド入力 at chipKIT Wi-FIRE
- manはあるけど、/usr/games/のソースはあるけど入って無いみたい
/root # w
10:49AM up 2 mins, 1 user, load averages: 0.38, 0.17, 0.06
USER TTY FROM LOGIN@ IDLE WHAT
root co - 10:47AM 0 (w)
/root # ps alx
UID PID PPID CPU PRI NI VSZ RSS WCHAN STAT TT TIME COMMAND
0 0 0 0 -18 0 0 0 schedu DLs ?? 0:00.04 (swapper)
0 1 0 1 10 0 168 0 wait IWs ?? 0:00.08 /sbin/init
0 2 0 20 -18 0 0 0 - RL ?? 0:10.52 (pagedaemon)
0 27 1 0 18 0 20 0 pause IWs ?? 0:00.23 update
0 29 1 0 18 0 216 0 pause IWs ?? 0:00.15 cron
0 33 1 2 18 0 380 36 pause Ss 4 0:04.33 -sh (ksh)
0 60 33 2 28 0 200 92 - R+ 4 0:00.05 (ps)
/root # df -i
Filesystem 1K-blocks Used Avail Capacity iused ifree %iused Mounted on
/dev/sd0a 200860 67196 117592 36% 2317 28561 8% /
デモ: LiteBSD man at chipKIT Wi-FIRE
/root # man uptime|cat
UPTIME(1) BSD General Commands Manual UPTIME(1)
NAME
uptime — show how long system has been running
SYNOPSIS
uptime
DESCRIPTION
The uptime utility displays the current time, the length of time the sys‐
tem has been up, the number of users, and the load average of the system
over the last 1, 5, and 15 minutes.
FILES
/vmunix system name list
SEE ALSO
w(1)
HISTORY
The uptime command appeared in 3.0BSD.
3rd Berkeley Distribution April 18, 1994 3rd Berkeley Distribution
デモ: LiteBSD GPIO at chipKIT Wi-FIRE
おわりに
RetroBSDやLiteBSDで遊びませんか?
- まだ実装されていないドライバがあります (無線LAN, USB, ...)
- 最近、FreeBSDでビルドできるようになりました
- 時に動かないコマンドもありますorz
- 実機がなくても、RetroBSDにはVirtualMIPS(pic32)エミュレータがあります
むとうのやりたいこと
- RetroBSDで、echoやbcやawkなどを直す
- TCP/IP回りの調査
- LiteBSDでADCは動かない?