Discussion:
SDIO on STM32F4x
(too old to reply)
Meier Lorenz
2013-04-19 06:39:43 UTC
Permalink
Hi Greg / list,

I'm currently bringing up SDIO on the F4 (I'm aware that this works on the ST dev board). It does detect the card, but fails to mount the filesystem and I wanted to check if you see something obvious.

Note that this on a ~6 weeks old NuttX tree, and I can't immediately update (I will if you think there are relevant things in).

I see the /dev/mmcsd0 device being created.

And this is the diff of all changes in code and config:

in board.h:

+/* DMA Channl/Stream Selections *****************************************************/
+/* Stream selections are arbitrary for now but might become important in the future
+ * is we set aside more DMA channels/streams.
+ *
+ * SDIO DMA
+ * DMAMAP_SDIO_1 = Channel 4, Stream 3 <- may later be used by SPI DMA
+ * DMAMAP_SDIO_2 = Channel 4, Stream 6
+ */
+
+#define DMAMAP_SDIO DMAMAP_SDIO_1
+


in the defconfig:


-CONFIG_STM32_SDIO=n
+CONFIG_STM32_SDIO=y

This is what I collected from your examples - I found some of these settings confusing and the hint with the legacy build behaviour (comment taken from the F4 dev board defconfig) hints it may need some changes:


#
+# Maintain legacy build behavior (revisit)
+#
+
+CONFIG_MMCSD=y
+CONFIG_MMCSD_SPI=y
+CONFIG_MMCSD_SDIO=y
+CONFIG_MTD=y
+
+#
+# SPI-based MMC/SD driver
+#
+CONFIG_MMCSD_NSLOTS=1
+CONFIG_MMCSD_READONLY=n
+CONFIG_MMCSD_SPICLOCK=12500000
+
+#
+# STM32 SDIO-based MMC/SD driver
+#
+CONFIG_SDIO_DMA=y
+#CONFIG_SDIO_PRI=128
+#CONFIG_SDIO_DMAPRIO
+#CONFIG_SDIO_WIDTH_D1_ONLY
+CONFIG_MMCSD_MULTIBLOCK_DISABLE=y
+CONFIG_MMCSD_MMCSUPPORT=n
+CONFIG_MMCSD_HAVECARDDETECT=n
+
+#

Block driver buffer is disabled (both options =n), and:


+CONFIG_NSH_MMCSDSLOTNO=0
+CONFIG_NSH_MMCSDMINOR=0


Board init (taken from the F4 dev board example, except for HAVE_MMCSD, which wasn't defined and I couldn't track down where in the build system it would have been defined, hints welcome).



+ #ifdef CONFIG_MMCSD # XXX: HAVE_MMCSD seemed to get nowhere defined
+ /* First, get an instance of the SDIO interface */
+
+ sdio = sdio_initialize(CONFIG_NSH_MMCSDSLOTNO);
+ if (!sdio) {
+ message("nsh_archinitialize: Failed to initialize SDIO slot %d\n",
+ CONFIG_NSH_MMCSDSLOTNO);
+ return -ENODEV;
+ }
+
+ /* Now bind the SDIO interface to the MMC/SD driver */
+ int ret = mmcsd_slotinitialize(CONFIG_NSH_MMCSDMINOR, sdio);
+ if (ret != OK) {
+ message("nsh_archinitialize: Failed to bind SDIO to the MMC/SD driver: %d\n", ret);
+ return ret;
+ }
+
+ /* Then let's guess and say that there is a card in the slot. There is no card detect GPIO. */
+ sdio_mediachange(sdio, true);
+
+ message("[boot] Initialized SDIO\n");
+ #endif
+





The attempted mount command was:
mount -t vfat /dev/mmcsd0 /fs/microsd


This is the complete FS debug log:

