Jump to content


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  


    River Patroller

  • 4,089 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.


#2 flashjazzcat OFFLINE  



  • 14,431 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
.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

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

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.

  • Stephen and Larry like this

#3 Larry OFFLINE  


    River Patroller

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

Posted Wed Jul 18, 2012 8:27 AM

Thanks, Jon!


#4 Chilly Willy OFFLINE  

Chilly Willy


  • 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:

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