diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-09-24 15:51:48 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-09-24 15:51:48 +0000 |
commit | 3a9970e4b125c4a629d957d35ca67f662c69ff00 (patch) | |
tree | 57575d4289b1d76f23fc786438be6d0332c4b656 /nuttx | |
parent | 885d507dd53d6f95c83397b7993431619cb08c5b (diff) | |
download | px4-nuttx-3a9970e4b125c4a629d957d35ca67f662c69ff00.tar.gz px4-nuttx-3a9970e4b125c4a629d957d35ca67f662c69ff00.tar.bz2 px4-nuttx-3a9970e4b125c4a629d957d35ca67f662c69ff00.zip |
Fixes STM32F107 DMA issue
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5182 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx')
-rw-r--r-- | nuttx/ChangeLog | 4 | ||||
-rw-r--r-- | nuttx/arch/arm/src/stm32/chip/stm32_eth.h | 7 | ||||
-rw-r--r-- | nuttx/arch/arm/src/stm32/stm32_eth.c | 16 | ||||
-rw-r--r-- | nuttx/arch/arm/src/stm32/stm32_idle.c | 23 | ||||
-rw-r--r-- | nuttx/configs/fire-stm32v2/nsh/defconfig | 4 | ||||
-rw-r--r-- | nuttx/configs/shenzhou/nsh/defconfig | 4 | ||||
-rw-r--r-- | nuttx/configs/stm3240g-eval/discover/defconfig | 4 | ||||
-rw-r--r-- | nuttx/configs/stm3240g-eval/xmlrpc/defconfig | 4 |
8 files changed, 50 insertions, 16 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 42110fd79..eb9680aef 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -3386,3 +3386,7 @@ case now (either space or a fieldwidth must be provided). But at least some of the bad logic that attempted to handle this case has been removed (noted by Kate). + * arch/arm/src/stm32/stm32_eth.c: DMA buffer sizes must be an + even multiple of 4, 8, or 16 bytes. + * arch/arm/src/stm32/stm32_idle.c: Fixes STM32F107 DMA issues: + We cannot go into sleep mode while Ethernet is actively DMAing. diff --git a/nuttx/arch/arm/src/stm32/chip/stm32_eth.h b/nuttx/arch/arm/src/stm32/chip/stm32_eth.h index 0b5ef18ca..a4a109d01 100644 --- a/nuttx/arch/arm/src/stm32/chip/stm32_eth.h +++ b/nuttx/arch/arm/src/stm32/chip/stm32_eth.h @@ -711,7 +711,9 @@ /* RDES0: Receive descriptor Word0 */ #define ETH_RDES0_PCE (1 << 0) /* Bit 0: Payload checksum error */ -#define ETH_RDES0_ESA (1 << 0) /* Bit 0: Extended status available */ +#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +# define ETH_RDES0_ESA (1 << 0) /* Bit 0: Extended status available */ +#endif #define ETH_RDES0_CE (1 << 1) /* Bit 1: CRC error */ #define ETH_RDES0_DBE (1 << 2) /* Bit 2: Dribble bit error */ #define ETH_RDES0_RE (1 << 3) /* Bit 3: Receive error */ @@ -735,8 +737,9 @@ /* RDES1: Receive descriptor Word1 */ -#define ETH_RDES1_RBS1_SHIFT (0) /* Bits 0-12: Receive buffer 1 size */ +#define ETH_RDES1_RBS1_SHIFT (0) /* Bits 0-12: Receive buffer 1 size */ #define ETH_RDES1_RBS1_MASK (0x1fff << ETH_RDES1_RBS1_SHIFT) + /* Bit 13: Reserved */ #define ETH_RDES1_RCH (1 << 14) /* Bit 14: Second address chained */ #define ETH_RDES1_RER (1 << 15) /* Bit 15: Receive end of ring */ #define ETH_RDES1_RBS2_SHIFT (16) /* Bits 16-28: Receive buffer 2 size */ diff --git a/nuttx/arch/arm/src/stm32/stm32_eth.c b/nuttx/arch/arm/src/stm32/stm32_eth.c index ab9cac209..2e892c9e5 100644 --- a/nuttx/arch/arm/src/stm32/stm32_eth.c +++ b/nuttx/arch/arm/src/stm32/stm32_eth.c @@ -186,10 +186,12 @@ #endif /* Add 4 to the configured buffer size to account for the 2 byte checksum - * memory needed at the end of the maximum size packet. + * memory needed at the end of the maximum size packet. Buffer sizes must + * be an even multiple of 4, 8, or 16 bytes (depending on buswidth). We + * will use the 16-byte alignment in all cases. */ -#define OPTIMAL_ETH_BUFSIZE (CONFIG_NET_BUFSIZE+4) +#define OPTIMAL_ETH_BUFSIZE ((CONFIG_NET_BUFSIZE + 4 + 15) & ~15) #ifndef CONFIG_STM32_ETH_BUFSIZE # define CONFIG_STM32_ETH_BUFSIZE OPTIMAL_ETH_BUFSIZE @@ -199,6 +201,10 @@ # error "CONFIG_STM32_ETH_BUFSIZE is too large" #endif +#if (CONFIG_STM32_ETH_BUFSIZE & 15) != 0 +# error "CONFIG_STM32_ETH_BUFSIZE must be aligned" +#endif + #if CONFIG_STM32_ETH_BUFSIZE != OPTIMAL_ETH_BUFSIZE # warning "You using an incomplete/untested configuration" #endif @@ -1470,9 +1476,6 @@ static int stm32_recvframe(FAR struct stm32_ethmac_s *priv) { priv->segments++; - nllvdbg("rxhead: %p rxcurr: %p segments: %d\n", - priv->rxhead, priv->rxcurr, priv->segments); - /* Check if the there is only one segment in the frame */ if (priv->segments == 1) @@ -1484,6 +1487,9 @@ static int stm32_recvframe(FAR struct stm32_ethmac_s *priv) rxcurr = priv->rxcurr; } + nllvdbg("rxhead: %p rxcurr: %p segments: %d\n", + priv->rxhead, priv->rxcurr, priv->segments); + /* Check if any errors are reported in the frame */ if ((rxdesc->rdes0 & ETH_RDES0_ES) == 0) diff --git a/nuttx/arch/arm/src/stm32/stm32_idle.c b/nuttx/arch/arm/src/stm32/stm32_idle.c index 791a79429..0b69ff648 100644 --- a/nuttx/arch/arm/src/stm32/stm32_idle.c +++ b/nuttx/arch/arm/src/stm32/stm32_idle.c @@ -45,6 +45,7 @@ #include <arch/irq.h> +#include "chip.h" #include "stm32_pm.h" #include "up_internal.h" @@ -178,11 +179,31 @@ void up_idle(void) up_idlepm(); - /* Sleep until an interrupt occurs to save power */ + /* Sleep until an interrupt occurs to save power. + * + * NOTE: There is an STM32F107 errata that is fixed by the following + * workaround: + * + * "2.17.11 Ethernet DMA not working after WFI/WFE instruction + * Description + * If a WFI/WFE instruction is executed to put the system in sleep mode + * while the Ethernet MAC master clock on the AHB bus matrix is ON and all + * remaining masters clocks are OFF, the Ethernet DMA will be not able to + * perform any AHB master accesses during sleep mode." + * + * Workaround + * Enable DMA1 or DMA2 clocks in the RCC_AHBENR register before + * executing the WFI/WFE instruction." + * + * Here the workaround is just don't go into SLEEP mode for the connectivity + * line parts if Ethernet is enabled. + */ +#if !defined(CONFIG_STM32_CONNECTIVITYLINE) || !defined(CONFIG_STM32_ETHMAC) BEGIN_IDLE(); asm("WFI"); END_IDLE(); #endif +#endif } diff --git a/nuttx/configs/fire-stm32v2/nsh/defconfig b/nuttx/configs/fire-stm32v2/nsh/defconfig index 0802af3c9..d6aaae05a 100644 --- a/nuttx/configs/fire-stm32v2/nsh/defconfig +++ b/nuttx/configs/fire-stm32v2/nsh/defconfig @@ -456,7 +456,7 @@ CONFIG_NET_BUFSIZE=562 CONFIG_NET_TCP=y CONFIG_NET_TCP_CONNS=16 CONFIG_NET_MAX_LISTENPORTS=16 -CONFIG_NET_TCP_READAHEAD_BUFSIZE=562 +# CONFIG_NET_TCP_READAHEAD_BUFSIZE=562 CONFIG_NET_NTCP_READAHEAD_BUFFERS=8 CONFIG_NET_TCP_RECVDELAY=0 # CONFIG_NET_TCPBACKLOG is not set @@ -469,7 +469,7 @@ CONFIG_NET_ICMP_PING=y # CONFIG_NET_PINGADDRCONF is not set # CONFIG_NET_IGMP is not set CONFIG_NET_STATISTICS=y -CONFIG_NET_RECEIVE_WINDOW=562 +# CONFIG_NET_RECEIVE_WINDOW=562 CONFIG_NET_ARPTAB_SIZE=16 # CONFIG_NET_ARP_IPIN is not set diff --git a/nuttx/configs/shenzhou/nsh/defconfig b/nuttx/configs/shenzhou/nsh/defconfig index 313f9f57b..0a699d334 100644 --- a/nuttx/configs/shenzhou/nsh/defconfig +++ b/nuttx/configs/shenzhou/nsh/defconfig @@ -388,7 +388,7 @@ CONFIG_NET_BUFSIZE=562 CONFIG_NET_TCP=y CONFIG_NET_TCP_CONNS=40 CONFIG_NET_MAX_LISTENPORTS=40 -CONFIG_NET_TCP_READAHEAD_BUFSIZE=562 +# CONFIG_NET_TCP_READAHEAD_BUFSIZE=562 CONFIG_NET_NTCP_READAHEAD_BUFFERS=16 CONFIG_NET_TCP_RECVDELAY=0 CONFIG_NET_TCPBACKLOG=y @@ -401,7 +401,7 @@ CONFIG_NET_ICMP_PING=y # CONFIG_NET_PINGADDRCONF is not set # CONFIG_NET_IGMP is not set CONFIG_NET_STATISTICS=y -CONFIG_NET_RECEIVE_WINDOW=562 +# CONFIG_NET_RECEIVE_WINDOW=562 CONFIG_NET_ARPTAB_SIZE=16 # CONFIG_NET_ARP_IPIN is not set diff --git a/nuttx/configs/stm3240g-eval/discover/defconfig b/nuttx/configs/stm3240g-eval/discover/defconfig index 81a5b3c91..71dce1028 100644 --- a/nuttx/configs/stm3240g-eval/discover/defconfig +++ b/nuttx/configs/stm3240g-eval/discover/defconfig @@ -388,7 +388,7 @@ CONFIG_NET_BUFSIZE=650 CONFIG_NET_TCP=y CONFIG_NET_TCP_CONNS=40 CONFIG_NET_MAX_LISTENPORTS=40 -CONFIG_NET_TCP_READAHEAD_BUFSIZE=562 +# CONFIG_NET_TCP_READAHEAD_BUFSIZE=562 CONFIG_NET_NTCP_READAHEAD_BUFFERS=16 CONFIG_NET_TCP_RECVDELAY=0 CONFIG_NET_TCPBACKLOG=y @@ -401,7 +401,7 @@ CONFIG_NET_ICMP_PING=y # CONFIG_NET_PINGADDRCONF is not set # CONFIG_NET_IGMP is not set CONFIG_NET_STATISTICS=y -CONFIG_NET_RECEIVE_WINDOW=562 +# CONFIG_NET_RECEIVE_WINDOW=562 CONFIG_NET_ARPTAB_SIZE=16 CONFIG_NET_ARP_IPIN=y diff --git a/nuttx/configs/stm3240g-eval/xmlrpc/defconfig b/nuttx/configs/stm3240g-eval/xmlrpc/defconfig index 5c70327b9..cd80ea618 100644 --- a/nuttx/configs/stm3240g-eval/xmlrpc/defconfig +++ b/nuttx/configs/stm3240g-eval/xmlrpc/defconfig @@ -382,7 +382,7 @@ CONFIG_NET_BUFSIZE=650 CONFIG_NET_TCP=y CONFIG_NET_TCP_CONNS=40 CONFIG_NET_MAX_LISTENPORTS=40 -CONFIG_NET_TCP_READAHEAD_BUFSIZE=562 +# CONFIG_NET_TCP_READAHEAD_BUFSIZE=562 CONFIG_NET_NTCP_READAHEAD_BUFFERS=16 CONFIG_NET_TCP_RECVDELAY=0 CONFIG_NET_TCPBACKLOG=y @@ -395,7 +395,7 @@ CONFIG_NET_ICMP_PING=y # CONFIG_NET_PINGADDRCONF is not set # CONFIG_NET_IGMP is not set CONFIG_NET_STATISTICS=y -CONFIG_NET_RECEIVE_WINDOW=562 +# CONFIG_NET_RECEIVE_WINDOW=562 CONFIG_NET_ARPTAB_SIZE=16 CONFIG_NET_ARP_IPIN=y |