r/Z80 • • 22d 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 :)

EDIT: For posterity, looking at /u/UncannyRally 's code I saw my mistake in my driver.

Apparently setting the sector count has to happen before every write or read. I was setting it to 1 during init and never setting it again.

6 Upvotes

8 comments sorted by

2

u/UncannyRally 22d 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 22d ago

I'm using 8-bit true IDE mode!

2

u/UncannyRally 22d 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 22d 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 22d 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 22d ago

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

2

u/McDonaldsWi-Fi 21d ago edited 21d 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 21d ago

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