ABDE
ramdisk_register: buffer: 2000098c nsectors: 31510657 sectsize: 128
nsh_romfsetc: Mounting ROMFS filesystem[boot] Successfully initialized SPI port 1
[boot] Initializing SPI port 2
[boot] Successfully initialized SPI port 2
at target=/etc with source=/dev/ram0
romfs_bind: Entry
rd_open: Entry
rd_geometry: Entry
rd_geometry: available: true mediachanged: false writeenabled: false
rd_geometry: nsectors: 31510657 sectorsize: 128
rd_ioctl: Entry
rd_ioctl: ppv: 2000098c
stm32_setclkcr: CLKCR: 000001b2 PWR: 00000000
stm32_reset: CLCKR: 000001b2 POWER: 00000003
mmcsd_slotinitialize: minor: 0
mmcsd_hwinitialize: DMA supported: 1
mmcsd_hwinitialize: Attached MMC/SD interrupts
stm32_registercallback: Register 807b5f1(10004ac0)
stm32_callbackenable: eventset: 02
stm32_callback: Callback 807b5f1(10004ac0) cbevents: 02 cdstatus: 00
mmcsd_slotinitialize: MMC/SD slot is empty
sdio_mediachange: cdstatus OLD: 00 NEW: 01
stm32_callback: Callback 807b5f1(10004ac0) cbevents: 02 cdstatus: 01
stm32_callback: Callback to 807b5f1(10004ac0)
mmcsd_mediachange: arg: 10004ac0
mmcsd_probe: type: 0 probed: 0
mmcsd_removed: type: 0 present: 1
stm32_setclkcr: CLKCR: 000001b2 PWR: 00000003
stm32_sendcmd: cmd: 00000000 arg: 00000000 regval: 00000400
stm32_sendcmd: cmd: 00000000 arg: 00000000 regval: 00000400
stm32_sendcmd: cmd: 00000208 arg: 000001aa regval: 00000448
mmcsd_cardidentify: SD V2.x card
stm32_sendcmd: cmd: 00000077 arg: 00000000 regval: 00000477
stm32_sendcmd: cmd: 00000129 arg: c0100000 regval: 00000469
mmcsd_cardidentify: R3: 00ff8000
stm32_sendcmd: cmd: 00000077 arg: 00000000 regval: 00000477
stm32_sendcmd: cmd: 00000129 arg: c0100000 regval: 00000469
mmcsd_cardidentify: R3: 80ff8000
stm32_sendcmd: cmd: 000000c2 arg: 00000000 regval: 000004c2
mmcsd_decodeCID: mid: 6f oid: 6f00 pnm: SMI prv: 0 psn: 0 mdt: c6 crc: 67
stm32_sendcmd: cmd: 000001c3 arg: 00000000 regval: 00000443
mmcsd_sdinitialize: RCA: b368
stm32_sendcmd: cmd: 0000004d arg: b3680000 regval: 0000044d
stm32_sendcmd: cmd: 000000c9 arg: b3680000 regval: 000004c9
mmcsd_decodeCSD: CSD:
mmcsd_decodeCSD: CSD_STRUCTURE: 0 SPEC_VERS: 0 (MMC)
mmcsd_decodeCSD: TAAC {TIME_UNIT: 0 TIME_VALUE: 0} NSAC: 0
mmcsd_decodeCSD: TRAN_SPEED {TRANSFER_RATE_UNIT: 2 TIME_VALUE: 6}
mmcsd_decodeCSD: CCC: 1333
mmcsd_decodeCSD: READ_BL_LEN: 10 READ_BL_PARTIAL: 1
mmcsd_decodeCSD: WRITE_BLK_MISALIGN: 0 READ_BLK_MISALIGN: 0
mmcsd_decodeCSD: DSR_IMP: 0
mmcsd_decodeCSD: SD Byte Addressing:
mmcsd_decodeCSD: C_SIZE: 3681 C_SIZE_MULT: 7
mmcsd_decodeCSD: VDD_R_CURR_MIN: 5 VDD_R_CURR_MAX: 5
mmcsd_decodeCSD: VDD_W_CURR_MIN: 5 VDD_W_CURR_MAX: 5
mmcsd_decodeCSD: SD_ER_BLK_EN: 1 SD_SECTOR_SIZE: 127 (SD) SD_WP_GRP_SIZE: 63
mmcsd_decodeCSD: WP_GRP_EN: 0 MMC DFLT_ECC: 0 (MMC) R2W_FACTOR: 5
mmcsd_decodeCSD: WRITE_BL_LEN: 10 WRITE_BL_PARTIAL: 0
mmcsd_decodeCSD: FILE_FORMAT_GROUP: 0 COPY: 0
mmcsd_decodeCSD: PERM_WRITE_PROTECT: 0 TMP_WRITE_PROTECT: 0
mmcsd_decodeCSD: FILE_FORMAT: 0 ECC: 0 (MMC) CRC: 65
mmcsd_decodeCSD: Capacity: 1885184Kb, Block size: 512b, nblocks: 3770368 wrprotect: 0
stm32_sendcmd: cmd: 00000087 arg: b3680000 regval: 00000447
stm32_setclkcr: CLKCR: 00000101 PWR: 00000003
stm32_sendcmd: cmd: 00000050 arg: 00000008 regval: 00000450
stm32_sendcmd: cmd: 00000077 arg: b3680000 regval: 00000477
stm32_sendcmd: cmd: 00000473 arg: 00000000 regval: 00000473
mmcsd_decodeSCR: SCR:
mmcsd_decodeSCR: SCR_STRUCTURE: 0 SD_VERSION: 2
mmcsd_decodeSCR: DATA_STATE_AFTER_ERASE: 0 SD_SECURITY: 2 SD_BUS_WIDTHS: 5
mmcsd_decodeSCR: Manufacturing data: 00000000
stm32_sendcmd: cmd: 00000077 arg: b3680000 regval: 00000477
stm32_sendcmd: cmd: 0000006a arg: 00000000 regval: 0000046a
stm32_sendcmd: cmd: 00000077 arg: b3680000 regval: 00000477
stm32_sendcmd: cmd: 00000046 arg: 00000002[boot] Initialized SDIO
regval: 00000446
mmcsd_widebus: Wide bus operation selected
stm32_setclkcr: CLKCR: 00000901 PWR: 00000003
mmcsd_probe: Capacity: 1885184 Kbytes
stm32_callbackenable: eventset: 01
stm32_callback: Callback 807b5f1(10004ac0) cbevents: 01 cdstatus: 01
romfs_open: Open 'init.d/rcS'
rd_geometry: Entry
rd_geometry: available: true mediachanged: false writeenabled: false
rd_geometry: nsectors: 31510657 sectorsize: 128
romfs_read: Read 256 bytes from offset 0
rd_geometry: Entry
rd_geometry: available: true mediachanged: false writeenabled: false
rd_geometry: nsectors: 31510657 sectorsize: 128
romfs_read: Read sector 213
romfs_filecacheread: sector: 213 cached: 0 sectorsize: 128 XIP base: 2000098c buffer: 2000098c
romfs_filecacheread: XIP buffer: 2000740c
romfs_read: Return 96 bytes from sector offset 32
romfs_read: Read 1 sectors starting with 214
romfs_read: Read sector 215
romfs_filecacheread: sector: 215 cached: 213 sectorsize: 128 XIP base: 2000098c buffer: 2000740c
romfs_filecacheread: XIP buffer: 2000750c
romfs_read: Return 32 bytes from sector offset 0
romfs_read: Read 256 bytes from offset 256
rd_geometry: Entry
rd_geometry: available: true mediachanged: false writeenabled: false
rd_geometry: nsectors: 31510657 sectorsize: 128
romfs_read: Read sector 215
romfs_filecacheread: sector: 215 cached: 215 sectorsize: 128 XIP base: 2000098c buffer: 2000750c
romfs_read: Return 96 bytes from sector offset 32
romfs_read: Read 1 sectors starting with 216
romfs_read: Read sector 217
romfs_filecacheread: sector: 217 cached: 215 sectorsize: 128 XIP base: 2000098c buffer: 2000750c
romfs_filecacheread: XIP buffer: 2000760c
romfs_read: Return 32 bytes from sector offset 0
romfs_read: Read 256 bytes from offset 512
rd_geometry: Entry
rd_geometry: available: true mediachanged: false writeenabled: false
rd_geometry: nsectors: 31510657 sectorsize: 128
romfs_read: Read sector 217
romfs_filecacheread: sector: 217 cached: 217 sectorsize: 128 XIP base: 2000098c buffer: 2000760c
romfs_read: Return 96 bytes from sector offset 32
romfs_read: Read 1 sectors starting with 218
romfs_read: Read sector 219
romfs_filecacheread: sector: 219 cached: 217 sectorsize: 128 XIP base: 2000098c buffer: 2000760c
romfs_filecacheread: XIP buffer: 2000770c
romfs_read: Return 32 bytes from sector offset 0
[init] looking for microSD...
romfs_read: Read 256 bytes from offset 768
rd_geometry: Entry
rd_geometry: available: true mediachanged: false writeenabled: false
rd_geometry: nsectors: 31510657 sectorsize: 128
romfs_read: Read sector 219
romfs_filecacheread: sector: 219 cached: 219 sectorsize: 128 XIP base: 2000098c buffer: 2000770c
romfs_read: Return 96 bytes from sector offset 32
romfs_read: Read 1 sectors starting with 220
romfs_read: Read sector 221
romfs_filecacheread: sector: 221 cached: 219 sectorsize: 128 XIP base: 2000098c buffer: 2000770c
romfs_filecacheread: XIP buffer: 2000780c
romfs_read: Return 32 bytes from sector offset 0
mmcsd_open: Entry
mmcsd_geometry: Entry
mmcsd_geometry: available: true mediachanged: true writeenabled: true
mmcsd_geometry: nsectors: 3770368 sstm32_dmacallback: DMA error 08, remaining: 512
ectorsize: 512
mmcsd_read: startsector: 0 nsectors: 1 sectorsize: 512
mmcsd_readsingle: startblock=0
mmcsd_readsingle: offset=0
stm32_sendcmd: cmd: 00000050 arg: 00000200 regval: 00000450
stm32_sendcmd: cmd: 00000451 arg: 00000000 regval: 00000451
mmcsd_eventwait: ERROR: Awakened with 10
mmcsd_readsingle: ERROR: CMD17 transfer failed: -5
mount: Bind method failed: -5
nsh: mount: mount failed: 5
[init] no microSD card found
romfs_read: Read 256 bytes from offset 1024
rd_geometry: Entry
rd_geometry: available: true mediachanged: false writeenabled: false
rd_geometry: nsectors: 31510657 sectorsize: 128
romfs_read: Read sector 221
romfs_filecacheread: sector: 221 cached: 221 sectorsize: 128 XIP base: 2000098c buffer: 2000780c
romfs_read: Return 96 bytes from sector offset 32
romfs_read: Read 1 sectors starting with 222
romfs_read: Read sector 223
romfs_filecacheread: sector: 223 cached: 221 sectorsize: 128 XIP base: 2000098c buffer: 2000780c
romfs_filecacheread: XIP buffer: 2000790c
romfs_read: Return 32 bytes from sector offset 0
romfs_read: Read 256 bytes from offset 1280
rd_geometry: Entry
rd_geometry: available: true mediachanged: false writeenabled: false
rd_geometry: nsectors: 31510657 sectorsize: 128
romfs_read: Read sector 223
romfs_filecacheread: sector: 223 cached: 223 sectorsize: 128 XIP base: 2000098c buffer: 2000790c
romfs_read: Return 96 bytes from sector offset 32
romfs_read: Read 1 sesercon: Registering CDC/ACM serial driver
ctors starting with 224
romfs_reasercon: Successfully registered the CDC/ACM serial driver
d: Read sector 225
romfs_filecacheread: sector: 225 cached: 223 sectorsize: 128 XIP base: 2000098c buffer: 2000790c
romfs_filecacheread: XIP buffer: 20007a0c
romfs_read: Return 32 bytes from sector offset 0
uart_register: Registering /dev/ttyACM0
[init] USB interface connected
romfs_read: Read 256 bytes from offset 1536
rd_geometry: Entry
rd_geometry: available: true mediachanged: false writeenabled: false
rd_geometry: nsectors: 31510657 sectorsize: 128
romfs_read: Read sector 225
romfs_filecacheread: sector: 225 cached: 225 sectorsize: 128 XIP base: 2000098c buffer: 20007a0c
romfs_read: Return 96 bytes from sector offset 32
romfs_read: Read sector 226
romfs_filecacheread: sector: 226 cached: 225 sectorsize: 128 XIP base: 2000098c buffer: 20007a0c
romfs_filecacheread: XIP buffer: 20007a8c
romfs_read: Return 73 bytes from sector offset 0
romfs_filecacheread: XIP buffer: 20007a8c
romfs_read: Return 73 bytes from sector offset 0
romfs_stat: Entry
rd_geometry: Entry
rd_geometry: available: true mediachanged: false writeenabled: false
rd_geometry: nsectors: 31510657 sectorsize: 128
romfs_stat: Failed to find directory: -2
romfs_read: Read 256 bytes from offset 1705
rd_geometry: Entry
rd_geometry: available: true mediachanged: false writeenabled: false
rd_geometry: nsectors: 31510657 sectorsize: 128
romfs_close: Closing
Meier Lorenz
2013-04-19 06:47:46 UTC
Permalink
I forgot, since it was already activated as default:

