2019-04-13 05:16:12 +10:00
|
|
|
# RC2014
|
|
|
|
|
|
|
|
The [RC2014][rc2014] is a nice and minimal z80 system that has the advantage
|
|
|
|
of being available in an assembly kit. Assembling it yourself involves quite a
|
|
|
|
bit of soldering due to the bus system. However, one very nice upside of that
|
|
|
|
bus system is that each component is isolated and simple.
|
|
|
|
|
|
|
|
The machine used in this recipe is the "Classic" RC2014 with an 8k ROM module
|
|
|
|
, 32k of RAM, a 7.3728Mhz clock and a serial I/O.
|
|
|
|
|
|
|
|
The ROM module being supplied in the assembly kit is an EPROM, not EEPROM, so
|
|
|
|
you can't install Collapse OS on it. You'll have to supply your own.
|
|
|
|
|
|
|
|
There are many options around to boot arbitrary sources. What was used in this
|
|
|
|
recipe was a AT28C64B EEPROM module. I chose it because it's compatible with
|
|
|
|
the 8k ROM module which is very convenient. If you do the same, however, don't
|
|
|
|
forget to set the A14 jumper to high because what is the A14 pin on the AT27
|
|
|
|
ROM module is the WE pin on the AT28! Setting the jumper high will keep is
|
|
|
|
disabled.
|
|
|
|
|
2019-05-08 05:26:52 +10:00
|
|
|
## Related recipes
|
|
|
|
|
|
|
|
This recipe is for installing a minimal Collapse OS system on the RC2014. There
|
|
|
|
are other recipes related to the RC2014:
|
|
|
|
|
2019-06-15 04:15:30 +10:00
|
|
|
* [Writing to a AT28 from Collapse OS](eeprom/README.md)
|
2019-05-08 05:26:52 +10:00
|
|
|
* [Accessing a MicroSD card](sdcard/README.md)
|
2019-06-04 03:34:16 +10:00
|
|
|
* [Assembling binaries](zasm/README.md)
|
2019-07-20 05:45:13 +10:00
|
|
|
* [Interfacing a PS/2 keyboard](ps2/README.md)
|
2019-05-08 05:26:52 +10:00
|
|
|
|
2019-11-04 08:09:11 +11:00
|
|
|
## Recipe
|
2019-04-13 05:16:12 +10:00
|
|
|
|
2019-11-04 08:09:11 +11:00
|
|
|
The goal is to have the shell running and accessible through the Serial I/O.
|
2019-12-12 06:05:34 +11:00
|
|
|
To make things fun, we play with I/Os using RC2014's Digital I/O module.
|
2019-04-13 05:16:12 +10:00
|
|
|
|
|
|
|
You'll need specialized tools to write data to the AT28 EEPROM. There seems to
|
|
|
|
be many devices around made to write in flash and EEPROM modules, but being in
|
|
|
|
a "understand everything" mindset, I [built my own][romwrite]. This is the
|
|
|
|
device I use in this recipe.
|
|
|
|
|
|
|
|
### Gathering parts
|
|
|
|
|
2019-05-21 01:00:14 +10:00
|
|
|
* [zasm][zasm]
|
2019-04-13 05:16:12 +10:00
|
|
|
* [romwrite][romwrite] and its specified dependencies
|
|
|
|
* [GNU screen][screen]
|
|
|
|
* A FTDI-to-TTL cable to connect to the Serial I/O module of the RC2014
|
2019-12-12 06:05:34 +11:00
|
|
|
* (Optional) RC2014's Digital I/O module
|
2019-04-13 05:16:12 +10:00
|
|
|
|
2019-04-17 01:50:16 +10:00
|
|
|
### Write glue.asm
|
2019-04-14 06:01:20 +10:00
|
|
|
|
2019-04-17 01:50:16 +10:00
|
|
|
[This is what your glue code would look like.](glue.asm)
|
2019-04-14 06:01:20 +10:00
|
|
|
|
|
|
|
The `platform.inc` include is there to load all platform-specific constants
|
|
|
|
(such as `RAMSTART` and `RAMEND`).
|
|
|
|
|
|
|
|
Then come the reset vectors. If course, we have our first jump to our main init
|
|
|
|
routine, and then we have a jump to the interrupt handler defined in `acia.asm`.
|
|
|
|
|
|
|
|
We need to plug this one in so that we can receive characters from the ACIA.
|
|
|
|
|
|
|
|
Then comes the usual `di` to aoid interrupts during init, and stack setup.
|
|
|
|
|
|
|
|
We set interrupt mode to 1 because that's what `acia.asm` is written around.
|
|
|
|
|
|
|
|
Then, we init ACIA, shell, enable interrupt and give control of the main loop
|
2019-12-12 06:05:34 +11:00
|
|
|
to the BASIC shell.
|
2019-04-14 06:01:20 +10:00
|
|
|
|
2019-04-15 01:11:13 +10:00
|
|
|
What comes below is actual code include from parts we want to include in our
|
|
|
|
OS. As you can see, we need to tell each module where to put their variables.
|
2019-12-12 06:05:34 +11:00
|
|
|
See `apps/README.md` for details.
|
2019-04-14 06:01:20 +10:00
|
|
|
|
2019-12-12 06:05:34 +11:00
|
|
|
You can also see from the `STDIO_GETC` and `STDIO_PUTC` macros that the shell
|
|
|
|
is decoupled from the ACIA and can get its IO from anything. See comments in
|
|
|
|
`kernel/stdio.asm` for details.
|
2019-04-15 04:24:29 +10:00
|
|
|
|
2019-04-13 05:16:12 +10:00
|
|
|
### Build the image
|
|
|
|
|
|
|
|
We only have the shell to build, so it's rather straightforward:
|
|
|
|
|
2020-01-01 07:07:39 +11:00
|
|
|
../../emul/zasm/zasm ../../kernel < glue.asm > os.bin
|
2019-11-05 06:45:10 +11:00
|
|
|
|
|
|
|
Running `make` will also work.
|
2019-04-13 05:16:12 +10:00
|
|
|
|
2020-01-03 08:59:38 +11:00
|
|
|
### Emulate
|
|
|
|
|
|
|
|
The Collapse OS project includes a RC2014 emulator suitable for this image.
|
|
|
|
You can invoke it with `make emul`. See `emul/hw/rc2014/README.md` for details.
|
|
|
|
|
2019-04-13 05:16:12 +10:00
|
|
|
### Write to the ROM
|
|
|
|
|
|
|
|
Plug your romwrite atmega328 to your computer and identify the tty bound to it.
|
|
|
|
In my case (arduino uno), it's `/dev/ttyACM0`. Then:
|
|
|
|
|
|
|
|
screen /dev/ttyACM0 9600
|
|
|
|
CTRL-A + ":quit"
|
|
|
|
cat rom.bin | pv -L 10 > /dev/ttyACM0
|
|
|
|
|
|
|
|
See romwrite's README for details about these commands.
|
|
|
|
|
|
|
|
### Running
|
|
|
|
|
|
|
|
Put the AT28 in the ROM module, don't forget to set the A14 jumper high, then
|
|
|
|
power the thing up. Connect the FTDI-to-TTL cable to the Serial I/O module and
|
|
|
|
identify the tty bound to it (in my case, `/dev/ttyUSB0`). Then:
|
|
|
|
|
|
|
|
screen /dev/ttyUSB0 115200
|
|
|
|
|
|
|
|
Press the reset button on the RC2014 and you should see the Collapse OS prompt!
|
2019-12-12 06:05:34 +11:00
|
|
|
See documentation in `apps/basic/README.md` for details.
|
|
|
|
|
|
|
|
For now, let's have some fun with the Digital I/O module. Type this:
|
|
|
|
|
|
|
|
```
|
|
|
|
> a=0
|
|
|
|
> 10 out 0 a
|
|
|
|
> 20 sleep 0xffff
|
|
|
|
> 30 a=a+1
|
|
|
|
> 40 goto 10
|
|
|
|
> run
|
|
|
|
```
|
|
|
|
|
|
|
|
You now have your Digital I/O lights doing a pretty dance, forever.
|
2019-04-13 05:16:12 +10:00
|
|
|
|
|
|
|
[rc2014]: https://rc2014.co.uk
|
|
|
|
[romwrite]: https://github.com/hsoft/romwrite
|
2019-05-21 01:00:14 +10:00
|
|
|
[zasm]: ../../tools/emul
|
2019-04-13 05:16:12 +10:00
|
|
|
[screen]: https://www.gnu.org/software/screen/
|