Jump to content

Photo

A (relatively) easy way to read the ID string from CF or SD?

IDE SD Card CF Card

3 replies to this topic

#1 Larry OFFLINE  

Larry

    River Patroller

  • 4,091 posts
  • Location:U.S. -- Midwest

Posted Wed Jul 18, 2012 6:31 AM

Can anyone clue me in on how to read this string? 128 bytes, I believe.

Thanks,
Larry

#2 flashjazzcat ONLINE  

flashjazzcat

    Quadrunner

  • 14,439 posts
  • Location:United Kingdom

Posted Wed Jul 18, 2012 8:04 AM

For CF: read the Identify Device buffer using command code $EC. You'll need a 16-bit data register or you can switch the drive to 8-bit PIO mode first.

Name starts at word 27, IIRC, so that's byte offset 54 into the buffer. The ASCII bytes for the name are stored in reverse order: 2 , 1, 4, 3, etc, etc.

Below are some bits of code from the SIDE driver which do this job. GET_MEDIA_NAME actually pulls the media name from the buffer, puts it some place else, then trims it to a manageable length.

.local get_drive_model ; if media is a CF card, show the drive info
lda #$80+$20
sta ddevic
jsr id2 ; bios_identify_dev
bcs cfa_rej
jsr get_media_name
clc
cfa_rej
rts
.endl
;
.local id2 ; get device info (bypasses bank switching)
jsr set_internal_buf ; point to internal sector buffer
lda #3 ; read full 512 bytes
sta slenmsb
lda #$EC ; IDENTIFY DEVICE command
jmp sector_rw
.endl
;

.local get_media_name
ldx #0
ldy #54
dn1
lda (bufrlo),y
sta namebuf+1,x
iny
lda (bufrlo),y
sta namebuf,x
iny
inx
inx
cpx #40
bcc dn1
trimsp2 ; get rid of trailing spaces
dex
bmi trimdone2
lda namebuf,x
cmp #32
beq trimsp2
trimdone2
inx
lda #0
sta namebuf,x
cpx #40
bcc trimdone2
rts
.endl
;

Unsure what would be different about an SD card: I only use SD cards through an IDE-SD adapter, so the driver protocols are identical there.

Edited by flashjazzcat, Wed Jul 18, 2012 8:05 AM.


#3 Larry OFFLINE  

Larry

    River Patroller

  • Topic Starter
  • 4,091 posts
  • Location:U.S. -- Midwest

Posted Wed Jul 18, 2012 8:27 AM

Thanks, Jon!

-Larry

#4 Chilly Willy OFFLINE  

Chilly Willy

    Dragonstomper

  • 747 posts
  • Location:The Land of Enchantment

Posted Thu Jul 19, 2012 5:23 PM

All the NeoMyth cart menus have SDIO support for SD/SDHC cards. SDIO is using the 4-bit parallel access of the SD card rather than the serial most interfaces use. It's easier to do on "lesser" systems since it just needs GPIO to the SD card. All the NeoMyth menus are open source and found here:
http://code.google.c.../neo-myth-menu/

The N64 menu uses C code everything but the main data transfer loop when reading sectors. The current code can detect and initialize an SD card in less than a second.





Also tagged with one or more of these keywords: IDE, SD Card, CF Card

0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users