Thursday, April 27, 2017

Building Z80 Emulator for CP/M on ESP8266 with a Raspberry Pi

Last month I saw an intriguing article on creating a Z80 CP/M Emulator on my favorite device - the ESP8266 on hackaday.io.

https://hackaday.io/project/20552-cpm-8266

My first real computer was a dual processor 6502 / Z80. That was a bit of a misnomer, as one could not actually use both them at the same time. This was a "Basis 108" Apple II compatible from West Germany: A behemoth of a computer in an awesome cast aluminum case. Essentially the "second" processor was the Z80 add-on board but built-in to the motherboard. The thoughts of revisiting my old friend CP/M was too hard to resist.

I used my existing Build-ESP8266 project on a Raspberry Pi, originally created to ease compiling of MicroPython:

https://github.com/gojimmypi/build_esp8266

As this script downloads and recompiles everything needed for the ESP8266 toolchain, it was a simple matter to adapt for this Z80 CP/M project.

I only needed to adjust one value in the ./cpm8266/code/Makefile

-FLASHBAUD      =  921600
+FLASHBAUD      =  115200
The speed of 921600 was just too crazy, giving an error at upload time:

Makefile:180: recipe for target 'flashinit' failed
make: *** [flashinit] Error 2
So adjusting down to 115200 solved that problem.

I also had the ESP8266 toolchain installed in slightly different locations. Fortunately everything was parameterized in environment variables. So when using my Build_ESP8266 script the values are:

export ESP8266SDK=/opt/esp-open-sdk/
export ESPPORT=/dev/ttyUSB0
export ESPTOOL=/opt/esp-open-sdk/esptool/esptool.py

I added these items to my doPathLink.sh (be sure to run with source command):

source ./doPathLink.sh

From their instructions, I only needed add a few additional items not covered in my Build_esp8266.sh script:

Install prerequisites for cpm8266
apt-get install z80asm cpmtools zip vim-common

After that, a quick compile and upload via "make full" and voila! A working CP/M emulator, shockingly easy!

 
Many thanks to the SmallRoomLabs folks - this is an awesome project! Seeing a CP/M prompt in a putty window is unbelievable!
 
Now I wonder if I can get WiFi working from CP/M....
 
 



1 comment:

  1. Sadly crosstool-NG (installed as part of esp-open-sdk) doesn't seem to build on ARM right now, at least with the current GCC, and after several hours of fighting with it I've given up finding a way to pass the appropriate compiler flags to it. >.<

    ReplyDelete

comments are welcome, but I prefer not to allow links to promotions or other unrelated services.

Find gojimmypi at gojimmypi.github.io

I'm currently working on my new blog home at  gojimmypi.github.io After implementing a variety of features such as dark mode , syntax hi...