Page 3 of 4

Re: Compact flash pinout?

Posted: Tue Nov 25, 2025 4:29 pm
by barnacle
Huzzah! Finally I can read from all the flash cards I have to hand - from 512MB to 4GB. At least, the info block:

Code: Select all

  Serial:      004123B1305S274                                                  
Firmware: 5HDX 4.3                                                              
   Model: 0SanDisk SDCFH2-2048                                                  
LBA size:                                                                       

  Serial: CA171107305A1WqBG0H5                                                  
Firmware: wCF B61F                                                              
   Model: K512MB CompactFlash                                                   
LBA size:                                                                       
  
  Serial:      5B3C0C090021FF5                                                  
Firmware: 3Ver7.01                                                              
   Model: KCF CARD                                                              
LBA size:                                                                       

  Serial: qCF26539439500003FY0                                                  
Firmware: 13.37                                                                 
   Model:  SILICONSYSTEMS UDMA                                                  
LBA size:                                                                       
There's more work to be done; at least an off-by-one in the data string decoding.
This is all in 65c02 code on the Mesolithic, with an adaptor to a Chinese IDE44 to CF card hanging off a little glue logic, and running at 5v from a powered USB extension block:
cf_44_adaptor.pdf
(82.1 KiB) Downloaded 41 times
And here's how it looks...
IMG_20251125_171135.jpg
I am much happier now.

Neil

Turns out it works much better if the ~rd goes to the ~rd pin, and ~wr goes to the ~wr...

Re: Compact flash pinout?

Posted: Tue Nov 25, 2025 5:21 pm
by GlennSmith
I'd like the schematic of the anti-gravity field generator! :D

Re: Compact flash pinout?

Posted: Tue Nov 25, 2025 7:30 pm
by barnacle
Good, isn't it? Takes all those wires just to hold it down... :mrgreen:

Neil

Re: Compact flash pinout?

Posted: Wed Nov 26, 2025 12:13 am
by BigDumbDinosaur
GlennSmith wrote:
I'd like the schematic of the anti-gravity field generator! :D

Neil must have used solid building wire to make the connections.  :D  Helps control ground bounce and VCC sag.

Re: Compact flash pinout?

Posted: Wed Nov 26, 2025 3:04 am
by plasmo
IDE44 adapter is 2mm pitch, so it is a pain to prototype. Levitating is a good approach. I myself used a 2mm-to-2.54mm adapter.
Bill

Re: Compact flash pinout?

Posted: Wed Nov 26, 2025 6:20 am
by barnacle
BigDumbDinosaur wrote:
Neil must have used solid building wire to make the connections.  :D  Helps control ground bounce and VCC sag.
Also can be used for slicing boiled eggs. It's 22awg wirewrap wire. I bought the cheapest adaptors I found on AliExpress with pins, and forgot that they would be 2mm. But it works. I have more confidence in the card illustrated upthread, which hasn't arrived from JLC yet.

Might be worth finding out if it still works at 3.3v... A minor wiring change and I can power the Mesolithic board on 3.3v. I saw a spec that suggested that the access timing was 600ns at 3.3, 300ns at 5v, but it was twenty years old and probably wouldn't be directly relevant to modern high 100MB/s parts. The Mesolithic runs at 1.8MHz.

I did note that the CF cards I found for sale on Ali were not particularly inexpensive. Cheaper than my first hard drive (£300/30MB!) but still several euros for 256MB.

Neil

Re: Compact flash pinout?

Posted: Wed Nov 26, 2025 6:21 am
by barnacle
(Also - I note the smaller text didn't work for BDD as it didn't for me.)

Re: Compact flash pinout?

Posted: Wed Nov 26, 2025 12:44 pm
by barnacle
After a little tidying,

Code: Select all

- generic 2GB labeled 'memorysystems.com'
  Serial: CF26539439500003FY01                                                  
Firmware: 3.37                                                                  
   Model: SILICONSYSTEMS UDMA                                                   
LBA size: 003D0FE0                                                              
 
- SanDisk 2GB                                                                               
  Serial:     004123B1305S2745                                                  
Firmware: HDX 4.30                                                              
   Model: SanDisk SDCFH2-2048                                                   
