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

Walter Gavin wrote 11/30/2020 at 15:33 point

I have z80 emulator for dos 6.2 with IBM's it can run any old software without Z80 hardwares. I knew hard to find softwares that I have it because of copyright.

  Are you sure? yes | no

Walter Gavin wrote 11/30/2020 at 15:03 point

  They made first Z80 cpu system that can running with cpm, plm51 and plm86 before dos 5.1 or 6.2. I still have plm51 software that I used with z80 emulator with dos. Let you know I am deaf and used to be electronic tech for private company long time ago that they taught me how it works for programmers. I think your designed with arduino is very neat and coolest for old systems. I wish I could give you plm51 software with compression. I think you might have it not surely. Thanks. 

  Are you sure? yes | no

Marcelo Dantas wrote 11/30/2020 at 16:39 point

Hi Walter, I do not have PL/M compiler for CP/M, if could be a good addition to the collection. Take a look at the RunCPM readme on GitHub, I have added there a link for my entire CP/M software collection.
If you have anything that is not there already, and you want to contribute to the collection, feel free to do so. 
Just make the communication via the GitHub (or join the Discord server).

Thanks!

  Are you sure? yes | no

Walter Gavin wrote 11/29/2020 at 11:49 point

What about PL/M 51 for 8051 microcontroller it is pascal language to run on Z80 emulator I do have pl/m 51. 

  Are you sure? yes | no

Marcelo Dantas wrote 11/30/2020 at 08:56 point

Give it a try, any CP/M 2.2 application that doesn't use direct access to disk and hardware should work, unless it has hardcoded terminal escape sequences other than ansi/vt100.

  Are you sure? yes | no

Marcelo Dantas wrote 11/30/2020 at 09:04 point

Keep in mind that cpmduino has merged into RunCPM and moved to GitHub. Make sure you get any source code from there.

This page is kept only for historical reasons. 

  Are you sure? yes | no

fabian wrote 07/19/2018 at 13:57 point

please change link to RunCPM

  Are you sure? yes | no

moxhamj wrote 06/23/2017 at 13:32 point

Brilliant project. Working right out of the box. I used Putty for a terminal as this can handle the VT100 codes that Wordstar uses. Also bumped the baud rate up to 115200. Having used emulations in the past that needed CP/M disk images, this is *much* easier with your system of putting files in fat32 directories. Must have been a lot of work behind the scenes getting that working! Next step - building a terminal using one of the cheap TFT touchscreens. Cheers, James Moxham

  Are you sure? yes | no

Marcelo Dantas wrote 06/26/2017 at 15:38 point

Glad you are having fun. It was a lot of work indeed.

Once you have your project done, make sure to send pictures, I would love to see them.

Cheers!

Marcelo.

  Are you sure? yes | no

moxhamj wrote 07/14/2018 at 02:12 point

Sorry it took a year (!) but I finally have a VT100 terminal working on a touchscreen. It works brilliantly with this project. Just need to do some level translation from 5V to 3V. I need to write it up etc. Code and photos are on the RC2014 google group forum. 

  Are you sure? yes | no

Martian wrote 01/23/2017 at 21:36 point

  Are you sure? yes | no

Martian wrote 01/23/2017 at 14:19 point

I'll write it up as a project and send you a link ;-)

  Are you sure? yes | no

Marcelo Dantas wrote 01/23/2017 at 14:05 point

Awesome news!!! .... have pictures??? ... share your experience. I keep thinking about building a hardware version myself ... just too lazy.

  Are you sure? yes | no

Martian wrote 01/23/2017 at 09:04 point

Just a quick update, I finished building my CP/M computer, it's nicely cased etc.  Got the drive full of software and I have been using it a lot, thanks again for this project and helping me build my own CP/M computer!

  Are you sure? yes | no

Marcelo Dantas wrote 07/29/2016 at 00:22 point

Hi All,

Now the Arduino DUE version has access to the Arduino DUE pins via BDOS calls.

So you can write CP/M programs in any language capable to run BDOS calls, and access the Arduino DUE pins with them.

The Arduino DUE call framework was written by a good friend, Kzysztof Klis.

Have fun,

Marcelo.

  Are you sure? yes | no

Martian wrote 06/09/2016 at 21:49 point

