Close
0%
0%

CPMDuino

Emulation of a Z80 CP/M computer on an Arduino DUE (merged onto RunCPM)

Similar projects worth following
(Attention: this project has been merged onto my RunCPM project, also featured here)(Attention: All contributions to this project have been moved to the GitHub page.)
Wrote an emulation of a Z80 computer running CP/M inside an Arduino DUE.
This is modeled after an emulation I wrote for Windows, which allows to run old CP/M 2.2 applications on modern windows operating systems.
It can be easily ported to other operating systems, so I ported it to the Arduino platform.
The Arduino required is the DUE, due (no pun intended) to the amount of memory it has, which is needed to contain the 64K RAM for the CP/M CPU.
The sourcecode for the emulator and the original one for windows are to be found at: https://github.com/MockbaTheBorg/RunCPM

MAKE SURE TO FOLLOW THIS PROJECT ON GITHUB AND DISCORD!

Instead of using CP/M disk images, which can be cumbersome and complicated to manage, this project uses a regular FAT filesystem, and emulates CP/M disk drives as subfolders to the SD card, so folder "A" will be disk A:, folder "B" will be disk B: and so on, up to disk P: (the max supported by CP/M).

The emulations acts like a framework on top of the disk system, making the emulated Z80 CPU "think" it has a real CP/M disk environment available.

Some of the physical disk related calls (like moving a disk drive head) are not available, for obvious reasons.

So far I have tried Wordstar, Microsoft Basic, Turbo Pascal, dBase II, UCD Micromumps and more. Everything worked fine, so I guess the emulation if pretty solid.

My special thanks goes to a guy from California called Tom Burnett, for being an "early adopter" and providing a second set of eyes by doing a lot of debugging/testing.

  • 1 × Arduino DUE
  • 1 × SD Card shield
  • 30 × Sleepless nights

View project log

Enjoy this project?

Share

Discussions

Mark Bramwell wrote 11/20/2015 at 18:14 point

oops!  Unless you can read my mind, you need the URL for the screen shot:

 www . foxhollow . ca / CPMduino.png              <== removes spaces for picture

user libraries are installed here:   C:\Users\mbramwell\Documents\Arduino\libraries\SdFat

stock libraries are here:  C:\Program Files (x86)\Arduino\libraries

If you un-install arduino, only the C:\Program Files (x86)\Arduino\libraries gets removed.  The user libraries stay in your c:\users\...\documents folder.  I wonder if you have a SdFat library stored there.

  Are you sure? yes | no

Marcelo Dantas wrote 11/20/2015 at 18:41 point

Oh ok ... I am an Arduino newbie, so let me check there for something... and ...

Tada... there's a SdFat library there. Removing it gets me to the obvious SdFat.h missing, so that's definitely the one being used.

It came from https://github.com/greiman/SdFat

  Are you sure? yes | no

Mark Bramwell wrote 11/20/2015 at 18:06 point

newly installed OS.  Arduino installed for the 1st time.  Your results are promising.  

You do not mention sdFat. 

I just removed sdFat from libraries and of course I get "fatal error: SdFat.h: No such file or directory".  Did you just happen to have a SdFat directory in documents\Arduino\libraires ?

I have placed a screenshot of my library menu open.  Look way down at the bottom.  See under Contributed libraries?  It shows SdFat.  Since you do not mention that you added SdFat, I wonder if it shows up on that list. If yes, the library is in your userid Documents folder and not in your c:\program files(86)\arduino\libraries folder (and probably survived your PC reload if you have backed up your documents folder).

FYI: I have more than 1 laptop.  I have arduino.cc installed on one laptop and arduino.org installed on the other. I have been playing with arduino boards for a LONG time. This feels like a file/library difference problem.

  Are you sure? yes | no

Mark Bramwell wrote 11/20/2015 at 05:43 point

I have given it a try.  Still no go.  "abstraction_arduino.h:189:7: error: 'class SdFile' has no member named 'getFilename'"

The arduino community seems broken.  arduino.cc versus arduino.org