CONFIG_ARCH_DMA=y

CONFIG_STM32_DMA1=y
CONFIG_STM32_DMA2=y


On 19 Apr 2013, at 08:39, "Meier Lorenz" <lm-gy3b+***@public.gmane.org<mailto:lm-gy3b+***@public.gmane.org>>
wrote:



Hi Greg / list,

I'm currently bringing up SDIO on the F4 (I'm aware that this works on the ST dev board). It does detect the card, but fails to mount the filesystem and I wanted to check if you see something obvious.

Note that this on a ~6 weeks old NuttX tree, and I can't immediately update (I will if you think there are relevant things in).

I see the /dev/mmcsd0 device being created.

And this is the diff of all changes in code and config:

in board.h:

+/* DMA Channl/Stream Selections *****************************************************/
+/* Stream selections are arbitrary for now but might become important in the future
+ * is we set aside more DMA channels/streams.
+ *
+ * SDIO DMA
+ * DMAMAP_SDIO_1 = Channel 4, Stream 3 <- may later be used by SPI DMA
+ * DMAMAP_SDIO_2 = Channel 4, Stream 6
+ */
+
+#define DMAMAP_SDIO DMAMAP_SDIO_1
+

in the defconfig:

-CONFIG_STM32_SDIO=n
+CONFIG_STM32_SDIO=y

This is what I collected from your examples - I found some of these settings confusing and the hint with the legacy build behaviour (comment taken from the F4 dev board defconfig) hints it may need some changes:

#
+# Maintain legacy build behavior (revisit)
+#
+
+CONFIG_MMCSD=y
+CONFIG_MMCSD_SPI=y
+CONFIG_MMCSD_SDIO=y
+CONFIG_MTD=y
+
+#
+# SPI-based MMC/SD driver
+#
+CONFIG_MMCSD_NSLOTS=1
+CONFIG_MMCSD_READONLY=n
+CONFIG_MMCSD_SPICLOCK=12500000
+
+#
+# STM32 SDIO-based MMC/SD driver
+#
+CONFIG_SDIO_DMA=y
+#CONFIG_SDIO_PRI=128
+#CONFIG_SDIO_DMAPRIO
+#CONFIG_SDIO_WIDTH_D1_ONLY
+CONFIG_MMCSD_MULTIBLOCK_DISABLE=y
+CONFIG_MMCSD_MMCSUPPORT=n
+CONFIG_MMCSD_HAVECARDDETECT=n
+
+#

Block driver buffer is disabled (both options =n), and:

+CONFIG_NSH_MMCSDSLOTNO=0
+CONFIG_NSH_MMCSDMINOR=0

