|
| 1 | +# FUZIX Port to the Rosco r2 SBC |
| 2 | + |
| 3 | +Warren Toomey - 2025/02/05 |
| 4 | + |
| 5 | +## Introduction |
| 6 | + |
| 7 | +This is the port of FUZIX to the Rosco r2 m68k SBC: |
| 8 | +https://github.com/rosco-m68k/rosco_m68k |
| 9 | + |
| 10 | +It's a work in progress and some things don't work well yet. |
| 11 | + |
| 12 | +## Building FUZIX |
| 13 | + |
| 14 | +You will need the toolchain described in |
| 15 | +https://github.com/rosco-m68k/rosco_m68k/blob/develop/code/Toolchain.md |
| 16 | + |
| 17 | +At the top-level FUZIX directory, you can do: |
| 18 | + |
| 19 | +``` |
| 20 | +make TARGET=rosco-r2 kernel # Build the kernel, which creates |
| 21 | + # the file Kernel/fuzix.bin |
| 22 | +make TARGET=rosco-r2 diskimage # Builds the libraries and applications, |
| 23 | + # and then creates the filesystem image |
| 24 | + # Images/rosco-r2/filesys.img |
| 25 | +make TARGET=rosco-r2 kclean # Clean up the kernel build. Do this if |
| 26 | + # you make any kernel config changes |
| 27 | +make TARGET=rosco-r2 clean # Clean up everything |
| 28 | +``` |
| 29 | + |
| 30 | +There is a shell script here called `mk_fs_img`. Once you have |
| 31 | +`Kernel/fuzix.bin` and `Images/rosco-r2/filesys.img` you can run |
| 32 | +this script to make the SD card image `sdcard.img` which has the |
| 33 | +bootable kernel in partition 1 and the populated FUZIX filesystem |
| 34 | +in partition 2. |
| 35 | + |
| 36 | +## Booting with an SD Card |
| 37 | + |
| 38 | +Copy the card image `sdcard.img` to your SD card. Under Linux I do: |
| 39 | + |
| 40 | +``` |
| 41 | +cat sdcard.img > /dev/sdc; sync; sync |
| 42 | +``` |
| 43 | + |
| 44 | +At boot time, the SD card should appear as `hda` with two partitions. |
| 45 | +Use the boot device `hda2` and login as `root` with no password: |
| 46 | + |
| 47 | +``` |
| 48 | +FUZIX version 0.5 |
| 49 | +Copyright (c) 1988-2002 by H.F.Bower, D.Braun, S.Nitschke, H.Peraza |
| 50 | +Copyright (c) 1997-2001 by Arcady Schekochikhin, Adriano C. R. da Cunha |
| 51 | +Copyright (c) 2013-2015 Will Sowerbutts <will@sowerbutts.com> |
| 52 | +Copyright (c) 2014-2025 Alan Cox <alan@etchedpixels.co.uk> |
| 53 | +Devboot |
| 54 | +Motorola 68010 processor detected. |
| 55 | +1024KiB total RAM, 917KiB available to processes (125 processes max) |
| 56 | +Enabling interrupts ... ok. |
| 57 | +SD drive 0: hda: hda1 hda2 |
| 58 | +CH375 device: not found |
| 59 | +bootdev: hda2 |
| 60 | +... |
| 61 | +login: root |
| 62 | +``` |
| 63 | + |
| 64 | +## Booting with the CH375 Device and a USB Drive |
| 65 | + |
| 66 | +If you have built the CH375 daughter board as described |
| 67 | +[here](https://github.com/DoctorWkt/xv6-rosco-r2/tree/ch375/hardware) |
| 68 | +then you can copy the FUZIX filesystem to a USB drive and mount it |
| 69 | +as the root device. |
| 70 | + |
| 71 | +However, as the Rosco r2 SBC boots from the SD card, you need to copy |
| 72 | +the SD card image `sdcard.img` to both your SD card and your USB drive. |
| 73 | + |
| 74 | +At boot time, the SD card should appear as `hdb` with two partitions. |
| 75 | +Use the boot device `hdb2` and login as `root` with no password. |
| 76 | + |
| 77 | +If you have installed 1M of expansion RAM on the daughter board and closed |
| 78 | +jumper JP4, then the kernel will see the extra RAM and report that you have |
| 79 | +2M of RAM. |
| 80 | + |
| 81 | +``` |
| 82 | +FUZIX version 0.5 |
| 83 | +Copyright (c) 1988-2002 by H.F.Bower, D.Braun, S.Nitschke, H.Peraza |
| 84 | +Copyright (c) 1997-2001 by Arcady Schekochikhin, Adriano C. R. da Cunha |
| 85 | +Copyright (c) 2013-2015 Will Sowerbutts <will@sowerbutts.com> |
| 86 | +Copyright (c) 2014-2025 Alan Cox <alan@etchedpixels.co.uk> |
| 87 | +Devboot |
| 88 | +Motorola 68010 processor detected. |
| 89 | +2048KiB total RAM, 1941KiB available to processes (125 processes max) |
| 90 | +Enabling interrupts ... ok. |
| 91 | +SD drive 0: hda: hda1 hda2 |
| 92 | +CH375 device: hdb: hdb1 hdb2 |
| 93 | +bootdev: hdb2 |
| 94 | +... |
| 95 | +login: root |
| 96 | +``` |
| 97 | + |
| 98 | +## Configuration |
| 99 | + |
| 100 | +Look in `config.h` for compile-time configuration defines. |
| 101 | +`TTY_INIT_BAUD` is set for 115200 baud. `CONFIG_FLAT` means we have no MMU. |
| 102 | +`CONFIG_SD` and `SD_DRIVE_COUNT` sets us up for one SD card. |
| 103 | +`CONFIG_USB` supports my USB expansion board: |
| 104 | +https://github.com/DoctorWkt/xv6-rosco-r2/tree/ch375/hardware |
| 105 | + |
| 106 | +This line in `fuzix.ld`: |
| 107 | + |
| 108 | +``` |
| 109 | +ram (rwx) : ORIGIN = 0x2000, LENGTH = 0x100000-0x2000 |
| 110 | +``` |
| 111 | + |
| 112 | +says that the kernel starts at $2000 and we have $100000 (1 Meg) of RAM. |
| 113 | + |
| 114 | +## Booting |
| 115 | + |
| 116 | +The Rosco ROM loads the kernel at address $40000. The code in `crt0.S` |
| 117 | +copies the kernel down to $2000. Then, interrupts are enabled and the |
| 118 | +BSS gets cleared. These functions are then called: `init_early()`, |
| 119 | +`init_hardware()` and `fuzix_main()`. |
| 120 | + |
| 121 | +## Devices |
| 122 | + |
| 123 | +`devices.c` holds a tables of devices and associated functions. The |
| 124 | +main ones are the block devices (0) and the tty device (2). |
| 125 | +`device_init()` is called to probe devices and initialise them. |
| 126 | + |
| 127 | +## The DUART |
| 128 | + |
| 129 | +The code to use the XR68C681 DUART is in `devtty.c`. I have made the |
| 130 | +`tty_setup()` function do essentially nothing. The Rosco ROM sets the |
| 131 | +DUART up for 115200 baud. The Fuzix code then does something which |
| 132 | +scrambles the 115200 baud setting. Until I can figure it out, I've |
| 133 | +just disabled it. |
| 134 | + |
| 135 | +## The SD Card |
| 136 | + |
| 137 | +The kernel is configured to have SD card support. The file `p68000.S` has |
| 138 | +assembly functions to bit-bang the SD card using the DUART: |
| 139 | + |
| 140 | +``` |
| 141 | + .globl sd_spi_clock |
| 142 | + .globl sd_spi_raise_cs |
| 143 | + .globl sd_spi_lower_cs |
| 144 | + .globl sd_spi_transmit_byte |
| 145 | + .globl sd_spi_receive_byte |
| 146 | + .globl sd_spi_transmit_sector |
| 147 | + .globl sd_spi_receive_sector |
| 148 | +``` |
| 149 | + |
| 150 | +and the high-level SD card code is in `Kernel/dev/devsd.c` and |
| 151 | +`Kernel/dev/devsd_discard.c`. |
0 commit comments