Thanks for the prompt reply, great project you have there.  I think I'll acquire a Due, I'd love my own little CP/M computer.  I'll let you know how I get on.  :)

  Are you sure? yes | no

Martian wrote 06/09/2016 at 19:43 point

Where does this project stand as of June 2016?  If I buy a Due and download the source, can I build a reliable CP/M system with it?

Also I have a SPI MicroSD adaptor from another project I've been working on, would that work as is?

Thanks..

  Are you sure? yes | no

Marcelo Dantas wrote 06/09/2016 at 20:16 point

I have it running on a Due with a micro SD shield ... the code is fully function and emulates a CP/M machine nicely.

  Are you sure? yes | no

Marcelo Dantas wrote 06/09/2016 at 20:17 point

Regarding the SPI MicroSD, as long as you use the same FAT library (see posts below) then you should have no problems. But it is still a hit/miss ... I can't make guarantees on your adapter, unfortunately.

  Are you sure? yes | no

Martian wrote 12/24/2016 at 21:39 point

Just an update, I've treated myself to a DUE clone and have used the SPI MicroSD adaptor, works fantastically.  Boots CP/M, can run MBASIC programs.  I'm having problems locating working software like WordStar etc.  Most places I find that have VT-100 friendly software seem to be in .DSK files and I can't mount those or extract the apps from them.  Any ideas?  Or do you know of a better archive?

  Are you sure? yes | no

CRISTIAN wrote 11/30/2015 at 00:58 point

Thank you, you're very kind, try to implement the code in a Arduino Mega.

  Are you sure? yes | no

CRISTIAN wrote 11/27/2015 at 22:44 point

Tkanks for you atencion!.

I managed refedinir the ROMSIZE , but ahun no conflict with the int32 SP ; tells me that :

sketch\cpu.h:11:7: error: expected ')' before 'volatile'.

Perhaps the int SP, has a conflict .
What could I do?

  Are you sure? yes | no

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

Hello Christian,

The ATmega328 has only 32K bytes of Flash, while the compiled code of CPMDuino has 57K, so it will not fit.

I am quite sure that you are having these errors because of this incompatibility.

Your only option would be to use an Arduino DUE.