Board init (taken from the F4 dev board example, except for HAVE_MMCSD, which wasn't defined and I couldn't track down where in the build system it would have been defined, hints welcome).

+ #ifdef CONFIG_MMCSD # XXX: HAVE_MMCSD seemed to get nowhere defined
+ /* First, get an instance of the SDIO interface */
+
+ sdio = sdio_initialize(CONFIG_NSH_MMCSDSLOTNO);
+ if (!sdio) {
+ message("nsh_archinitialize: Failed to initialize SDIO slot %d\n",
+ CONFIG_NSH_MMCSDSLOTNO);
+ return -ENODEV;
+ }
+
+ /* Now bind the SDIO interface to the MMC/SD driver */
+ int ret = mmcsd_slotinitialize(CONFIG_NSH_MMCSDMINOR, sdio);
+ if (ret != OK) {
+ message("nsh_archinitialize: Failed to bind SDIO to the MMC/SD driver: %d\n", ret);
+ return ret;
+ }
+
+ /* Then let's guess and say that there is a card in the slot. There is no card detect GPIO. */
+ sdio_mediachange(sdio, true);
+
+ message("[boot] Initialized SDIO\n");
+ #endif
+

The attempted mount command was:
mount -t vfat /dev/mmcsd0 /fs/microsd

This is the complete FS debug log:

ABDE
ramdisk_register: buffer: 2000098c nsectors: 31510657 sectsize: 128
nsh_romfsetc: Mounting ROMFS filesystem[boot] Successfully initialized SPI port 1
[boot] Initializing SPI port 2
[boot] Successfully initialized SPI port 2
at target=/etc with source=/dev/ram0
romfs_bind: Entry
rd_open: Entry
rd_geometry: Entry
rd_geometry: available: true mediachanged: false writeenabled: false
rd_geometry: nsectors: 31510657 sectorsize: 128
rd_ioctl: Entry
rd_ioctl: ppv: 2000098c
stm32_setclkcr: CLKCR: 000001b2 PWR: 00000000
stm32_reset: CLCKR: 000001b2 POWER: 00000003
mmcsd_slotinitialize: minor: 0
mmcsd_hwinitialize: DMA supported: 1
mmcsd_hwinitialize: Attached MMC/SD interrupts
stm32_registercallback: Register 807b5f1(10004ac0)
stm32_callbackenable: eventset: 02
stm32_callback: Callback 807b5f1(10004ac0) cbevents: 02 cdstatus: 00
mmcsd_slotinitialize: MMC/SD slot is empty
sdio_mediachange: cdstatus OLD: 00 NEW: 01
stm32_callback: Callback 807b5f1(10004ac0) cbevents: 02 cdstatus: 01
stm32_callback: Callback to 807b5f1(10004ac0)
mmcsd_mediachange: arg: 10004ac0
mmcsd_probe: type: 0 probed: 0
mmcsd_removed: type: 0 present: 1
stm32_setclkcr: CLKCR: 000001b2 PWR: 00000003
stm32_sendcmd: cmd: 00000000 arg: 00000000 regval: 00000400
stm32_sendcmd: cmd: 00000000 arg: 00000000 regval: 00000400
stm32_sendcmd: cmd: 00000208 arg: 000001aa regval: 00000448
mmcsd_cardidentify: SD V2.x card
stm32_sendcmd: cmd: 00000077 arg: 00000000 regval: 00000477
stm32_sendcmd: cmd: 00000129 arg: c0100000 regval: 00000469
mmcsd_cardidentify: R3: 00ff8000
stm32_sendcmd: cmd: 00000077 arg: 00000000 regval: 00000477
stm32_sendcmd: cmd: 00000129 arg: c0100000 regval: 00000469
mmcsd_cardidentify: R3: 80ff8000
stm32_sendcmd: cmd: 000000c2 arg: 00000000 regval: 000004c2
mmcsd_decodeCID: mid: 6f oid: 6f00 pnm: SMI prv: 0 psn: 0 mdt: c6 crc: 67
stm32_sendcmd: cmd: 000001c3 arg: 00000000 regval: 00000443
mmcsd_sdinitialize: RCA: b368
stm32_sendcmd: cmd: 0000004d arg: b3680000 regval: 0000044d
stm32_sendcmd: cmd: 000000c9 arg: b3680000 regval: 000004c9
mmcsd_decodeCSD: CSD:
mmcsd_decodeCSD: CSD_STRUCTURE: 0 SPEC_VERS: 0 (MMC)
mmcsd_decodeCSD: TAAC {TIME_UNIT: 0 TIME_VALUE: 0} NSAC: 0
mmcsd_decodeCSD: TRAN_SPEED {TRANSFER_RATE_UNIT: 2 TIME_VALUE: 6}
mmcsd_decodeCSD: CCC: 1333
mmcsd_decodeCSD: READ_BL_LEN: 10 READ_BL_PARTIAL: 1
mmcsd_decodeCSD: WRITE_BLK_MISALIGN: 0 READ_BLK_MISALIGN: 0
mmcsd_decodeCSD: DSR_IMP: 0
mmcsd_decodeCSD: SD Byte Addressing:
mmcsd_decodeCSD: C_SIZE: 3681 C_SIZE_MULT: 7
mmcsd_decodeCSD: VDD_R_CURR_MIN: 5 VDD_R_CURR_MAX: 5
mmcsd_decodeCSD: VDD_W_CURR_MIN: 5 VDD_W_CURR_MAX: 5
mmcsd_decodeCSD: SD_ER_BLK_EN: 1 SD_SECTOR_SIZE: 127 (SD) SD_WP_GRP_SIZE: 63
mmcsd_decodeCSD: WP_GRP_EN: 0 MMC DFLT_ECC: 0 (MMC) R2W_FACTOR: 5
mmcsd_decodeCSD: WRITE_BL_LEN: 10 WRITE_BL_PARTIAL: 0
mmcsd_decodeCSD: FILE_FORMAT_GROUP: 0 COPY: 0
mmcsd_decodeCSD: PERM_WRITE_PROTECT: 0 TMP_WRITE_PROTECT: 0
mmcsd_decodeCSD: FILE_FORMAT: 0 ECC: 0 (MMC) CRC: 65
mmcsd_decodeCSD: Capacity: 1885184Kb, Block size: 512b, nblocks: 3770368 wrprotect: 0
stm32_sendcmd: cmd: 00000087 arg: b3680000 regval: 00000447
stm32_setclkcr: CLKCR: 00000101 PWR: 00000003
stm32_sendcmd: cmd: 00000050 arg: 00000008 regval: 00000450
stm32_sendcmd: cmd: 00000077 arg: b3680000 regval: 00000477
stm32_sendcmd: cmd: 00000473 arg: 00000000 regval: 00000473
mmcsd_decodeSCR: SCR:
mmcsd_decodeSCR: SCR_STRUCTURE: 0 SD_VERSION: 2
mmcsd_decodeSCR: DATA_STATE_AFTER_ERASE: 0 SD_SECURITY: 2 SD_BUS_WIDTHS: 5
mmcsd_decodeSCR: Manufacturing data: 00000000
stm32_sendcmd: cmd: 00000077 arg: b3680000 regval: 00000477
stm32_sendcmd: cmd: 0000006a arg: 00000000 regval: 0000046a
stm32_sendcmd: cmd: 00000077 arg: b3680000 regval: 00000477
stm32_sendcmd: cmd: 00000046 arg: 00000002[boot] Initialized SDIO
regval: 00000446
mmcsd_widebus: Wide bus operation selected
stm32_setclkcr: CLKCR: 00000901 PWR: 00000003
mmcsd_probe: Capacity: 1885184 Kbytes
stm32_callbackenable: eventset: 01
stm32_callback: Callback 807b5f1(10004ac0) cbevents: 01 cdstatus: 01
romfs_open: Open 'init.d/rcS'
rd_geometry: Entry
rd_geometry: available: true mediachanged: false writeenabled: false
rd_geometry: nsectors: 31510657 sectorsize: 128
romfs_read: Read 256 bytes from offset 0
rd_geometry: Entry
rd_geometry: available: true mediachanged: false writeenabled: false
rd_geometry: nsectors: 31510657 sectorsize: 128
romfs_read: Read sector 213
romfs_filecacheread: sector: 213 cached: 0 sectorsize: 128 XIP base: 2000098c buffer: 2000098c
romfs_filecacheread: XIP buffer: 2000740c
romfs_read: Return 96 bytes from sector offset 32
romfs_read: Read 1 sectors starting with 214
romfs_read: Read sector 215
romfs_filecacheread: sector: 215 cached: 213 sectorsize: 128 XIP base: 2000098c buffer: 2000740c
romfs_filecacheread: XIP buffer: 2000750c
romfs_read: Return 32 bytes from sector offset 0
romfs_read: Read 256 bytes from offset 256
rd_geometry: Entry
rd_geometry: available: true mediachanged: false writeenabled: false
rd_geometry: nsectors: 31510657 sectorsize: 128
romfs_read: Read sector 215
romfs_filecacheread: sector: 215 cached: 215 sectorsize: 128 XIP base: 2000098c buffer: 2000750c
romfs_read: Return 96 bytes from sector offset 32
romfs_read: Read 1 sectors starting with 216
romfs_read: Read sector 217
romfs_filecacheread: sector: 217 cached: 215 sectorsize: 128 XIP base: 2000098c buffer: 2000750c
romfs_filecacheread: XIP buffer: 2000760c
romfs_read: Return 32 bytes from sector offset 0
romfs_read: Read 256 bytes from offset 512
rd_geometry: Entry
rd_geometry: available: true mediachanged: false writeenabled: false
rd_geometry: nsectors: 31510657 sectorsize: 128
romfs_read: Read sector 217
romfs_filecacheread: sector: 217 cached: 217 sectorsize: 128 XIP base: 2000098c buffer: 2000760c
romfs_read: Return 96 bytes from sector offset 32
romfs_read: Read 1 sectors starting with 218
romfs_read: Read sector 219
romfs_filecacheread: sector: 219 cached: 217 sectorsize: 128 XIP base: 2000098c buffer: 2000760c
romfs_filecacheread: XIP buffer: 2000770c
romfs_read: Return 32 bytes from sector offset 0
[init] looking for microSD...
romfs_read: Read 256 bytes from offset 768
rd_geometry: Entry
rd_geometry: available: true mediachanged: false writeenabled: false
rd_geometry: nsectors: 31510657 sectorsize: 128
romfs_read: Read sector 219
romfs_filecacheread: sector: 219 cached: 219 sectorsize: 128 XIP base: 2000098c buffer: 2000770c
romfs_read: Return 96 bytes from sector offset 32
romfs_read: Read 1 sectors starting with 220
romfs_read: Read sector 221
romfs_filecacheread: sector: 221 cached: 219 sectorsize: 128 XIP base: 2000098c buffer: 2000770c
romfs_filecacheread: XIP buffer: 2000780c
romfs_read: Return 32 bytes from sector offset 0
mmcsd_open: Entry
mmcsd_geometry: Entry
mmcsd_geometry: available: true mediachanged: true writeenabled: true
mmcsd_geometry: nsectors: 3770368 sstm32_dmacallback: DMA error 08, remaining: 512
ectorsize: 512
mmcsd_read: startsector: 0 nsectors: 1 sectorsize: 512
mmcsd_readsingle: startblock=0
mmcsd_readsingle: offset=0
stm32_sendcmd: cmd: 00000050 arg: 00000200 regval: 00000450
stm32_sendcmd: cmd: 00000451 arg: 00000000 regval: 00000451
mmcsd_eventwait: ERROR: Awakened with 10
mmcsd_readsingle: ERROR: CMD17 transfer failed: -5
mount: Bind method failed: -5
nsh: mount: mount failed: 5
[init] no microSD card found
romfs_read: Read 256 bytes from offset 1024
rd_geometry: Entry
rd_geometry: available: true mediachanged: false writeenabled: false
rd_geometry: nsectors: 31510657 sectorsize: 128
romfs_read: Read sector 221
romfs_filecacheread: sector: 221 cached: 221 sectorsize: 128 XIP base: 2000098c buffer: 2000780c
romfs_read: Return 96 bytes from sector offset 32
romfs_read: Read 1 sectors starting with 222
romfs_read: Read sector 223
romfs_filecacheread: sector: 223 cached: 221 sectorsize: 128 XIP base: 2000098c buffer: 2000780c
romfs_filecacheread: XIP buffer: 2000790c
romfs_read: Return 32 bytes from sector offset 0
romfs_read: Read 256 bytes from offset 1280
rd_geometry: Entry
rd_geometry: available: true mediachanged: false writeenabled: false
rd_geometry: nsectors: 31510657 sectorsize: 128
romfs_read: Read sector 223
romfs_filecacheread: sector: 223 cached: 223 sectorsize: 128 XIP base: 2000098c buffer: 2000790c
romfs_read: Return 96 bytes from sector offset 32
romfs_read: Read 1 sesercon: Registering CDC/ACM serial driver
ctors starting with 224
romfs_reasercon: Successfully registered the CDC/ACM serial driver
d: Read sector 225
romfs_filecacheread: sector: 225 cached: 223 sectorsize: 128 XIP base: 2000098c buffer: 2000790c
romfs_filecacheread: XIP buffer: 20007a0c
romfs_read: Return 32 bytes from sector offset 0
uart_register: Registering /dev/ttyACM0
[init] USB interface connected
romfs_read: Read 256 bytes from offset 1536
rd_geometry: Entry
rd_geometry: available: true mediachanged: false writeenabled: false
rd_geometry: nsectors: 31510657 sectorsize: 128
romfs_read: Read sector 225
romfs_filecacheread: sector: 225 cached: 225 sectorsize: 128 XIP base: 2000098c buffer: 20007a0c
romfs_read: Return 96 bytes from sector offset 32
romfs_read: Read sector 226
romfs_filecacheread: sector: 226 cached: 225 sectorsize: 128 XIP base: 2000098c buffer: 20007a0c
romfs_filecacheread: XIP buffer: 20007a8c
romfs_read: Return 73 bytes from sector offset 0
romfs_filecacheread: XIP buffer: 20007a8c
romfs_read: Return 73 bytes from sector offset 0
romfs_stat: Entry
rd_geometry: Entry
rd_geometry: available: true mediachanged: false writeenabled: false
rd_geometry: nsectors: 31510657 sectorsize: 128
romfs_stat: Failed to find directory: -2
romfs_read: Read 256 bytes from offset 1705
rd_geometry: Entry
rd_geometry: available: true mediachanged: false writeenabled: false
rd_geometry: nsectors: 31510657 sectorsize: 128
romfs_close: Closing






