本帖最后由 老鸟 于 2023-4-30 22:42 编辑
实际使用的at32f437vmt7,前面的板块好像还没有这个。 最近在移植nuttx系统到at32f437下,在使用sd卡时,初始化sd卡都是正常的,可正常识别卡的容量,然后切换到4线模式,手动挂载文件系统时出现发送cmd17命令后收到起始位错误。对比stm32f4和at32f437的sdio寄存器分布,两者除了时钟分频系数范围有区别外,
其他基本一致,参考stm32的sdio驱动修改后,出现以上情况,同样的卡在stm32上能正常识别、挂载。同时用逻辑分析仪查看,两者的波形是一致的,不明白问题出在哪里,at和st的sdio还有什么区别要注意的,
下面附一个at32f437初始化和挂载sd卡的debug信息,未使用dma(初始化有两个报错应该是用的贴片sd卡不支持这个命令,在st下也是同样的)
at32_setclkcr: CLKCR: 000101ce PWR: 00000000
at32_reset: CLCKR: 000101ce POWER: 00000003
at32_sdinitialize: Initialized SDIO slot 0
mmcsd_slotinitialize: minor: 0
mmcsd_hwinitialize: DMA supported: 0
mmcsd_hwinitialize: Attached MMC/SD interrupts
at32_registercallback: Register 0x8005e29(0x200046d0)
at32_callbackenable: eventset: 02
at32_callback: Callback 0x8005e29(0x200046d0) cbevents: 02 cdstatus: 00
mmcsd_slotinitialize: MMC/SD slot is empty
at32_sdinitialize: Bound SDIO slot 0 to the MMC/SD driver, minor=0
sdio_mediachange: cdstatus OLD: 00 NEW: 01
at32_callback: Callback 0x8005e29(0x200046d0) cbevents: 02 cdstatus: 01
at32_callback: Callback to 0x8005e29(0x200046d0)
mmcsd_mediachange: arg: 0x200046d0
mmcsd_probe: type: 0 probed: 0
mmcsd_removed: type: 0 present: 1
at32_setclkcr: CLKCR: 000100ce PWR: 00000003
at32_setclkcr: CLKCR: 000101ce PWR: 00000003
at32_sendcmd: cmd: 00000000 arg: 00000000 regval: 00000400 enabled irq: 00000000
at32_sendcmd: cmd: 00008101 arg: 40200000 regval: 00000441 enabled irq: 00000000
at32_recvshort: ERROR: Timeout STA: 00000004
mmcsd_cardidentify: ERROR: CMD1 RECVR3: -110
at32_sendcmd: cmd: 00000208 arg: 000001aa regval: 00000448 enabled irq: 00000000
mmcsd_cardidentify: SD V2.x card
at32_sendcmd: cmd: 00000077 arg: 00000000 regval: 00000477 enabled irq: 00000000
mmcsd_recv_r1: ERROR: R1=00400120
mmcsd_cardidentify: ERROR: mmcsd_recv_r1(CMD55) failed: -5
at32_sendcmd: cmd: 00000077 arg: 00000000 regval: 00000477 enabled irq: 00000000
at32_sendcmd: cmd: 00000129 arg: 40100000 regval: 00000469 enabled irq: 00000000
mmcsd_cardidentify: R3: 40ff8000
at32_sendcmd: cmd: 00000077 arg: 00000000 regval: 00000477 enabled irq: 00000000
at32_sendcmd: cmd: 00000129 arg: 40100000 regval: 00000469 enabled irq: 00000000
mmcsd_cardidentify: R3: 40ff8000
at32_sendcmd: cmd: 00000077 arg: 00000000 regval: 00000477 enabled irq: 00000000
at32_sendcmd: cmd: 00000129 arg: 40100000 regval: 00000469 enabled irq: 00000000
mmcsd_cardidentify: R3: c0ff8000
mmcsd_cardidentify: SD V2.x card with block addressing
at32_sendcmd: cmd: 000000c2 arg: 00000000 regval: 000004c2 enabled irq: 00000000
mmcsd_decode_cid: mid: 66 oid: 2346 pnm: CS032 prv: 1 psn: 353050129 mdt: 15b crc: 0d
at32_sendcmd: cmd: 000001c3 arg: 00000000 regval: 00000443 enabled irq: 00000000
mmcsd_sdinitialize: RCA: 1388
at32_sendcmd: cmd: 0000004d arg: 13880000 regval: 0000044d enabled irq: 00000000
at32_sendcmd: cmd: 000000c9 arg: 13880000 regval: 000004c9 enabled irq: 00000000
mmcsd_decode_csd: CSD:
mmcsd_decode_csd: CSD_STRUCTURE: 1 SPEC_VERS: 0 (MMC)
mmcsd_decode_csd: TAAC {TIME_UNIT: 6 TIME_VALUE: 1} NSAC: 0
mmcsd_decode_csd: TRAN_SPEED {TRANSFER_RATE_UNIT: 2 TIME_VALUE: 6}
mmcsd_decode_csd: CCC: 1461
mmcsd_decode_csd: READ_BL_LEN: 9 READ_BL_PARTIAL: 0
mmcsd_decode_csd: WRITE_BLK_MISALIGN: 0 READ_BLK_MISALIGN: 0
mmcsd_decode_csd: DSR_IMP: 0
mmcsd_decode_csd: SD Block Addressing:
mmcsd_decode_csd: C_SIZE: 7391 SD_ER_BLK_EN: 1
mmcsd_decode_csd: SD_SECTOR_SIZE: 127 SD_WP_GRP_SIZE: 0
mmcsd_decode_csd: WP_GRP_EN: 0 MMC DFLT_ECC: 0 (MMC) R2W_FACTOR: 2
mmcsd_decode_csd: WRITE_BL_LEN: 9 WRITE_BL_PARTIAL: 0
mmcsd_decode_csd: FILE_FORMAT_GROUP: 0 COPY: 0
mmcsd_decode_csd: PERM_WRITE_PROTECT: 0 TMP_WRITE_PROTECT: 0
mmcsd_decode_csd: FILE_FORMAT: 0 ECC: 0 (MMC) CRC: 107
mmcsd_decode_csd: Capacity: 3784704Kb, Block size: 512b, nblocks: 7569408 wrprotect: 0
at32_sendcmd: cmd: 00000087 arg: 13880000 regval: 00000447 enabled irq: 00000000
at32_setclkcr: CLKCR: 00000116 PWR: 00000003
at32_sendcmd: cmd: 00000050 arg: 00000008 regval: 00000450 enabled irq: 00000000
at32_sendcmd: cmd: 00000077 arg: 13880000 regval: 00000477 enabled irq: 0000832a
at32_sendcmd: cmd: 00000473 arg: 00000000 regval: 00000473 enabled irq: 0000832a
mmcsd_decode_scr: SCR:
mmcsd_decode_scr: SCR_STRUCTURE: 0 SD_VERSION: 2
mmcsd_decode_scr: DATA_STATE_AFTER_ERASE: 0 SD_SECURITY: 3 SD_BUS_WIDTHS: 5
mmcsd_decode_scr: Manufacturing data: 00000000
at32_sendcmd: cmd: 00000077 arg: 13880000 regval: 00000477 enabled irq: 00000000
at32_sendcmd: cmd: 0000006a arg: 00000000 regval: 0000046a enabled irq: 00000000
at32_sendcmd: cmd: 00000077 arg: 13880000 regval: 00000477 enabled irq: 00000000
at32_sendcmd: cmd: 00000046 arg: 00000002 regval: 00000446 enabled irq: 00000000
mmcsd_widebus: Wide bus operation selected
at32_setclkcr: CLKCR: 00000916 PWR: 00000003
mmcsd_probe: Capacity: 3784704 Kbytes
at32_callbackenable: eventset: 01
at32_callback: Callback 0x8005e29(0x200046d0) cbevents: 01 cdstatus: 01
NuttShell (NSH) NuttX-12.0.0
nsh> ls /dev
/dev:
console
mmcsd0
null
ttyS0
nsh> mount -t vfat /dev/mmcsd0 /mnt
find_blockdriver: pathname="/dev/mmcsd0"
mmcsd_open: Entry
mmcsd_geometry: Entry
mmcsd_geometry: available: true mediachanged: true writeenabled: true
mmcsd_geometry: nsectors: 7569408 sectorsize: 512
mmcsd_read: startsector: 0 nsectors: 1 sectorsize: 512
mmcsd_readsingle: startblock=0
mmcsd_readsingle: offset=0
at32_sendcmd: cmd: 00000050 arg: 00000200 regval: 00000450 enabled irq: 00000000
at32_sendcmd: cmd: 00000451 arg: 00000000 regval: 00000451 enabled irq: 0000832a
at32_interrupt: ERROR: Start bit, remaining: 512
mmcsd_eventwait: ERROR: Awakened with 14
mmcsd_readsingle: ERROR: CMD17 transfer failed: -5
nx_mount: ERROR: Bind method failed: -5
nsh: mount: mount failed: 5
nsh>
|