News:

The Savage///Circuits website has been upgraded to a more efficient theme.

Main Menu

Z80 Emulation Using the RP2040

Started by Chris Savage, Dec 31, 2025, 09:05 AM

Previous topic - Next topic

granz

Quote from: MicroNut on Mar 26, 2026, 09:40 AMI had a job back in 1986 that had a computer that ran CP/M. We didn't use it but during some of my down time I played Monopoly on it.
I never had much chance to play with CP/M either. Being a TRS-er (my first computer was that ZX-81, but my first "real" computer - that had disk drives and a real (not the thermal) printer was the TRS-80 Model I) I played with TRS-DOS, NewDOS and LDOS, much more than CP/M. The Model II, and IV, could run CP/M, but the Model I took some expensive hardware to run it.

Quote from: MicroNut on Mar 26, 2026, 09:40 AMI thought about getting that Geeekboard with the LCD. The buzzer doesn't always buzz on the boards but when I connected mine to power it usually did so I have it tied to ground. It annoys my wife since my "workshop" is my side of the recliner couch with a lapboard. It drowns out the audio from the episode of Gilmore Girls she's watching :)

Strange, I wonder what the difference is? I'll have to take a look at the schematics to see what they did differently in the wiring. I wonder if there is something that you can do to to the board to stop the buzzing while leaving the speaker header pin open to use? Have you tried leaving a wire connecting the speaker input to one of the GPIO pins of the Pico?

MicroNut

The buzzing is a strange thing. If you look at the reviews, many people had this problem and grounding it was the solution. My guess is that the board is multilayered with a power plane a ground plane. And the power plane may be too close to the buzzer trace causing the floating issue. They may have corrected it for your LCD board.
Always looking to the stars.

granz

Quote from: Chris Savage on Mar 26, 2026, 10:32 AM
Quote from: granz on Mar 26, 2026, 08:09 AMI have seen that board, but decided on the one with the LCD instead.

I couldn't help but notice one thing missing from the Pico Breadboard Kit...namely, the breadboard! LOL


Yeah, I normally think that the half-sized breadboards are a bit too small (unless I am trying to design a tiny dev kit, of course. :P ) That is why I chose the one with the LCD, rather than the breadboard.

The double breadboards is one of the things that I really like about my K & H, DT-01 Digital Trainer (https://www.kandh.com.tw/dt-01-digital-trainer-dt-01.html), the Propeller Professional Development board in my Portable Workstation - Notebook (https://zappbots.altervista.org/forum/viewtopic.php?f=40&t=327) and the several Radio Shack-style breadboards (https://www.amazon.com/Makeronics-Solderless-Tie-Points-Breadboard-Prototyping/dp/B07Q34YND5).

Chris Savage

Quote from: MicroNut on Mar 25, 2026, 10:03 PMI decided to join the fun ;D . My setup is the following: Pico WH, Parallax 32312 Micro SD Card adapter. I did the suggested doubling of the ground and power jumpers and I got the SD card running so now I'm running RunCPM. Next I'll try the emulator that Chris pointed out to see if I can use the Pico's Wifi.

So, the CP/M install doesn't require the Z80 Emulation? I guess I thought the emulator provided the Z80 capability to run the O/S AND the assembly programming.  :-\

                     Bringing concepts to life through engineering.

granz

Quote from: Chris Savage on Mar 27, 2026, 04:38 PMSo, the CP/M install doesn't require the Z80 Emulation? I guess I thought the emulator provided the Z80 capability to run the O/S AND the assembly programming.  :-\

RunCPM is an emulator, written in C, which has been ported to many different platforms (https://github.com/MockbaTheBorg/RunCPM). The version that we are reviewing here has been ported to the Raspberry Pi Pico (https://github.com/guidol70/RunCPM_RPi_Pico). It is a regular .UF2 file (object code file for the Pico,) and once installed on the Pico, turns it into a Z-80 based CP/M system. So, yes the RunCPM is, in and of itself, a Z-80 emulator. Included in that emulator is a BIOS to allow the Z-80 to read from, and write to, the SD card, and boot the CP/M included there.

One of the great things about this Pico version is that it is distributed in the .UF2 format (although you can download the source and compile it yourself with a C compiler.) The .UF2 format allows it to be simple to install. The Pico has a built-in "boot loader," where you hold down the Boot button in the Pico while plugging the USB cable into your PC. When you plug it in, it appears to your OS (Windows, Mac or Linux) as a new drive - like a thumb drive. This new "drive" has two files already on it, and you just click-and-drag the .UF2 file onto that new "drive." This copies the file to the Pico, and when the file is done copying, the new drive on your PC disappears, the Pico reboots and starts running the program in that .UF2 file. In the case of RunCPM, that program is the Z-80 emulator, along with the custom BIOS and the CP/M files on the SD card. The rest of the SD card is for hard drives, which are actually just sub-directories (folders) named A through P (for drives A: through P: - 16 drives is the maximum that CP/M can access.)

Chris Savage


                     Bringing concepts to life through engineering.

MicroNut

#81
The last few days I've been running the RunCPM Pico emulator and the Z80 Pico emulator which runs CP/M 2.2 and here is what I found out.

RunCPM https://github.com/guidol70/RunCPM_RPi_Pico
This has many versions. You do need to be careful of which version to use based on your Pico. I tried the 275MHz version on a Pico W and it didn't work. The author mentioned using the 260MHz version and that worked. The latest 260MHz version is 6.7. Another thing is that when you compile the ino file for the 260MHz version it won't compile because of a mismatch error in the SDFat library it uses but the other versions compiled. I had to downgrade my Pico board version from 5.5.1 to 4.0.0 to compile it. Thankfully as @granz pointed out there is a uf2 file so there is no need to compile it.

Using the AI Codec I tried adding telnet to the code. Codec was able to add it but when I ran it the banner in the serial terminal showed WIFI is unsupported. I found creating CP/M disks was very easy to do on the SD card since the cp/m rom is built into the emulator.


Z80 Emulator https://github.com/djbottrill/rp2040_z80_emulator
This emulator will boot into Nascom Basic if it doesn't find CPM 2.2 roms in the root directory of the SD card. If it does detect if you are using a Pico W it will start up the Telnet server Pico80.

The documentation on how to set up the SD card and use CPM is poor and at first I couldn't get it to work. With Codec I found out how to use it. It needs the rom files with a txt mapping file in the root directory, a directory /downloads with the cpm files you want to use and a /disk director with A.dsk, B.dsk... .  You need to copy the SD Card directory in GitHub into your SD card. Transferring files is a bit of a chore. There are 3 commands you need to use.

SDPATH <directory> This switches the CP/M to that directory on the SD card. It defaults to /download if not used.

SDFILES - Shows the files in SDPATH.

SDCOPY <File> Copies the file found in the SDPATH to the current dsk file the CPM is using.

This is very cumbersome. I found a bug in the CPM. When you do DIR or DIR *.* you only see DOWNLOAD COM. You must have part of the file name in the wildcard to have it show up. BTW, DOWNLOAD is a program to download serially or through Telnet a program to the disk. I haven't tried it and there is no documentation on what protocol to use.

There is just the ino source file so you do need to install Arduino and add the Pico board to compile and run it.


My take on this is if you want to introduce someone to Z80 by using a Pico, RunCPM is your best bet. It is much easier to use. I'm going to go through the source code so I can fix the mismatch, implement telnet and figure out how to configure the speed. Once I have it worked out I'll fork the project on Github.


Always looking to the stars.

MicroNut

I've been always a little leery of AI but with a long discussion with Codec I got Telnet on RunCPM working and got it updated so it will compile with the 5.5.1 version of the board. It still needs a little polishing and testing.
Always looking to the stars.

granz

Quote from: MicroNut on Mar 28, 2026, 04:04 PMI've been always a little leery of AI but with a long discussion with Codec I got Telnet on RunCPM working and got it updated so it will compile with the 5.5.1 version of the board. It still needs a little polishing and testing.
Very impressive, thanks. I forget, does Telnet have up/down-load capabilities? I just checked the Telnet client that comes with Linux Mint, but the help screen did not mention anything. Do you know of a telnet client which does (and incidentally will your Telnet server for RunCPM have any file transfer built in)? I guess that we could just shell out of Telnet and use Xmodem to send/receive files - IIRC RunCPM does have Xmodem included.

MicroNut

Here is RunCPM with WIFI for the Pico W

This only works on the Pico W. To use edit the wifi.cfg file to have your ssid, password and optionally the hostname. If Enable is set to 0 it will use serial rather than Wifi. The fallback entries are something the AI put in and doesn't affect the operation. Now put the edited file in the root directory in the SD Card.

If you don't put wifi.cfg into the SD Card it will use the defaults in wifi_config.h file, which currently has the Enable set to 0, so serial will be used.

To compile the source use the Arduino IDE and put in the following in the Additional Boards manager
https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
It will compile for the current version 5.5.1 and select the Pico W board.

Then using Putty or install Telnet in Windows. It will use the IP assigned to the Pico and Port 23 to communicate with the Pico. For serial the baud rate is 115200. The behavior is the same regardless if it uses Telnet or serial.

@granz Telnet does not have file transfer ability. ExtraPutty can do XModem and YModem file transfers. There is xmodem80 that works for the esp8266. I haven't tried it but it may work. Let me know if it works.
Always looking to the stars.

granz

Quote from: MicroNut on Mar 29, 2026, 06:29 PMThis only works on the Pico W.
How about the Pico 2W?

Quote from: MicroNut on Mar 29, 2026, 06:29 PMTo use edit the wifi.cfg file to have your ssid, password and optionally the hostname.
Can we give an IP address for static IP?

Quote from: MicroNut on Mar 29, 2026, 06:29 PMIf Enable is set to 0 it will use serial rather than Wifi. The fallback entries are something the AI put in and doesn't affect the operation. Now put the edited file in the root directory in the SD Card.

If you don't put wifi.cfg into the SD Card it will use the defaults in wifi_config.h file, which currently has the Enable set to 0, so serial will be used.

To compile the source use the Arduino IDE and put in the following in the Additional Boards manager
https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
It will compile for the current version 5.5.1 and select the Pico W board.

Then using Putty or install Telnet in Windows. It will use the IP assigned to the Pico and Port 23 to communicate with the Pico. For serial the baud rate is 115200. The behavior is the same regardless if it uses Telnet or serial.

@granz Telnet does not have file transfer ability. ExtraPutty can do XModem and YModem file transfers. There is xmodem80 that works for the esp8266. I haven't tried it but it may work. Let me know if it works.

This looks great, I'm going to give it a try tomorrow. This may change our game plan - no wiring needed.

MicroNut

#86
I don't have a 2W to test but if you do try compiling it with that board selected. When I tried just the Pico board the compiler threw an error saying this board does not support Wifi. It does compile for the 2W

A static IP? I queried Chat GPT and it said it can be added to the wifi.cfg with some modifications since it looks like the Wifi API permits static IP configuration setup.

I'm busy until Tuesday then I'll look into making a 7.1 version with static ip.
Always looking to the stars.

granz

Thanks, and thanks for this work that you are doing on this.

Chris Savage

#88
Quote from: granz on Mar 30, 2026, 05:39 AMThanks, and thanks for this work that you are doing on this.

I would like to second that sentiment. The more of us who research and share this stuff, the more people we help, even if we never know it.  ;)

                     Bringing concepts to life through engineering.

MicroNut

Here is version 7.1 of RunCPM

This adds Static IP settings in wifi.cfg.

You will also notice CONNECT_TIME_OUT which is the connection timeout for the wifi (15 seconds) when it times out the FallbackAP settings will be used to make a WIFI Access Point that the your computer will connect to. Just scan the WIFI on your computer and the FALLBACK_AP_SSID will show up to connect to. If you want a password then put one in FALLBACK_AP_PASSWORD and the FALLBACK_AP_IP is the IP you connect to with Telnet using port 23

The defaults are wifi_config.h
Always looking to the stars.

SMF spam blocked by CleanTalk