------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/nuttx/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/nuttx/join
(Yahoo! ID required)

<*> To change settings via email:
nuttx-digest-***@public.gmane.org
nuttx-fullfeatured-***@public.gmane.org

<*> To unsubscribe from this group, send an email to:
nuttx-unsubscribe-***@public.gmane.org

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
Gregory N
2013-04-19 14:17:16 UTC
Permalink
Hi, Lorenz,

There was another recent question about gettting SD working on an STM32 here: http://tech.groups.yahoo.com/group/nuttx/message/3757 . The problem there was a DMA problem.
Post by Meier Lorenz
I'm currently bringing up SDIO on the F4 (I'm aware that this works on the ST dev board). It does detect the card, but fails to mount the filesystem and I wanted to check if you see something obvious.
Note that this on a ~6 weeks old NuttX tree, and I can't immediately update (I will if you think there are relevant things in).
I see the /dev/mmcsd0 device being created.
+/* DMA Channl/Stream Selections *****************************************************/
+/* Stream selections are arbitrary for now but might become important in the future
+ * is we set aside more DMA channels/streams.
+ *
+ * SDIO DMA
+ * DMAMAP_SDIO_1 = Channel 4, Stream 3 <- may later be used by SPI DMA
+ * DMAMAP_SDIO_2 = Channel 4, Stream 6
+ */
+
+#define DMAMAP_SDIO DMAMAP_SDIO_1
This setting depends only upon how you share DMA channels amongst devices. You just need to make sure that this channel selection does not conflict any other device. I know that you use a lot of DMA channles for your UARTs so you should verify this.