The Arduino DUE has 96K of RAM and 512K of flash (see the differences here: https://www.arduino.cc/en/Products/Compare).

In fact, I chose the Arduino DUE to migrate my Windows based code exactly because it had lots of memory (RAM and Flash).

CPMDuino is a very big code, it needs lots of memory and CPU power to run.

Feel free to send me an email on marcelo[dot]f[dot]dantas[at]gmail[dot]com if you want to discuss other options.

Abraços,

Marcelo.

  Are you sure? yes | no

CRISTIAN wrote 11/26/2015 at 23:28 point

Arduino:1.6.6 Hourly Build 2015/07/20 04:41 (Windows 8.1), Placa:"Arduino Nano, ATmega328"
In file included from CPMduino.ino:12:0:
sketch\abstraction_arduino.h:18:18: error: size of array 'RAM' is negative
 uint8 RAM[RAMSIZE]; // RAM must go into memory
                  ^
In file included from c:\users\fmv\downloads\arduino\arduino-nightly\hardware\tools\avr\avr\include\avr\io.h:99:0,
                 from c:\users\fmv\downloads\arduino\arduino-nightly\hardware\tools\avr\avr\include\avr\pgmspace.h:88,
                 from C:\Users\FMV\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.8\cores\arduino/Arduino.h:28,
                 from C:\Users\FMV\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.8\libraries\SPI/SPI.h:17,
                 from CPMduino.ino:3:
sketch\cpu.h:11:7: error: expected unqualified-id before 'volatile'
 int32 SP;  /* SP register                                  */
       ^
sketch\cpu.h:11:7: error: expected ')' before 'volatile'
sketch\cpu.h:11:7: error: expected ')' before 'volatile'
Error de compilación
  This report would have more information with
  "Show verbose output during compilation"
  activala desde Archivo > Preferencias

  Are you sure? yes | no

Marcelo Dantas wrote 11/27/2015 at 13:23 point

Hi Cristian,

The CPMDuino code is specific for the Arduino DUE, because the CP/M machines had usually 64K of RAM, so only the Arduino DUE (as far as I know) is able to run it.

Maybe the other Arduinos would be able to do it by adapting the RAM abstraction functions inside abstraction.h, and by adding extra external RAM onto the board. 

However this would be a bit more complicated than I wanted to (and would add extra devices to the board) so I decided not to go that way.

I am not sure also if the UNO would be up to the task of running the emulation, as the DUE has a pretty powerful ARM processor.

Grande abraço,

Marcelo.

  Are you sure? yes | no

CRISTIAN wrote 11/26/2015 at 23:28 point

Greetings, I congratulate you on your project , it is very Become interested , the reason for my question is whether the porgrama runs on Arduino one or nano, and another question is to know what is the mistake that keeps compile. I get:

  Are you sure? yes | no

Mark Bramwell wrote 11/22/2015 at 16:56 point

I am making great progress with the ESP8266 telnet server.  My question to you is:  What ESP8266 modules do you have?  I went nuts on ebay a few weeks ago and purchased a pair of every type I could find.  My favorite for development work is the nodemcu because it is the ESP8266 + power supply + USB chip all on a single board.  It makes it very easy to use and is breadboard friendly.

How do you expect to hook up one of these to your DUE? The 3.3v power requirements is higher than what is normally on an arduino output. The nodemcu will take raw 5v in and has its own regulator. I am thinking hooking into the DUE's raw power output pin and let the ESP board regulate it.

  Are you sure? yes | no

Marcelo Dantas wrote 11/23/2015 at 04:06 point

I ended up buying the modules without a breakout board of any type (they looked bigger in the picture)... so I had to order breakout boards on eBay, which are going to arrive at any moment.

Then I will decide how to do it. But this is subject for a new project. Let's not clutter here, drop me a note at marcelo[dot]f[dot]dantas[at]gmail[dot]com.

Cheers,

Marcelo.

  Are you sure? yes | no

yeti wrote 11/21/2015 at 04:47 point

Can you please make versioned archives for download instead of presenting all source files individually? Or what about gitlab or something competitive?

  Are you sure? yes | no

Marcelo Dantas wrote 11/21/2015 at 13:57 point

Hi Yeti,

When I wrote CPMDuino I had no experience whatsoever with Github. Sorry.

The version at sourceforge is the latest, I uploaded it only when I considered the software to be finished. I am not developing it anymore.

I may move it into Github in the future, but being it so small (9 files only) and stale (no new versions for a while) I see no point on doing it right now.

Cheers,

Marcelo. 

  Are you sure? yes | no

Mark Bramwell wrote 11/20/2015 at 21:59 point

Success!   It compiles (no errors or warnings).  I'll document the steps on my site, I am sure google will find it if others start looking.  I want to add telnet support via an ESP8266.  Give me a week or two and I'll post my progress.

Thanks for help me through this all!

  Are you sure? yes | no

Marcelo Dantas wrote 11/20/2015 at 22:39 point

Cool ... that's good news.

I just got a couple ESP8266 modules myself for another project.

If you manage to make it work with the ESP8266 please let me know. I would like to give it a try too.

Cheers!

  Are you sure? yes | no

Mark Bramwell wrote 11/20/2015 at 19:06 point
ok, finding that library in your

c:\users\...\documents folder makes sense.

I am trying to make my environment match yours. 

I now get this error: " abstraction_arduino.h:189: error: 'class SdFile' has no member named 'getFilename'    dir.getFilename((char*)dirname);

I have manually done a search.  "getFilename" does not exist in any of the sd or sdfat libraries.  It only exists in your abstraction_arduino.h   (and is being called by your code but the actual code is not in there)

The sourceforge link in your blog has 9 files.  Can you confirm that 9 files are the required amount?  One of your messages mentions CPM22.BIN which is not in that 9-file listing but I found it in the windows version.  Do I need more source files (other than the 9 CPMduino files) ?

  Are you sure? yes | no

Marcelo Dantas wrote 11/20/2015 at 20:37 point

Yup ... only those 9 files.

The "getFilename" comes from "dir", which is instantiated on line 6 of CPMduino.ino from SdFile.

SdFile.cpp somehow is on my SdFat library, and googling for that sent me to a SdFat created by SparkFun.

It has been some time since I created this project, so I am not sure anymore which SdFat library I used. And looks like everyone creates their own.

So, to make things easier for you (I know its cheating) I have uploaded my SdFat to the sourceforge site.

Please grab that one and give it a try. It should solve the problem.

Please let me know if it works.

  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