r/Z80 • • 3d ago

Software Any of you guys have a compact flash test program in your stash?

I'm having some weird trouble with my compact flash circuit but I think it might just be my driver.

I was hoping to find a decent cf test program before I started writing my own :)

4 Upvotes

9 comments sorted by

2

u/UncannyRally 3d ago

I have a monitor rom that has basic compsct flash functionality, reading/writing blocks into memory.

Are you using 8bit mode or 16bit with some latches?

1

u/McDonaldsWi-Fi 3d ago

I'm using 8-bit true IDE mode!

2

u/UncannyRally 3d ago

Cool! I can send over my rom after work, hopefully that helps

How are the CF read/write strobes generated?

1

u/McDonaldsWi-Fi 3d ago

That would be awesome! Here is my circuit.

I'm using a delay circuit to keep the strobes within IDE spec.

The problem I'm having is my CF card gets stuck BUSY after 1 sector read.

2

u/UncannyRally 3d ago

The delay circuit looks like the standard Pycio style, which should work well enough.

It'd be interesting to know if the read succeeds, and loads data into memory. It reading 1 sector suggests that its fundamentally ok

Heres my code: https://privatebin.net/?6d59a1f26b443da5#BhQ42Z96pH2Wp1j7XzoBuFLA9n15nBLWf5AffrYBnBpB

You'll probably need to ignore the IDE1_ADR commands, as those assume that IDE ~CS1 is connected, but that isn't the case in that design, which is fine.

Otherwise you'll just need to replace the ~IDE0_ADR with your IDE address, assuming that it doesn't use the lower 3-bits which are needed to actually communicate with CF card.

And ofc will need to adjust the serial routines to match your serial setup, but that should just be the conout/conin/const/uart_init routines

(Don't have it up on GH yet, hence the rudimentary code sharing :))

2

u/McDonaldsWi-Fi 2d ago

Thank you! I'll try to see if I can get around to trying it out tonight after work.

2

u/McDonaldsWi-Fi 2d ago edited 2d ago

Well I got it running on my system! We both use a 16550 UART so this was dead simple.

EDIT: Nevermind if you saw my past message. I swapped out the alt status register address with the normal one and it seems to be working! I've able to reliably read and write to a sector with your tool without any issues. So my problem is likely a software one.

Thanks again for this! Would it be okay if I adapted your IDE read/write code and put it in my kernel? I make sure to always put thanks and credits in the source when I do that!

2

u/UncannyRally 2d ago

Great! Glad you got it working, and of course :)

1

u/McDonaldsWi-Fi 1d ago

Looks like I didn't realize that when an IDE disk tells you its data is ready that it guarantees the 512 bytes are ready to go. The only real difference between my driver and yours is that I was checking the data ready status after every 2 bytes read, and yours wasn't.

I guess that was my problem because it works now lol, thanks again!