The arduino.cc IDE is 1.6.6   It has the most features but less compatible.  I had to change some other sketches to make them compile with the latest IDE.

The arduino.org IDE is 1.7.7 but seems to be older. My old sketches compile without changes but the IDE does not have the boards & library updating features.

There are MANY sdfat libraries out there.  I have tried them all.  They are all very similar but not identical. If you manage to get it to compile on your computer, let me know exactly what software components you used.  I'll keep trying random things in case I get lucky.

If someone has this working, exactly what IDE version did you use and what sdfat library?

  Are you sure? yes | no

Marcelo Dantas wrote 11/20/2015 at 14:31 point

Don't worry ... we will get to the bottom of this.

I will put my lab back together later today and rebuild the code.

  Are you sure? yes | no

Marcelo Dantas wrote 11/20/2015 at 17:25 point

I have followed these steps:

1 - Went to arduino.cc, downloaded and installed Arduino 1.6.6;

2 - Added support to Arduino DUE under tools->board->boards manager;

3 - Ran all updates for Arduino (the IDE offered updates, which I accepted);

4 - Compiled the code;

5 - Got a few warnings regarding use of NULL on arith. and string conversion;

6 - Loaded the code onto the board and it seems to work with no glitches.

Not sure if it inherited anything from the previous installation, which I removed completely, but all I needed seemed to be available and I didn't have to import any extra libraries.

Do you have multiple Arduino IDEs installed? Maybe the system PATH is pointing to wrong compilers?

  Are you sure? yes | no

Mark Bramwell wrote 11/19/2015 at 15:42 point

I was using arduino 1.6.5 with the lastest sdfat lib from greiman.  Lots of errors.  

A few days ago I updated to the 'just released' 1.6.6.  Different errors but they all seem to relate to the sdfat library.  Specifically I get "CPMduino:9: error: 'SdFat' does not name a type     SdFat SD;"

I have gone through the arduino IDE and updated all boards and libraries to the latest. I feel if the root cause of the first error is resolved, all the other SD errors would disappear.

  Are you sure? yes | no

Marcelo Dantas wrote 11/19/2015 at 16:22 point

I think this is the one I used: https://github.com/adafruit/SD

Please give it a try and let me know.

Cheers,

Marcelo.

  Are you sure? yes | no

Mark Bramwell wrote 11/16/2015 at 21:01 point
I am interested in giving this a try.

 I have a DEU, shield but I cannot get the sdfat to compile. I think I have the latest of EVERYTHING.  I get a few errors on compile. 

I have CPM running under Linux. I also have a Cromemco Z2 S100 box.  I would like to get this compiled on a nodeMCU/ESP8266 with an eventual telnet server instead of serial I/O.

What specific vesion of sdfat should I find?

  Are you sure? yes | no

Marcelo Dantas wrote 11/18/2015 at 13:59 point

Hi Mark,

I don't remember which version I used. Since I did it I had my computer reinstalled and ended up losing my original Arduino environment.

What are the errors you are experiencing? Maybe they can provide a clue.

Cheers,

Marcelo.

  Are you sure? yes | no

Ryan Gass wrote 01/04/2015 at 01:40 point

I have a nice 40x4 character LCD that would make a decent display, but I have not found any good way to automatically scroll the text up the way a serial terminal would. I might try writing a screen buffer for my TFT display.

  Are you sure? yes | no

Ryan Gass wrote 01/04/2015 at 03:29 point

I set up my UNO with a TFT display as a 40 column serial terminal. It works pretty well, but I think CP/M is in 80 column mode. Can this be changed?

  Are you sure? yes | no

Marcelo Dantas wrote 01/04/2015 at 07:46 point

Having CP/M run on 40 columns is possible, but tricky.

Some application work better (if at all) if you have a vt100 (or similar serial terminal) emulation.

The most common were the vt100 (ansi) and the adm3a.

  Are you sure? yes | no

Ryan Gass wrote 01/04/2015 at 14:58 point

