Kjetil's Information Center: A Blog About My Projects

CP/M on the GR-SAKURA

I have ported my "kaytil" Z80 CP/M 2.2 emulator to the Gadget Renesas GR-SAKURA reference board. This means it's possible to run all kinds of off-the shelf CP/M games and software on this board.

Even though it's based on the "kaytil" codebase, some heavy modifications have been done. All the trace and debug functions have been removed to reduce the binary size and also to speed up emulation. The Z80 emulation core remains the same but the console and disk emulations have been adapted to the different hardware. The CPM 2.2 and CBIOS binaries are embedded directly into the code to allow for easier standalone operation.

For the floppy disk emulation, the floppy disk images needs to be placed at the root directory on a FAT16 formatted MicroSD card (first partition) and be named "A.IMG", "B.IMG", "C.IMG" and "D.IMG" for each of the four drives. The MicroSD card on the GR-SAKURA is read through SPI and is kind of slow, so a simple caching mechanism has been implemented where the lowest sectors are cached in memory. To get optimal performance the FAT16 partition should be placed as close as possible to the MBR, possibly on sector 3, as this should get the actual FAT table cached into memory. Note that there is only read support, any writes to floppy disk by the CP/M OS are simply ignored. The four on-board LEDs on the GR-SAKURA are used as disk activity indicators.

For the console emulation I was first considering to use Renesas USB-CDC library to provide this over the USB connection, but I could not get it to work properly, as it seemed to get congested by too much traffic and just freeze. Instead, the first UART is used, marked by pins 0 (RX) and pin 1 (TX) on the GR-SAKURA, and it runs on 115200 baud for best performance. Same as the "kaytil" emulator on Linux; conversion between ADM-3A codes to VT100/ANSI codes are done in the emulator already. I wonder if it would have been technically possible to remove this conversion and connect a real Lear Siegler ADM-3A terminal (with a voltage level shifter) directory to the GR-SAKURA...

The RX CPU on the GR-SAKURA runs at 96MHz I believe, and compiling the emulator with -O2 optimization makes the speed nearly similar to a real Kaypro II, which is nice.

You can download the first version here and there is also a branch on the "kaytil" git repo.

Topic: Open Source, by Kjetil @ 04/10-2021, Article Link