You also really should convert to use the kconfig-frontends tools. There is a HowTo here: http://www.nuttx.org/doku.php?id=wiki:howtos:convertconfig . That will save a lot of time and help prevent configuration errors in the future.
Post by Meier Lorenz
#
+# Maintain legacy build behavior (revisit)
+#
+
+CONFIG_MMCSD=y
+CONFIG_MMCSD_SPI=y
+CONFIG_MMCSD_SDIO=y
+CONFIG_MTD=y
You don't need CONFIG_MMCSD_SPI=y. That enables SPI-based MMC/SD support. But don't worry about it; it doesn't do anything but enable more menus if you you use the kconfig-frontends configurations.
Post by Meier Lorenz
+#
+# SPI-based MMC/SD driver
+#
+CONFIG_MMCSD_NSLOTS=1
+CONFIG_MMCSD_READONLY=n
+CONFIG_MMCSD_SPICLOCK=12500000
Standard SD cards are capable of running at 25MHz. However, often board layouts prohibit higher speeds. I would think that 12.5MHz should be safe????
Post by Meier Lorenz
+#
+# STM32 SDIO-based MMC/SD driver
+#
+CONFIG_SDIO_DMA=y
+#CONFIG_SDIO_PRI=128
+#CONFIG_SDIO_DMAPRIO
+#CONFIG_SDIO_WIDTH_D1_ONLY
+CONFIG_MMCSD_MULTIBLOCK_DISABLE=y
+CONFIG_MMCSD_MMCSUPPORT=n
+CONFIG_MMCSD_HAVECARDDETECT=n
Card detect is a nice feature if your board supports it. Otherwise, the SD driver cannot know when there is a card present in the slot or not.
Post by Meier Lorenz
Board init (taken from the F4 dev board example, except for HAVE_MMCSD, which wasn't defined and I couldn't track down where in the build system it would have been defined, hints welcome).
... [snip] ...
mount -t vfat /dev/mmcsd0 /fs/microsd
ABDE
... [snip] ...
stm32_setclkcr: CLKCR: 000001b2 PWR: 00000000
stm32_reset: CLCKR: 000001b2 POWER: 00000003
mmcsd_slotinitialize: minor: 0
mmcsd_hwinitialize: DMA supported: 1
mmcsd_hwinitialize: Attached MMC/SD interrupts
stm32_registercallback: Register 807b5f1(10004ac0)
stm32_callbackenable: eventset: 02
stm32_callback: Callback 807b5f1(10004ac0) cbevents: 02 cdstatus: 00
mmcsd_slotinitialize: MMC/SD slot is empty
sdio_mediachange: cdstatus OLD: 00 NEW: 01
stm32_callback: Callback 807b5f1(10004ac0) cbevents: 02 cdstatus: 01
stm32_callback: Callback to 807b5f1(10004ac0)
mmcsd_mediachange: arg: 10004ac0
mmcsd_probe: type: 0 probed: 0
mmcsd_removed: type: 0 present: 1
stm32_setclkcr: CLKCR: 000001b2 PWR: 00000003
stm32_sendcmd: cmd: 00000000 arg: 00000000 regval: 00000400
stm32_sendcmd: cmd: 00000000 arg: 00000000 regval: 00000400
stm32_sendcmd: cmd: 00000208 arg: 000001aa regval: 00000448
mmcsd_cardidentify: SD V2.x card
stm32_sendcmd: cmd: 00000077 arg: 00000000 regval: 00000477
stm32_sendcmd: cmd: 00000129 arg: c0100000 regval: 00000469
mmcsd_cardidentify: R3: 00ff8000
stm32_sendcmd: cmd: 00000077 arg: 00000000 regval: 00000477
stm32_sendcmd: cmd: 00000129 arg: c0100000 regval: 00000469
mmcsd_cardidentify: R3: 80ff8000
stm32_sendcmd: cmd: 000000c2 arg: 00000000 regval: 000004c2
mmcsd_decodeCID: mid: 6f oid: 6f00 pnm: SMI prv: 0 psn: 0 mdt: c6 crc: 67
stm32_sendcmd: cmd: 000001c3 arg: 00000000 regval: 00000443
mmcsd_sdinitialize: RCA: b368
stm32_sendcmd: cmd: 0000004d arg: b3680000 regval: 0000044d
stm32_sendcmd: cmd: 000000c9 arg: b3680000 regval: 000004c9
mmcsd_decodeCSD: CSD_STRUCTURE: 0 SPEC_VERS: 0 (MMC)
mmcsd_decodeCSD: TAAC {TIME_UNIT: 0 TIME_VALUE: 0} NSAC: 0
mmcsd_decodeCSD: TRAN_SPEED {TRANSFER_RATE_UNIT: 2 TIME_VALUE: 6}
mmcsd_decodeCSD: CCC: 1333
mmcsd_decodeCSD: READ_BL_LEN: 10 READ_BL_PARTIAL: 1
mmcsd_decodeCSD: WRITE_BLK_MISALIGN: 0 READ_BLK_MISALIGN: 0
mmcsd_decodeCSD: DSR_IMP: 0
mmcsd_decodeCSD: C_SIZE: 3681 C_SIZE_MULT: 7
mmcsd_decodeCSD: VDD_R_CURR_MIN: 5 VDD_R_CURR_MAX: 5
mmcsd_decodeCSD: VDD_W_CURR_MIN: 5 VDD_W_CURR_MAX: 5
mmcsd_decodeCSD: SD_ER_BLK_EN: 1 SD_SECTOR_SIZE: 127 (SD) SD_WP_GRP_SIZE: 63
mmcsd_decodeCSD: WP_GRP_EN: 0 MMC DFLT_ECC: 0 (MMC) R2W_FACTOR: 5
mmcsd_decodeCSD: WRITE_BL_LEN: 10 WRITE_BL_PARTIAL: 0
mmcsd_decodeCSD: FILE_FORMAT_GROUP: 0 COPY: 0
mmcsd_decodeCSD: PERM_WRITE_PROTECT: 0 TMP_WRITE_PROTECT: 0
mmcsd_decodeCSD: FILE_FORMAT: 0 ECC: 0 (MMC) CRC: 65
mmcsd_decodeCSD: Capacity: 1885184Kb, Block size: 512b, nblocks: 3770368 wrprotect: 0
stm32_sendcmd: cmd: 00000087 arg: b3680000 regval: 00000447
stm32_setclkcr: CLKCR: 00000101 PWR: 00000003
stm32_sendcmd: cmd: 00000050 arg: 00000008 regval: 00000450
stm32_sendcmd: cmd: 00000077 arg: b3680000 regval: 00000477
stm32_sendcmd: cmd: 00000473 arg: 00000000 regval: 00000473
mmcsd_decodeSCR: SCR_STRUCTURE: 0 SD_VERSION: 2
mmcsd_decodeSCR: DATA_STATE_AFTER_ERASE: 0 SD_SECURITY: 2 SD_BUS_WIDTHS: 5
mmcsd_decodeSCR: Manufacturing data: 00000000
stm32_sendcmd: cmd: 00000077 arg: b3680000 regval: 00000477
stm32_sendcmd: cmd: 0000006a arg: 00000000 regval: 0000046a
stm32_sendcmd: cmd: 00000077 arg: b3680000 regval: 00000477
stm32_sendcmd: cmd: 00000046 arg: 00000002[boot] Initialized SDIO
regval: 00000446
Here things get more interesting because now we switch to high speed mode and a wide 4-bit bus. All subsequent SD accesses will also use DMA.
Post by Meier Lorenz
mmcsd_widebus: Wide bus operation selected
stm32_setclkcr: CLKCR: 00000901 PWR: 00000003
mmcsd_probe: Capacity: 1885184 Kbytes
stm32_callbackenable: eventset: 01
stm32_callback: Callback 807b5f1(10004ac0) cbevents: 01 cdstatus: 01
... [snip] ...
[init] looking for microSD...
... [snip] ...
mmcsd_open: Entry
mmcsd_geometry: Entry
mmcsd_geometry: available: true mediachanged: true writeenabled: true
NOTE that the following line includes an error message from the DMA interrupt handler:

stm32_dmacallback: DMA error 08, remaining: 512

That comes from:

static void stm32_dmacallback(DMA_HANDLE handle, uint8_t status, void *arg)
{
...
/* Get the result of the DMA transfer */

if ((status & DMA_STATUS_ERROR) != 0)
{
flldbg("DMA error %02x, remaining: %d\n", status, priv->remaining);
result = SDIOWAIT_ERROR;
}
...
}

Note also that no data was transferred, i.e., that 512 bytes of data still remain to be transferred. What kind of memory are you trying to DMA into? The F4 has several RAM resources:

1) System SRAM -- works fine for DMA
2) CCM SRAM -- Cannot be used for DAM
3) External SRAM -- I have seen DMA fail on external SRAM in the past but I don't know how to fix it.
Post by Meier Lorenz
mmcsd_geometry: nsectors: 3770368 sstm32_dmacallback: DMA error 08, remaining: 512
ectorsize: 512
mmcsd_read: startsector: 0 nsectors: 1 sectorsize: 512
mmcsd_readsingle: startblock=0
mmcsd_readsingle: offset=0
stm32_sendcmd: cmd: 00000050 arg: 00000200 regval: 00000450
stm32_sendcmd: cmd: 00000451 arg: 00000000 regval: 00000451
mmcsd_eventwait: ERROR: Awakened with 10
mmcsd_readsingle: ERROR: CMD17 transfer failed: -5
mount: Bind method failed: -5
nsh: mount: mount failed: 5
[init] no microSD card found
... [snip] ...
So your DMA is failing. There is either some problem with the SETUP or with the memory that you are DMAing into. I recommend that you turn on DMA debug output so that you can see what happened. The DMA debug does a non-invasive collection of DMA register snapshots before and after transfers. To enabled these snapshots, you would would need:

CONFIG_DEBUG_FS=y: You already have this setting

CONFIG_SDIO_XFRDEBUG=y: This enables sampling SDIO registers

CONFIG_DEBUG_DMA=y: If set with CONFIG_SDIO_DMA and the above, then DMA registers will be sampled as well.

