This feels like quite a milestone in this project. It's pulled together a whole bunch of things I've done previously into one working piece of almost awesomeness.
My PCW finally boots from an SD card. Actually, first it boots from the printer ROM as usual, but then the CPLD makes the EEPROM jump in, which loads J14CPM3.EMS off the SD card into memory and boots it.
At which point CP/M wants to load PROFILE.SUB from drive A:, and as CP/M knows nothing about my SD Card, despite being loaded from it, you still need a disk in the drive. It takes about 3.5 seconds to boot to this point, compared to about 10 seconds when booting from a disk.
If you watch the video, you'll also notice that the screen is filled with rubbish while it's booting. This is because I haven't bothered to initialise it — I should probably initialise it and put a pretty picture or something there while it boots.
A few of the problems I had while getting this to work:
- I hadn't set up the stack pointer before calling a routine, which caused all sorts of random havoc.
- I was running code from the ROM, forgetting that it would be trying to write to unwriteable memory. One of the first things the bootstrap programme now does is copies itself into RAM.
- I forgot to use the WAIT signal when the SPI code is running in slow mode during SD card initialization, which meant my code was trying to send things before the previous data was sent.
- I hadn't anticipated how fast the SPI interface would be when running in fast mode using the PCW's 32MHz clock — it is so fast that it finishes sending a byte to the SD card before the OUT instruction has finished executing. Because the IORQ and WR lines were still low, it then sent the same byte a second time. I added a flag into the VHDL code so that it won't send another byte until another M1 signal has been seen.
- After writing the bootstrap programme to the ROM I hadn't bothered to protect it, so when I made mistakes and the code ran amok, it ended up clobbering the bootstrap programme. I wrote some utilities — UNPROTECT and ROMDUMP to help.
- I made all sorts of other silly Z80 assembly mistakes, such as somehow forgetting to actually call my sd_read_block routine when trying to load CP/M!
However, it is working now, and I have created a few Z80 libraries (SD, ROM and DUMP) to make it easier to do this stuff.
I now need to patch CP/M to recognise the SD Card as an actual disk drive (or several disk drives). If I was going to keep drive A: around I might have just used FID files, but if there is no drive A: (or if I want to be able to boot quickly without looking at drive A:) then I'm going to have to patch CP/M instead, which should be another interesting challenge.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.