Fuzix OS on BSD
https://gyazo.com/26887c1f78fa2deb8b088e7be05ecf28
本当は、関西*BSDユーザ会で発表しようと思ってたのですが、機会を逃して発表できずなので、流用しました。 はじめに
色々なCPUで動くFuzix OSが、なぜか、むとうのまわりで流行っています
浜松Fuzixユーザーグループ
エミュレーターだけではなく、たくさんの実機で動かしている
https://gyazo.com/d3f5719034d7fadc5b444864fc2b84a8
BSD界隈: 以下の動画参照
omron LUNAのサブCPU(Z80)で動かすために作業している
fuzix and NetBSD/lunaの同時実行!!
https://www.youtube.com/watch?v=lC7Digkemi8&t=2611s
ちょっくらFreeBSD/aarch64(Pinebook)なんかで試してみました
Fuzix OSとは?
2024/08/01現在のバージョンは0.5
色々な8bit/16bitのCPUで動くUnixのようなもの
FuzixOS: Because Small Is Beautiful
めちゃくちゃ多くの対応プラットフォーム(詳しくは、公式トップページを確認)
例: Z80(MSX), ESP8266, 6800, 8086, ARM(RP2040), PDP11, ...
ライセンスは、GPL v2 + LGPL(ライブラリ部分)
100個ほどのコマンドが/binや/usr/binなどに存在
SYS3 - SYS5.x + 少しのPOSIX対応
BCPL, CC, asm, Forthなどもある
Raspberry Pi PicoでFuzix OS
ちょこっと試してみたい場合に便利
filesystem.uf2を書き込む
バージョンは0.3.1とちょっと古い
Pico以外のハードウエア(SDなど)は不要
code:shell
% sudo cu -l /dev/cu.usbmodem0000000000001 -s 115200
Connected.
Current time is 23:37:29
Enter new time: 14:00:00
^ ^
n n Fuzix 0.3.1
@<
Welcome to Fuzix
m m
login: root
Welcome to FUZIX.
コマンド一覧: /usr/binは無い
code:shell
# cd /bin
# ls|wc -l
115
# for f in *
do
echo -n ${f}" "
done
ac accton at atrun banner basename bd blkdiscard cal cat chgrp chmod chown cksum cmp col comm cp cron crypt cut date dc dd decomp16 deroff df diff diff3 diffh dirname dosread du echo ed env false fdisk fforth fgrep free fsck fsck-fuzix grep head id join kill levee ll ln logname look ls makekey man marksman mesg mkdir mkfifo mkfs mknod more mount mv newgrp od pagesize passwd pg pr printenv prtroot ps ptx pwd reboot remount rev rm rmdir setdate sh sleep sort split ssh stty su sum swapon sync tail tar tee test time touch tr true tsort tty umount uniq uptime uud uue wall wc which who whoami write xargs yes
設定ファイル一覧
code:shell
# ls /etc
inittab
issue
motd
mtab
passwd
rc
termcap
エミュレーターでFuzix OS
Fuzix World Vol.1では、以下のようなエミュレーターで動作させている
Z80 CPU
RC2014: rc2014
Tom's SBC: searle
Easy Z80: rc2014
RC2014 with RomWBW and Z80: rc2014
RetroBrew/N8VEM SBC v2: rbcv2
Z180 CPU
Small Computer Central SC126: rc2014-z180
MC68000 CPU
Tiny68K: tiny68k
RC2014エミュレーターの作成
RC2014エミュレーターでの動作例(Tested on macOS and FreeBSD/aarch64(Pinebook))
Makefileの厳しいコンパイラチェックフラグを削除
FreeBSDの場合、gccを直指定している所の変更が必要(詳細略)
code:一部.diff
% diff -u Makefile.org Makefile
--- Makefile.org 2024-07-31 14:53:04.000000000 +0900
+++ Makefile 2024-07-31 14:53:11.000000000 +0900
@@ -1,5 +1,5 @@
-CFLAGS = -Wall -pedantic -g3 -Werror
+CFLAGS =
all: rc2014 rcbus-1802 rcbus-6303 rcbus-6502 rcbus-65c816-mini \
rcbus-65c816 rcbus-6800 rcbus-68008 rcbus-6809 rcbus-68hc11 \
diff --git a/lib65c816/config.mk b/lib65c816/config.mk
index 23b3690..d840263 100644
--- a/lib65c816/config.mk
+++ b/lib65c816/config.mk
@@ -1,6 +1,5 @@
-CC := gcc
CCFLAGS := -c -O2 -fomit-frame-pointer $(CCOPTS) -DDEBUG -Werror
-LD := gcc
+LD := $(CC)
LDFLAGS :=
PREFIX := /opt/v65c816/
(snip)
$ gmake
Fuzix on RC2014 with RomWBW
以下の手順で、とりあえず動く
作業ディレクトリの作成
code:shell
% mkdir work
% cd work
ROMの準備: 最新のv3.4.1では動かせなかった
code:shell
% mkdir roms
% cd roms
% unzip ../RomWBW-v3.0.1-Package.zip
(snip)
% cd ..
ディスクイメージファイルの準備
ダウンロードがとても遅いので気長に待って…
code:shell
% mkdir rc2014
% mv emu-ide.img rc2014/
code:shell
% ../rc2014 -b -r roms/Binary/RCZ80_std.rom -i rc2014/emu-ide.img -s -w -R -c
RomWBW HBIOS v3.0.1, 2020-04-04
RC2014 Z80 @ 7.372MHz
0 MEM W/S, 1 I/O W/S, INT MODE 1
512KB ROM, 512KB RAM
SIO0: IO=0x80 SIO MODE=115200,8,N,1
SIO1: IO=0x82 SIO MODE=115200,8,N,1
DSRTC: MODE=STD IO=0xC0 NOT PRESENT
MD: UNITS=2 ROMDISK=384KB RAMDISK=384KB
IDE: IO=0x10 MODE=RC
IDE0: 8-BIT LBA BLOCKS=0x00013150 SIZE=38MB
IDE1: NO MEDIA
PPIDE: IO=0x20 PPI NOT PRESENT
Unit Device Type Capacity/Mode
---------- ---------- ---------------- --------------------
Char 0 SIO0: RS-232 115200,8,N,1
Char 1 SIO1: RS-232 115200,8,N,1
Disk 0 MD1: RAM Disk 384KB,LBA
Disk 1 MD0: ROM Disk 384KB,LBA
Disk 2 IDE0: Hard Disk 38MB,LBA
Disk 3 IDE1: Hard Disk --
RC2014 Boot Loader
ROM: (M)onitor (C)P/M (Z)-System (F)orth (B)ASIC (T)-BASIC (P)LAY (U)SER ROM
Disk: (0)MD1 (1)MD0 (2)IDE0 (3)IDE1
Boot Selection?にIDE0ディスクに対応する2を、Slice(0-9)[0]?に0を入力
code:shell
Boot Selection? 2 Slice(0-9)0? 0 Booting Disk Unit 2, Slice 0...
Reading disk information...
Loc=F200 End=F400 Ent=F200 Label=Fuzix WBW Loader
CCINVALID(0xFF)
INVALID(0xFF)
FUZIX version 0.4
Copyright (c) 1988-2002 by H.F.Bower, D.Braun, S.Nitschke, H.Peraza
Copyright (c) 1997-2001 by Arcady Schekochikhin, Adriano C. R. da Cunha
Copyright (c) 2013-2015 Will Sowerbutts <will@sowerbutts.com>
Copyright (c) 2014-2023 Alan Cox <alan@etchedpixels.co.uk>
Devboot
RomWBW 3.0 on an RC2014@7MHz.
Z80 CTC detected at 0x88.
DS1302 detected at 0x00C0.
PS/2 self test: FF
tty1: Z80 SIO at 0x0080.
tty2: Z80 SIO at 0x0082.
512kB total RAM, 400kB available to processes (20 processes max)
Enabling interrupts ... ok.
IDE drive 0: hda: hda1 hda2 (swap)
IDE drive 1:
IDE drive 2:
IDE drive 3:
SD drive 0: no card found
w5100: unsupported value 0xff written to MR
w5100: writing 0xfe to unsupported register 0x100
w5100: writing 0x04 to unsupported register 0x100
w5100: unsupported value 0xff written to MR
w5100: writing 0x14 to unsupported register 0x100
w5100: unsupported value 0xff written to MR
w5100: writing 0x08 to unsupported register 0x100
w5100: unsupported value 0xee written to MR
w5100: unsupported value 0xff written to MR
bootdevとしてhda1を指定
code:shell
bootdev: hda1
Mounting root fs (root_dev=1, ro): OK
Starting /init
2 buffers added
init version 0.9.1
Checking root file system.
^ ^
n n Fuzix 0.4
@<
Welcome to Fuzix
m m
login: root
Welcome to FUZIX.
#
コマンド一覧(/bin/, /usr/bin/)
/usr/games/もある: advent, cowsayのみ
code:shell
# ls /bin /usr/bin|wc -l
182
# cd /bin
# for f in *
do
echo -n ${f}" "
done
banner basename bd border cal cat chgrp chmem chmod chown cksum cmp cp cut date dd decomp16 df dirname dosread du echo ed env factor false fdisk fgrep flashrom free fsck fsck-fuzix fsh gptparse grep groups halt hd head id ink kbdrate kill killall ll ln logname ls mail man mkdir mkfifo mkfs mknod mode more mount mv nvtool od pagesize paper passwd printenv prtroot ps pwd reboot remount rm rmdir sed seq setboot setdate sh shutdown sleep sort ssh stty su substroot sum swapon sync tail tar tee telinit termcap tget touch tr true ue umount uname uniq uptime uud uue vi vile wc which who whoami write xargs yes
# cd /usr/bin
# for f in *
do
echo -n ${f}" "
done
[ ac accton almanac as09 at atrun bcpl calendar clear col comm cpp cron crypt dc deroff diff diff3 diffh dig dw dwdate dwgetty dwterm echoping expr fforth find htget httpd icint icintv ifconfig join ld09 look m4 make makekey mesg netd-coconic netd-eth netd-lwwire netd-slip newgrp ntpdate pg picol pilot ping pr ptx rev rpilot scc6801 scc6809 scc8080 sccz80 split sum telnet test time tinyirc tsort units wall
設定ファイル(/etc/)
code:shell
# ls /etc
fstab
group
inittab
issue
motd
mtab
netrc
passwd
rc
rc.halt
rc.reboot
resolv.conf
termcap
Shell scriptも動く(なんか、メチャ遅い)
code:bin.sh
for f in /bin/* /usr/bin/*
do
echo -n basename ${f}" "
done
code:shell
# chmod a+x bin.sh
# ./bin.sh
banner basename bd border cal cat chgrp chmem chmod chown cksum cmp cp cut date dd decomp16 df dirname dosread du echo ed env factor false fdisk fgrep flashrom free fsck fsck-fuzix fsh gptparse grep groups halt hd head id ink kbdrate kill killall ll ln logname ls mail man mkdir mkfifo mkfs mknod mode more mount mv nvtool od pagesize paper passwd printenv prtroot ps pwd reboot remount rm rmdir sed seq setboot setdate sh shutdown sleep sort ssh stty su substroot sum swapon sync tail tar tee telinit termcap tget touch tr true ue umount uname uniq uptime uud uue vi vile wc which who whoami write xargs yes [ ac accton almanac as09 at atrun bcpl calendar clear col comm cpp cron crypt dc deroff diff diff3 diffh dig dw dwdate dwgetty dwterm echoping expr fforth find htget httpd icint icintv ifconfig join ld09 look m4 make makekey mesg netd-coconic netd-eth netd-lwwire netd-slip newgrp ntpdate pg picol pilot ping pr ptx rev rpilot scc6801 scc6809 scc8080 sccz80 split sum telnet test time tinyirc tsort units wall
気になったこと
Wiznet w5100をprobeしているので、Ethernetが使える?
ifconfig, telnet, ssh, httpdなどなどもある
viも動かせる(termcapはvt52とxtermのみ)
$ TERM=xterm vi
なぜか、export TERM=xtermできない
おまけ: Fuzix以外で遊ぶ
RomWBWではCP/M, Basic, Forthなども利用可能
Boot Selection?でROMの頭文字を入力
code:shell
RC2014 Boot Loader
(snip)
ROM: (M)onitor (C)P/M (Z)-System (F)orth (B)ASIC (T)-BASIC (P)LAY (U)SER ROM
Disk: (0)MD1 (1)MD0 (2)IDE0 (3)IDE1
Boot Selection?
Fuzix on N8VEM SBC v2
rc2014とほとんど同じだったので、簡単に実行手順だけ
後の説明で、イメージがbuildできたのはこいつ用です
code:shell
$ mkdir sbcv2
$ cd sbcv2/
$ cd ../
$ ../rbcv2 -r roms/Binary/SBC_std.rom -i sbcv2/emu-ide.img
Fuzixを自分で作る
なんか、ドキュメントがほとんどなく、Web検索しても古いものが多くて、めんどくさかったです
開発環境は、デフォルトで/opt/fccにインストール
アセンブラ
code:shell
% gmake
% sudo gmake install
Cコンパイラ
Patch
Makefile: gccじゃなくて$(CC)使うように変えるだけ
cpp*: /lib/cppじゃなくて/usr/bin/cppを使うように変える
test/Makefile: emu65c816が作れないのでとりあえず消しとく
test/lib65c816/config.mk: (一個上の処理で不要だが)gcc直指定を削除
code:patch.diff
diff --git a/Makefile b/Makefile
index 2b2c860..27555ef 100644
--- a/Makefile
+++ b/Makefile
@@ -71,100 +71,100 @@ $(OBJS3): $(INC1) $(INC2)
backend-super8.o: backend-super8.c backend-z8.c
cc: cc.o
- gcc -g3 $< -o cc
+ $(CC) -g3 $< -o cc
(snip)
diff --git a/cpp b/cpp
index 2bbe953..ecea7cd 100755
--- a/cpp
+++ b/cpp
@@ -1,4 +1,4 @@
# Temporary until we get our own cpp
#
-/lib/cpp -undef -nostdinc $*
+/usr/bin/cpp -undef -nostdinc $*
(snip)
diff --git a/test/Makefile b/test/Makefile
index 3498c38..bd141f0 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -1,4 +1,5 @@
-all: emu6502 emu65c816 emu6800 emu85 emuz8 emuz80 byte1802 emu6809 ee200 nova \
+#all: emu6502 emu65c816 emu6800 emu85 emuz8 emuz80 byte1802 emu6809 ee200 nova \
+all: emu6502 emu6800 emu85 emuz8 emuz80 byte1802 emu6809 ee200 nova \
testcrt0.o testcrtz80.o testcrt0_6502.o testcrt0_65c816.o \
testcrt0_6303.o testcrt0_6803.o testcrt0_6809.o testcrt0_z8.o \
testcrt0_byte1802.o testcrt0_ee200.o testcrt0_nova.o testcrt0_nova3.o
diff --git a/test/lib65c816/config.mk b/test/lib65c816/config.mk
index 23b3690..d840263 100644
--- a/test/lib65c816/config.mk
+++ b/test/lib65c816/config.mk
@@ -1,6 +1,5 @@
-CC := gcc
CCFLAGS := -c -O2 -fomit-frame-pointer $(CCOPTS) -DDEBUG -Werror
-LD := gcc
+LD := $(CC)
LDFLAGS :=
PREFIX := /opt/v65c816/
Build
なぜか、3回ほどエラーで止まるが、gmake実行する度に少しずつ進む
$ gmake
結局FUZIXをコンパイルできるところまでは至らず…
$ sudo pkg install -y boost-all texinfo
code:shell
$ cd sdcc280/sdcc
$ CPPFLAGS="-I/usr/local/include" ./configure --prefix=/opt/sdcc --disable-pic14-port --disable-pic16-port # PIC16やPIC14は別の開発環境が必要
$ gmake
$ gmake install
FUZIX
$ sudo pkg install -y bash perl5
make->$(MAKE): Library/libs/Makefile.*
マジックコメント対応
/bin/bash -> /usr/local/bin/bash: Library/link/ld*
/usr/bin/perl -> /usr/local/bin/perl: Standalone/filesystem-src/build-filesystem-ng
code:shell
# make -> gmake
cd Library/libs
for f in Makefile.*
do
cp ${f} ${f}.org
sed -i -e 's/make/gmake/g' ${f}
sed -i -e 's/cfgmake/cfmake/g'
done
# /bin/bash -> /usr/local/bin/bash
cd ../..
cd Library/link
for f in ld*
do
cp ${f} ${f}.org
sed -i -e 's#/bin/bash#/usr/local/bin/bash#' ${f}
done
as及びldのコマンドオプション順序違い: Kernel/platform/platform-sbcv2/Makefile
code:diff
diff --git a/Kernel/platform/platform-sbcv2/Makefile b/Kernel/platform/platform-sbcv2/Makefile
index f5a7c7f8c..9dd246b72 100644
--- a/Kernel/platform/platform-sbcv2/Makefile
+++ b/Kernel/platform/platform-sbcv2/Makefile
@@ -60,6 +60,7 @@ clean:
#
image: bootblock
$(CROSS_LD) -b -C 0x0100 -S 0xF400 -f CLDBbXSs -o fuzix.bin \
+ -m fuzix.tmpmap \
crt0.o commonmem.o sbcv2.o ../../start.o \
../../version.o ../../cpu-z80u/lowlevel-z80u.o \
../../usermem.o tricks.o main.o discard.o \
@@ -76,7 +77,7 @@ image: bootblock
../../dev/net/net_native.o ../../dev/net/net_w5x00.o wiznet.o \
../../dev/ds1302_rbc.o ../../dev/ds1302.o ../../dev/ds1302_discard.o \
../../dev/tinyide_ppide_rbc.o ../../dev/devfd.o \
- /opt/fcc/lib/z80/libz80.a -m fuzix.tmpmap
+ /opt/fcc/lib/z80/libz80.a
perl -lpe '$$_=hex' fuzix.tmpmap | paste -d" " - fuzix.tmpmap | sort -n | cut -d" " -f 2- >../../fuzix.map
../../tools/pack85 <../../fuzix.map fuzix.bin ../../fuzix.bin
cp boot-romwbw.bin fuzix.romwbw
@@ -86,7 +87,7 @@ image: bootblock
#
bootblock:
asz80 boot-romwbw.S
- ldz80 -b boot-romwbw.o -o boot-romwbw.tmp
+ ldz80 -b -o boot-romwbw.tmp boot-romwbw.o
# Chop off the leading 61440 bytes we don't want
dd if=boot-romwbw.tmp of=boot-romwbw.bin bs=512 count=2 skip=120
(snip)
$ gmake
$ gmake diskimage
diskimageはImages/sbcv2/emu-ide.imgに生成される
$ ../rbcv2 -r roms/Binary/SBC_std.rom -i ../../FUZIX/Images/sbcv2/emu-ide.img
JNUG/NBUGでのFuzix OS展望
FuzixをBSDで動かしている様子
とりあえず、LUNA emulator(nono)に実装 nono on FreeBSD/aarch64(Pinebook)
とりあえず、omron LUNAエミュレーターのnonoも動かしてみましょう 必要なpkg(他にもいるかも)
$ sudo pkg install -y wx32-gtk3 gettext-tools
wx-configをこのコマンド名で使えるようにする
code:shell
$ sudo ln -s /usr/local/bin/wxgtk3u-3.2-config /usr/local/bin/wx-config
Build
code:shell
$ ./configure
$ make
https://gyazo.com/bc31ef23cab7d1764750509a00210cb7
おわりに
Fuzix OSをFreeBSD/aarch64(Pinebook)で動かしてみました
グチ: 本当にコレ、手元でbuildできるのか確認してるか?
LUNAエミュレータのnonoも同じく動かしてみました
参考文献
https://gyazo.com/828a760413c96034de0aae062d0b3866
Fuzix World Vol.1
様々なエミュレーターでFuzixを動かす
小江戸らぐ発行の「Linux User」掲載のFuzix関連記事の抜粋
ラズパイ400でお手軽Fuzix
FPGAでFuzix
FuzixでEthernet