Greg
Gregory N
2013-04-19 14:31:20 UTC
Permalink
Hi, Lorenz,
Post by Gregory N
1) System SRAM -- works fine for DMA
2) CCM SRAM -- Cannot be used for DAM
3) External SRAM -- I have seen DMA fail on external SRAM in the past but I don't know how to fix it.
My bet is that you are trying to do DMA from CCM memory. If you turn on DMA (as indicated below). You will know for sure.

If you are using CCM RAM, then there are one of two things you can do:

1) In arch/arm/src/stm32/Kconfig:

config STM32_CCMEXCLUDE
bool "Exclude CCM SRAM from the heap"
depends on STM32_STM32F20XX || STM32_STM32F40XX
default y if ARCH_DMA || ELF
---help---
Exclude CCM SRAM from the HEAP because (1) it cannot be used for DMA
and (2) it appears to be impossible to execute ELF modules from CCM
RAM.

This will eliminate the CCM RAM from the heap. Now it cannot be allocated for MMC/SD sector I/O buffers and you should get only DMA-able memory.

2) Or, if you don't want to lose the CCM memory: In fs/fat/Kconfig:

config FAT_DMAMEMORY
bool "DMA memory allocator"
default n
---help---
The FAT file system allocates two I/O buffers for data transfer, each
are the size of one device sector. One of the buffers is allocated
once for each FAT volume that is mounted; the other buffers are
allocated each time a FAT file is opened.

Some hardware, however, may require special DMA-capable memory in
order to perform the the transfers. If FAT_DMAMEMORY is defined
then the architecture-specific hardware must provide the funtions
fat_dma_alloc() and fat_dma_free(): fat_dmalloc() will allocate
DMA-capable memory of the specified size; fat_dmafree() is the
corresponding function that will be called to free the DMA-capable
memory
Post by Gregory N
CONFIG_DEBUG_FS=y: You already have this setting
CONFIG_SDIO_XFRDEBUG=y: This enables sampling SDIO registers
CONFIG_DEBUG_DMA=y: If set with CONFIG_SDIO_DMA and the above, then DMA registers will be sampled as well.
Greg
Meier Lorenz
2013-04-19 16:30:46 UTC
Permalink
Greg,

Thanks for the pointers. Given that the CCM memory is one third of the total memory of this chip and its a similar issue exists with UART DMA (where I believe an architecture-aware solution has been implemented to address this) I assumed its the case here as well.

I will get back once I have some results.

-Lorenz

On 19 Apr 2013, at 16:31, Gregory N <spudarnia-/***@public.gmane.org<mailto:spudarnia-/***@public.gmane.org>> wrote:




Hi, Lorenz,
Post by Gregory N
1) System SRAM -- works fine for DMA
2) CCM SRAM -- Cannot be used for DAM
3) External SRAM -- I have seen DMA fail on external SRAM in the past but I don't know how to fix it.
My bet is that you are trying to do DMA from CCM memory. If you turn on DMA (as indicated below). You will know for sure.

If you are using CCM RAM, then there are one of two things you can do:

1) In arch/arm/src/stm32/Kconfig:

config STM32_CCMEXCLUDE
bool "Exclude CCM SRAM from the heap"
depends on STM32_STM32F20XX || STM32_STM32F40XX
default y if ARCH_DMA || ELF
---help---
Exclude CCM SRAM from the HEAP because (1) it cannot be used for DMA
and (2) it appears to be impossible to execute ELF modules from CCM
RAM.

This will eliminate the CCM RAM from the heap. Now it cannot be allocated for MMC/SD sector I/O buffers and you should get only DMA-able memory.

2) Or, if you don't want to lose the CCM memory: In fs/fat/Kconfig:

config FAT_DMAMEMORY
bool "DMA memory allocator"
default n
---help---
The FAT file system allocates two I/O buffers for data transfer, each
are the size of one device sector. One of the buffers is allocated
once for each FAT volume that is mounted; the other buffers are
allocated each time a FAT file is opened.

Some hardware, however, may require special DMA-capable memory in
order to perform the the transfers. If FAT_DMAMEMORY is defined
then the architecture-specific hardware must provide the funtions
fat_dma_alloc() and fat_dma_free(): fat_dmalloc() will allocate
DMA-capable memory of the specified size; fat_dmafree() is the
corresponding function that will be called to free the DMA-capable
memory
Post by Gregory N
CONFIG_DEBUG_FS=y: You already have this setting
CONFIG_SDIO_XFRDEBUG=y: This enables sampling SDIO registers
CONFIG_DEBUG_DMA=y: If set with CONFIG_SDIO_DMA and the above, then DMA registers will be sampled as well.
Greg






------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/nuttx/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/nuttx/join
(Yahoo! ID required)

<*> To change settings via email:
nuttx-digest-***@public.gmane.org
nuttx-fullfeatured-***@public.gmane.org

<*> To unsubscribe from this group, send an email to:
nuttx-unsubscribe-***@public.gmane.org

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
Gregory N
2013-04-19 18:20:34 UTC
Permalink
Hi, Lorenz,
Post by Meier Lorenz
Thanks for the pointers. Given that the CCM memory is one third of the total memory of this chip and its a similar issue exists with UART DMA (where I believe an architecture-aware solution has been implemented to address this) I assumed its the case here as well.
I will get back once I have some results.
The UART DMA memory is not allocated using malloc. I believe that the UART DMA buffers are set aside as arrays in .bss. Your linker script determines where .bss lies. But .bss is not in CCM memory in any of the of linker scripts I have.

The FAT file system is different, it uses malloc to create DMA buffers. It is indeterminant what memory will be provided when malloc is called. That depends on the size of allocation and size of the available chunks (malloc implements a best fit algorithm). But, in general, I believe that would allocate from CCM memory first.

Greg
Michael Smith
2013-04-24 17:35:44 UTC
Permalink
Greg,

Just to close the loop; this was indeed a CCM vs DMA configuration issue.

= Mike
Post by Gregory N
Hi, Lorenz,
Post by Meier Lorenz
Thanks for the pointers. Given that the CCM memory is one third of the total memory of this chip and its a similar issue exists with UART DMA (where I believe an architecture-aware solution has been implemented to address this) I assumed its the case here as well.
I will get back once I have some results.
The UART DMA memory is not allocated using malloc. I believe that the UART DMA buffers are set aside as arrays in .bss. Your linker script determines where .bss lies. But .bss is not in CCM memory in any of the of linker scripts I have.
The FAT file system is different, it uses malloc to create DMA buffers. It is indeterminant what memory will be provided when malloc is called. That depends on the size of allocation and size of the available chunks (malloc implements a best fit algorithm). But, in general, I believe that would allocate from CCM memory first.
Greg
Loading...