I was trying to see how portable I could make it with what I have, but I think the real solution would be to either build/buy a vt100 terminal board or just not use serial and emulate a display controller with the DUE. I don't know how easy emulating a display would be. I've seen it done with a 6502 emulator, but I don't know how CP/M interacts with display controllers.

  Are you sure? yes | no

Marcelo Dantas wrote 01/04/2015 at 19:36 point

Just think serial. CP/M machines were (almost all of them) based on serial monitors. The machines which had their own displays and ran CP/M, did so through some sort of terminal emulation. So you would have to implement, for example, a vt100 emulation (interpret all the ANSI character control sequences).

The source code of such emulation could be easily (or maybe not so easily) adapted from any open source terminal emulator.

I recommend vt100 (ANSI) because this was the terminal type to which almost all of the CP/M programs had support for.

  Are you sure? yes | no

Ryan Gass wrote 01/04/2015 at 20:27 point

The Parallax Propeller chip would be a good fit as a display driver then. It is used a lot for retro computing projects and there is vt100 emulation code for both VGA and composite out. It would add components and cost though, so I might try finding a vt100 parser for Arduino.

  Are you sure? yes | no

Marcelo Dantas wrote 01/05/2015 at 04:39 point

I have found this. Seems cool, didn't have a chance to check it yet though: http://www.microvga.com/

  Are you sure? yes | no

Ryan Gass wrote 01/05/2015 at 05:35 point

I found this:

https://github.com/mkschreder/avr-vt100

Also, a Raspberry Pi computer and TFT makes a perfect terminal, but it's a bit over powered.

  Are you sure? yes | no

Ryan Gass wrote 01/03/2015 at 03:42 point

I got CPMDuino working pretty well with a PS/2 keyboard on a DUE. I'm thinking of making a classic computer clone with a built in keyboard and a video output.

  Are you sure? yes | no

Marcelo Dantas wrote 01/03/2015 at 05:01 point

That is pretty cool. I am interested on seeing the PS2 keyboard adaptation.

There should be still plenty of flash on it to hold a VGA output.

  Are you sure? yes | no

Ryan Gass wrote 01/03/2015 at 13:36 point

Here is the adapted code: https://codebender.cc/sketch:72128

  Are you sure? yes | no

Ryan Gass wrote 01/03/2015 at 15:13 point

Here is the code adapted to use a USB keyboard with the DUE's USB host: https://codebender.cc/sketch:72138

  Are you sure? yes | no

Marcelo Dantas wrote 01/03/2015 at 19:29 point

Cooool!!

  Are you sure? yes | no

Freire wrote 01/01/2015 at 22:23 point

Still some memory/resource for VGA?

http://stimmer.github.io/DueVGA/


It would be perfect!

  Are you sure? yes | no

Marcelo Dantas wrote 01/01/2015 at 23:41 point

I don't know how big this VGA lib would get. But it would definitely be cool to have VGA/Keyboard on CPMDuino.

Not sure if I am feeling brave enough to do the adaptation though, lol.

  Are you sure? yes | no

ucasano wrote 12/30/2014 at 16:48 point

I am not able to download a copy of your git repo.

  Are you sure? yes | no

Marcelo Dantas wrote 12/30/2014 at 17:58 point

HI, I am not sure if I did set up the git repo. Not sure if sourceforge should do it automagically, but you can download the files from the files page directly (unfortunately one by one).

I will check the GIT mode to see if I can make it work. It is definitely a more practical approach.

  Are you sure? yes | no

YH-workshop wrote 12/30/2014 at 16:24 point

Nice project! How fast is the emulated Z80 in the Arduino Due? Is it up to 1MHz?

  Are you sure? yes | no

Marcelo Dantas wrote 12/30/2014 at 18:02 point

Hi YH, I didn't have a change to chrono it, but it is pretty fast. I have been using many CP/M applications on it, and things like Wordstar and dBaseII for example are running pretty fast.

Unfortunately I don't have an application that I could chrono side by side with a physical CP/M machine (in fact I don't even have a physical CP/M machine).

If someone had an application that takes xxx seconds to execute on a real 4Mhz Z80 we could run it on the DUE and time it.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates