Getting CP/M-65 to boot on a physical PAL-2 with minimal HW and wiring

The earlier Native CP/M for the 6502 topic introduced David Given’s CP/M-65 project and mentioned its BBC Micro and C64 ports. I wanted to see how it would behave on a small physical KIM-1-compatible machine.

I now have CP/M-65 booting on a physical PAL-2, using an SD card module wired directly to the user RIOT. No interface board was needed, just the SD module and a few jumper wires.

My first problem sent me in the wrong direction for quite a while. The signal on PA3 only rose to about 2 V instead of the expected 5 V, so I assumed that I had made a soldering mistake or created a leakage path somewhere on the PAL-2.

The cause was a bad 6532 RIOT supplied with the kit. The chip otherwise appeared to work, but that one output produced only about 2 V for a logical high. Replacing it fixed the level, although this turned out not to be the reason CP/M-65 would not boot.

The next mistake was mine. I had connected the SD module to the PA pins of the RIOT used by the keyboard. It must be connected to port A of the user RIOT, mapped at $1700:

SD CS    -> PA4
SD SCK   -> PA3
SD MOSI  -> PA2
SD MISO  -> PA1

PAL-2 with the SD card module connected directly to the user RIOT using jumper wires.

Correcting the wiring was still not enough. The stock CP/M-65 SD loader did not get through initialization with my card. The card returns R1 $00 for CMD8, while the original loader expects $01 and stops with:

Abnormal termination. Error Code: 00

The card also checks the CRC of every command even in SPI mode. I asked Claude to help me inspect and patch the loader. The modified loader now:

  • accepts R1 $00 or $01 after CMD8 and CMD55;
  • sends valid CRCs for CMD55 and ACMD41 ($65 and $77);
  • sends CMD59 after initialization to disable CRC checking, so the unchanged BIOS can continue using its dummy CRC values for sector reads and writes.

At the end I was mostly watching the signals on the oscilloscope while Claude worked through the SD initialization code via the PAL-2. This was an oddly satisfying way to debug a 6502 machine.

The patched loader is loaded at $0200 and started from the monitor with:

0200 G

The patched loader was transferred and verified at 9600 baud; CP/M-65 then booted and displayed the contents of drive A.

The result is a working CP/M-65 system on a physical PAL-2 with a directly connected SD module.

I have put the patched source, ready-to-load binaries, SD image, diagnostic programs, wiring details and startup procedure on GitHub:

The full debugging story is here:

My PAL-2/KIM-1 project log, including the earlier stages of the build, is here:

Has anyone else tried CP/M-65 on physical KIM-1-compatible hardware? I would be interested to know whether other modern SD cards show the same CMD8 response or CRC behaviour.

3 Likes

Have you tried it with a standard sized SD card with out the patch?
Can you add a second sd card? Nice to see a KIM upgraded to floppies
or similar.

Hi Oldben!

I use SDHC 16GB card made by Verbatim. Actually I was looking for something smaller, but this is the smallest one I can buy today…

1 Like

Oops - you probably ment the real size, SDHC micro versus SDHC, right? Not GBs… No, unfortunantely I do not have 5V SDHC adatper for it.

I meant the original SD cards. no hc or micro added or omitted.
Standard sized SD cards and adapters are still around on ebay
mostly from china. I like them because they are bigger and smaller
as CP/M can only have 128 files per disk. 32 MB is just right for CP/M
or DOS 2.1. I run mine at 5 volts , but they can run 3.3 volts, but I have no
OS written for them. Just BIOS block read and write.
I consider them floppy replacements.

1 Like