classilla / dclinux

Dreamcast Linux, dusted off.
26 stars 0 forks source link

Dusted-off Dreamcast Linux (DODCL)

Another Old VCR Revival!

This is a revised version of the the original 2001 Dreamcast Linux with QoL improvements for modern users and a more straightforward build-burn process. Its primary purpose is to serve as a historical reconstruction, not necessarily a production-ready standard distribution. It exists under the same license as Linux.

The aim with Dusted-off DC Linux is to maintain compatibility with older binaries built for 2K1 DC Linux yet add additional features that make it more convenient to work with. Most of all, a DODCL build should feel nearly indistinguishable in user experience from the original 2K1 DC Linux. No features or tools should be removed if at all possible, and in-place upgrades should be avoided.

Features

Before you file an issue

Things we know don't work

Don't file issues about these.

Some of these things can't be fixed until we get the source code. Unfortunately the source for 2K1 DC Linux and its boot components was stored on a now-defunct FTP server, but we're still looking. Some components such as the kernel and SH-Boot (but not eCos) are still available from the LinuxSH CVS server. For everything that we built, we include the source (or patches against source) in /usr/src.

How to use the disc

DODCL is distributed as components, not as a .cdi image or .bin/.cue you can directly burn. We're willing to add instructions here for other operating systems, but here's how it would work for Linux and probably most BSDs:

If you're burning coasters that the Dreamcast keeps treating as audio CDs, or the burn script plain doesn't work, ensure your drive can burn at the rated speed (we try to burn as close to 4x as possible; my USB Apple SuperDrive burns fine at 10x). You might also try changing -C 0,11700 in ./BURN.sh to a value like -C 0,11702.

NFS

NFS (Network File System) lets you mount remote filesystems on other servers locally. If your Dreamcast has a Broadband Adapter, DODCL not only supports NFS but also supports swap-over-NFS to give you more virtual memory. Almost any modern OS can act as an NFS server.

Without an NFS server, your DC Linux machine will operate standalone. This is supported and works, but most portions of the filesystem will be read-only and the remainder must fit into the RAM disk. Remember: your DC has only 16MB of RAM, which is now also being occupied by the RAM disk, kernel and any running processes, and there is no swap. A lot of things will still work fine but nothing will persist.

If the hostname nfs can be resolved, DODCL will automatically try to mount volumes from it. The relevant section of /etc/fstab looks like this:

nfs:/netfs/dreamcast/linux /netfs nfs rw,hard,intr,rsize=4096,wsize=4096 0 0
nfs:/netfs/dreamcast/linux/tmp /tmp nfs rw,hard,intr,rsize=4096,wsize=4096 0 0

This will automount /netfs/dreamcast/linux on /netfs and /netfs/dreamcast/linux/tmp on /tmp when the system boots. The rsize and wsize have been selected for good performance with the BBA. You can of course mount additional filesystems to /mnt or other locations with the mount -t nfs command after the system is booted; we recommend using the same options (i.e., -o rw,hard,intr,rsize=4096,wsize=4096).

Instructions on how to configure an NFS server are beyond the scope of this document, but for simplicity our local NetBSD NFS server has this for its /etc/exports:

/netfs -alldirs -mapall=censored:censored -noresvport -noresvmnt

This forces all files to be created with uid censored and gid censored (which is fine, since there's only one uid on DODCL anyway) and allows subdirectories to be mounted.

With /netfs mounted, /netfs/startup.sh will be run if it exists and is executable as part of startup, and /netfs/profile, /netfs/csh.cshrc, /netfs/csh.login and /netfs/csh.logout will be executed if they exist and are executable as part of shell startup after executing the defaults in /etc. The shell defaults to bash, so if you want to use tcsh like the other beautiful people, put a line like exec /usr/bin/tcsh into /netfs/profile. You can also set environment variables, aliases, paths, etc. within these files.

If you intend to compile programs on the Dreamcast or run a lot of X apps, you'll really need additional memory or your DC may insidiously run out of space and freeze. DODCL supports swap-over-NFS, allowing you to use the NFS mount as swap. This can be a source of additional system instability if you have a slow network, so it is not the default.

To set up the swapfile, create a file named swapfile of the desired size on the NFS server in what gets mapped to /netfs (I use a 268,435,456 byte file named /netfs/dreamcast/linux/swapfile giving me an additional 256MB of headroom). On the Dreamcast, type mkswap /netfs/swapfile to do the initial configuration. Once this is done, any time you want to enable swap, /etc/init.d/nfsswap.sh start brings it up and /etc/init.d/nfsswap.sh stop disables it. This requires /dev/loop/7; keep in mind that Linux 2.4 has a hard cap of eight loop devices.

NFS is intrinsically far slower than a local disk, and swap-over-NFS is far slower than ordinary virtual memory. Expect that things like compilation and configure scripts will require much more time than on a comparable CPU with local disks.

The Dreamcast Broadband Adapter uses the Realtek 8139 NIC and the driver really stinks in this version of the kernel, something we intend to address if possible in the future. Most of the time this is okay but if you get errors like eth0: Too much work at interrupt, IntrStatus=0x0010. on the console, you're being bit by driver bugs. There is no way around this issue other than to reduce your network activity, such as logging out if you're simultaneously connected remotely, or stop heavy jobs that might cause a lot of NFS reads and writes. Your Dreamcast may freeze if this flaw interrupts a critical swap operation. Sorry.

NTP

NTP (Network Time Protocol) synchronizes your Dreamcast's clock with external time servers supporting the NTP protocol. This is particularly important because DC Linux doesn't support the hardware clock and the time tends to run slow with heavy I/O, leading to "clock slew" errors with things like make.

DODCL provides a pre-built chrony, which is a modern NTP client-server codebase, and a basic configuration file in /usr/etc/chrony.conf:

server ntp iburst
pool pool.ntp.org iburst
driftfile /var/lib/chrony/drift
makestep 1 3

This will automatically try to use a local timesource named ntp along with the North American pool at pool.ntp.org. Either or both will be used depending on their availability. If neither are available, chronyd will simply run in the background. You can use chronyc to check the source(s) being consulted and statistics. The time is stepped initially and then more slowly slewed thereafter.

The time is not synchronized to or from the Dreamcast's hardware clock. If your DC is constantly asking for the time when you turn it on, you may need to replace the battery. On the other hand, you needn't worry about properly setting it if you're just going to boot Linux because it will figure it out automatically.

The default timezone for DODCL is JST, as a tip of the hat to the original maintainers. Because /etc/localtime is part of the initrd and a little tricky to change in place, a simpler solution is to just change the TZ environment variable in your startup scripts (see above). For example, I do export TZ=PST8PDT in /netfs/profile, which sets my shell to North American Pacific time (PST/PDT). The timezones in /usr/share/zoneinfo are up to date with 2023 daylight savings, copied directly from Fedora 37.

Other notes

License

Licenses are determined by the individual packages. Linux itself and anything we added and wrote ourselves are either public domain or GPLv2. Have fun.