LBA size: 003D0FE0                                                              
                    
- Kingston 4GB
  Serial:     5B3C0C090021FF53
Firmware: Ver7.01K
   Model: CF CARD             
LBA size: 00771FF0
The LBA sizes seem correct, roughly 2G and 4G. Curiously, since I tidied up the code and removed all the helper calls, I can't read the 512MB card. More investigation is required.

I'm also making progress discovering FAT32. I think when I have something to say, that might be in a separate thread.

Neil

Re: Compact flash pinout?

Posted: Wed Nov 26, 2025 12:48 pm
by barnacle
Ah, the half gig seems to require the power to be cycled; that's supposed to be a requirement to go into trueIDE mode but the other three were fine with removing and replacing the card and a hard reset.

Code: Select all

  Serial: A171107305A1WqBG0H5w
Firmware: CF B61FK
   Model: 512MB CompactFlash C
LBA size: 000F45F0
Again, the quoted memory size is correct.

Neil

Re: Compact flash pinout?

Posted: Wed Nov 26, 2025 1:18 pm
by barnacle
The code to display the information so far.
main.asm
(10.57 KiB) Downloaded 36 times
Obviously, this is still fragmentary, and contains currently unused helper routines.

Neil

Re: Compact flash pinout?

Posted: Wed Nov 26, 2025 2:05 pm
by plasmo
To speed up CF read, once DRQ bit is set, you can read 512 bytes in a tight loop without checking DRQ.
Bill

Re: Compact flash pinout?

Posted: Wed Nov 26, 2025 2:46 pm
by gfoot
In case it's useful to you: I have some code here to read from FAT32 filesystems on SD cards, which could be retargetted to CF fairly easily I should think: https://github.com/gfoot/sdcard6502/blo ... libfat32.s

My code only supported reading, but others have extended it with code to write to the filesystem which you can find in forks or pull-requests.

Re: Compact flash pinout?

Posted: Wed Nov 26, 2025 3:13 pm
by SamCoVT
That looks like good progress.
If you want to write the FAT32 routines yourself, I found this resource very helpful:
https://www.pjrc.com/tech/8051/ide/fat32.html
The author has highlighted the important items in each data structure and given their offsets. I was able to get read-only support for FAT32 working. I never got around to getting writing working (I would probably switch to FAT16 if I wanted to support writing as well)

Re: Compact flash pinout?

Posted: Wed Nov 26, 2025 3:28 pm
by barnacle
@Bill, thanks, I grabbed that code from a 6800 example and couldn't find a further reference as to what DRQ might actually be, so left it as he'd used it. I'll try moving it outside the loop.

@GFoot - thanks, I'll bear it in mind. My aim is to do it myself to understand what's going on (and possibly have a different subset of FAT32 functionality when I'm finished).

@Sam - I've already got that web page open :mrgreen: it's been useful to get as far as the FAT but after that it tails off a bit. I've been also using some university course notes: https://cislinux2.washburn.edu/zzmech/c ... System.pdf (digital forensics!) and https://www.cs.fsu.edu/~cop4610t/lectur ... week11.pdf (who uses some of PCJR's images, I think).

Neil

Re: Compact flash pinout?

Posted: Wed Nov 26, 2025 9:25 pm
by BigDumbDinosaur
barnacle wrote:
The code to display the information so far...
Instead of...

Code: Select all

putchar:                        ; output a single character in A
         pha
pc_wait:
         lda ACIASTATUS
         and #2
         beq pc_wait
         pla
         sta ACIADATA
         rts

...you could try...

Code: Select all

putchar:                        ; output a single character in A
         pha
         lda #%00000010         ;status mask
;
pc_wait: bit ACIASTATUS         ;UART ready?
         beq pc_wait            ;nope
;
         pla
         sta ACIADATA
         rts

...and gain a little performance.  Even faster would be to copy .A to .X or .Y if either index register is available, and avoid the penalty of two stack accesses in order to protect the datum to be written to the UART.

Quote:
My aim is to do it myself to understand what's going on (and possibly have a different subset of FAT32 functionality when I'm finished).
Perhaps the attached will be useful to you.

FAT_filesystem.pdf
FAT Filesystem
(84.66 KiB) Downloaded 29 times