From 3207ae47319ee00ec83841c4019fca903d5c4580 Mon Sep 17 00:00:00 2001 From: patacongo Date: Tue, 21 Feb 2012 22:00:28 +0000 Subject: [PATCH] STM32 SDIO DMA: Ignore DMA FIFO errors; these seem to be bogus. SD multiple block transfers result in CRC errors; avoid them by using smaller FTP buffer sizes git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4410 7fd9a85b-ad96-42d3-883c-3090e2eb8679 --- apps/include/netutils/ftpd.h | 10 ++++---- nuttx/Documentation/NuttxPortingGuide.html | 4 ++-- nuttx/TODO | 28 ++++++++++++++++++++-- nuttx/arch/arm/src/stm32/stm32_dma.h | 6 ++--- nuttx/arch/arm/src/stm32/stm32_sdio.c | 21 +--------------- nuttx/arch/arm/src/stm32/stm32f40xxx_dma.c | 7 ++++-- nuttx/configs/README.txt | 4 ++-- nuttx/configs/stm3240g-eval/README.txt | 22 +++++++++++++++++ nuttx/configs/stm3240g-eval/nsh/defconfig | 5 ++-- nuttx/configs/stm3240g-eval/nsh2/defconfig | 5 ++-- 10 files changed, 72 insertions(+), 40 deletions(-) diff --git a/apps/include/netutils/ftpd.h b/apps/include/netutils/ftpd.h index f7581c89e..71a2096bb 100755 --- a/apps/include/netutils/ftpd.h +++ b/apps/include/netutils/ftpd.h @@ -2,7 +2,7 @@ * apps/include/netutils/ftpd.h * * Copyright (C) 2012 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -61,9 +61,9 @@ * CONFIG_FTPD_SERVERID - The server name to use in FTP communications. * Default: "NuttX FTP Server" * CONFIG_FTPD_CMDBUFFERSIZE - The maximum size of one command. Default: - * 512 bytes. + * 128 bytes. * CONFIG_FTPD_DATABUFFERSIZE - The size of the I/O buffer for data - * transfers. Default: 2048 bytes. + * transfers. Default: 512 bytes. * CONFIG_FTPD_WORKERSTACKSIZE - The stacksize to allocate for each * FTP daemon worker thread. Default: 2048 bytes. */ @@ -85,11 +85,11 @@ #endif #ifndef CONFIG_FTPD_CMDBUFFERSIZE -# define CONFIG_FTPD_CMDBUFFERSIZE 512 +# define CONFIG_FTPD_CMDBUFFERSIZE 128 #endif #ifndef CONFIG_FTPD_DATABUFFERSIZE -# define CONFIG_FTPD_DATABUFFERSIZE 2048 +# define CONFIG_FTPD_DATABUFFERSIZE 512 #endif #ifndef CONFIG_FTPD_WORKERSTACKSIZE diff --git a/nuttx/Documentation/NuttxPortingGuide.html b/nuttx/Documentation/NuttxPortingGuide.html index 62f795887..c9656a6c5 100644 --- a/nuttx/Documentation/NuttxPortingGuide.html +++ b/nuttx/Documentation/NuttxPortingGuide.html @@ -4923,10 +4923,10 @@ build CONFIG_FTPD_SERVERID: The server name to use in FTP communications. Default: "NuttX FTP Server"
  • - CONFIG_FTPD_CMDBUFFERSIZE: The maximum size of one command. Default: 512 bytes. + CONFIG_FTPD_CMDBUFFERSIZE: The maximum size of one command. Default: 128 bytes.
  • - CONFIG_FTPD_DATABUFFERSIZE: The size of the I/O buffer for data transfers. Default: 2048 bytes. + CONFIG_FTPD_DATABUFFERSIZE: The size of the I/O buffer for data transfers. Default: 512 bytes.
  • CONFIG_FTPD_WORKERSTACKSIZE: The stacksize to allocate for each FTP daemon worker thread. Default: 2048 bytes. diff --git a/nuttx/TODO b/nuttx/TODO index 44a607ec4..c62e93a1e 100644 --- a/nuttx/TODO +++ b/nuttx/TODO @@ -1,4 +1,4 @@ -NuttX TODO List (Last updated February 12, 2012) +NuttX TODO List (Last updated February 21, 2012) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This file summarizes known NuttX bugs, limitations, inconsistencies with @@ -31,7 +31,7 @@ nuttx/ (2) ARM/LPC313x (arch/arm/src/lpc313x/) (3) ARM/STR71x (arch/arm/src/str71x/) (3) ARM/LM3S6918 (arch/arm/src/lm3s/) - (5) ARM/STM32 (arch/arm/src/stm32/) + (7) ARM/STM32 (arch/arm/src/stm32/) (3) AVR (arch/avr) (0) Intel x86 (arch/x86) (4) 8051 / MCS51 (arch/8051/) @@ -1143,6 +1143,30 @@ o ARM/STM32 (arch/arm/src/stm32/) Status: Open Priority: Medium + Title: F4 SDIO MULTI-BLOCK TRANSFER FAILURES + Description: If you use a large I/O buffer to access the file system, then the + MMCSD driver will perform multiple block SD transfers. With DMA + ON, this seems to result in CRC errors detected by the hardware + during the transfer. Workaround: Use I/O buffers less the 1024 + bytes. + Status: Open + Priority: Medium + + Title: DMA BOUNDARY CROSSING + Description: I see this statement in the reference manual: "The burst + configuration has to be selected in order to respect the AHB protocol, + where bursts must not cross the 1 KB address boundary because the + minimum address space that can be allocated to a single slave + is 1 KB. This means that the 1 KB address boundary should not be crossed + by a burst block transfer, otherwise an AHB error would be generated, + that is not reported by the DMA registers." + + The implication is that there may be some unenforced alignment + requirements for some DMAs. There is nothing in the DMA driver to + prevent this now. + Status: Open + Priority: Low (I am not even sure if this is a problem yet). + o AVR (arch/avr) ^^^^^^^^^^^^^^ diff --git a/nuttx/arch/arm/src/stm32/stm32_dma.h b/nuttx/arch/arm/src/stm32/stm32_dma.h index 84b861e89..2ebd691d9 100644 --- a/nuttx/arch/arm/src/stm32/stm32_dma.h +++ b/nuttx/arch/arm/src/stm32/stm32_dma.h @@ -60,13 +60,13 @@ */ #if defined(CONFIG_STM32_STM32F10XX) -# define DMA_STATUS_FEIF 0 -# define DMA_STATUS_DMEIF 0 +# define DMA_STATUS_FEIF 0 /* (Not available in F1) */ +# define DMA_STATUS_DMEIF 0 /* (Not available in F1) */ # define DMA_STATUS_TEIF DMA_CHAN_TEIF_BIT /* Channel Transfer Error */ # define DMA_STATUS_HTIF DMA_CHAN_HTIF_BIT /* Channel Half Transfer */ # define DMA_STATUS_TCIF DMA_CHAN_TCIF_BIT /* Channel Transfer Complete */ #elif defined(CONFIG_STM32_STM32F40XX) -# define DMA_STATUS_FEIF DMA_STREAM_FEIF_BIT /* Stream FIFO error */ +# define DMA_STATUS_FEIF 0 /* Stream FIFO error (ignored) */ # define DMA_STATUS_DMEIF DMA_STREAM_DMEIF_BIT /* Stream direct mode error */ # define DMA_STATUS_TEIF DMA_STREAM_TEIF_BIT /* Stream Transfer Error */ # define DMA_STATUS_HTIF DMA_STREAM_HTIF_BIT /* Stream Half Transfer */ diff --git a/nuttx/arch/arm/src/stm32/stm32_sdio.c b/nuttx/arch/arm/src/stm32/stm32_sdio.c index 60db7373b..9672aaf0c 100644 --- a/nuttx/arch/arm/src/stm32/stm32_sdio.c +++ b/nuttx/arch/arm/src/stm32/stm32_sdio.c @@ -188,26 +188,7 @@ # define SDIO_TXDMA32_CONFIG (CONFIG_SDIO_DMAPRIO|DMA_CCR_MSIZE_32BITS|\ DMA_CCR_PSIZE_32BITS|DMA_CCR_MINC|DMA_CCR_DIR) -/* STM32 F4 stream configuration register (SCR) settings. - * - * Hmmm... I see conflicting statements in the Reference Manual. In the DMA - * section it says: - - * "Note: The Burst mode is allowed only when incremetation is enabled: - * – When the PINC bit is at ‘0’, the PBURST bits should also be cleared to ‘00’ - * – When the MINC bit is at ‘0’, the MBURST bits should also be cleared to ‘00’." - * - * But in the SDIO section it says: - * - * "4. Configure the DMA2 as follows: - * ... - * c) Program DMA2_Stream3 or DMA2_Stream6 Channel4 control register - * (memory increment, not peripheral increment, peripheral and source - * width is word size). - * ... - * e) Configure the incremental burst transfer to 4 beats (at least from - * peripheral side)..." - */ +/* STM32 F4 stream configuration register (SCR) settings. */ #elif defined(CONFIG_STM32_STM32F40XX) # define SDIO_RXDMA32_CONFIG (DMA_SCR_PFCTRL|DMA_SCR_DIR_P2M|DMA_SCR_MINC|\ diff --git a/nuttx/arch/arm/src/stm32/stm32f40xxx_dma.c b/nuttx/arch/arm/src/stm32/stm32f40xxx_dma.c index 02d996631..db09cfd2e 100644 --- a/nuttx/arch/arm/src/stm32/stm32f40xxx_dma.c +++ b/nuttx/arch/arm/src/stm32/stm32f40xxx_dma.c @@ -676,11 +676,14 @@ void stm32_dmasetup(DMA_HANDLE handle, uint32_t paddr, uint32_t maddr, * case, a FIFO error (flag FEIFx of the DMA_HISR or DMA_LISR register) will be * generated when the stream is enabled, then the stream will be automatically * disabled." + * + * NOTE: The FEIFx error interrupt is not enabled because the FEIFx seems to + * be reported spuriously causing good transfers to be marked as failures. */ regval = dmast_getreg(dmast, STM32_DMA_SFCR_OFFSET); - regval &= ~(DMA_SFCR_FTH_MASK | DMA_SFCR_FS_MASK); - regval |= (DMA_SFCR_FTH_FULL | DMA_SFCR_DMDIS | DMA_SFCR_FEIE); + regval &= ~(DMA_SFCR_FTH_MASK | DMA_SFCR_FS_MASK | DMA_SFCR_FEIE); + regval |= (DMA_SFCR_FTH_FULL | DMA_SFCR_DMDIS); dmast_putreg(dmast, STM32_DMA_SFCR_OFFSET, regval); /* "Configure data transfer direction, circular mode, peripheral & memory diff --git a/nuttx/configs/README.txt b/nuttx/configs/README.txt index 6df735970..fc8373df9 100644 --- a/nuttx/configs/README.txt +++ b/nuttx/configs/README.txt @@ -953,9 +953,9 @@ defconfig -- This is a configuration file similar to the Linux CONFIG_FTPD_SERVERID - The server name to use in FTP communications. Default: "NuttX FTP Server" CONFIG_FTPD_CMDBUFFERSIZE - The maximum size of one command. Default: - 512 bytes. + 128 bytes. CONFIG_FTPD_DATABUFFERSIZE - The size of the I/O buffer for data - transfers. Default: 2048 bytes. + transfers. Default: 512 bytes. CONFIG_FTPD_WORKERSTACKSIZE - The stacksize to allocate for each FTP daemon worker thread. Default: 2048 bytes. diff --git a/nuttx/configs/stm3240g-eval/README.txt b/nuttx/configs/stm3240g-eval/README.txt index e4902947e..3c4f7e77c 100755 --- a/nuttx/configs/stm3240g-eval/README.txt +++ b/nuttx/configs/stm3240g-eval/README.txt @@ -737,6 +737,28 @@ Where is one of the following: Then DMA works fine. The downside is, of course, is that we lose 64Kb of precious SRAM. + 5. Another SDIO/DMA issue. This one is probably a software bug. This is + the bug as stated in the TODO list: + + "If you use a large I/O buffer to access the file system, then the + MMCSD driver will perform multiple block SD transfers. With DMA + ON, this seems to result in CRC errors detected by the hardware + during the transfer. Workaround: Use I/O buffers less the 1024 + bytes." + + For this reason, CONFIG_FTPD_DATABUFFERSIZE=512 appears in the defconfig + file. + + 6. Another DMA-related concern. I see this statement in the reference + manual: "The burst configuration has to be selected in order to respect + the AHB protocol, where bursts must not cross the 1 KB address boundary + because the minimum address space that can be allocated to a single slave + is 1 KB. This means that the 1 KB address boundary should not be crossed + by a burst block transfer, otherwise an AHB error would be generated, + that is not reported by the DMA registers." + + There is nothing in the DMA driver to prevent this now. + ostest: ------ This configuration directory, performs a simple OS test using diff --git a/nuttx/configs/stm3240g-eval/nsh/defconfig b/nuttx/configs/stm3240g-eval/nsh/defconfig index 76800c671..bb4b25222 100644 --- a/nuttx/configs/stm3240g-eval/nsh/defconfig +++ b/nuttx/configs/stm3240g-eval/nsh/defconfig @@ -864,9 +864,9 @@ CONFIG_NET_RESOLV_ENTRIES=4 # CONFIG_FTPD_SERVERID - The server name to use in FTP communications. # Default: "NuttX FTP Server" # CONFIG_FTPD_CMDBUFFERSIZE - The maximum size of one command. Default: -# 512 bytes. +# 128 bytes. # CONFIG_FTPD_DATABUFFERSIZE - The size of the I/O buffer for data -# transfers. Default: 2048 bytes. +# transfers. Default: 512 bytes. # CONFIG_FTPD_WORKERSTACKSIZE - The stacksize to allocate for each # FTP daemon worker thread. Default: 2048 bytes. # @@ -876,6 +876,7 @@ CONFIG_NET_RESOLV_ENTRIES=4 # CONFIG_DISABLE_PTHREAD - pthread support is required # CONFIG_DISABLE_POLL - poll() support is required # +CONFIG_FTPD_CMDBUFFERSIZE=512 # # RTC Configuration diff --git a/nuttx/configs/stm3240g-eval/nsh2/defconfig b/nuttx/configs/stm3240g-eval/nsh2/defconfig index 25ab466b8..1160cc96d 100644 --- a/nuttx/configs/stm3240g-eval/nsh2/defconfig +++ b/nuttx/configs/stm3240g-eval/nsh2/defconfig @@ -865,9 +865,9 @@ CONFIG_NET_RESOLV_ENTRIES=4 # CONFIG_FTPD_SERVERID - The server name to use in FTP communications. # Default: "NuttX FTP Server" # CONFIG_FTPD_CMDBUFFERSIZE - The maximum size of one command. Default: -# 512 bytes. +# 128 bytes. # CONFIG_FTPD_DATABUFFERSIZE - The size of the I/O buffer for data -# transfers. Default: 2048 bytes. +# transfers. Default: 512 bytes. # CONFIG_FTPD_WORKERSTACKSIZE - The stacksize to allocate for each # FTP daemon worker thread. Default: 2048 bytes. # @@ -877,6 +877,7 @@ CONFIG_NET_RESOLV_ENTRIES=4 # CONFIG_DISABLE_PTHREAD - pthread support is required # CONFIG_DISABLE_POLL - poll() support is required # +CONFIG_FTPD_CMDBUFFERSIZE=512 # # RTC Configuration