Date: Fri, 21 Sep 2012 17:32:30 +0000
Subject: [PATCH 02/31] Add support for Fire STM32v3; sscanf fixes from Kate
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5168 42af7a65-404d-4744-a932-0658087f49c3
---
apps/netutils/webserver/Kconfig | 4 +-
nuttx/ChangeLog | 9 +
nuttx/Documentation/NuttX.html | 6 +-
nuttx/configs/Kconfig | 8 +-
nuttx/configs/README.txt | 3 +-
nuttx/configs/fire-stm32v2/Kconfig | 22 +++
nuttx/configs/fire-stm32v2/README.txt | 16 +-
nuttx/configs/fire-stm32v2/nsh/defconfig | 17 +-
.../configs/fire-stm32v2/src/fire-internal.h | 18 +-
nuttx/lib/stdio/lib_sscanf.c | 164 +++++++++++++-----
10 files changed, 205 insertions(+), 62 deletions(-)
diff --git a/apps/netutils/webserver/Kconfig b/apps/netutils/webserver/Kconfig
index 78b0ff12ca..edca8dfdd2 100644
--- a/apps/netutils/webserver/Kconfig
+++ b/apps/netutils/webserver/Kconfig
@@ -6,6 +6,7 @@
config NETUTILS_WEBSERVER
bool "uIP web server"
default n
+ depends on NET_TCP
---help---
Enable support for the uIP web server. This tiny web server was
from uIP 1.0, but has undergone many changes. It is, however,
@@ -74,10 +75,11 @@ config NETUTILS_HTTPD_SERVERHEADER_DISABLE
config NETUTILS_HTTPD_TIMEOUT
int "Receive Timeout (sec)"
default 0
+ depends on NET_SOCKOPTS
---help---
Receive timeout setting (in seconds). A timeout value of zero
disables the timeout. An HTTP 408 error is generated if the timeout
- expires.
+ expires. This option depends on support for socket options (sockopts).
choice
prompt "File Transfer Method"
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index 7ad830d890..42110fd794 100644
--- a/nuttx/ChangeLog
+++ b/nuttx/ChangeLog
@@ -3377,3 +3377,12 @@
commands used in the build (Contributed by Richard Cochran).
* drivers/net/enc28j60.c: The ENC28J60 Ethernet driver is
now functional.
+ * configs/fire-stm32v2: Add support or the fire-stm32v3 board as
+ well (untested because I do not have a v3 board).
+ * lib/stdio/lib_sscanf.c: Add %n psuedo-format (from Kate).
+ * lib/stdio/lib_sscanf.c: There is an issue of handling input
+ when (1) no fieldwidth is provided and (2) there is no space
+ seperating the input values. No solutions is in place for this
+ 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).
diff --git a/nuttx/Documentation/NuttX.html b/nuttx/Documentation/NuttX.html
index 6b120f4e23..b51b5e7b32 100644
--- a/nuttx/Documentation/NuttX.html
+++ b/nuttx/Documentation/NuttX.html
@@ -1753,7 +1753,7 @@
STM32F103VCT chip. Contributed by Laurent Latil.
- This M3 Wildfire development board (STM32F103VET6), version 2.
+ The M3 Wildfire development board (STM32F103VET6), version 2.
See http://firestm32.taobao.com (the current board is version 3).
@@ -1787,7 +1787,9 @@
Support for the Wildfire board was included in version 6.22 of NuttX.
The board port is basically functional.
Not all features have been verified.
- The ENC28J60 network is not yet functional.
+ Support for FAT file system on an an SD card had been verified.
+ The ENC28J60 network is functional (but required lifting the chip select pin on the W25x16 part).
+ Customizations for the v3 version of the Wildfire board a selectable (but untested).
diff --git a/nuttx/configs/Kconfig b/nuttx/configs/Kconfig
index 12cc41ea72..752a5b0983 100644
--- a/nuttx/configs/Kconfig
+++ b/nuttx/configs/Kconfig
@@ -130,8 +130,8 @@ config ARCH_BOARD_EZ80F910200ZCO
development kit, eZ80F091 part, and the Zilog ZDS-II Windows command line
tools. The development environment is Cygwin under WinXP.
-config ARCH_BOARD_FIRE_STM32V2
- bool "M3 Wildfire STM32v2 board"
+config ARCH_BOARD_FIRE_STM32
+ bool "M3 Wildfire STM3 board (v2 or v3)"
depends on ARCH_CHIP_STM32F103VET6
select ARCH_HAVE_LEDS
select ARCH_HAVE_BUTTONS
@@ -607,7 +607,7 @@ config ARCH_BOARD
default "ekk-lm3s9b96" if ARCH_BOARD_EKK_LM3S9B96
default "ez80f0910200kitg" if ARCH_BOARD_EZ80F910200KITG
default "ez80f0910200zco" if ARCH_BOARD_EZ80F910200ZCO
- default "fire-stm32v2" if ARCH_BOARD_FIRE_STM32V2
+ default "fire-stm32v2" if ARCH_BOARD_FIRE_STM32
default "hymini-stm32v" if ARCH_BOARD_HYMINI_STM32V
default "kwikstik-k40" if ARCH_BOARD_KWIKSTIK_K40
default "lincoln60" if ARCH_BOARD_LINCOLN60
@@ -747,7 +747,7 @@ endif
if ARCH_BOARD_EZ80F910200ZCO
source "configs/ez80f910200zco/Kconfig"
endif
-if ARCH_BOARD_FIRE_STM32V2
+if ARCH_BOARD_FIRE_STM32
source "configs/fire-stm32v2/Kconfig"
endif
if ARCH_BOARD_HYMINI_STM32V
diff --git a/nuttx/configs/README.txt b/nuttx/configs/README.txt
index b5ada6ee5d..5bbec874f7 100644
--- a/nuttx/configs/README.txt
+++ b/nuttx/configs/README.txt
@@ -1570,7 +1570,8 @@ configs/ez80f0910200zco
configs/fire-stm32v2
A configuration for the M3 Wildfire STM32 board. This board is based on the
- STM32F103VET6 chip. See http://firestm32.taobao.com
+ STM32F103VET6 chip. See http://firestm32.taobao.com . Version 2 and 3 of
+ the boards are supported but only version 2 has been tested.
configs/hymini-stm32v
A configuration for the HY-Mini STM32v board. This board is based on the
diff --git a/nuttx/configs/fire-stm32v2/Kconfig b/nuttx/configs/fire-stm32v2/Kconfig
index 3f4b857dad..4249a3dbde 100644
--- a/nuttx/configs/fire-stm32v2/Kconfig
+++ b/nuttx/configs/fire-stm32v2/Kconfig
@@ -4,3 +4,25 @@
#
comment "M3 Wildfire Configuration"
+
+if ARCH_BOARD_FIRE_STM32
+
+choice
+ prompt "Select Wildfire STM32 version"
+ default ARCH_BOARD_FIRE_STM32V2
+ ---help---
+ This port has logic differences to support either the Version 2 or
+ Version 3 of the Wildfire board.
+
+config ARCH_BOARD_FIRE_STM32V2
+ bool "Wildfire STM32v2"
+ ---help---
+ Selects the M3 Wildfire version 2.
+
+config ARCH_BOARD_FIRE_STM32V3
+ bool "Wildfire STM32v3"
+ ---help---
+ Selects the M3 Wildfire version 3.
+
+endchoice
+endif
diff --git a/nuttx/configs/fire-stm32v2/README.txt b/nuttx/configs/fire-stm32v2/README.txt
index d9a4d14cad..6382a7363e 100644
--- a/nuttx/configs/fire-stm32v2/README.txt
+++ b/nuttx/configs/fire-stm32v2/README.txt
@@ -4,6 +4,10 @@ README
This README discusses issues unique to NuttX configurations for the M3
Wildfire development board (STM32F103VET6). See http://firestm32.taobao.com
+This configuration should support both the version 2 and version 3 of the
+Wildfire board (using NuttX configuration options). However, only version 2
+has been verified.
+
Contents
========
@@ -27,8 +31,10 @@ PIN NAME SIGNAL NOTES
1 PE2 PE2-C-RCLK Camera (P9)
2 PE3 PE3-USB-M USB2.0
-3 PE4 PE4-BEEP LS1 Bell
-4 PE5 (no name) 10Mbps ENC28J60 Interrupt
+3 PE4 PE4-BEEP LS1 Bell (v2)
+ PE4 10Mbps ENC28J60 Interrupt (v3)
+4 PE5 (no name) 10Mbps ENC28J60 Interrupt (v2)
+ PE5 KEY1, Low when closed (pulled high if open) (v3)
5 PE6
6 VBAT BT1 Battery (BT1)
7 PC13 Header 7X2
@@ -64,7 +70,8 @@ PIN NAME SIGNAL NOTES
32 PA7 PA7-SPI1-MOSI 2.4" TFT + Touchscreen, 10Mbit ENC28J60, SPI 2M FLASH
33 PC4 PC4-LED2 LED2, Active low (pulled high)
34 PC5 PC5-LED3 LED3, Active low (pulled high)
-35 PB0 PB0-KEY1 KEY1, Low when closed (pulled high if open)
+35 PB0 PB0-KEY1 KEY1, Low when closed (pulled high if open) (v2)
+ PB0 Header P5 (v3)
36 PB1 PB1-KEY2 KEY2, Low when closed (pulled high if open)
37 PB2 BOOT1/DGND
38 PE7 PE7-FSMC_D4 2.4" TFT + Touchscreen
@@ -525,7 +532,8 @@ M3 Wildfire-specific Configuration Options
CONFIG_ARCH_BOARD_name - For use in C code
- CONFIG_ARCH_BOARD_FIRE_STM32V2=y
+ CONFIG_ARCH_BOARD_FIRE_STM32V2=y (Version 2)
+ CONFIG_ARCH_BOARD_FIRE_STM32V3=y (Version 3)
CONFIG_ARCH_LOOPSPERMSEC - Must be calibrated for correct operation
of delay loops
diff --git a/nuttx/configs/fire-stm32v2/nsh/defconfig b/nuttx/configs/fire-stm32v2/nsh/defconfig
index fd51878010..0802af3c94 100644
--- a/nuttx/configs/fire-stm32v2/nsh/defconfig
+++ b/nuttx/configs/fire-stm32v2/nsh/defconfig
@@ -150,6 +150,7 @@ CONFIG_STM32_USART2=y
CONFIG_STM32_USB=y
# CONFIG_STM32_WWDG is not set
CONFIG_STM32_SPI=y
+CONFIG_STM32_I2C=y
#
# Alternate Pin Mapping
@@ -171,6 +172,15 @@ CONFIG_STM32_JTAG_FULL_ENABLE=y
# CONFIG_STM32_SPI_INTERRUPTS is not set
# CONFIG_STM32_SPI_DMA is not set
+#
+# I2C Configuration
+#
+# CONFIG_STM32_I2C_DYNTIMEO is not set
+CONFIG_STM32_I2CTIMEOSEC=0
+CONFIG_STM32_I2CTIMEOMS=500
+CONFIG_STM32_I2CTIMEOTICKS=500
+# CONFIG_STM32_I2C_DUTY16_9 is not set
+
#
# SDIO Configuration
#
@@ -215,7 +225,7 @@ CONFIG_BOOT_RUNFROMFLASH=y
#
# Board Selection
#
-CONFIG_ARCH_BOARD_FIRE_STM32V2=y
+CONFIG_ARCH_BOARD_FIRE_STM32=y
# CONFIG_ARCH_BOARD_CUSTOM is not set
CONFIG_ARCH_BOARD="fire-stm32v2"
@@ -238,6 +248,8 @@ CONFIG_NSH_MMCSDSPIPORTNO=0
#
# M3 Wildfire Configuration
#
+CONFIG_ARCH_BOARD_FIRE_STM32V2=y
+# CONFIG_ARCH_BOARD_FIRE_STM32V3 is not set
#
# RTOS Features
@@ -316,6 +328,8 @@ CONFIG_I2C_TRANSFER=y
# CONFIG_I2C_WRITEREAD is not set
CONFIG_I2C_POLLED=y
# CONFIG_I2C_TRACE is not set
+CONFIG_ARCH_HAVE_I2CRESET=y
+# CONFIG_I2C_RESET is not set
CONFIG_SPI=y
# CONFIG_SPI_OWNBUS is not set
CONFIG_SPI_EXCHANGE=y
@@ -348,6 +362,7 @@ CONFIG_ENC28J60_SPIMODE=0
CONFIG_ENC28J60_FREQUENCY=20000000
# CONFIG_ENC28J60_STATS is not set
# CONFIG_ENC28J60_HALFDUPPLEX is not set
+# CONFIG_ENC28J60_DUMPPACKET is not set
# CONFIG_NET_E1000 is not set
# CONFIG_NET_SLIP is not set
# CONFIG_NET_VNET is not set
diff --git a/nuttx/configs/fire-stm32v2/src/fire-internal.h b/nuttx/configs/fire-stm32v2/src/fire-internal.h
index e9f7a85089..7ab78a08fe 100644
--- a/nuttx/configs/fire-stm32v2/src/fire-internal.h
+++ b/nuttx/configs/fire-stm32v2/src/fire-internal.h
@@ -166,7 +166,8 @@
* PIN NAME SIGNAL NOTES
* --- ------ -------------- -------------------------------------------------------------------
*
- * 35 PB0 PB0-KEY1 KEY1, Low when closed (pulled high if open)
+ * 35 PB0 PB0-KEY1 KEY1, Low when closed (pulled high if open) (v2)
+ * 35 PE5 PB0 KEY1, Low when closed (pulled high if open) (v3)
* 36 PB1 PB1-KEY2 KEY2, Low when closed (pulled high if open)
*/
@@ -174,8 +175,13 @@
#define MAX_IRQBUTTON BUTTON_KEY2
#define NUM_IRQBUTTONS (MAX_IRQBUTTON - MIN_IRQBUTTON + 1)
-#define GPIO_BTN_KEY1 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
+#ifdef CONFIG_ARCH_BOARD_FIRE_STM32V3
+# define GPIO_BTN_KEY1 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
+ GPIO_EXTI|GPIO_PORTE|GPIO_PIN5)
+#else
+# define GPIO_BTN_KEY1 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
GPIO_EXTI|GPIO_PORTB|GPIO_PIN0)
+#endif
#define GPIO_BTN_KEY2 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
GPIO_EXTI|GPIO_PORTB|GPIO_PIN1)
@@ -207,7 +213,8 @@
* 31 PA6 PA6-SPI1-MISO 2.4" TFT + Touchscreen, 10Mbit ENC28J60, SPI 2M FLASH
* 32 PA7 PA7-SPI1-MOSI 2.4" TFT + Touchscreen, 10Mbit ENC28J60, SPI 2M FLASH
* 98 PE1 PE1-FSMC_NBL1 2.4" TFT + Touchscreen, 10Mbit EN28J60 Reset
- * 4 PE5 (no name) 10Mbps ENC28J60 Interrupt
+ * 4 PE5 (no name) 10Mbps ENC28J60 Interrupt (v2)
+ * 4 PE4 PE4 10Mbps ENC28J60 Interrupt (v3)
*/
#if defined(CONFIG_STM32_FSMC) && defined(CONFIG_ENC28J60)
@@ -224,9 +231,14 @@
GPIO_OUTPUT_SET|GPIO_PORTA|GPIO_PIN4)
# define GPIO_ENC28J60_RESET (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\
GPIO_OUTPUT_CLEAR|GPIO_PORTE|GPIO_PIN1)
+#ifdef CONFIG_ARCH_BOARD_FIRE_STM32V3
+# define GPIO_ENC28J60_INTR (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
+ GPIO_EXTI|GPIO_PORTE|GPIO_PIN4)
+#else /* CONFIG_ARCH_BOARD_FIRE_STM32V2 */
# define GPIO_ENC28J60_INTR (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
GPIO_EXTI|GPIO_PORTE|GPIO_PIN5)
#endif
+#endif
/* MP3
*
diff --git a/nuttx/lib/stdio/lib_sscanf.c b/nuttx/lib/stdio/lib_sscanf.c
index 01c96c21dd..11b5f387e8 100644
--- a/nuttx/lib/stdio/lib_sscanf.c
+++ b/nuttx/lib/stdio/lib_sscanf.c
@@ -1,7 +1,7 @@
/****************************************************************************
* lib/stdio/lib_sscanf.c
*
- * Copyright (C) 2007, 2008, 2011 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007, 2008, 2011-2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
*
* Redistribution and use in source and binary forms, with or without
@@ -63,7 +63,7 @@
* Global Function Prototypes
****************************************************************************/
-int vsscanf(char *buf, const char *s, va_list ap);
+int vsscanf(char *buf, const char *fmt, va_list ap);
/**************************************************************************
* Global Constant Data
@@ -109,67 +109,81 @@ int sscanf(FAR const char *buf, FAR const char *fmt, ...)
* ANSI standard vsscanf implementation.
*
****************************************************************************/
-int vsscanf(FAR char *buf, FAR const char *s, va_list ap)
+
+int vsscanf(FAR char *buf, FAR const char *fmt, va_list ap)
{
+ FAR char *bufstart;
+ FAR char *tv;
+ FAR const char *tc;
int count;
int noassign;
int width;
int base = 10;
int lflag;
- FAR char *tv;
- FAR const char *tc;
char tmp[MAXLN];
- lvdbg("vsscanf: buf=\"%s\" fmt=\"%s\"\n", buf, s);
+ lvdbg("vsscanf: buf=\"%s\" fmt=\"%s\"\n", buf, fmt);
- count = noassign = width = lflag = 0;
- while (*s && *buf)
+ /* Remember the start of the input buffer. We will need this for %n
+ * calculations.
+ */
+
+ bufstart = buf;
+
+ /* Parse the format, extracting values from the input buffer as needed */
+
+ count = 0;
+ noassign = 0;
+ width = 0;
+ lflag = 0;
+
+ while (*fmt && *buf)
{
/* Skip over white space */
- while (isspace(*s))
+ while (isspace(*fmt))
{
- s++;
+ fmt++;
}
/* Check for a conversion specifier */
- if (*s == '%')
+ if (*fmt == '%')
{
lvdbg("vsscanf: Specifier found\n");
/* Check for qualifiers on the conversion specifier */
- s++;
- for (; *s; s++)
+ fmt++;
+ for (; *fmt; fmt++)
{
- lvdbg("vsscanf: Processing %c\n", *s);
+ lvdbg("vsscanf: Processing %c\n", *fmt);
- if (strchr("dibouxcsefg%", *s))
+ if (strchr("dibouxcsefgn%", *fmt))
{
break;
}
- if (*s == '*')
+ if (*fmt == '*')
{
noassign = 1;
}
- else if (*s == 'l' || *s == 'L')
+ else if (*fmt == 'l' || *fmt == 'L')
{
lflag = 1;
}
- else if (*s >= '1' && *s <= '9')
+ else if (*fmt >= '1' && *fmt <= '9')
{
- for (tc = s; isdigit(*s); s++);
- strncpy(tmp, tc, s - tc);
- tmp[s - tc] = '\0';
+ for (tc = fmt; isdigit(*fmt); fmt++);
+ strncpy(tmp, tc, fmt - tc);
+ tmp[fmt - tc] = '\0';
width = atoi(tmp);
- s--;
+ fmt--;
}
}
/* Process %s: String conversion */
- if (*s == 's')
+ if (*fmt == 's')
{
lvdbg("vsscanf: Performing string conversion\n");
@@ -178,9 +192,26 @@ int vsscanf(FAR char *buf, FAR const char *s, va_list ap)
buf++;
}
+ /* Was a fieldwidth specified? */
+
if (!width)
{
- width = strcspn(buf, spaces);
+ /* No... is there a space after the format? */
+
+#if 0 /* Needs more thought */
+ if (isspace(*(s + 1)) || *(s + 1) == 0)
+#endif
+ {
+ /* Use the input up until the first white space is
+ * encountered. NOTE: This means that values on the
+ * input line must be separated by whitespace or they
+ * will get combined! This is a bug. We have no good
+ * way of determining the width of the data if there
+ * is no field with and no space separating the input.
+ */
+
+ width = strcspn(buf, spaces);
+ }
}
if (!noassign)
@@ -189,17 +220,22 @@ int vsscanf(FAR char *buf, FAR const char *s, va_list ap)
strncpy(tv, buf, width);
tv[width] = '\0';
}
+
buf += width;
}
/* Process %c: Character conversion */
- else if (*s == 'c')
+ else if (*fmt == 'c')
{
lvdbg("vsscanf: Performing character conversion\n");
+ /* Was a fieldwidth specified? */
+
if (!width)
{
+ /* No, then width is this one single character */
+
width = 1;
}
@@ -209,12 +245,13 @@ int vsscanf(FAR char *buf, FAR const char *s, va_list ap)
strncpy(tv, buf, width);
tv[width] = '\0';
}
+
buf += width;
}
/* Process %d, %o, %b, %x, %u: Various integer conversions */
- else if (strchr("dobxu", *s))
+ else if (strchr("dobxu", *fmt))
{
lvdbg("vsscanf: Performing integer conversion\n");
@@ -229,37 +266,47 @@ int vsscanf(FAR char *buf, FAR const char *s, va_list ap)
* conversion specification.
*/
- if (*s == 'd' || *s == 'u')
+ if (*fmt == 'd' || *fmt == 'u')
{
base = 10;
}
- else if (*s == 'x')
+ else if (*fmt == 'x')
{
base = 16;
}
- else if (*s == 'o')
+ else if (*fmt == 'o')
{
base = 8;
}
- else if (*s == 'b')
+ else if (*fmt == 'b')
{
base = 2;
}
- /* Copy the integer string into a temporary working buffer. */
+ /* Was a fieldwidth specified? */
if (!width)
{
+ /* No... is there a space after the format? */
+
+#if 0 /* Needs more thought */
if (isspace(*(s + 1)) || *(s + 1) == 0)
+#endif
{
+ /* Use the input up until the first white space is
+ * encountered. NOTE: This means that values on the
+ * input line must be separated by whitespace or they
+ * will get combined! This is a bug. We have no good
+ * way of determining the width of the data if there
+ * is no field with and no space separating the input.
+ */
+
width = strcspn(buf, spaces);
}
- else
- {
- width = strchr(buf, *(s + 1)) - buf;
- }
}
+ /* Copy the numeric string into a temporary working buffer. */
+
strncpy(tmp, buf, width);
tmp[width] = '\0';
@@ -284,7 +331,7 @@ int vsscanf(FAR char *buf, FAR const char *s, va_list ap)
/* Process %f: Floating point conversion */
- else if (*s == 'f')
+ else if (*fmt == 'f')
{
#ifndef CONFIG_LIBC_FLOATINGPOINT
/* No floating point conversions */
@@ -303,20 +350,30 @@ int vsscanf(FAR char *buf, FAR const char *s, va_list ap)
buf++;
}
- /* Copy the real string into a temporary working buffer. */
+ /* Was a fieldwidth specified? */
if (!width)
{
+ /* No... is there a space after the format? */
+
+#if 0 /* Needs more thought */
if (isspace(*(s + 1)) || *(s + 1) == 0)
+#endif
{
- width = strcspn(buf, spaces);
- }
- else
- {
- width = strchr(buf, *(s + 1)) - buf;
+ /* Use the input up until the first white space is
+ * encountered. NOTE: This means that values on the
+ * input line must be separated by whitespace or they
+ * will get combined! This is a bug. We have no good
+ * way of determining the width of the data if there
+ * is no field with and no space separating the input.
+ */
+
+ width = strcspn(buf, spaces);
}
}
+ /* Copy the real string into a temporary working buffer. */
+
strncpy(tmp, buf, width);
tmp[width] = '\0';
buf += width;
@@ -356,13 +413,28 @@ int vsscanf(FAR char *buf, FAR const char *s, va_list ap)
#endif
}
- if (!noassign)
+ /* Process %n: Character count */
+
+ else if (*fmt == 'n')
+ {
+ lvdbg("vsscanf: Performing character count\n");
+
+ if (!noassign)
+ {
+ int *pint = va_arg(ap, int*);
+ *pint = (int)(buf - bufstart) - 1;
+ }
+ }
+
+ /* Note %n does not count as a conversion */
+
+ if (!noassign && *fmt != 'n')
{
count++;
}
width = noassign = lflag = 0;
- s++;
+ fmt++;
}
/* Its is not a conversion specifier */
@@ -374,13 +446,13 @@ int vsscanf(FAR char *buf, FAR const char *s, va_list ap)
buf++;
}
- if (*s != *buf)
+ if (*fmt != *buf)
{
break;
}
else
{
- s++;
+ fmt++;
buf++;
}
}
From 99bc5e453b0145f39528d73bae18fc5e6743cda4 Mon Sep 17 00:00:00 2001
From: patacongo
Date: Fri, 21 Sep 2012 17:34:13 +0000
Subject: [PATCH 03/31] One more sscanf change
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5169 42af7a65-404d-4744-a932-0658087f49c3
---
nuttx/lib/stdio/lib_sscanf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/nuttx/lib/stdio/lib_sscanf.c b/nuttx/lib/stdio/lib_sscanf.c
index 11b5f387e8..a744c51d38 100644
--- a/nuttx/lib/stdio/lib_sscanf.c
+++ b/nuttx/lib/stdio/lib_sscanf.c
@@ -422,7 +422,7 @@ int vsscanf(FAR char *buf, FAR const char *fmt, va_list ap)
if (!noassign)
{
int *pint = va_arg(ap, int*);
- *pint = (int)(buf - bufstart) - 1;
+ *pint = (int)(buf - bufstart);
}
}
From e8f1a8bff986a170bb03cd2f10bb08d90dab35f0 Mon Sep 17 00:00:00 2001
From: patacongo
Date: Fri, 21 Sep 2012 17:55:08 +0000
Subject: [PATCH 04/31] Recent I2C changes for F4 broke F1
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5170 42af7a65-404d-4744-a932-0658087f49c3
---
nuttx/arch/arm/src/stm32/stm32_i2c.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/nuttx/arch/arm/src/stm32/stm32_i2c.c b/nuttx/arch/arm/src/stm32/stm32_i2c.c
index 12a036f806..c44a823dbb 100644
--- a/nuttx/arch/arm/src/stm32/stm32_i2c.c
+++ b/nuttx/arch/arm/src/stm32/stm32_i2c.c
@@ -1574,13 +1574,14 @@ static int stm32_i2c_process(FAR struct i2c_dev_s *dev, FAR struct i2c_msg_s *ms
struct stm32_i2c_inst_s *inst = (struct stm32_i2c_inst_s *)dev;
FAR struct stm32_i2c_priv_s *priv = inst->priv;
uint32_t status = 0;
+ uint32_t ahbenr;
int errval = 0;
ASSERT(count);
/* Disable FSMC that shares a pin with I2C1 (LBAR) */
- (void)stm32_i2c_disablefsmc(priv);
+ ahbenr = stm32_i2c_disablefsmc(priv);
/* Wait for any STOP in progress. NOTE: If we have to disable the FSMC
* then we cannot do this at the top of the loop, unfortunately. The STOP
From 4a5f639e222c25405bbe0c381d7aa0880029761a Mon Sep 17 00:00:00 2001
From: patacongo
Date: Fri, 21 Sep 2012 18:51:04 +0000
Subject: [PATCH 05/31] Fix bug in last sscanf change
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5171 42af7a65-404d-4744-a932-0658087f49c3
---
nuttx/lib/stdio/lib_sscanf.c | 109 ++++++++++++++++++++---------------
1 file changed, 64 insertions(+), 45 deletions(-)
diff --git a/nuttx/lib/stdio/lib_sscanf.c b/nuttx/lib/stdio/lib_sscanf.c
index a744c51d38..032164ba1e 100644
--- a/nuttx/lib/stdio/lib_sscanf.c
+++ b/nuttx/lib/stdio/lib_sscanf.c
@@ -79,6 +79,64 @@ int vsscanf(char *buf, const char *fmt, va_list ap);
static const char spaces[] = " \t\n\r\f\v";
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Function: findwidth
+ *
+ * Description:
+ * Try to figure out the width of the input data.
+ *
+ ****************************************************************************/
+
+static int findwidth(FAR const char *buf, FAR const char *fmt)
+{
+ FAR const char *next = fmt + 1;
+
+ /* No... is there a space after the format? Or does the format string end
+ * here?
+ */
+
+ if (isspace(*next) || *next == 0)
+ {
+ /* Use the input up until the first white space is encountered. */
+
+ return strcspn(buf, spaces);
+ }
+
+ /* No.. Another possibility is the the format character is followed by
+ * some recognizable delimiting value.
+ */
+
+ if (*next != '%')
+ {
+ /* If so we will say that the string ends there if we can find that
+ * delimiter in the input string.
+ */
+
+ FAR const char *ptr = strchr(buf, *next);
+ if (ptr)
+ {
+ return (int)(ptr - buf);
+ }
+ }
+
+ /* No... the format has not delimiter and is back-to-back with the next
+ * formats (or no is following by a delimiter that does not exist in the
+ * input string). At this point we just bail and Use the input up until
+ * the first white space is encountered.
+ *
+ * NOTE: This means that values from the following format may be
+ * concatenated with the first. This is a bug. We have no generic way of
+ * determining the width of the data if there is no fieldwith, no space
+ * separating the input, and no usable delimiter character.
+ */
+
+ return strcspn(buf, spaces);
+}
+
/****************************************************************************
* Private Variables
****************************************************************************/
@@ -196,22 +254,9 @@ int vsscanf(FAR char *buf, FAR const char *fmt, va_list ap)
if (!width)
{
- /* No... is there a space after the format? */
+ /* No... Guess a field width using some heuristics */
-#if 0 /* Needs more thought */
- if (isspace(*(s + 1)) || *(s + 1) == 0)
-#endif
- {
- /* Use the input up until the first white space is
- * encountered. NOTE: This means that values on the
- * input line must be separated by whitespace or they
- * will get combined! This is a bug. We have no good
- * way of determining the width of the data if there
- * is no field with and no space separating the input.
- */
-
- width = strcspn(buf, spaces);
- }
+ width = findwidth(buf, fmt);
}
if (!noassign)
@@ -287,22 +332,9 @@ int vsscanf(FAR char *buf, FAR const char *fmt, va_list ap)
if (!width)
{
- /* No... is there a space after the format? */
+ /* No... Guess a field width using some heuristics */
-#if 0 /* Needs more thought */
- if (isspace(*(s + 1)) || *(s + 1) == 0)
-#endif
- {
- /* Use the input up until the first white space is
- * encountered. NOTE: This means that values on the
- * input line must be separated by whitespace or they
- * will get combined! This is a bug. We have no good
- * way of determining the width of the data if there
- * is no field with and no space separating the input.
- */
-
- width = strcspn(buf, spaces);
- }
+ width = findwidth(buf, fmt);
}
/* Copy the numeric string into a temporary working buffer. */
@@ -354,22 +386,9 @@ int vsscanf(FAR char *buf, FAR const char *fmt, va_list ap)
if (!width)
{
- /* No... is there a space after the format? */
+ /* No... Guess a field width using some heuristics */
-#if 0 /* Needs more thought */
- if (isspace(*(s + 1)) || *(s + 1) == 0)
-#endif
- {
- /* Use the input up until the first white space is
- * encountered. NOTE: This means that values on the
- * input line must be separated by whitespace or they
- * will get combined! This is a bug. We have no good
- * way of determining the width of the data if there
- * is no field with and no space separating the input.
- */
-
- width = strcspn(buf, spaces);
- }
+ width = findwidth(buf, fmt);
}
/* Copy the real string into a temporary working buffer. */
From 6052cd078a07e5f3c4f7481537f2b17c48d32d98 Mon Sep 17 00:00:00 2001
From: patacongo
Date: Fri, 21 Sep 2012 22:05:41 +0000
Subject: [PATCH 06/31] More sscanf: Long flag (as in %ld) not be used in all
of the places it should be
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5172 42af7a65-404d-4744-a932-0658087f49c3
---
nuttx/lib/stdio/lib_sscanf.c | 54 ++++++++++++++++++++++++++----------
1 file changed, 40 insertions(+), 14 deletions(-)
diff --git a/nuttx/lib/stdio/lib_sscanf.c b/nuttx/lib/stdio/lib_sscanf.c
index 032164ba1e..7e1fae276d 100644
--- a/nuttx/lib/stdio/lib_sscanf.c
+++ b/nuttx/lib/stdio/lib_sscanf.c
@@ -38,9 +38,11 @@
****************************************************************************/
#include
+
#include
#include
#include
+#include
#include
#include
#include
@@ -173,11 +175,11 @@ int vsscanf(FAR char *buf, FAR const char *fmt, va_list ap)
FAR char *bufstart;
FAR char *tv;
FAR const char *tc;
+ bool lflag;
+ bool noassign;
int count;
- int noassign;
int width;
int base = 10;
- int lflag;
char tmp[MAXLN];
lvdbg("vsscanf: buf=\"%s\" fmt=\"%s\"\n", buf, fmt);
@@ -191,9 +193,9 @@ int vsscanf(FAR char *buf, FAR const char *fmt, va_list ap)
/* Parse the format, extracting values from the input buffer as needed */
count = 0;
- noassign = 0;
width = 0;
- lflag = 0;
+ noassign = false;
+ lflag = false;
while (*fmt && *buf)
{
@@ -223,11 +225,13 @@ int vsscanf(FAR char *buf, FAR const char *fmt, va_list ap)
if (*fmt == '*')
{
- noassign = 1;
+ noassign = true;
}
else if (*fmt == 'l' || *fmt == 'L')
{
- lflag = 1;
+ /* NOTE: Missing check for long long ('ll') */
+
+ lflag = true;
}
else if (*fmt >= '1' && *fmt <= '9')
{
@@ -349,15 +353,24 @@ int vsscanf(FAR char *buf, FAR const char *fmt, va_list ap)
buf += width;
if (!noassign)
{
- int *pint = va_arg(ap, int*);
#ifdef SDCC
char *endptr;
- int tmpint = strtol(tmp, &endptr, base);
+ long tmplong = strtol(tmp, &endptr, base);
#else
- int tmpint = strtol(tmp, NULL, base);
+ long tmplong = strtol(tmp, NULL, base);
#endif
- lvdbg("vsscanf: Return %d to 0x%p\n", tmpint, pint);
- *pint = tmpint;
+ if (lflag)
+ {
+ long *plong = va_arg(ap, long*);
+ lvdbg("vsscanf: Return %ld to 0x%p\n", tmplong, plong);
+ *plong = tmplong;
+ }
+ else
+ {
+ int *pint = va_arg(ap, int*);
+ lvdbg("vsscanf: Return %ld to 0x%p\n", tmplong, pint);
+ *pint = (int)tmplong;
+ }
}
}
@@ -440,8 +453,18 @@ int vsscanf(FAR char *buf, FAR const char *fmt, va_list ap)
if (!noassign)
{
- int *pint = va_arg(ap, int*);
- *pint = (int)(buf - bufstart);
+ size_t nchars = (size_t)(buf - bufstart);
+
+ if (lflag)
+ {
+ long *plong = va_arg(ap, long*);
+ *plong = (long)nchars;
+ }
+ else
+ {
+ int *pint = va_arg(ap, int*);
+ *pint = (int)nchars;
+ }
}
}
@@ -452,7 +475,10 @@ int vsscanf(FAR char *buf, FAR const char *fmt, va_list ap)
count++;
}
- width = noassign = lflag = 0;
+ width = 0;
+ noassign = false;
+ lflag = false;
+
fmt++;
}
From 1b7786e0e26cadbad49812f5fd97650e18cd7378 Mon Sep 17 00:00:00 2001
From: patacongo
Date: Sat, 22 Sep 2012 12:23:35 +0000
Subject: [PATCH 07/31] More webserver updates from Kate
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5173 42af7a65-404d-4744-a932-0658087f49c3
---
apps/ChangeLog.txt | 2 +
apps/netutils/webserver/httpd.c | 221 ++++++++++++++++++++++++--------
2 files changed, 167 insertions(+), 56 deletions(-)
diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt
index e098099155..c5b8dec92d 100644
--- a/apps/ChangeLog.txt
+++ b/apps/ChangeLog.txt
@@ -336,3 +336,5 @@
can now be used to limit the server to a single thread. Option
CONFIG_NETUTILS_HTTPD_TIMEOUT can be used to generate HTTP 408 errors.
Both from Kate.
+ * apps/netutils/webserver/httpd.c: Improvements to HTTP parser from
+ Kate.
diff --git a/apps/netutils/webserver/httpd.c b/apps/netutils/webserver/httpd.c
index 29438c77af..ebcf300b68 100644
--- a/apps/netutils/webserver/httpd.c
+++ b/apps/netutils/webserver/httpd.c
@@ -118,8 +118,6 @@
* Private Data
****************************************************************************/
-static const char g_httpcmdget[] = "GET ";
-
/****************************************************************************
* Private Functions
****************************************************************************/
@@ -179,7 +177,7 @@ static void httpd_dumpbuffer(FAR const char *msg, FAR const char *buffer, unsign
/* CONFIG_DEBUG, CONFIG_DEBUG_VERBOSE, and CONFIG_DEBUG_NET have to be
* defined or the following does nothing.
*/
-
+
nvdbgdumpbuffer(msg, (FAR const uint8_t*)buffer, nbytes);
}
#else
@@ -194,8 +192,10 @@ static void httpd_dumppstate(struct httpd_state *pstate, const char *msg)
nvdbg(" filename: [%s]\n", pstate->ht_filename);
nvdbg(" htfile len: %d\n", pstate->ht_file.len);
nvdbg(" sockfd: %d\n", pstate->ht_sockfd);
+#ifndef CONFIG_NETUTILS_HTTPD_SCRIPT_DISABLE
nvdbg(" scriptptr: %p\n", pstate->ht_scriptptr);
nvdbg(" scriptlen: %d\n", pstate->ht_scriptlen);
+#endif
nvdbg(" sndlen: %d\n", pstate->ht_sndlen);
#endif
}
@@ -373,6 +373,11 @@ static int send_headers(struct httpd_state *pstate, int status, int len)
(void) snprintf(cl, sizeof cl, "Content-Length: %d\r\n", len);
}
+ if (status == 413)
+ {
+ /* TODO: here we "SHOULD" include a Retry-After header */
+ }
+
i = snprintf(s, sizeof s,
"HTTP/1.0 %d %s\r\n"
#ifndef CONFIG_NETUTILS_HTTPD_SERVERHEADER_DISABLE
@@ -498,73 +503,167 @@ done:
return ret;
}
-static inline int httpd_cmd(struct httpd_state *pstate)
+static inline int httpd_parse(struct httpd_state *pstate)
{
- ssize_t recvlen;
- int i;
+ char *o;
- /* Get the next HTTP command. We will handle only GET */
+ enum
+ {
+ STATE_METHOD,
+ STATE_HEADER,
+ STATE_BODY
+ } state;
+
+ state = STATE_METHOD;
+ o = pstate->ht_buffer;
+
+ do
+ {
+ char *start;
+ char *end;
+
+ if (o == pstate->ht_buffer + sizeof pstate->ht_buffer)
+ {
+ ndbg("[%d] ht_buffer overflow\n");
+ return 413;
+ }
+
+ {
+ ssize_t r;
+
+ r = recv(pstate->ht_sockfd, o,
+ sizeof pstate->ht_buffer - (o - pstate->ht_buffer), 0);
+ if (r == 0)
+ {
+ ndbg("[%d] connection lost\n", pstate->ht_sockfd);
+ return ERROR;
+ }
- recvlen = recv(pstate->ht_sockfd, pstate->ht_buffer, HTTPD_IOBUFFER_SIZE, 0);
#if CONFIG_NETUTILS_HTTPD_TIMEOUT > 0
- if (recvlen < 0 && errno == EWOULDBLOCK)
- {
- ndbg("[%d] recv timeout\n");
- return httpd_senderror(pstate, 408);
- }
- else
+ if (r == -1 && errno == EWOULDBLOCK)
+ {
+ ndbg("[%d] recv timeout\n");
+ return 408;
+ }
#endif
- if (recvlen < 0)
- {
- ndbg("[%d] recv failed: %d\n", pstate->ht_sockfd, errno);
- return httpd_senderror(pstate, 400);
- }
- else if (recvlen == 0)
- {
- ndbg("[%d] connection lost\n", pstate->ht_sockfd);
- return httpd_senderror(pstate, 400);
+ if (r == -1)
+ {
+ ndbg("[%d] recv failed: %d\n", pstate->ht_sockfd, errno);
+ return 400;
+ }
+
+ o += r;
+ }
+
+ /* Here o marks the end of the total block currently awaiting processing.
+ * There may be multiple lines in a block; next we deal with each in turn.
+ */
+
+ for (start = pstate->ht_buffer;
+ (end = memchr(start, '\r', o - start)), end != NULL;
+ start = end)
+ {
+ *end = '\0';
+ end++;
+
+ /* Here start and end are a single line within the current block */
+
+ httpd_dumpbuffer("Incoming HTTP line", start, end - start);
+
+ if (*end != '\n')
+ {
+ ndbg("[%d] expected CRLF\n");
+ return 400;
+ }
+
+ end++;
+
+ switch (state)
+ {
+ char *v;
+
+ case STATE_METHOD:
+ if (0 != strncmp(start, "GET ", 4))
+ {
+ ndbg("[%d] method not supported\n");
+ return 501;
+ }
+
+ start += 4;
+ v = start + strcspn(start, " ");
+
+ if (0 != strcmp(v, " HTTP/1.0") && 0 != strcmp(v, " HTTP/1.1"))
+ {
+ ndbg("[%d] HTTP/%d.%d not supported\n", major, minor);
+ return 505;
+ }
+
+ /* TODO: url decoding */
+
+ if (v - start >= sizeof pstate->ht_filename)
+ {
+ ndbg("[%d] ht_filename overflow\n");
+ return 414;
+ }
+
+ *v = '\0';
+ (void) strcpy(pstate->ht_filename, start);
+ state = STATE_HEADER;
+ break;
+
+ case STATE_HEADER:
+ if (*start == '\0')
+ {
+ state = STATE_BODY;
+ break;
+ }
+
+ v = start + strcspn(start, ":");
+ if (*v != '\0')
+ {
+ *v = '\0', v++;
+ v += strspn(v, ": ");
+ }
+
+ if (*start == '\0' || *v == '\0')
+ {
+ ndbg("[%d] header parse error\n");
+ return 400;
+ }
+
+ nvdbg("[%d] Request header %s: %s\n", pstate->ht_sockfd, start, v);
+
+ if (0 == strcasecmp(start, "Content-Length") && 0 != atoi(v))
+ {
+ ndbg("[%d] non-zero request length\n");
+ return 413;
+ }
+
+ break;
+
+ case STATE_BODY:
+ /* Not implemented */
+ break;
+ }
+ }
+
+ /* Shuffle down for the next block */
+
+ memmove(pstate->ht_buffer, start, o - start);
+ o -= start;
}
+ while (state != STATE_BODY);
- httpd_dumpbuffer("Incoming buffer", pstate->ht_buffer, recvlen);
-
- /* We will handle only GET */
-
- if (strncmp(pstate->ht_buffer, g_httpcmdget, strlen(g_httpcmdget)) != 0)
- {
- ndbg("[%d] Unsupported command\n", pstate->ht_sockfd);
- return httpd_senderror(pstate, 405);
- }
-
- /* Get the name of the file to provide */
-
- if (pstate->ht_buffer[4] != ISO_slash)
- {
- ndbg("[%d] Missing path\n", pstate->ht_sockfd);
- return httpd_senderror(pstate, 400);
- }
#if !defined(CONFIG_NETUTILS_HTTPD_SENDFILE) && !defined(CONFIG_NETUTILS_HTTPD_MMAP)
- else if (pstate->ht_buffer[5] == ISO_space)
+ if (0 == strcmp(pstate->ht_filename, "/")
{
strncpy(pstate->ht_filename, "/" CONFIG_NETUTILS_HTTPD_INDEX, strlen("/" CONFIG_NETUTILS_HTTPD_INDEX));
}
#endif
- else
- {
- for (i = 0;
- i < (HTTPD_MAX_FILENAME-1) && pstate->ht_buffer[i+4] != ISO_space;
- i++)
- {
- pstate->ht_filename[i] = pstate->ht_buffer[i+4];
- }
-
- pstate->ht_filename[i]='\0';
- }
nvdbg("[%d] Filename: %s\n", pstate->ht_sockfd, pstate->ht_filename);
- /* Then send the file */
-
- return httpd_sendfile(pstate);
+ return 200;
}
/****************************************************************************
@@ -589,6 +688,8 @@ static void *httpd_handler(void *arg)
if (pstate)
{
+ int status;
+
/* Re-initialize the thread state structure */
memset(pstate, 0, sizeof(struct httpd_state));
@@ -596,7 +697,15 @@ static void *httpd_handler(void *arg)
/* Then handle the next httpd command */
- ret = httpd_cmd(pstate);
+ status = httpd_parse(pstate);
+ if (status >= 400)
+ {
+ ret = httpd_senderror(pstate, status);
+ }
+ else
+ {
+ ret = httpd_sendfile(pstate);
+ }
/* End of command processing -- Clean up and exit */
From 4f381f2185dcf6f2e6d302538f82a9ccb5f1b106 Mon Sep 17 00:00:00 2001
From: patacongo
Date: Sat, 22 Sep 2012 14:06:47 +0000
Subject: [PATCH 08/31] Correct Shenzhou LED controls
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5174 42af7a65-404d-4744-a932-0658087f49c3
---
nuttx/configs/shenzhou/README.txt | 6 +-
nuttx/configs/shenzhou/nsh/defconfig | 119 ++++++++++--------
nuttx/configs/shenzhou/scripts/ld.script | 12 +-
nuttx/configs/shenzhou/scripts/ld.script.dfu | 12 +-
.../configs/shenzhou/src/shenzhou-internal.h | 8 +-
nuttx/configs/shenzhou/src/up_autoleds.c | 20 +--
6 files changed, 101 insertions(+), 76 deletions(-)
diff --git a/nuttx/configs/shenzhou/README.txt b/nuttx/configs/shenzhou/README.txt
index 9ee77ea06f..e68bd7bf9f 100644
--- a/nuttx/configs/shenzhou/README.txt
+++ b/nuttx/configs/shenzhou/README.txt
@@ -381,12 +381,12 @@ events as follows:
* If LED1, LED2, LED3 are statically on, then NuttX probably failed to boot
and these LEDs will give you some indication of where the failure was
- ** The normal state is LED3 ON and LED1 faintly glowing. This faint glow
+ ** The normal state is LED1 ON and LED1 faintly glowing. This faint glow
is because of timer interupts that result in the LED being illuminated
on a small proportion of the time.
*** LED2 may also flicker normally if signals are processed.
-**** LED4 may not be available if RS-485 is also used it will then indicate
- the RS-485 direction.
+**** LED4 may not be available if RS-485 is also used. For RS-485, it will
+ then indicate the RS-485 direction.
Shenzhou-specific Configuration Options
============================================
diff --git a/nuttx/configs/shenzhou/nsh/defconfig b/nuttx/configs/shenzhou/nsh/defconfig
index 0c18b129f2..70d9540db8 100644
--- a/nuttx/configs/shenzhou/nsh/defconfig
+++ b/nuttx/configs/shenzhou/nsh/defconfig
@@ -175,6 +175,7 @@ CONFIG_ARCH_BOARD_STM32_CUSTOM_CLOCKCONFIG=y
CONFIG_STM32_PHYADDR=1
CONFIG_STM32_MII=y
CONFIG_STM32_MII_MCO=y
+# CONFIG_STM32_MII_EXTCLK is not set
CONFIG_STM32_AUTONEG=y
CONFIG_STM32_PHYSR=16
CONFIG_STM32_PHYSR_SPEED=0x0002
@@ -200,7 +201,7 @@ CONFIG_ARCH_STACKDUMP=y
CONFIG_DRAM_START=0x20000000
CONFIG_DRAM_SIZE=65536
CONFIG_ARCH_HAVE_INTERRUPTSTACK=y
-# CONFIG_ARCH_INTERRUPTSTACK is not set
+CONFIG_ARCH_INTERRUPTSTACK=0
#
# Boot options
@@ -307,6 +308,7 @@ CONFIG_DEV_NULL=y
# CONFIG_CAN is not set
# CONFIG_PWM is not set
# CONFIG_I2C is not set
+CONFIG_ARCH_HAVE_I2CRESET=y
CONFIG_SPI=y
# CONFIG_SPI_OWNBUS is not set
CONFIG_SPI_EXCHANGE=y
@@ -468,142 +470,142 @@ CONFIG_NAMEDAPP=y
#
#
-# ADC example
+# ADC Example
#
# CONFIG_EXAMPLES_ADC is not set
#
-# Buttons example
+# Buttons Example
#
# CONFIG_EXAMPLES_BUTTONS is not set
#
-# CAN example
+# CAN Example
#
# CONFIG_EXAMPLES_CAN is not set
#
-# USB CDC/ACM class driver example
+# USB CDC/ACM Class Driver Example
#
# CONFIG_EXAMPLES_CDCACM is not set
#
-# USB composite class driver example
+# USB composite Class Driver Example
#
# CONFIG_EXAMPLES_COMPOSITE is not set
#
-# DHCP server example
+# DHCP Server Example
#
# CONFIG_EXAMPLES_DHCPD is not set
#
-# FTP client example
+# FTP Client Example
#
# CONFIG_EXAMPLES_FTPC is not set
#
-# FTP server example
+# FTP Server Example
#
# CONFIG_EXAMPLES_FTPD is not set
#
-# "Hello, World!" example
+# "Hello, World!" Example
#
# CONFIG_EXAMPLES_HELLO is not set
#
-# "Hello, World!" C++ example
+# "Hello, World!" C++ Example
#
# CONFIG_EXAMPLES_HELLOXX is not set
#
-# USB HID keyboard example
+# USB HID Keyboard Example
#
# CONFIG_EXAMPLES_HIDKBD is not set
#
-# IGMP example
+# IGMP Example
#
# CONFIG_EXAMPLES_IGMP is not set
#
-# LCD read/write example
+# LCD Read/Write Example
#
# CONFIG_EXAMPLES_LCDRW is not set
#
-# Memory management example
+# Memory Management Example
#
# CONFIG_EXAMPLES_MM is not set
#
-# File system mount example
+# File System Mount Example
#
# CONFIG_EXAMPLES_MOUNT is not set
#
-# FreeModBus example
+# FreeModBus Example
#
# CONFIG_EXAMPLES_MODBUS is not set
#
-# Network test example
+# Network Test Example
#
# CONFIG_EXAMPLES_NETTEST is not set
#
-# NuttShell (NSH) example
+# NuttShell (NSH) Example
#
CONFIG_EXAMPLES_NSH=y
#
-# NULL example
+# NULL Example
#
# CONFIG_EXAMPLES_NULL is not set
#
-# NX graphics example
+# NX Graphics Example
#
# CONFIG_EXAMPLES_NX is not set
#
-# NxConsole example
+# NxConsole Example
#
# CONFIG_EXAMPLES_NXCONSOLE is not set
#
-# NXFFS file system example
+# NXFFS File System Example
#
# CONFIG_EXAMPLES_NXFFS is not set
#
-# NXFLAT example
+# NXFLAT Example
#
# CONFIG_EXAMPLES_NXFLAT is not set
#
-# NX graphics "Hello, World!" example
+# NX Graphics "Hello, World!" Example
#
# CONFIG_EXAMPLES_NXHELLO is not set
#
-# NX graphics image example
+# NX Graphics image Example
#
# CONFIG_EXAMPLES_NXIMAGE is not set
#
-# NX graphics lines example
+# NX Graphics lines Example
#
# CONFIG_EXAMPLES_NXLINES is not set
#
-# NX graphics text example
+# NX Graphics Text Example
#
# CONFIG_EXAMPLES_NXTEXT is not set
#
-# OS test example
+# OS Test Example
#
# CONFIG_EXAMPLES_OSTEST is not set
@@ -613,104 +615,113 @@ CONFIG_EXAMPLES_NSH=y
# CONFIG_EXAMPLES_PASHELLO is not set
#
-# Pipe example
+# Pipe Example
#
# CONFIG_EXAMPLES_PIPE is not set
#
-# Poll example
+# Poll Example
#
# CONFIG_EXAMPLES_POLL is not set
#
-# Pulse width modulation (PWM) example
+# Pulse Width Modulation (PWM) Example
#
#
-# Quadrature encoder example
+# Quadrature Encoder Example
#
# CONFIG_EXAMPLES_QENCODER is not set
#
-# RGMP example
+# RGMP Example
#
# CONFIG_EXAMPLES_RGMP is not set
#
-# ROMFS example
+# ROMFS Example
#
# CONFIG_EXAMPLES_ROMFS is not set
#
-# sendmail example
+# sendmail Example
#
# CONFIG_EXAMPLES_SENDMAIL is not set
#
-# Serial loopback example
+# Serial Loopback Example
#
# CONFIG_EXAMPLES_SERLOOP is not set
#
-# Telnet daemon example
+# Telnet Daemon Example
#
# CONFIG_EXAMPLES_TELNETD is not set
#
-# THTTPD web server example
+# THTTPD Web Server Example
#
# CONFIG_EXAMPLES_THTTPD is not set
#
-# TIFF generation example
+# TIFF Generation Example
#
# CONFIG_EXAMPLES_TIFF is not set
#
-# Touchscreen example
+# Touchscreen Example
#
# CONFIG_EXAMPLES_TOUCHSCREEN is not set
#
-# UDP example
+# UDP Example
#
# CONFIG_EXAMPLES_UDP is not set
#
-# uIP web server example
+# UDP Discovery Daemon Example
+#
+# CONFIG_EXAMPLE_DISCOVER is not set
+
+#
+# uIP Web Server Example
#
# CONFIG_EXAMPLES_UIP is not set
#
-# USB serial test example
+# USB Serial Test Example
#
# CONFIG_EXAMPLES_USBSERIAL is not set
#
-# USB mass storage class example
+# USB Mass Storage Class Example
#
# CONFIG_EXAMPLES_USBMSC is not set
#
-# USB serial terminal example
+# USB Serial Terminal Example
#
# CONFIG_EXAMPLES_USBTERM is not set
#
-# Watchdog timer example
+# Watchdog timer Example
#
# CONFIG_EXAMPLES_WATCHDOG is not set
#
-# wget example
+# wget Example
#
# CONFIG_EXAMPLES_WGET is not set
#
-# WLAN example
+# WLAN Example
#
# CONFIG_EXAMPLES_WLAN is not set
+#
+# XML RPC Example
+#
+
#
# Interpreters
#
@@ -790,6 +801,16 @@ CONFIG_NETUTILS_WEBCLIENT=y
#
# CONFIG_NETUTILS_WEBSERVER is not set
+#
+# UDP Discovery Utility
+#
+# CONFIG_NETUTILS_DISCOVER is not set
+
+#
+# XML-RPC library
+#
+# CONFIG_NETUTILS_XMLRPC is not set
+
#
# ModBus
#
diff --git a/nuttx/configs/shenzhou/scripts/ld.script b/nuttx/configs/shenzhou/scripts/ld.script
index 14f924baec..f07d4432d1 100644
--- a/nuttx/configs/shenzhou/scripts/ld.script
+++ b/nuttx/configs/shenzhou/scripts/ld.script
@@ -63,6 +63,12 @@ SECTIONS
_etext = ABSOLUTE(.);
} > flash
+ __exidx_start = ABSOLUTE(.);
+ .ARM.exidx : {
+ *(.ARM.exidx*)
+ } >flash
+ __exidx_end = ABSOLUTE(.);
+
_eronly = ABSOLUTE(.);
/* The STM32F107VC has 64Kb of SRAM beginning at the following address */
@@ -79,12 +85,6 @@ SECTIONS
*(.ARM.extab*)
} >sram
- __exidx_start = ABSOLUTE(.);
- .ARM.exidx : {
- *(.ARM.exidx*)
- } >sram
- __exidx_end = ABSOLUTE(.);
-
.bss : {
_sbss = ABSOLUTE(.);
*(.bss .bss.*)
diff --git a/nuttx/configs/shenzhou/scripts/ld.script.dfu b/nuttx/configs/shenzhou/scripts/ld.script.dfu
index 53e3ee4fca..b9d94c7a0f 100644
--- a/nuttx/configs/shenzhou/scripts/ld.script.dfu
+++ b/nuttx/configs/shenzhou/scripts/ld.script.dfu
@@ -65,6 +65,12 @@ SECTIONS
_etext = ABSOLUTE(.);
} > flash
+ __exidx_start = ABSOLUTE(.);
+ .ARM.exidx : {
+ *(.ARM.exidx*)
+ } >flash
+ __exidx_end = ABSOLUTE(.);
+
_eronly = ABSOLUTE(.);
/* The STM32F107VC has 64Kb of SRAM beginning at the following address */
@@ -81,12 +87,6 @@ SECTIONS
*(.ARM.extab*)
} >sram
- __exidx_start = ABSOLUTE(.);
- .ARM.exidx : {
- *(.ARM.exidx*)
- } >sram
- __exidx_end = ABSOLUTE(.);
-
.bss : {
_sbss = ABSOLUTE(.);
*(.bss .bss.*)
diff --git a/nuttx/configs/shenzhou/src/shenzhou-internal.h b/nuttx/configs/shenzhou/src/shenzhou-internal.h
index 19460bc998..48b06e7b0a 100644
--- a/nuttx/configs/shenzhou/src/shenzhou-internal.h
+++ b/nuttx/configs/shenzhou/src/shenzhou-internal.h
@@ -113,13 +113,13 @@
*/
#define GPIO_LED1 (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\
- GPIO_OUTPUT_CLEAR|GPIO_PORTD|GPIO_PIN2)
+ GPIO_OUTPUT_SET|GPIO_PORTD|GPIO_PIN2)
#define GPIO_LED2 (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\
- GPIO_OUTPUT_CLEAR|GPIO_PORTD|GPIO_PIN3)
+ GPIO_OUTPUT_SET|GPIO_PORTD|GPIO_PIN3)
#define GPIO_LED3 (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\
- GPIO_OUTPUT_CLEAR|GPIO_PORTD|GPIO_PIN4)
+ GPIO_OUTPUT_SET|GPIO_PORTD|GPIO_PIN4)
#define GPIO_LED4 (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\
- GPIO_OUTPUT_CLEAR|GPIO_PORTD|GPIO_PIN5)
+ GPIO_OUTPUT_SET|GPIO_PORTD|GPIO_PIN7)
/* TFT LCD
*
diff --git a/nuttx/configs/shenzhou/src/up_autoleds.c b/nuttx/configs/shenzhou/src/up_autoleds.c
index 996836c792..3c467c8ad7 100644
--- a/nuttx/configs/shenzhou/src/up_autoleds.c
+++ b/nuttx/configs/shenzhou/src/up_autoleds.c
@@ -203,24 +203,26 @@ static struct pm_callback_s g_ledscb =
static inline void led_clrbits(unsigned int clrbits)
{
+ /* All LEDs are pulled up and, hence, active low */
+
if ((clrbits & SHENZHOU_LED1) != 0)
{
- stm32_gpiowrite(GPIO_LED1, false);
+ stm32_gpiowrite(GPIO_LED1, true);
}
if ((clrbits & SHENZHOU_LED2) != 0)
{
- stm32_gpiowrite(GPIO_LED2, false);
+ stm32_gpiowrite(GPIO_LED2, true);
}
if ((clrbits & SHENZHOU_LED3) != 0)
{
- stm32_gpiowrite(GPIO_LED3, false);
+ stm32_gpiowrite(GPIO_LED3, true);
}
if ((clrbits & SHENZHOU_LED4) != 0)
{
- stm32_gpiowrite(GPIO_LED4, false);
+ stm32_gpiowrite(GPIO_LED4, true);
}
}
@@ -234,24 +236,26 @@ static inline void led_clrbits(unsigned int clrbits)
static inline void led_setbits(unsigned int setbits)
{
+ /* All LEDs are pulled up and, hence, active low */
+
if ((setbits & SHENZHOU_LED1) != 0)
{
- stm32_gpiowrite(GPIO_LED1, true);
+ stm32_gpiowrite(GPIO_LED1, false);
}
if ((setbits & SHENZHOU_LED2) != 0)
{
- stm32_gpiowrite(GPIO_LED2, true);
+ stm32_gpiowrite(GPIO_LED2, false);
}
if ((setbits & SHENZHOU_LED3) != 0)
{
- stm32_gpiowrite(GPIO_LED3, true);
+ stm32_gpiowrite(GPIO_LED3, false);
}
if ((setbits & SHENZHOU_LED4) != 0)
{
- stm32_gpiowrite(GPIO_LED4, true);
+ stm32_gpiowrite(GPIO_LED4, false);
}
}
From fc8f6c972a15241790d9443f33b2e97d4347c3c8 Mon Sep 17 00:00:00 2001
From: patacongo
Date: Sat, 22 Sep 2012 15:12:50 +0000
Subject: [PATCH 09/31] Make the Olimex stm32 p107 clock configuratin the
standard for connectivity line devices
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5175 42af7a65-404d-4744-a932-0658087f49c3
---
nuttx/arch/arm/src/stm32/Kconfig | 4 +-
nuttx/arch/arm/src/stm32/stm32f10xxx_rcc.c | 127 ++++++++++++-
.../configs/olimex-stm32-p107/include/board.h | 32 ++--
nuttx/configs/olimex-stm32-p107/nsh/defconfig | 1 -
.../olimex-stm32-p107/ostest/defconfig | 1 -
nuttx/configs/olimex-stm32-p107/src/up_boot.c | 108 -----------
nuttx/configs/shenzhou/include/board.h | 32 ++--
nuttx/configs/shenzhou/nsh/defconfig | 2 +-
nuttx/configs/shenzhou/src/Makefile | 4 -
nuttx/configs/shenzhou/src/up_clockconfig.c | 167 ------------------
10 files changed, 158 insertions(+), 320 deletions(-)
delete mode 100644 nuttx/configs/shenzhou/src/up_clockconfig.c
diff --git a/nuttx/arch/arm/src/stm32/Kconfig b/nuttx/arch/arm/src/stm32/Kconfig
index a0f9a48921..c7dae44608 100644
--- a/nuttx/arch/arm/src/stm32/Kconfig
+++ b/nuttx/arch/arm/src/stm32/Kconfig
@@ -1732,11 +1732,11 @@ config STM32_MII_EXTCLK
endchoice
config STM32_AUTONEG
- bool "Use autonegtiation"
+ bool "Use autonegotiation"
default y
depends on STM32_ETHMAC
---help---
- Use PHY autonegotion to determine speed and mode
+ Use PHY autonegotiation to determine speed and mode
config STM32_ETHFD
bool "Full duplex"
diff --git a/nuttx/arch/arm/src/stm32/stm32f10xxx_rcc.c b/nuttx/arch/arm/src/stm32/stm32f10xxx_rcc.c
index 10b8572cf0..47ed5e016b 100644
--- a/nuttx/arch/arm/src/stm32/stm32f10xxx_rcc.c
+++ b/nuttx/arch/arm/src/stm32/stm32f10xxx_rcc.c
@@ -90,7 +90,7 @@ static inline void rcc_reset(void)
regval = getreg32(STM32_RCC_CR); /* Reset HSEBYP bit */
regval &= ~RCC_CR_HSEBYP;
putreg32(regval, STM32_RCC_CR);
-
+
regval = getreg32(STM32_RCC_CFGR); /* Reset PLLSRC, PLLXTPRE, PLLMUL and USBPRE bits */
regval &= ~(RCC_CFGR_PLLSRC|RCC_CFGR_PLLXTPRE|RCC_CFGR_PLLMUL_MASK|RCC_CFGR_USBPRE);
putreg32(regval, STM32_RCC_CFGR);
@@ -235,7 +235,7 @@ static inline void rcc_enableapb1(void)
regval |= RCC_APB1ENR_SPI2EN;
#endif
-
+
#ifdef CONFIG_STM32_SPI3
/* SPI 3 clock enable */
@@ -411,13 +411,128 @@ static inline void rcc_enableapb2(void)
* Name: stm32_stdclockconfig
*
* Description:
- * Called to change to new clock based on settings in board.h
- *
+ * Called to change to new clock based on settings in board.h. This
+ * version is for the Connectivity Line parts.
+ *
* NOTE: This logic would need to be extended if you need to select low-
* power clocking modes!
****************************************************************************/
-#ifndef CONFIG_ARCH_BOARD_STM32_CUSTOM_CLOCKCONFIG
+#if !defined(CONFIG_ARCH_BOARD_STM32_CUSTOM_CLOCKCONFIG) && defined(CONFIG_STM32_CONNECTIVITYLINE)
+static void stm32_stdclockconfig(void)
+{
+ uint32_t regval;
+
+ /* Enable HSE */
+
+ regval = getreg32(STM32_RCC_CR);
+ regval &= ~RCC_CR_HSEBYP; /* Disable HSE clock bypass */
+ regval |= RCC_CR_HSEON; /* Enable HSE */
+ putreg32(regval, STM32_RCC_CR);
+
+ /* Set flash wait states
+ * Sysclk runs with 72MHz -> 2 waitstates.
+ * 0WS from 0-24MHz
+ * 1WS from 24-48MHz
+ * 2WS from 48-72MHz
+ */
+
+ regval = getreg32(STM32_FLASH_ACR);
+ regval &= ~FLASH_ACR_LATENCY_MASK;
+ regval |= (FLASH_ACR_LATENCY_2|FLASH_ACR_PRTFBE);
+ putreg32(regval, STM32_FLASH_ACR);
+
+ /* Set up PLL input scaling (with source = PLL2) */
+
+ regval = getreg32(STM32_RCC_CFGR2);
+ regval &= ~(RCC_CFGR2_PREDIV2_MASK | RCC_CFGR2_PLL2MUL_MASK |
+ RCC_CFGR2_PREDIV1SRC_MASK | RCC_CFGR2_PREDIV1_MASK);
+ regval |= (STM32_PLL_PREDIV2 | STM32_PLL_PLL2MUL |
+ RCC_CFGR2_PREDIV1SRC_PLL2 | STM32_PLL_PREDIV1);
+ putreg32(regval, STM32_RCC_CFGR2);
+
+ /* Set the PCLK2 divider */
+
+ regval = getreg32(STM32_RCC_CFGR);
+ regval &= ~(RCC_CFGR_PPRE2_MASK | RCC_CFGR_HPRE_MASK);
+ regval |= STM32_RCC_CFGR_PPRE2;
+ regval |= RCC_CFGR_HPRE_SYSCLK;
+ putreg32(regval, STM32_RCC_CFGR);
+
+ /* Set the PCLK1 divider */
+
+ regval = getreg32(STM32_RCC_CFGR);
+ regval &= ~RCC_CFGR_PPRE1_MASK;
+ regval |= STM32_RCC_CFGR_PPRE1;
+ putreg32(regval, STM32_RCC_CFGR);
+
+ /* Enable PLL2 */
+
+ regval = getreg32(STM32_RCC_CR);
+ regval |= RCC_CR_PLL2ON;
+ putreg32(regval, STM32_RCC_CR);
+
+ /* Wait for PLL2 ready */
+
+ while((getreg32(STM32_RCC_CR) & RCC_CR_PLL2RDY) == 0);
+
+ /* Setup PLL3 for MII/RMII clock on MCO */
+
+#if defined(CONFIG_STM32_MII_MCO) || defined(CONFIG_STM32_RMII_MCO)
+ regval = getreg32(STM32_RCC_CFGR2);
+ regval &= ~(RCC_CFGR2_PLL3MUL_MASK);
+ regval |= STM32_PLL_PLL3MUL;
+ putreg32(regval, STM32_RCC_CFGR2);
+
+ /* Switch PLL3 on */
+
+ regval = getreg32(STM32_RCC_CR);
+ regval |= RCC_CR_PLL3ON;
+ putreg32(regval, STM32_RCC_CR);
+
+ while ((getreg32(STM32_RCC_CR) & RCC_CR_PLL3RDY) == 0);
+#endif
+
+ /* Set main PLL source and multiplier */
+
+ regval = getreg32(STM32_RCC_CFGR);
+ regval &= ~(RCC_CFGR_PLLSRC | RCC_CFGR_PLLMUL_MASK);
+ regval |= (RCC_CFGR_PLLSRC | STM32_PLL_PLLMUL);
+ putreg32(regval, STM32_RCC_CFGR);
+
+ /* Switch main PLL on */
+
+ regval = getreg32(STM32_RCC_CR);
+ regval |= RCC_CR_PLLON;
+ putreg32(regval, STM32_RCC_CR);
+
+ while ((getreg32(STM32_RCC_CR) & RCC_CR_PLLRDY) == 0);
+
+ /* Select PLL as system clock source */
+
+ regval = getreg32(STM32_RCC_CFGR);
+ regval &= ~RCC_CFGR_SW_MASK;
+ regval |= RCC_CFGR_SW_PLL;
+ putreg32(regval, STM32_RCC_CFGR);
+
+ /* Wait until PLL is used as the system clock source */
+
+ while ((getreg32(STM32_RCC_CFGR) & RCC_CFGR_SWS_PLL) == 0);
+}
+#endif
+
+/****************************************************************************
+ * Name: stm32_stdclockconfig
+ *
+ * Description:
+ * Called to change to new clock based on settings in board.h. This
+ * version is for the non-Connectivity Line parts.
+ *
+ * NOTE: This logic would need to be extended if you need to select low-
+ * power clocking modes!
+ ****************************************************************************/
+
+#if !defined(CONFIG_ARCH_BOARD_STM32_CUSTOM_CLOCKCONFIG) && !defined(CONFIG_STM32_CONNECTIVITYLINE)
static void stm32_stdclockconfig(void)
{
uint32_t regval;
@@ -430,7 +545,7 @@ static void stm32_stdclockconfig(void)
volatile int32_t timeout;
/* Enable External High-Speed Clock (HSE) */
-
+
regval = getreg32(STM32_RCC_CR);
regval &= ~RCC_CR_HSEBYP; /* Disable HSE clock bypass */
regval |= RCC_CR_HSEON; /* Enable HSE */
diff --git a/nuttx/configs/olimex-stm32-p107/include/board.h b/nuttx/configs/olimex-stm32-p107/include/board.h
index 2fe6e5aafe..d531eb1129 100644
--- a/nuttx/configs/olimex-stm32-p107/include/board.h
+++ b/nuttx/configs/olimex-stm32-p107/include/board.h
@@ -57,9 +57,18 @@
/* On-board crystal frequency is 25MHz (HSE) */
#define STM32_BOARD_XTAL 25000000ul
-#define STM32_PLL_FREQUENCY (72000000)
-#define STM32_SYSCLK_FREQUENCY STM32_PLL_FREQUENCY
+/* PLL ouput is 72MHz */
+
+#define STM32_PLL_PREDIV2 RCC_CFGR2_PREDIV2d5 /* 25MHz / 5 => 5MHz */
+#define STM32_PLL_PLL2MUL RCC_CFGR2_PLL2MULx8 /* 5MHz * 8 => 40MHz */
+#define STM32_PLL_PREDIV1 RCC_CFGR2_PREDIV1d5 /* 40MHz / 5 => 8MHz */
+#define STM32_PLL_PLLMUL RCC_CFGR_PLLMUL_CLKx9 /* 8MHz * 9 => 72Mhz */
+#define STM32_PLL_FREQUENCY (72000000)
+
+/* SYCLLK and HCLK are the PLL frequency */
+
+#define STM32_SYSCLK_FREQUENCY STM32_PLL_FREQUENCY
#define STM32_HCLK_FREQUENCY STM32_PLL_FREQUENCY
#define STM32_BOARD_HCLK STM32_HCLK_FREQUENCY /* same as above, to satisfy compiler */
@@ -88,6 +97,12 @@
#define STM32_APB1_TIM6_CLKIN (STM32_PCLK1_FREQUENCY)
#define STM32_APB1_TIM7_CLKIN (STM32_PCLK1_FREQUENCY)
+/* MCO output */
+
+#if defined(CONFIG_STM32_MII_MCO) || defined(CONFIG_STM32_RMII_MCO)
+# define STM32_PLL_PLL3MUL RCC_CFGR2_PLL3MULx10
+#endif
+
/************************************************************************************
* Public Function Prototypes
************************************************************************************/
@@ -102,16 +117,3 @@
************************************************************************************/
void stm32_boardinitialize(void);
-
-/************************************************************************************
- * Name: stm32_board_clockconfig
- *
- * Description:
- * Any STM32 board may replace the "standard" board clock configuration logic with
- * its own, custom clock cofiguration logic.
- *
- ************************************************************************************/
-
-#ifdef CONFIG_ARCH_BOARD_STM32_CUSTOM_CLOCKCONFIG
-void stm32_board_clockconfig(void);
-#endif
diff --git a/nuttx/configs/olimex-stm32-p107/nsh/defconfig b/nuttx/configs/olimex-stm32-p107/nsh/defconfig
index 5c38a49efa..e3fb69ca2e 100644
--- a/nuttx/configs/olimex-stm32-p107/nsh/defconfig
+++ b/nuttx/configs/olimex-stm32-p107/nsh/defconfig
@@ -41,7 +41,6 @@ CONFIG_ARCH_CORTEXM3=y
CONFIG_ARCH_CHIP="stm32"
CONFIG_ARCH_CHIP_STM32F107VC=y
CONFIG_ARCH_BOARD="olimex-stm32-p107"
-CONFIG_ARCH_BOARD_STM32_CUSTOM_CLOCKCONFIG=y
CONFIG_BOARD_LOOPSPERMSEC=5483
CONFIG_DRAM_START=0x20000000
CONFIG_DRAM_SIZE=65536
diff --git a/nuttx/configs/olimex-stm32-p107/ostest/defconfig b/nuttx/configs/olimex-stm32-p107/ostest/defconfig
index 3710ee95b7..36fade11bb 100644
--- a/nuttx/configs/olimex-stm32-p107/ostest/defconfig
+++ b/nuttx/configs/olimex-stm32-p107/ostest/defconfig
@@ -41,7 +41,6 @@ CONFIG_ARCH_CORTEXM3=y
CONFIG_ARCH_CHIP="stm32"
CONFIG_ARCH_CHIP_STM32F107VC=y
CONFIG_ARCH_BOARD="olimex-stm32-p107"
-CONFIG_ARCH_BOARD_STM32_CUSTOM_CLOCKCONFIG=y
CONFIG_BOARD_LOOPSPERMSEC=5483
CONFIG_DRAM_START=0x20000000
CONFIG_DRAM_SIZE=65536
diff --git a/nuttx/configs/olimex-stm32-p107/src/up_boot.c b/nuttx/configs/olimex-stm32-p107/src/up_boot.c
index d8cba509e4..d7ece5a1e0 100644
--- a/nuttx/configs/olimex-stm32-p107/src/up_boot.c
+++ b/nuttx/configs/olimex-stm32-p107/src/up_boot.c
@@ -71,111 +71,3 @@
void stm32_boardinitialize(void)
{
}
-
-/************************************************************************************
- * Name: stm32_board_clockconfig
- *
- * Description:
- * Any STM32 board may replace the "standard" board clock configuration logic with
- * its own, custom clock cofiguration logic.
- *
- ************************************************************************************/
-
-#ifdef CONFIG_ARCH_BOARD_STM32_CUSTOM_CLOCKCONFIG
-void stm32_board_clockconfig(void)
-{
- uint32_t regval;
-
- regval = getreg32(STM32_RCC_CR);
- regval &= ~RCC_CR_HSEBYP; /* Disable HSE clock bypass */
- regval |= RCC_CR_HSEON; /* Enable HSE */
- putreg32(regval, STM32_RCC_CR);
-
- /* Set flash wait states
- * Sysclk runs with 72MHz -> 2 waitstates.
- * 0WS from 0-24MHz
- * 1WS from 24-48MHz
- * 2WS from 48-72MHz
- */
-
- regval = getreg32(STM32_FLASH_ACR);
- regval &= ~FLASH_ACR_LATENCY_MASK;
- regval |= (FLASH_ACR_LATENCY_2|FLASH_ACR_PRTFBE);
- putreg32(regval, STM32_FLASH_ACR);
-
- regval = getreg32(STM32_RCC_CFGR2);
- regval &= ~(RCC_CFGR2_PREDIV2_MASK
- | RCC_CFGR2_PLL2MUL_MASK
- | RCC_CFGR2_PREDIV1SRC_MASK
- | RCC_CFGR2_PREDIV1_MASK);
- regval |= RCC_CFGR2_PREDIV2d5; /* 25MHz / 5 */
- regval |= RCC_CFGR2_PLL2MULx8; /* 5MHz * 8 => 40MHz */
- regval |= RCC_CFGR2_PREDIV1SRC_PLL2; /* Use PLL2 as input for PREDIV1 */
- regval |= RCC_CFGR2_PREDIV1d5; /* 40MHz / 5 => 8MHz */
- putreg32(regval, STM32_RCC_CFGR2);
-
- /* Set the PCLK2 divider */
-
- regval = getreg32(STM32_RCC_CFGR);
- regval &= ~(RCC_CFGR_PPRE2_MASK | RCC_CFGR_HPRE_MASK);
- regval |= STM32_RCC_CFGR_PPRE2;
- regval |= RCC_CFGR_HPRE_SYSCLK;
- putreg32(regval, STM32_RCC_CFGR);
-
- /* Set the PCLK1 divider */
-
- regval = getreg32(STM32_RCC_CFGR);
- regval &= ~RCC_CFGR_PPRE1_MASK;
- regval |= STM32_RCC_CFGR_PPRE1;
- putreg32(regval, STM32_RCC_CFGR);
-
- regval = getreg32(STM32_RCC_CR);
- regval |= RCC_CR_PLL2ON;
- putreg32(regval, STM32_RCC_CR);
-
- /* Wait for PLL2 ready */
-
- while((getreg32(STM32_RCC_CR) & RCC_CR_PLL2RDY) == 0);
-
- /* Setup PLL3 for RMII clock on MCO */
-
- regval = getreg32(STM32_RCC_CFGR2);
- regval &= ~(RCC_CFGR2_PLL3MUL_MASK);
- regval |= RCC_CFGR2_PLL3MULx10;
- putreg32(regval, STM32_RCC_CFGR2);
-
- /* Switch PLL3 on */
-
- regval = getreg32(STM32_RCC_CR);
- regval |= RCC_CR_PLL3ON;
- putreg32(regval, STM32_RCC_CR);
-
- while ((getreg32(STM32_RCC_CR) & RCC_CR_PLL3RDY) == 0);
-
- /* Set main PLL source 8MHz * 9 => 72MHz*/
-
- regval = getreg32(STM32_RCC_CFGR);
- regval &= ~(RCC_CFGR_PLLSRC | RCC_CFGR_PLLMUL_MASK);
- regval |= (RCC_CFGR_PLLSRC | RCC_CFGR_PLLMUL_CLKx9);
- putreg32(regval, STM32_RCC_CFGR);
-
- /* Switch main PLL on */
-
- regval = getreg32(STM32_RCC_CR);
- regval |= RCC_CR_PLLON;
- putreg32(regval, STM32_RCC_CR);
-
- while ((getreg32(STM32_RCC_CR) & RCC_CR_PLLRDY) == 0);
-
- /* Select PLL as system clock source */
-
- regval = getreg32(STM32_RCC_CFGR);
- regval &= ~RCC_CFGR_SW_MASK;
- regval |= RCC_CFGR_SW_PLL;
- putreg32(regval, STM32_RCC_CFGR);
-
- /* Wait until PLL is used as the system clock source */
-
- while ((getreg32(STM32_RCC_CFGR) & RCC_CFGR_SWS_PLL) == 0);
-}
-#endif
diff --git a/nuttx/configs/shenzhou/include/board.h b/nuttx/configs/shenzhou/include/board.h
index 2e82742ec6..8e4d895318 100644
--- a/nuttx/configs/shenzhou/include/board.h
+++ b/nuttx/configs/shenzhou/include/board.h
@@ -57,9 +57,18 @@
/* On-board crystal frequency is 25MHz (HSE) */
#define STM32_BOARD_XTAL 25000000ul
-#define STM32_PLL_FREQUENCY (72000000)
-#define STM32_SYSCLK_FREQUENCY STM32_PLL_FREQUENCY
+/* PLL ouput is 72MHz */
+
+#define STM32_PLL_PREDIV2 RCC_CFGR2_PREDIV2d5 /* 25MHz / 5 => 5MHz */
+#define STM32_PLL_PLL2MUL RCC_CFGR2_PLL2MULx8 /* 5MHz * 8 => 40MHz */
+#define STM32_PLL_PREDIV1 RCC_CFGR2_PREDIV1d5 /* 40MHz / 5 => 8MHz */
+#define STM32_PLL_PLLMUL RCC_CFGR_PLLMUL_CLKx9 /* 8MHz * 9 => 72Mhz */
+#define STM32_PLL_FREQUENCY (72000000)
+
+/* SYCLLK and HCLK are the PLL frequency */
+
+#define STM32_SYSCLK_FREQUENCY STM32_PLL_FREQUENCY
#define STM32_HCLK_FREQUENCY STM32_PLL_FREQUENCY
#define STM32_BOARD_HCLK STM32_HCLK_FREQUENCY /* same as above, to satisfy compiler */
@@ -88,6 +97,12 @@
#define STM32_APB1_TIM6_CLKIN (STM32_PCLK1_FREQUENCY)
#define STM32_APB1_TIM7_CLKIN (STM32_PCLK1_FREQUENCY)
+/* MCO output */
+
+#if defined(CONFIG_STM32_MII_MCO) || defined(CONFIG_STM32_RMII_MCO)
+# define STM32_PLL_PLL3MUL RCC_CFGR2_PLL3MULx10
+#endif
+
/* LED definitions ******************************************************************/
/* If CONFIG_ARCH_LEDS is not defined, then the user can control the LEDs in any
* way. The following definitions are used to access individual LEDs.
@@ -316,19 +331,6 @@
void stm32_boardinitialize(void);
-/************************************************************************************
- * Name: stm32_board_clockconfig
- *
- * Description:
- * Any STM32 board may replace the "standard" board clock configuration logic with
- * its own, custom clock cofiguration logic.
- *
- ************************************************************************************/
-
-#ifdef CONFIG_ARCH_BOARD_STM32_CUSTOM_CLOCKCONFIG
-void stm32_board_clockconfig(void);
-#endif
-
/************************************************************************************
* Button support.
*
diff --git a/nuttx/configs/shenzhou/nsh/defconfig b/nuttx/configs/shenzhou/nsh/defconfig
index 70d9540db8..f231b26325 100644
--- a/nuttx/configs/shenzhou/nsh/defconfig
+++ b/nuttx/configs/shenzhou/nsh/defconfig
@@ -161,7 +161,7 @@ CONFIG_STM32_JTAG_FULL_ENABLE=y
# CONFIG_STM32_JTAG_NOJNTRST_ENABLE is not set
# CONFIG_STM32_JTAG_SW_ENABLE is not set
# CONFIG_STM32_FORCEPOWER is not set
-CONFIG_ARCH_BOARD_STM32_CUSTOM_CLOCKCONFIG=y
+# CONFIG_ARCH_BOARD_STM32_CUSTOM_CLOCKCONFIG is not set`
#
# SPI Configuration
diff --git a/nuttx/configs/shenzhou/src/Makefile b/nuttx/configs/shenzhou/src/Makefile
index 50ddaa5cad..c12a251f0f 100644
--- a/nuttx/configs/shenzhou/src/Makefile
+++ b/nuttx/configs/shenzhou/src/Makefile
@@ -42,10 +42,6 @@ AOBJS = $(ASRCS:.S=$(OBJEXT))
CSRCS = up_boot.c up_spi.c up_mmcsd.c
-ifeq ($(CONFIG_ARCH_BOARD_STM32_CUSTOM_CLOCKCONFIG),y)
-CSRCS += up_clockconfig.c
-endif
-
ifeq ($(CONFIG_HAVE_CXX),y)
CSRCS += up_cxxinitialize.c
endif
diff --git a/nuttx/configs/shenzhou/src/up_clockconfig.c b/nuttx/configs/shenzhou/src/up_clockconfig.c
deleted file mode 100644
index 6c3bd56e14..0000000000
--- a/nuttx/configs/shenzhou/src/up_clockconfig.c
+++ /dev/null
@@ -1,167 +0,0 @@
-/************************************************************************************
- * configs/olimex-stm32-p107/src/up_boot.c
- * arch/arm/src/board/up_boot.c
- *
- * Copyright (C) 2009, 2012 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name NuttX nor the names of its contributors may be
- * used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- ************************************************************************************/
-
-/************************************************************************************
- * Included Files
- ************************************************************************************/
-
-#include
-
-#include
-
-#include
-
-#include "up_arch.h"
-
-/************************************************************************************
- * Pre-processor Definitions
- ************************************************************************************/
-
-/************************************************************************************
- * Private Functions
- ************************************************************************************/
-
-/************************************************************************************
- * Public Functions
- ************************************************************************************/
-
-/************************************************************************************
- * Name: stm32_board_clockconfig
- *
- * Description:
- * Any STM32 board may replace the "standard" board clock configuration logic with
- * its own, custom clock cofiguration logic.
- *
- ************************************************************************************/
-
-#ifdef CONFIG_ARCH_BOARD_STM32_CUSTOM_CLOCKCONFIG
-void stm32_board_clockconfig(void)
-{
- uint32_t regval;
-
- regval = getreg32(STM32_RCC_CR);
- regval &= ~RCC_CR_HSEBYP; /* Disable HSE clock bypass */
- regval |= RCC_CR_HSEON; /* Enable HSE */
- putreg32(regval, STM32_RCC_CR);
-
- /* Set flash wait states
- * Sysclk runs with 72MHz -> 2 waitstates.
- * 0WS from 0-24MHz
- * 1WS from 24-48MHz
- * 2WS from 48-72MHz
- */
-
- regval = getreg32(STM32_FLASH_ACR);
- regval &= ~FLASH_ACR_LATENCY_MASK;
- regval |= (FLASH_ACR_LATENCY_2|FLASH_ACR_PRTFBE);
- putreg32(regval, STM32_FLASH_ACR);
-
- regval = getreg32(STM32_RCC_CFGR2);
- regval &= ~(RCC_CFGR2_PREDIV2_MASK
- | RCC_CFGR2_PLL2MUL_MASK
- | RCC_CFGR2_PREDIV1SRC_MASK
- | RCC_CFGR2_PREDIV1_MASK);
- regval |= RCC_CFGR2_PREDIV2d5; /* 25MHz / 5 */
- regval |= RCC_CFGR2_PLL2MULx8; /* 5MHz * 8 => 40MHz */
- regval |= RCC_CFGR2_PREDIV1SRC_PLL2; /* Use PLL2 as input for PREDIV1 */
- regval |= RCC_CFGR2_PREDIV1d5; /* 40MHz / 5 => 8MHz */
- putreg32(regval, STM32_RCC_CFGR2);
-
- /* Set the PCLK2 divider */
-
- regval = getreg32(STM32_RCC_CFGR);
- regval &= ~(RCC_CFGR_PPRE2_MASK | RCC_CFGR_HPRE_MASK);
- regval |= STM32_RCC_CFGR_PPRE2;
- regval |= RCC_CFGR_HPRE_SYSCLK;
- putreg32(regval, STM32_RCC_CFGR);
-
- /* Set the PCLK1 divider */
-
- regval = getreg32(STM32_RCC_CFGR);
- regval &= ~RCC_CFGR_PPRE1_MASK;
- regval |= STM32_RCC_CFGR_PPRE1;
- putreg32(regval, STM32_RCC_CFGR);
-
- regval = getreg32(STM32_RCC_CR);
- regval |= RCC_CR_PLL2ON;
- putreg32(regval, STM32_RCC_CR);
-
- /* Wait for PLL2 ready */
-
- while((getreg32(STM32_RCC_CR) & RCC_CR_PLL2RDY) == 0);
-
- /* Setup PLL3 for RMII clock on MCO */
-
- regval = getreg32(STM32_RCC_CFGR2);
- regval &= ~(RCC_CFGR2_PLL3MUL_MASK);
- regval |= RCC_CFGR2_PLL3MULx10;
- putreg32(regval, STM32_RCC_CFGR2);
-
- /* Switch PLL3 on */
-
- regval = getreg32(STM32_RCC_CR);
- regval |= RCC_CR_PLL3ON;
- putreg32(regval, STM32_RCC_CR);
-
- while ((getreg32(STM32_RCC_CR) & RCC_CR_PLL3RDY) == 0);
-
- /* Set main PLL source 8MHz * 9 => 72MHz*/
-
- regval = getreg32(STM32_RCC_CFGR);
- regval &= ~(RCC_CFGR_PLLSRC | RCC_CFGR_PLLMUL_MASK);
- regval |= (RCC_CFGR_PLLSRC | RCC_CFGR_PLLMUL_CLKx9);
- putreg32(regval, STM32_RCC_CFGR);
-
- /* Switch main PLL on */
-
- regval = getreg32(STM32_RCC_CR);
- regval |= RCC_CR_PLLON;
- putreg32(regval, STM32_RCC_CR);
-
- while ((getreg32(STM32_RCC_CR) & RCC_CR_PLLRDY) == 0);
-
- /* Select PLL as system clock source */
-
- regval = getreg32(STM32_RCC_CFGR);
- regval &= ~RCC_CFGR_SW_MASK;
- regval |= RCC_CFGR_SW_PLL;
- putreg32(regval, STM32_RCC_CFGR);
-
- /* Wait until PLL is used as the system clock source */
-
- while ((getreg32(STM32_RCC_CFGR) & RCC_CFGR_SWS_PLL) == 0);
-}
-#endif
From 5f7c2b3eade6b23f1788fd4e5bc3f9b9f010c3af Mon Sep 17 00:00:00 2001
From: patacongo
Date: Sat, 22 Sep 2012 16:48:44 +0000
Subject: [PATCH 10/31] Shenzhou board uses RMII PHY interface, not MII
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5176 42af7a65-404d-4744-a932-0658087f49c3
---
nuttx/arch/arm/src/stm32/stm32_eth.c | 2 +-
nuttx/configs/shenzhou/README.txt | 4 ++--
nuttx/configs/shenzhou/include/board.h | 14 +++++++-------
nuttx/configs/shenzhou/nsh/defconfig | 9 ++++++---
4 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/nuttx/arch/arm/src/stm32/stm32_eth.c b/nuttx/arch/arm/src/stm32/stm32_eth.c
index 59f3def7f6..51dd7e1862 100644
--- a/nuttx/arch/arm/src/stm32/stm32_eth.c
+++ b/nuttx/arch/arm/src/stm32/stm32_eth.c
@@ -2854,7 +2854,7 @@ static void stm32_ethreset(FAR struct stm32_ethmac_s *priv)
* reset all the registers holds their reset values.
*/
- regval = stm32_getreg(STM32_ETH_DMABMR);
+ regval = stm32_getreg(STM32_ETH_DMABMR);
regval |= ETH_DMABMR_SR;
stm32_putreg(regval, STM32_ETH_DMABMR);
diff --git a/nuttx/configs/shenzhou/README.txt b/nuttx/configs/shenzhou/README.txt
index e68bd7bf9f..e929f2b8ba 100644
--- a/nuttx/configs/shenzhou/README.txt
+++ b/nuttx/configs/shenzhou/README.txt
@@ -560,9 +560,9 @@ Shenzhou-specific Configuration Options
CONFIG_STM32_PHYADDR - The 5-bit address of the PHY on the board
CONFIG_STM32_MII - Support Ethernet MII interface
- CONFIG_STM32_MII_MCO1 - Use MCO1 to clock the MII interface
- CONFIG_STM32_MII_MCO2 - Use MCO2 to clock the MII interface
+ CONFIG_STM32_MII_MCO - Use MCO to clock the MII interface
CONFIG_STM32_RMII - Support Ethernet RMII interface
+ CONFIG_STM32_RMII_MCO - Use MCO to clock the RMII interface
CONFIG_STM32_AUTONEG - Use PHY autonegotion to determine speed and mode
CONFIG_STM32_ETHFD - If CONFIG_STM32_AUTONEG is not defined, then this
may be defined to select full duplex mode. Default: half-duplex
diff --git a/nuttx/configs/shenzhou/include/board.h b/nuttx/configs/shenzhou/include/board.h
index 8e4d895318..df4386cf1b 100644
--- a/nuttx/configs/shenzhou/include/board.h
+++ b/nuttx/configs/shenzhou/include/board.h
@@ -166,9 +166,9 @@
* -- ---- -------------- ----------------------------------------------------------
* PN NAME SIGNAL NOTES
* -- ---- -------------- ----------------------------------------------------------
- * 24 PA1 MII_RX_CLK Ethernet PHY
- * RMII_REF_CLK Ethernet PHY
- * 25 PA2 MII_MDIO Ethernet PHY
+ * 24 PA1 MII_RX_CLK Ethernet PHY NOTE: Despite the MII labeling of these
+ * RMII_REF_CLK Ethernet PHY signals, the DM916AEP is actually configured
+ * 25 PA2 MII_MDIO Ethernet PHY to work in RMII mode.
* 48 PB11 MII_TX_EN Ethernet PHY
* 51 PB12 MII_TXD0 Ethernet PHY
* 52 PB13 MII_TXD1 Ethernet PHY
@@ -186,11 +186,11 @@
# ifndef CONFIG_STM32_ETH_REMAP
# error "STM32 Ethernet requires CONFIG_STM32_ETH_REMAP"
# endif
-# ifndef CONFIG_STM32_MII
-# error "STM32 Ethernet requires CONFIG_STM32_MII"
+# ifndef CONFIG_STM32_RMII
+# error "STM32 Ethernet requires CONFIG_STM32_RMII"
# endif
-# ifndef CONFIG_STM32_MII_MCO
-# error "STM32 Ethernet requires CONFIG_STM32_MII_MCO"
+# ifndef CONFIG_STM32_RMII_MCO
+# error "STM32 Ethernet requires CONFIG_STM32_RMII_MCO"
# endif
#endif
diff --git a/nuttx/configs/shenzhou/nsh/defconfig b/nuttx/configs/shenzhou/nsh/defconfig
index f231b26325..053717470e 100644
--- a/nuttx/configs/shenzhou/nsh/defconfig
+++ b/nuttx/configs/shenzhou/nsh/defconfig
@@ -161,7 +161,7 @@ CONFIG_STM32_JTAG_FULL_ENABLE=y
# CONFIG_STM32_JTAG_NOJNTRST_ENABLE is not set
# CONFIG_STM32_JTAG_SW_ENABLE is not set
# CONFIG_STM32_FORCEPOWER is not set
-# CONFIG_ARCH_BOARD_STM32_CUSTOM_CLOCKCONFIG is not set`
+# CONFIG_ARCH_BOARD_STM32_CUSTOM_CLOCKCONFIG is not set
#
# SPI Configuration
@@ -173,8 +173,8 @@ CONFIG_STM32_JTAG_FULL_ENABLE=y
# Ethernet MAC configuration
#
CONFIG_STM32_PHYADDR=1
-CONFIG_STM32_MII=y
-CONFIG_STM32_MII_MCO=y
+# CONFIG_STM32_MII is not set
+# CONFIG_STM32_MII_MCO is not set
# CONFIG_STM32_MII_EXTCLK is not set
CONFIG_STM32_AUTONEG=y
CONFIG_STM32_PHYSR=16
@@ -183,6 +183,9 @@ CONFIG_STM32_PHYSR_100MBPS=0x0000
CONFIG_STM32_PHYSR_MODE=0x0004
CONFIG_STM32_PHYSR_FULLDUPLEX=0x0004
# CONFIG_STM32_ETH_PTP is not set
+CONFIG_STM32_RMII=y
+CONFIG_STM32_RMII_MCO=y
+# CONFIG_STM32_RMII_EXTCLK is not set
#
# USB Host Configuration
From 45da426c19717b6e8c48058e1d67c833c16f44b9 Mon Sep 17 00:00:00 2001
From: patacongo
Date: Sat, 22 Sep 2012 19:19:56 +0000
Subject: [PATCH 11/31] STM32 Ethernet, Slightly differ register layout for
DM9161AEP PHY
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5177 42af7a65-404d-4744-a932-0658087f49c3
---
nuttx/arch/arm/src/stm32/Kconfig | 90 +++++++++++++++----
nuttx/arch/arm/src/stm32/stm32_eth.c | 81 ++++++++++++++---
.../configs/olimex-stm32-p107/include/board.h | 12 +--
nuttx/configs/shenzhou/include/board.h | 13 ++-
nuttx/configs/shenzhou/nsh/defconfig | 14 +--
5 files changed, 164 insertions(+), 46 deletions(-)
diff --git a/nuttx/arch/arm/src/stm32/Kconfig b/nuttx/arch/arm/src/stm32/Kconfig
index c7dae44608..26c4b20c91 100644
--- a/nuttx/arch/arm/src/stm32/Kconfig
+++ b/nuttx/arch/arm/src/stm32/Kconfig
@@ -1684,6 +1684,7 @@ config SDIO_WIDTH_D1_ONLY
endmenu
+if STM32_ETHMAC
menu "Ethernet MAC configuration"
config STM32_PHYADDR
@@ -1695,7 +1696,6 @@ config STM32_PHYADDR
config STM32_MII
bool "Use MII interface"
default n
- depends on STM32_ETHMAC
---help---
Support Ethernet MII interface.
@@ -1734,14 +1734,13 @@ endchoice
config STM32_AUTONEG
bool "Use autonegotiation"
default y
- depends on STM32_ETHMAC
---help---
Use PHY autonegotiation to determine speed and mode
config STM32_ETHFD
bool "Full duplex"
default n
- depends on STM32_ETHMAC && !STM32_AUTONEG
+ depends on !STM32_AUTONEG
---help---
If STM32_AUTONEG is not defined, then this may be defined to select full duplex
mode. Default: half-duplex
@@ -1749,61 +1748,104 @@ config STM32_ETHFD
config STM32_ETH100MBPS
bool "100 Mbps"
default n
- depends on STM32_ETHMAC && !STM32_AUTONEG
+ depends on !STM32_AUTONEG
---help---
If STM32_AUTONEG is not defined, then this may be defined to select 100 MBps
speed. Default: 10 Mbps
config STM32_PHYSR
- hex "PHY status register address"
+ int "PHY Status Register Address (decimal)"
depends on STM32_AUTONEG
---help---
This must be provided if STM32_AUTONEG is defined. The PHY status register
address may diff from PHY to PHY. This configuration sets the address of
the PHY status register.
-config STM32_PHYSR_SPEED
- hex "PHY speed mask"
+config STM32_PHYSR_ALTCONFIG
+ bool "PHY Status Alternate Bit Layout"
+ default n
depends on STM32_AUTONEG
+ ---help---
+ Different PHYs present speed and mode information in different ways. Some
+ will present separate information for speed and mode (this is the default).
+ Those PHYs, for example, may provide a 10/100 Mbps indication and a separate
+ full/half duplex indication. This options selects an alternative representation
+ where speed and mode information are combined. This might mean, for example,
+ separate bits for 10HD, 100HD, 10FD and 100FD.
+
+config STM32_PHYSR_SPEED
+ hex "PHY Speed Mask"
+ depends on STM32_AUTONEG && !STM32_PHYSR_ALTCONFIG
---help---
This must be provided if STM32_AUTONEG is defined. This provides bit mask
- indicating 10 or 100MBps speed.
+ for isolating the 10 or 100MBps speed indication.
config STM32_PHYSR_100MBPS
- hex "PHY 100Mbps speed value"
- depends on STM32_AUTONEG
+ hex "PHY 100Mbps Speed Value"
+ depends on STM32_AUTONEG && !STM32_PHYSR_ALTCONFIG
---help---
This must be provided if STM32_AUTONEG is defined. This provides the value
of the speed bit(s) indicating 100MBps speed.
config STM32_PHYSR_MODE
- hex "PHY mode mask"
- depends on STM32_AUTONEG
+ hex "PHY Mode Mask"
+ depends on STM32_AUTONEG && !STM32_PHYSR_ALTCONFIG
---help---
This must be provided if STM32_AUTONEG is defined. This provide bit mask
- indicating full or half duplex modes.
+ for isolating the full or half duplex mode bits.
config STM32_PHYSR_FULLDUPLEX
- hex "PHY full duplex mode value"
- depends on STM32_AUTONEG
+ hex "PHY Full Duplex Mode Value"
+ depends on STM32_AUTONEG && !STM32_PHYSR_ALTCONFIG
---help---
This must be provided if STM32_AUTONEG is defined. This provides the
value of the mode bits indicating full duplex mode.
+config STM32_PHYSR_ALTMODE
+ hex "PHY Mode Mask"
+ depends on STM32_AUTONEG && STM32_PHYSR_ALTCONFIG
+ ---help---
+ This must be provided if STM32_AUTONEG is defined. This provide bit mask
+ for isolating the speed and full/half duplex mode bits.
+
+config STM32_PHYSR_10HD
+ hex "10MHz/Half Duplex Value"
+ depends on STM32_AUTONEG && STM32_PHYSR_ALTCONFIG
+ ---help---
+ This must be provided if STM32_AUTONEG is defined. This is the value
+ under the bit mask that represents the 10Mbps, half duplex setting.
+
+config STM32_PHYSR_100HD
+ hex "100MHz/Half Duplex Value"
+ depends on STM32_AUTONEG && STM32_PHYSR_ALTCONFIG
+ ---help---
+ This must be provided if STM32_AUTONEG is defined. This is the value
+ under the bit mask that represents the 100Mbps, half duplex setting.
+
+config STM32_PHYSR_10FD
+ hex "10MHz/Full Duplex Value"
+ depends on STM32_AUTONEG && STM32_PHYSR_ALTCONFIG
+ ---help---
+ This must be provided if STM32_AUTONEG is defined. This is the value
+ under the bit mask that represents the 10Mbps, full duplex setting.
+
+config STM32_PHYSR_100FD
+ hex "100MHz/Full Duplex Value"
+ depends on STM32_AUTONEG && STM32_PHYSR_ALTCONFIG
+ ---help---
+ This must be provided if STM32_AUTONEG is defined. This is the value
+ under the bit mask that represents the 100Mbps, full duplex setting.
+
config STM32_ETH_PTP
bool "Precision Time Protocol (PTP)"
default n
- depends on STM32_ETHMAC
---help---
Precision Time Protocol (PTP). Not supported but some hooks are indicated
with this condition.
-endmenu
-
config STM32_RMII
bool
default y if !STM32_MII
- depends on STM32_ETHMAC
choice
prompt "RMII clock configuration"
@@ -1837,6 +1879,16 @@ config STM32_RMII_EXTCLK
endchoice
+config STM32_ETHMAC_REGDEBUG
+ bool "Register-Level Debug"
+ default n
+ depends on DEBUG
+ ---help---
+ Enable very low-level register access debug. Depends on DEBUG.
+
+endmenu
+endif
+
menu "USB Host Configuration"
config STM32_OTGFS_RXFIFO_SIZE
diff --git a/nuttx/arch/arm/src/stm32/stm32_eth.c b/nuttx/arch/arm/src/stm32/stm32_eth.c
index 51dd7e1862..b3392fa7a4 100644
--- a/nuttx/arch/arm/src/stm32/stm32_eth.c
+++ b/nuttx/arch/arm/src/stm32/stm32_eth.c
@@ -135,17 +135,35 @@
# ifndef CONFIG_STM32_PHYSR
# error "CONFIG_STM32_PHYSR must be defined in the NuttX configuration"
# endif
-# ifndef CONFIG_STM32_PHYSR_SPEED
-# error "CONFIG_STM32_PHYSR_SPEED must be defined in the NuttX configuration"
-# endif
-# ifndef CONFIG_STM32_PHYSR_100MBPS
-# error "CONFIG_STM32_PHYSR_100MBPS must be defined in the NuttX configuration"
-# endif
-# ifndef CONFIG_STM32_PHYSR_MODE
-# error "CONFIG_STM32_PHYSR_MODE must be defined in the NuttX configuration"
-# endif
-# ifndef CONFIG_STM32_PHYSR_FULLDUPLEX
-# error "CONFIG_STM32_PHYSR_FULLDUPLEX must be defined in the NuttX configuration"
+# ifdef CONFIG_STM32_PHYSR_ALTCONFIG
+# ifndef CONFIG_STM32_PHYSR_ALTMODE
+# error "CONFIG_STM32_PHYSR_ALTMODE must be defined in the NuttX configuration"
+# endif
+# ifndef CONFIG_STM32_PHYSR_10HD
+# error "CONFIG_STM32_PHYSR_10HD must be defined in the NuttX configuration"
+# endif
+# ifndef CONFIG_STM32_PHYSR_100HD
+# error "CONFIG_STM32_PHYSR_100HD must be defined in the NuttX configuration"
+# endif
+# ifndef CONFIG_STM32_PHYSR_10FD
+# error "CONFIG_STM32_PHYSR_10FD must be defined in the NuttX configuration"
+# endif
+# ifndef CONFIG_STM32_PHYSR_100FD
+# error "CONFIG_STM32_PHYSR_100FD must be defined in the NuttX configuration"
+# endif
+# else
+# ifndef CONFIG_STM32_PHYSR_SPEED
+# error "CONFIG_STM32_PHYSR_SPEED must be defined in the NuttX configuration"
+# endif
+# ifndef CONFIG_STM32_PHYSR_100MBPS
+# error "CONFIG_STM32_PHYSR_100MBPS must be defined in the NuttX configuration"
+# endif
+# ifndef CONFIG_STM32_PHYSR_MODE
+# error "CONFIG_STM32_PHYSR_MODE must be defined in the NuttX configuration"
+# endif
+# ifndef CONFIG_STM32_PHYSR_FULLDUPLEX
+# error "CONFIG_STM32_PHYSR_FULLDUPLEX must be defined in the NuttX configuration"
+# endif
# endif
#endif
@@ -2552,6 +2570,46 @@ static int stm32_phyinit(FAR struct stm32_ethmac_s *priv)
/* Remember the selected speed and duplex modes */
+ nvdbg("PHYSR[%d]: %04x\n", CONFIG_STM32_PHYSR, phyval);
+
+ /* Different PHYs present speed and mode information in different ways. IF
+ * This CONFIG_STM32_PHYSR_ALTCONFIG is selected, this indicates that the PHY
+ * represents speed and mode information are combined, for example, with
+ * separate bits for 10HD, 100HD, 10FD and 100FD.
+ */
+
+#ifdef CONFIG_STM32_PHYSR_ALTCONFIG
+ switch (phyval & CONFIG_STM32_PHYSR_ALTMODE)
+ {
+ default:
+ case CONFIG_STM32_PHYSR_10HD:
+ priv->fduplex = 0;
+ priv->mbps100 = 0;
+ break;
+
+ case CONFIG_STM32_PHYSR_100HD:
+ priv->fduplex = 0;
+ priv->mbps100 = 1;
+ break;
+
+ case CONFIG_STM32_PHYSR_10FD:
+ priv->fduplex = 1;
+ priv->mbps100 = 0;
+ break;
+
+ case CONFIG_STM32_PHYSR_100FD:
+ priv->fduplex = 1;
+ priv->mbps100 = 1;
+ break;
+ }
+
+ /* Different PHYs present speed and mode information in different ways. Some
+ * will present separate information for speed and mode (this is the default).
+ * Those PHYs, for example, may provide a 10/100 Mbps indication and a separate
+ * full/half duplex indication.
+ */
+
+#else
if ((phyval & CONFIG_STM32_PHYSR_MODE) == CONFIG_STM32_PHYSR_FULLDUPLEX)
{
priv->fduplex = 1;
@@ -2561,6 +2619,7 @@ static int stm32_phyinit(FAR struct stm32_ethmac_s *priv)
{
priv->mbps100 = 1;
}
+#endif
#else /* Auto-negotion not selected */
diff --git a/nuttx/configs/olimex-stm32-p107/include/board.h b/nuttx/configs/olimex-stm32-p107/include/board.h
index d531eb1129..42dd4f4d5b 100644
--- a/nuttx/configs/olimex-stm32-p107/include/board.h
+++ b/nuttx/configs/olimex-stm32-p107/include/board.h
@@ -50,8 +50,6 @@
* Pre-processor Definitions
************************************************************************************/
-#define BOARD_CFGR_MCO_SOURCE RCC_CFGR_PLL3CLK
-
/* Clocking *************************************************************************/
/* On-board crystal frequency is 25MHz (HSE) */
@@ -97,10 +95,14 @@
#define STM32_APB1_TIM6_CLKIN (STM32_PCLK1_FREQUENCY)
#define STM32_APB1_TIM7_CLKIN (STM32_PCLK1_FREQUENCY)
-/* MCO output */
-
+/* MCO output driven by PLL3. From above, we already have PLL3 input frequency as:
+ *
+ * STM32_PLL_PREDIV2 = 5, 25MHz / 5 => 5MHz
+ */
+
#if defined(CONFIG_STM32_MII_MCO) || defined(CONFIG_STM32_RMII_MCO)
-# define STM32_PLL_PLL3MUL RCC_CFGR2_PLL3MULx10
+# define BOARD_CFGR_MCO_SOURCE RCC_CFGR_PLL3CLK /* Source: PLL3 */
+# define STM32_PLL_PLL3MUL RCC_CFGR2_PLL3MULx10 /* MCO 5MHz * 10 = 50MHz */
#endif
/************************************************************************************
diff --git a/nuttx/configs/shenzhou/include/board.h b/nuttx/configs/shenzhou/include/board.h
index df4386cf1b..d396e25631 100644
--- a/nuttx/configs/shenzhou/include/board.h
+++ b/nuttx/configs/shenzhou/include/board.h
@@ -50,8 +50,6 @@
* Pre-processor Definitions
************************************************************************************/
-#define BOARD_CFGR_MCO_SOURCE RCC_CFGR_PLL3CLK
-
/* Clocking *************************************************************************/
/* On-board crystal frequency is 25MHz (HSE) */
@@ -97,10 +95,14 @@
#define STM32_APB1_TIM6_CLKIN (STM32_PCLK1_FREQUENCY)
#define STM32_APB1_TIM7_CLKIN (STM32_PCLK1_FREQUENCY)
-/* MCO output */
+/* MCO output driven by PLL3. From above, we already have PLL3 input frequency as:
+ *
+ * STM32_PLL_PREDIV2 = 5, 25MHz / 5 => 5MHz
+ */
#if defined(CONFIG_STM32_MII_MCO) || defined(CONFIG_STM32_RMII_MCO)
-# define STM32_PLL_PLL3MUL RCC_CFGR2_PLL3MULx10
+# define BOARD_CFGR_MCO_SOURCE RCC_CFGR_PLL3CLK /* Source: PLL3 */
+# define STM32_PLL_PLL3MUL RCC_CFGR2_PLL3MULx10 /* MCO 5MHz * 10 = 50MHz */
#endif
/* LED definitions ******************************************************************/
@@ -179,6 +181,9 @@
* 56 PD9 MII_RXD0 Ethernet PHY. Requires CONFIG_STM32_ETH_REMAP
* 57 PD10 MII_RXD1 Ethernet PHY. Requires CONFIG_STM32_ETH_REMAP
*
+ * The board desdign can support a 50MHz external clock to drive the PHY
+ * (U9). However, on my board, U9 is not present.
+ *
* 67 PA8 MCO DM9161AEP
*/
diff --git a/nuttx/configs/shenzhou/nsh/defconfig b/nuttx/configs/shenzhou/nsh/defconfig
index 053717470e..c4817c2ee0 100644
--- a/nuttx/configs/shenzhou/nsh/defconfig
+++ b/nuttx/configs/shenzhou/nsh/defconfig
@@ -174,14 +174,14 @@ CONFIG_STM32_JTAG_FULL_ENABLE=y
#
CONFIG_STM32_PHYADDR=1
# CONFIG_STM32_MII is not set
-# CONFIG_STM32_MII_MCO is not set
-# CONFIG_STM32_MII_EXTCLK is not set
CONFIG_STM32_AUTONEG=y
-CONFIG_STM32_PHYSR=16
-CONFIG_STM32_PHYSR_SPEED=0x0002
-CONFIG_STM32_PHYSR_100MBPS=0x0000
-CONFIG_STM32_PHYSR_MODE=0x0004
-CONFIG_STM32_PHYSR_FULLDUPLEX=0x0004
+CONFIG_STM32_PHYSR=17
+CONFIG_STM32_PHYSR_ALTCONFIG=y
+CONFIG_STM32_PHYSR_ALTMODE=0xf000
+CONFIG_STM32_PHYSR_10HD=0x1000
+CONFIG_STM32_PHYSR_100HD=0x4000
+CONFIG_STM32_PHYSR_10FD=0x2000
+CONFIG_STM32_PHYSR_100FD=0x8000
# CONFIG_STM32_ETH_PTP is not set
CONFIG_STM32_RMII=y
CONFIG_STM32_RMII_MCO=y
From c9bb9dd995c571e8406683c6b88b3f757460ffbb Mon Sep 17 00:00:00 2001
From: patacongo
Date: Sat, 22 Sep 2012 20:36:36 +0000
Subject: [PATCH 12/31] Adds support for keep-alive connections to webserver
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5178 42af7a65-404d-4744-a932-0658087f49c3
---
apps/ChangeLog.txt | 2 +
apps/include/netutils/httpd.h | 3 ++
apps/netutils/webserver/Kconfig | 18 ++++++++
apps/netutils/webserver/httpd.c | 76 +++++++++++++++++++++++++++------
4 files changed, 86 insertions(+), 13 deletions(-)
diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt
index c5b8dec92d..46ccccc7fb 100644
--- a/apps/ChangeLog.txt
+++ b/apps/ChangeLog.txt
@@ -338,3 +338,5 @@
Both from Kate.
* apps/netutils/webserver/httpd.c: Improvements to HTTP parser from
Kate.
+ * apps/netutils/webserver/httpd.c: Add support for Keep-alive connections
+ (from Kate).
diff --git a/apps/include/netutils/httpd.h b/apps/include/netutils/httpd.h
index 0318408023..20ddff2788 100644
--- a/apps/include/netutils/httpd.h
+++ b/apps/include/netutils/httpd.h
@@ -109,6 +109,9 @@ struct httpd_state
{
char ht_buffer[HTTPD_IOBUFFER_SIZE]; /* recv() buffer */
char ht_filename[HTTPD_MAX_FILENAME]; /* filename from GET command */
+#ifndef CONFIG_NETUTILS_HTTPD_KEEPALIVE_DISABLE
+ bool ht_keepalive; /* Connection: keep-alive */
+#endif
struct httpd_fs_file ht_file; /* Fake file data to send */
int ht_sockfd; /* The socket descriptor from accept() */
char *ht_scriptptr;
diff --git a/apps/netutils/webserver/Kconfig b/apps/netutils/webserver/Kconfig
index edca8dfdd2..69a39510d6 100644
--- a/apps/netutils/webserver/Kconfig
+++ b/apps/netutils/webserver/Kconfig
@@ -117,4 +117,22 @@ config NETUTILS_HTTPD_MMAP
representation.
endchoice
+
+config NETUTILS_HTTPD_KEEPALIVE_DISABLE
+ bool "Keepalive Disable"
+ default y if !NETUTILS_HTTPD_TIMEOUT
+ default n if NETUTILS_HTTPD_TIMEOUT
+ ---help---
+ Disabled HTTP keep-alive for HTTP clients. Keep-alive permits a
+ client to make multiple requests over the same connection, rather
+ than closing and opening a new socket for each request.
+
+ This depends on the content-length being known, and is automatically
+ disabled for situations where that header isn't produced (i.e.
+ scripting, CGI). Keep-alive is also disabled for certain error
+ responses.
+
+ Keep-alive should normally be disabled if timeouts are enabled,
+ otherwise a rogue HTTP client could block the httpd indefinitely.
+
endif
diff --git a/apps/netutils/webserver/httpd.c b/apps/netutils/webserver/httpd.c
index ebcf300b68..d7dae55da8 100644
--- a/apps/netutils/webserver/httpd.c
+++ b/apps/netutils/webserver/httpd.c
@@ -104,6 +104,16 @@
# define CONFIG_NETUTILS_HTTPD_TIMEOUT 0
#endif
+/* If timeouts are not enabled, then keep-alive is disabled. This is to
+ * prevent a rogue HTTP client from blocking the httpd indefinitely.
+ */
+
+#if !defined(CONFIG_NETUTILS_HTTPD_KEEPALIVE_DISABLE)
+# if CONFIG_NETUTILS_HTTPD_TIMEOUT == 0
+# define CONFIG_NETUTILS_HTTPD_KEEPALIVE_DISABLE
+# endif
+#endif
+
#if !defined(CONFIG_NETUTILS_HTTPD_SENDFILE) && !defined(CONFIG_NETUTILS_HTTPD_MMAP)
# ifndef CONFIG_NETUTILS_HTTPD_INDEX
# ifndef CONFIG_NETUTILS_HTTPD_SCRIPT_DISABLE
@@ -372,6 +382,12 @@ static int send_headers(struct httpd_state *pstate, int status, int len)
{
(void) snprintf(cl, sizeof cl, "Content-Length: %d\r\n", len);
}
+#ifndef CONFIG_NETUTILS_HTTPD_KEEPALIVE_DISABLE
+ else
+ {
+ pstate->ht_keepalive = false;
+ }
+#endif
if (status == 413)
{
@@ -383,12 +399,17 @@ static int send_headers(struct httpd_state *pstate, int status, int len)
#ifndef CONFIG_NETUTILS_HTTPD_SERVERHEADER_DISABLE
"Server: uIP/NuttX http://nuttx.org/\r\n"
#endif
- "Connection: close\r\n"
+ "Connection: %s\r\n"
"Content-type: %s\r\n"
"%s"
"\r\n",
status,
status >= 400 ? "Error" : "OK",
+#ifndef CONFIG_NETUTILS_HTTPD_KEEPALIVE_DISABLE
+ pstate->ht_keepalive ? "keep-alive" : "close",
+#else
+ "close",
+#endif
mime,
len >= 0 ? cl : "");
@@ -407,6 +428,13 @@ static int httpd_senderror(struct httpd_state *pstate, int status)
status = 500;
}
+#ifndef CONFIG_NETUTILS_HTTPD_KEEPALIVE_DISABLE
+ if (status != 404)
+ {
+ pstate->ht_keepalive = false;
+ }
+#endif
+
(void) snprintf(pstate->ht_filename, sizeof pstate->ht_filename,
"%s/%d.html",
CONFIG_NETUTILS_HTTPD_ERRPATH, status);
@@ -456,6 +484,9 @@ static int httpd_sendfile(struct httpd_state *pstate)
f = httpd_cgi(pstate->ht_filename);
if (f != NULL)
{
+#ifndef CONFIG_NETUTILS_HTTPD_KEEPALIVE_DISABLE
+ pstate->ht_keepalive = false;
+#endif
f(pstate, pstate->ht_filename);
return OK;
@@ -474,6 +505,9 @@ static int httpd_sendfile(struct httpd_state *pstate)
if (ptr != NULL &&
strncmp(ptr, ".shtml", strlen(".shtml")) == 0)
{
+#ifndef CONFIG_NETUTILS_HTTPD_KEEPALIVE_DISABLE
+ pstate->ht_keepalive = false;
+#endif
if (send_headers(pstate, 200, -1) != OK)
{
goto done;
@@ -594,7 +628,7 @@ static inline int httpd_parse(struct httpd_state *pstate)
if (0 != strcmp(v, " HTTP/1.0") && 0 != strcmp(v, " HTTP/1.1"))
{
- ndbg("[%d] HTTP/%d.%d not supported\n", major, minor);
+ ndbg("[%d] HTTP version not supported\n");
return 505;
}
@@ -638,7 +672,12 @@ static inline int httpd_parse(struct httpd_state *pstate)
ndbg("[%d] non-zero request length\n");
return 413;
}
-
+#ifndef CONFIG_NETUTILS_HTTPD_KEEPALIVE_DISABLE
+ else if (0 == strcasecmp(start, "Connection") && 0 == strcasecmp(v, "keep-alive"))
+ {
+ pstate->ht_keepalive = true;
+ }
+#endif
break;
case STATE_BODY:
@@ -650,7 +689,7 @@ static inline int httpd_parse(struct httpd_state *pstate)
/* Shuffle down for the next block */
memmove(pstate->ht_buffer, start, o - start);
- o -= start;
+ o -= (start - pstate->ht_buffer);
}
while (state != STATE_BODY);
@@ -695,17 +734,28 @@ static void *httpd_handler(void *arg)
memset(pstate, 0, sizeof(struct httpd_state));
pstate->ht_sockfd = sockfd;
- /* Then handle the next httpd command */
+#ifndef CONFIG_NETUTILS_HTTPD_KEEPALIVE_DISABLE
+ do
+ {
+ pstate->ht_keepalive = false;
+#endif
- status = httpd_parse(pstate);
- if (status >= 400)
- {
- ret = httpd_senderror(pstate, status);
- }
- else
- {
- ret = httpd_sendfile(pstate);
+ /* Then handle the next httpd command */
+
+ status = httpd_parse(pstate);
+ if (status >= 400)
+ {
+ ret = httpd_senderror(pstate, status);
+ }
+ else
+ {
+ ret = httpd_sendfile(pstate);
+ }
+
+#ifndef CONFIG_NETUTILS_HTTPD_KEEPALIVE_DISABLE
}
+ while (pstate->ht_keepalive);
+#endif
/* End of command processing -- Clean up and exit */
From 5b51b5e3a4a0446323c9f2dec527fb9484093c63 Mon Sep 17 00:00:00 2001
From: patacongo
Date: Sat, 22 Sep 2012 20:38:43 +0000
Subject: [PATCH 13/31] hpttd.h needs to include stdbool.h
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5179 42af7a65-404d-4744-a932-0658087f49c3
---
apps/include/netutils/httpd.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/apps/include/netutils/httpd.h b/apps/include/netutils/httpd.h
index 20ddff2788..2eb0d5bdeb 100644
--- a/apps/include/netutils/httpd.h
+++ b/apps/include/netutils/httpd.h
@@ -46,6 +46,9 @@
#include
+#include
+#include
+
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
From b58026b8f00d74550279392ae0d83f5acea978bb Mon Sep 17 00:00:00 2001
From: patacongo
Date: Sat, 22 Sep 2012 22:25:21 +0000
Subject: [PATCH 14/31] Add missing STM32 F1 pin remapping definitions
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5180 42af7a65-404d-4744-a932-0658087f49c3
---
apps/netutils/webserver/httpd.c | 1 -
.../arm/src/stm32/chip/stm32f10xxx_gpio.h | 80 +++++++++++--------
nuttx/arch/arm/src/stm32/stm32_gpio.c | 69 +++++++++-------
.../configs/shenzhou/src/shenzhou-internal.h | 28 +++++++
4 files changed, 111 insertions(+), 67 deletions(-)
diff --git a/apps/netutils/webserver/httpd.c b/apps/netutils/webserver/httpd.c
index d7dae55da8..f96fc5a6c4 100644
--- a/apps/netutils/webserver/httpd.c
+++ b/apps/netutils/webserver/httpd.c
@@ -739,7 +739,6 @@ static void *httpd_handler(void *arg)
{
pstate->ht_keepalive = false;
#endif
-
/* Then handle the next httpd command */
status = httpd_parse(pstate);
diff --git a/nuttx/arch/arm/src/stm32/chip/stm32f10xxx_gpio.h b/nuttx/arch/arm/src/stm32/chip/stm32f10xxx_gpio.h
index feeeda6dd2..a95d13100e 100644
--- a/nuttx/arch/arm/src/stm32/chip/stm32f10xxx_gpio.h
+++ b/nuttx/arch/arm/src/stm32/chip/stm32f10xxx_gpio.h
@@ -265,48 +265,58 @@
/* AF remap and debug I/O configuration register */
-#define AFIO_MAPR_SWJ_CFG_SHIFT (24) /* Bits 26-24: Serial Wire JTAG configuration*/
+#define AFIO_MAPR_SPI1_REMAP (1 << 0) /* Bit 0: SPI1 remapping */
+#define AFIO_MAPR_I2C1_REMAP (1 << 1) /* Bit 1: I2C1 remapping */
+#define AFIO_MAPR_USART1_REMAP (1 << 2) /* Bit 2: USART1 remapping */
+#define AFIO_MAPR_USART2_REMAP (1 << 3) /* Bit 3: USART2 remapping */
+#define AFIO_MAPR_USART3_REMAP_SHIFT (4) /* Bits 5-4: USART3 remapping */
+#define AFIO_MAPR_USART3_REMAP_MASK (3 << AFIO_MAPR_USART3_REMAP_SHIFT)
+# define AFIO_MAPR_USART3_NOREMAP (0 << AFIO_MAPR_USART3_REMAP_SHIFT) /* 00: No remap */
+# define AFIO_MAPR_USART3_PARTREMAP (1 << AFIO_MAPR_USART3_REMAP_SHIFT) /* 01: Partial remap */
+# define AFIO_MAPR_USART3_FULLREMAP (3 << AFIO_MAPR_USART3_REMAP_SHIFT) /* 11: Full remap */
+#define AFIO_MAPR_TIM1_REMAP_SHIFT (6) /* Bits 7-6: TIM1 remapping */
+#define AFIO_MAPR_TIM1_REMAP_MASK (3 << AFIO_MAPR_TIM1_REMAP_SHIFT)
+# define AFIO_MAPR_TIM1_NOREMAP (0 << AFIO_MAPR_TIM1_REMAP_SHIFT) /* 00: No remap */
+# define AFIO_MAPR_TIM1_PARTREMAP (1 << AFIO_MAPR_TIM1_REMAP_SHIFT) /* 01: Partial remap */
+# define AFIO_MAPR_TIM1_FULLREMAP (3 << AFIO_MAPR_TIM1_REMAP_SHIFT) /* 11: Full remap */
+#define AFIO_MAPR_TIM2_REMAP_SHIFT (8) /* Bits 9-8: TIM2 remapping */
+#define AFIO_MAPR_TIM2_REMAP_MASK (3 << AFIO_MAPR_TIM2_REMAP_SHIFT)
+# define AFIO_MAPR_TIM2_NOREMAP (0 << AFIO_MAPR_TIM2_REMAP_SHIFT) /* 00: No remap */
+# define AFIO_MAPR_TIM2_PARTREMAP1 (1 << AFIO_MAPR_TIM2_REMAP_SHIFT) /* 01: Partial remap */
+# define AFIO_MAPR_TIM2_PARTREMAP2 (2 << AFIO_MAPR_TIM2_REMAP_SHIFT) /* 10: Partial remap */
+# define AFIO_MAPR_TIM2_FULLREMAP (3 << AFIO_MAPR_TIM2_REMAP_SHIFT) /* 11: Full remap */
+#define AFIO_MAPR_TIM3_REMAP_SHIFT (10) /* Bits 11-10: TIM3 remapping */
+#define AFIO_MAPR_TIM3_REMAP_MASK (3 << AFIO_MAPR_TIM3_REMAP_SHIFT)
+# define AFIO_MAPR_TIM3_NOREMAP (0 << AFIO_MAPR_TIM3_REMAP_SHIFT) /* 00: No remap */
+# define AFIO_MAPR_TIM3_PARTREMAP (2 << AFIO_MAPR_TIM3_REMAP_SHIFT) /* 10: Partial remap */
+# define AFIO_MAPR_TIM3_FULLREMAP (3 << AFIO_MAPR_TIM3_REMAP_SHIFT) /* 11: Full remap */
+#define AFIO_MAPR_TIM4_REMAP (1 << 12) /* Bit 12: TIM4 remapping */
+#define AFIO_MAPR_CAN1_REMAP_SHIFT (13) /* Bits 14-13: CAN Alternate function remapping */
+#define AFIO_MAPR_CAN1_REMAP_MASK (3 << AFIO_MAPR_CAN1_REMAP_SHIFT)
+# define AFIO_MAPR_PA1112 (0 << AFIO_MAPR_CAN1_REMAP_SHIFT) /* 00: CANRX mapped to PA11, CANTX mapped to PA12 */
+# define AFIO_MAPR_PB89 (2 << AFIO_MAPR_CAN1_REMAP_SHIFT) /* 10: CANRX mapped to PB8, CANTX mapped to PB9 */
+# define AFIO_MAPR_PD01 (3 << AFIO_MAPR_CAN1_REMAP_SHIFT) /* 11: CANRX mapped to PD0, CANTX mapped to PD1 */
+#define AFIO_MAPR_PD01_REMAP (1 << 15) /* Bit 15 : Port D0/Port D1 mapping on OSC_IN/OSC_OUT */
+#define AFIO_MAPR_TIM5CH4_IREMAP (1 << 16) /* Bit 16: TIM5 channel4 internal remap */
+ /* Bits 17-20: Reserved */
+#ifdef CONFIG_STM32_CONNECTIVITYLINE
+# define AFIO_MAPR_ETH_REMAP (1 << 21) /* Bit 21: Ethernet MAC I/O remapping */
+# define AFIO_MAPR_CAN2_REMAP (1 << 22) /* Bit 22: CAN2 I/O remapping */
+# define AFIO_MAPR_MII_RMII_SEL (1 << 23) /* Bit 23: MII or RMII selection */
+#endif
+#define AFIO_MAPR_SWJ_CFG_SHIFT (24) /* Bits 26-24: Serial Wire JTAG configuration */
#define AFIO_MAPR_SWJ_CFG_MASK (7 << AFIO_MAPR_SWJ_CFG_SHIFT)
# define AFIO_MAPR_SWJRST (0 << AFIO_MAPR_SWJ_CFG_SHIFT) /* 000: Full SWJ (JTAG-DP + SW-DP): Reset State */
# define AFIO_MAPR_SWJ (1 << AFIO_MAPR_SWJ_CFG_SHIFT) /* 001: Full SWJ (JTAG-DP + SW-DP) but without JNTRST */
# define AFIO_MAPR_SWDP (2 << AFIO_MAPR_SWJ_CFG_SHIFT) /* 010: JTAG-DP Disabled and SW-DP Enabled */
# define AFIO_MAPR_DISAB (4 << AFIO_MAPR_SWJ_CFG_SHIFT) /* 100: JTAG-DP Disabled and SW-DP Disabled */
+ /* Bit 27: Reserved */
#ifdef CONFIG_STM32_CONNECTIVITYLINE
-# define AFIO_MAPR_MII_RMII_SEL (1 << 23) /* MII or RMII selection */
+# define AFIO_MAPR_SPI3_REMAP (1 << 28) /* Bit 28: SPI3 remapping */
+# define AFIO_MAPR_TIM2ITR1_IREMAP (1 << 29) /* Bit 29: TIM2 internal trigger 1 remapping */
+# define AFIO_MAPR_PTP_PPS_REMAP (1 << 30) /* Bit 30: Ethernet PTP PPS remapping */
#endif
-#define AFIO_MAPR_PD01_REMAP (1 << 15) /* Bit 15 : Port D0/Port D1 mapping on OSC_IN/OSC_OUT */
-#define AFIO_MAPR_CAN_REMAP_SHIFT (13) /* Bits 14-13: CAN Alternate function remapping */
-#define AFIO_MAPR_CAN_REMAP_MASK (3 << AFIO_MAPR_CAN_REMAP_SHIFT)
-# define AFIO_MAPR_PA1112 (0 << AFIO_MAPR_CAN_REMAP_SHIFT) /* 00: CANRX mapped to PA11, CANTX mapped to PA12 */
-# define AFIO_MAPR_PB89 (2 << AFIO_MAPR_CAN_REMAP_SHIFT) /* 10: CANRX mapped to PB8, CANTX mapped to PB9 */
-# define AFIO_MAPR_PD01 (3 << AFIO_MAPR_CAN_REMAP_SHIFT) /* 11: CANRX mapped to PD0, CANTX mapped to PD1 */
-#define AFIO_MAPR_TIM4_REMAP (1 << 12) /* Bit 12: TIM4 remapping */
-#define AFIO_MAPR_TIM3_REMAP_SHIFT (10) /* Bits 11-10: TIM3 remapping */
-#define AFIO_MAPR_TIM3_REMAP_MASK (3 << AFIO_MAPR_TIM3_REMAP_SHIFT)
-# define AFIO_MAPR_TIM3_NOREMAP (0 << AFIO_MAPR_TIM3_REMAP_SHIFT) /* 00: No remap (CH1/PA6, CH2/PA7, CH3/PB0, CH4/PB1) */
-# define AFIO_MAPR_TIM3_PARTREMAP (2 << AFIO_MAPR_TIM3_REMAP_SHIFT) /* 10: Partial remap (CH1/PB4, CH2/PB5, CH3/PB0, CH4/PB1) */
-# define AFIO_MAPR_TIM3_FULLREMAP (3 << AFIO_MAPR_TIM3_REMAP_SHIFT) /* 11: Full remap (CH1/PC6, CH2/PC7, CH3/PC8, CH4/PC9) */
-#define AFIO_MAPR_TIM2_REMAP_SHIFT (8) /* Bits 9-8: TIM2 remapping */
-#define AFIO_MAPR_TIM2_REMAP_MASK (3 << AFIO_MAPR_TIM2_REMAP_SHIFT)
-# define AFIO_MAPR_TIM2_NOREMAP (0 << AFIO_MAPR_TIM2_REMAP_SHIFT) /* 00: No remap (CH1/ETR/PA0, CH2/PA1, CH3/PA2, CH4/PA3) */
-# define AFIO_MAPR_TIM2_PARTREMAP1 (1 << AFIO_MAPR_TIM2_REMAP_SHIFT) /* 01: Partial remap (CH1/ETR/PA15, CH2/PB3, CH3/PA2, CH4/PA3) */
-# define AFIO_MAPR_TIM2_PARTREMAP2 (2 << AFIO_MAPR_TIM2_REMAP_SHIFT) /* 10: Partial remap (CH1/ETR/PA0, CH2/PA1, CH3/PB10, CH4/PB11) */
-# define AFIO_MAPR_TIM2_FULLREMAP (3 << AFIO_MAPR_TIM2_REMAP_SHIFT) /* 11: Full remap (CH1/ETR/PA15, CH2/PB3, CH3/PB10, CH4/PB11) */
-#define AFIO_MAPR_TIM1_REMAP_SHIFT (6) /* Bits 7-6: TIM1 remapping */
-#define AFIO_MAPR_TIM1_REMAP_MASK (3 << AFIO_MAPR_TIM1_REMAP_SHIFT)
-# define AFIO_MAPR_TIM1_NOREMAP (0 << AFIO_MAPR_TIM1_REMAP_SHIFT) /* 00: No remap (ETR/PA12, CH1/PA8, CH2/PA9, CH3/PA10, CH4/PA11, BKIN/PB12, CH1N/PB13, CH2N/PB14, CH3N/PB15) */
-# define AFIO_MAPR_TIM1_PARTREMAP (1 << AFIO_MAPR_TIM1_REMAP_SHIFT) /* 01: Partial remap (ETR/PA12, CH1/PA8, CH2/PA9, CH3/PA10, CH4/PA11, BKIN/PA6, CH1N/PA7, CH2N/PB0, CH3N/PB1) */
-# define AFIO_MAPR_TIM1_FULLREMAP (3 << AFIO_MAPR_TIM1_REMAP_SHIFT) /* 11: Full remap (ETR/PE7, CH1/PE9, CH2/PE11, CH3/PE13, CH4/PE14, BKIN/PE15, CH1N/PE8, CH2N/PE10, CH3N/PE12) */
-#define AFIO_MAPR_USART3_REMAP_SHIFT (6) /* Bits 5-4: USART3 remapping */
-#define AFIO_MAPR_USART3_REMAP_MASK (3 << AFIO_MAPR_USART3_REMAP_SHIFT)
-# define AFIO_MAPR_USART3_NOREMAP (0 << AFIO_MAPR_USART3_REMAP_SHIFT) /* 00: No remap (TX/PB10, RX/PB11, CK/PB12, CTS/PB13, RTS/PB14) */
-# define AFIO_MAPR_USART3_PARTREMAP (1 << AFIO_MAPR_USART3_REMAP_SHIFT) /* 01: Partial remap (TX/PC10, RX/PC11, CK/PC12, CTS/PB13, RTS/PB14) */
-# define AFIO_MAPR_USART3_FULLREMAP (3 << AFIO_MAPR_USART3_REMAP_SHIFT) /* 11: Full remap (TX/PD8, RX/PD9, CK/PD10, CTS/PD11, RTS/PD12) */
-#define AFIO_MAPR_USART2_REMAP (1 << 3) /* Bit 3: USART2 remapping */
-#define AFIO_MAPR_USART1_REMAP (1 << 2) /* Bit 2: USART1 remapping */
-#define AFIO_MAPR_I2C1_REMAP (1 << 1) /* Bit 1: I2C1 remapping */
-#define AFIO_MAPR_SPI1_REMAP (1 << 0) /* Bit 0: SPI1 remapping */
-
+ /* Bit 31: Reserved */
/* External interrupt configuration register 1 */
#define AFIO_EXTICR_PORT_MASK (0x0f)
diff --git a/nuttx/arch/arm/src/stm32/stm32_gpio.c b/nuttx/arch/arm/src/stm32/stm32_gpio.c
index 143e48a2c8..4703e82089 100644
--- a/nuttx/arch/arm/src/stm32/stm32_gpio.c
+++ b/nuttx/arch/arm/src/stm32/stm32_gpio.c
@@ -124,14 +124,27 @@ static inline void stm32_gpioremap(void)
uint32_t val = 0;
-#ifdef CONFIG_STM32_JTAG_FULL_ENABLE
- /* The reset default */
-#elif CONFIG_STM32_JTAG_NOJNTRST_ENABLE
- val |= AFIO_MAPR_SWJ; /* enabled but without JNTRST */
-#elif CONFIG_STM32_JTAG_SW_ENABLE
- val |= AFIO_MAPR_SWDP; /* set JTAG-DP disabled and SW-DP enabled */
-#else
- val |= AFIO_MAPR_DISAB; /* set JTAG-DP and SW-DP Disabled */
+#ifdef CONFIG_STM32_SPI1_REMAP
+ val |= AFIO_MAPR_SPI1_REMAP;
+#endif
+#ifdef CONFIG_STM32_SPI3_REMAP
+#endif
+
+#ifdef CONFIG_STM32_I2C1_REMAP
+ val |= AFIO_MAPR_I2C1_REMAP;
+#endif
+
+#ifdef CONFIG_STM32_USART1_REMAP
+ val |= AFIO_MAPR_USART1_REMAP;
+#endif
+#ifdef CONFIG_STM32_USART2_REMAP
+ val |= AFIO_MAPR_USART2_REMAP;
+#endif
+#ifdef CONFIG_STM32_USART3_FULL_REMAP
+ val |= AFIO_MAPR_USART3_FULLREMAP;
+#endif
+#ifdef CONFIG_STM32_USART3_PARTIAL_REMAP
+ val |= AFIO_MAPR_USART3_PARTREMAP;
#endif
#ifdef CONFIG_STM32_TIM1_FULL_REMAP
@@ -159,35 +172,29 @@ static inline void stm32_gpioremap(void)
val |= AFIO_MAPR_TIM4_REMAP;
#endif
-#ifdef CONFIG_STM32_USART1_REMAP
- val |= AFIO_MAPR_USART1_REMAP;
-#endif
-#ifdef CONFIG_STM32_USART2_REMAP
- val |= AFIO_MAPR_USART2_REMAP;
-#endif
-#ifdef CONFIG_STM32_USART3_FULL_REMAP
- val |= AFIO_MAPR_USART3_FULLREMAP;
-#endif
-#ifdef CONFIG_STM32_USART3_PARTIAL_REMAP
- val |= AFIO_MAPR_USART3_PARTREMAP;
-#endif
-
-#ifdef CONFIG_STM32_SPI1_REMAP
- val |= AFIO_MAPR_SPI1_REMAP;
-#endif
-#ifdef CONFIG_STM32_SPI3_REMAP
-#endif
-
-#ifdef CONFIG_STM32_I2C1_REMAP
- val |= AFIO_MAPR_I2C1_REMAP;
-#endif
-
#ifdef CONFIG_STM32_CAN1_REMAP1
val |= AFIO_MAPR_PB89;
#endif
#ifdef CONFIG_STM32_CAN1_REMAP2
val |= AFIO_MAPR_PD01;
#endif
+#ifdef CONFIG_STM32_CAN2_REMAP /* Connectivity line only */
+ val |= AFIO_MAPR_CAN2_REMAP;
+#endif
+
+#ifdef CONFIG_STM32_ETH_REMAP /* Connectivity line only */
+ val |= AFIO_MAPR_ETH_REMAP;
+#endif
+
+#ifdef CONFIG_STM32_JTAG_FULL_ENABLE
+ /* The reset default */
+#elif CONFIG_STM32_JTAG_NOJNTRST_ENABLE
+ val |= AFIO_MAPR_SWJ; /* enabled but without JNTRST */
+#elif CONFIG_STM32_JTAG_SW_ENABLE
+ val |= AFIO_MAPR_SWDP; /* set JTAG-DP disabled and SW-DP enabled */
+#else
+ val |= AFIO_MAPR_DISAB; /* set JTAG-DP and SW-DP Disabled */
+#endif
putreg32(val, STM32_AFIO_MAPR);
#endif
diff --git a/nuttx/configs/shenzhou/src/shenzhou-internal.h b/nuttx/configs/shenzhou/src/shenzhou-internal.h
index 48b06e7b0a..b5fb4e35c0 100644
--- a/nuttx/configs/shenzhou/src/shenzhou-internal.h
+++ b/nuttx/configs/shenzhou/src/shenzhou-internal.h
@@ -65,6 +65,34 @@
/* Shenzhou GPIO Configuration **********************************************************************/
/* STM3240G-EVAL GPIOs ******************************************************************************/
+/* Ethernet
+ *
+ * -- ---- -------------- ----------------------------------------------------------
+ * PN NAME SIGNAL NOTES
+ * -- ---- -------------- ----------------------------------------------------------
+ * 24 PA1 MII_RX_CLK Ethernet PHY NOTE: Despite the MII labeling of these
+ * RMII_REF_CLK Ethernet PHY signals, the DM916AEP is actually configured
+ * 25 PA2 MII_MDIO Ethernet PHY to work in RMII mode.
+ * 48 PB11 MII_TX_EN Ethernet PHY
+ * 51 PB12 MII_TXD0 Ethernet PHY
+ * 52 PB13 MII_TXD1 Ethernet PHY
+ * 16 PC1 MII_MDC Ethernet PHY
+ * 34 PC5 MII_INT Ethernet PHY
+ * 55 PD8 MII_RX_DV Ethernet PHY. Requires CONFIG_STM32_ETH_REMAP
+ * 55 PD8 RMII_CRSDV Ethernet PHY. Requires CONFIG_STM32_ETH_REMAP
+ * 56 PD9 MII_RXD0 Ethernet PHY. Requires CONFIG_STM32_ETH_REMAP
+ * 57 PD10 MII_RXD1 Ethernet PHY. Requires CONFIG_STM32_ETH_REMAP
+ *
+ * The board desdign can support a 50MHz external clock to drive the PHY
+ * (U9). However, on my board, U9 is not present.
+ *
+ * 67 PA8 MCO DM9161AEP
+ */
+
+#ifdef CONFIG_STM32_ETHMAC
+# define GPIO_MII_INT (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_EXTI|GPIO_PORTC|GPIO_PIN5)
+#endif
+
/* Wireless
*
* -- ---- -------------- -------------------------------------------------------------------
From 8da267c51855c21067b258bffcfa479ae52274c7 Mon Sep 17 00:00:00 2001
From: patacongo
Date: Sun, 23 Sep 2012 15:22:27 +0000
Subject: [PATCH 15/31] Shenzhou PHY address should be 0; make sure the F2/F4
bits are not set when using STM32 ethernet driver with F1
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5181 42af7a65-404d-4744-a932-0658087f49c3
---
nuttx/arch/arm/src/stm32/chip/stm32_eth.h | 27 +++++++++++++----
nuttx/arch/arm/src/stm32/stm32_eth.c | 35 ++++++++++++++++-------
nuttx/configs/shenzhou/nsh/defconfig | 2 +-
nuttx/drivers/net/enc28j60.h | 2 +-
4 files changed, 49 insertions(+), 17 deletions(-)
diff --git a/nuttx/arch/arm/src/stm32/chip/stm32_eth.h b/nuttx/arch/arm/src/stm32/chip/stm32_eth.h
index 431144009e..0b5ef18ca7 100644
--- a/nuttx/arch/arm/src/stm32/chip/stm32_eth.h
+++ b/nuttx/arch/arm/src/stm32/chip/stm32_eth.h
@@ -62,7 +62,9 @@
#define STM32_ETH_MACVLANTR_OFFSET 0x001c /* Ethernet MAC VLAN tag register */
#define STM32_ETH_MACRWUFFR_OFFSET 0x0028 /* Ethernet MAC remote wakeup frame filter reg */
#define STM32_ETH_MACPMTCSR_OFFSET 0x002c /* Ethernet MAC PMT control and status register */
-#define STM32_ETH_MACDBGR_OFFSET 0x0034 /* Ethernet MAC debug register */
+#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX)
+# define STM32_ETH_MACDBGR_OFFSET 0x0034 /* Ethernet MAC debug register */
+#endif
#define STM32_ETH_MACSR_OFFSET 0x0038 /* Ethernet MAC interrupt status register */
#define STM32_ETH_MACIMR_OFFSET 0x003c /* Ethernet MAC interrupt mask register */
#define STM32_ETH_MACA0HR_OFFSET 0x0040 /* Ethernet MAC address 0 high register */
@@ -132,7 +134,9 @@
#define STM32_ETH_MACVLANTR (STM32_ETHERNET_BASE+STM32_ETH_MACVLANTR_OFFSET)
#define STM32_ETH_MACRWUFFR (STM32_ETHERNET_BASE+STM32_ETH_MACRWUFFR_OFFSET)
#define STM32_ETH_MACPMTCSR (STM32_ETHERNET_BASE+STM32_ETH_MACPMTCSR_OFFSET)
-#define STM32_ETH_MACDBGR (STM32_ETHERNET_BASE+STM32_ETH_MACDBGR_OFFSET)
+#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX)
+# define STM32_ETH_MACDBGR (STM32_ETHERNET_BASE+STM32_ETH_MACDBGR_OFFSET)
+#endif
#define STM32_ETH_MACSR (STM32_ETHERNET_BASE+STM32_ETH_MACSR_OFFSET)
#define STM32_ETH_MACIMR (STM32_ETHERNET_BASE+STM32_ETH_MACIMR_OFFSET)
#define STM32_ETH_MACA0HR (STM32_ETHERNET_BASE+STM32_ETH_MACA0HR_OFFSET)
@@ -216,7 +220,9 @@
# define ETH_MACCR_IFG(n) ((12-((n) >> 3)) << ETH_MACCR_IFG_SHIFT) /* n bit times, n=40,48,..96 */
#define ETH_MACCR_JD (1 << 22) /* Bit 22: Jabber disable */
#define ETH_MACCR_WD (1 << 23) /* Bit 23: Watchdog disable */
-#define ETH_MACCR_CSTF (1 << 25) /* Bits 25: CRC stripping for Type frames */
+#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX)
+# define ETH_MACCR_CSTF (1 << 25) /* Bits 25: CRC stripping for Type frames */
+#endif
/* Ethernet MAC frame filter register */
@@ -303,6 +309,8 @@
/* Ethernet MAC debug register */
+#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX)
+
#define ETH_MACDBGR_MMRPEA (1 << 0) /* Bit 0: MAC MII receive protocol engine active */
#define ETH_MACDBGR_MSFRWCS_SHIFT (1) /* Bits 1-2: MAC small FIFO read / write controllers status */
#define ETH_MACDBGR_MSFRWCS_MASK (3 << ETH_MACDBGR_MSFRWCS_SHIFT)
@@ -337,6 +345,8 @@
#define ETH_MACDBGR_TFNE (1 << 24) /* Bit 24: Tx FIFO not empty */
#define ETH_MACDBGR_TFF (1 << 25) /* Bit 25: Tx FIFO full */
+#endif
+
/* Ethernet MAC interrupt status register */
#define ETH_MACSR_PMTS (1 << 3) /* Bit 3: PMT status */
@@ -419,7 +429,9 @@
#define ETH_MMCCR_ROR (1 << 2) /* Bit 2: Reset on read */
#define ETH_MMCCR_MCF (1 << 3) /* Bit 3: MMC counter freeze */
#define ETH_MMCCR_MCP (1 << 4) /* Bit 4: MMC counter preset */
-#define ETH_MMCCR_MCFHP (1 << 5) /* Bit 5: MMC counter Full-Half preset */
+#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX)
+# define ETH_MMCCR_MCFHP (1 << 5) /* Bit 5: MMC counter Full-Half preset */
+#endif
/* Ethernet MMC receive interrupt and interrupt mask registers */
@@ -453,6 +465,8 @@
#define ETH_PTPTSCR_TSSTU (1 << 3) /* Bit 3: Time stamp system time update */
#define ETH_PTPTSCR_TSITE (1 << 4) /* Bit 4: Time stamp interrupt trigger enable */
#define ETH_PTPTSCR_TSARU (1 << 5) /* Bit 5: Time stamp addend register update */
+
+#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX)
#define ETH_PTPTSCR_TSSARFE (1 << 8) /* Bit 8: Time stamp snapshot for all received frames enable */
#define ETH_PTPTSCR_TSSSR (1 << 9) /* Bit 9: Time stamp subsecond rollover: digital or binary rollover control */
#define ETH_PTPTSCR_TSPTPPSV2E (1 << 10) /* Bit 10: Time stamp PTP packet snooping for version2 format enable */
@@ -468,6 +482,7 @@
# define ETH_PTPTSCR_TSCNT_E2E (2 << ETH_PTPTSCR_TSCNT_SHIFT) /* 10: End-to-end transparent clock */
# define ETH_PTPTSCR_TSCNT_P2P (3 << ETH_PTPTSCR_TSCNT_SHIFT) /* 11: Peer-to-peer transparent clock */
#define ETH_PTPTSCR_TSPFFMAE (1 << 18) /* Bit 18: Time stamp PTP frame filtering MAC address enable */
+#endif
/* Ethernet PTP subsecond increment register */
@@ -543,7 +558,9 @@
#define ETH_DMABMR_USP (1 << 23) /* Bit 23: Use separate PBL */
#define ETH_DMABMR_FPM (1 << 24) /* Bit 24: 4xPBL mode */
#define ETH_DMABMR_AAB (1 << 25) /* Bit 25: Address-aligned beats */
-#define ETH_DMABMR_MB (1 << 26) /* Bit 26: Mixed burst */
+#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX)
+# define ETH_DMABMR_MB (1 << 26) /* Bit 26: Mixed burst */
+#endif
/* Ethernet DMA transmit poll demand register (32-bit) */
/* Ethernet DMA receive poll demand register (32-bit) */
diff --git a/nuttx/arch/arm/src/stm32/stm32_eth.c b/nuttx/arch/arm/src/stm32/stm32_eth.c
index b3392fa7a4..ab9cac209a 100644
--- a/nuttx/arch/arm/src/stm32/stm32_eth.c
+++ b/nuttx/arch/arm/src/stm32/stm32_eth.c
@@ -283,14 +283,22 @@
* ETH_MACCR_IFG Bits 17-19: Interframe gap
* ETH_MACCR_JD Bit 22: Jabber disable
* ETH_MACCR_WD Bit 23: Watchdog disable
- * ETH_MACCR_CSTF Bits 25: CRC stripping for Type frames
+ * ETH_MACCR_CSTF Bits 25: CRC stripping for Type frames (F2/F4 only)
*/
+#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX)
#define MACCR_CLEAR_BITS \
- ( ETH_MACCR_RE | ETH_MACCR_TE | ETH_MACCR_DC | ETH_MACCR_BL_MASK | \
+ (ETH_MACCR_RE | ETH_MACCR_TE | ETH_MACCR_DC | ETH_MACCR_BL_MASK | \
ETH_MACCR_APCS | ETH_MACCR_RD | ETH_MACCR_IPCO | ETH_MACCR_DM | \
ETH_MACCR_LM | ETH_MACCR_ROD | ETH_MACCR_FES | ETH_MACCR_CSD | \
- ETH_MACCR_IFG_MASK | ETH_MACCR_JD | ETH_MACCR_WD | ETH_MACCR_CSTF )
+ ETH_MACCR_IFG_MASK | ETH_MACCR_JD | ETH_MACCR_WD | ETH_MACCR_CSTF)
+#else
+#define MACCR_CLEAR_BITS \
+ (ETH_MACCR_RE | ETH_MACCR_TE | ETH_MACCR_DC | ETH_MACCR_BL_MASK | \
+ ETH_MACCR_APCS | ETH_MACCR_RD | ETH_MACCR_IPCO | ETH_MACCR_DM | \
+ ETH_MACCR_LM | ETH_MACCR_ROD | ETH_MACCR_FES | ETH_MACCR_CSD | \
+ ETH_MACCR_IFG_MASK | ETH_MACCR_JD | ETH_MACCR_WD)
+#endif
/* The following bits are set or left zero unconditionally in all modes.
*
@@ -307,7 +315,7 @@
* ETH_MACCR_IFG Interframe gap 0 (96 bits)
* ETH_MACCR_JD Jabber disable 0 (enabled)
* ETH_MACCR_WD Watchdog disable 0 (enabled)
- * ETH_MACCR_CSTF CRC stripping for Type frames 0 (disabled)
+ * ETH_MACCR_CSTF CRC stripping for Type frames 0 (disabled, F2/F4 only)
*
* The following are set conditioinally based on mode and speed.
*
@@ -462,13 +470,20 @@
* ETH_DMABMR_USP Bit 23: Use separate PBL
* ETH_DMABMR_FPM Bit 24: 4xPBL mode
* ETH_DMABMR_AAB Bit 25: Address-aligned beats
- * ETH_DMABMR_MB Bit 26: Mixed burst
+ * ETH_DMABMR_MB Bit 26: Mixed burst (F2/F4 only)
*/
+#if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX)
#define DMABMR_CLEAR_MASK \
(ETH_DMABMR_SR | ETH_DMABMR_DA | ETH_DMABMR_DSL_MASK | ETH_DMABMR_EDFE | \
ETH_DMABMR_PBL_MASK | ETH_DMABMR_RTPR_MASK | ETH_DMABMR_FB | ETH_DMABMR_RDP_MASK | \
ETH_DMABMR_USP | ETH_DMABMR_FPM | ETH_DMABMR_AAB | ETH_DMABMR_MB)
+#else
+#define DMABMR_CLEAR_MASK \
+ (ETH_DMABMR_SR | ETH_DMABMR_DA | ETH_DMABMR_DSL_MASK | ETH_DMABMR_EDFE | \
+ ETH_DMABMR_PBL_MASK | ETH_DMABMR_RTPR_MASK | ETH_DMABMR_FB | ETH_DMABMR_RDP_MASK | \
+ ETH_DMABMR_USP | ETH_DMABMR_FPM | ETH_DMABMR_AAB)
+#endif
/* The following bits are set or left zero unconditionally in all modes.
*
@@ -484,7 +499,7 @@
* ETH_DMABMR_USP Use separate PBL 1 (enabled)
* ETH_DMABMR_FPM 4xPBL mode 0 (disabled)
* ETH_DMABMR_AAB Address-aligned beats 1 (enabled)
- * ETH_DMABMR_MB Mixed burst 0 (disabled)
+ * ETH_DMABMR_MB Mixed burst 0 (disabled, F2/F4 only)
*/
#ifdef CONFIG_STM32_ETH_ENHANCEDDESC
@@ -2001,7 +2016,7 @@ static int stm32_ifup(struct uip_driver_s *dev)
ndbg("Bringing up: %d.%d.%d.%d\n",
dev->d_ipaddr & 0xff, (dev->d_ipaddr >> 8) & 0xff,
- (dev->d_ipaddr >> 16) & 0xff, dev->d_ipaddr >> 24 );
+ (dev->d_ipaddr >> 16) & 0xff, dev->d_ipaddr >> 24);
/* Configure the Ethernet interface for DMA operation. */
@@ -2242,7 +2257,7 @@ static void stm32_txdescinit(FAR struct stm32_ethmac_s *priv)
/* Initialize the next descriptor with the Next Descriptor Polling Enable */
- if( i < (CONFIG_STM32_ETH_NTXDESC-1))
+ if (i < (CONFIG_STM32_ETH_NTXDESC-1))
{
/* Set next descriptor address register with next descriptor base
* address
@@ -2321,7 +2336,7 @@ static void stm32_rxdescinit(FAR struct stm32_ethmac_s *priv)
/* Initialize the next descriptor with the Next Descriptor Polling Enable */
- if( i < (CONFIG_STM32_ETH_NRXDESC-1))
+ if (i < (CONFIG_STM32_ETH_NRXDESC-1))
{
/* Set next descriptor address register with next descriptor base
* address
@@ -2524,7 +2539,7 @@ static int stm32_phyinit(FAR struct stm32_ethmac_s *priv)
if (timeout >= PHY_RETRY_TIMEOUT)
{
- ndbg("Timed out waiting for link status\n");
+ ndbg("Timed out waiting for link status: %04x\n", phyval);
return -ETIMEDOUT;
}
diff --git a/nuttx/configs/shenzhou/nsh/defconfig b/nuttx/configs/shenzhou/nsh/defconfig
index c4817c2ee0..313f9f57be 100644
--- a/nuttx/configs/shenzhou/nsh/defconfig
+++ b/nuttx/configs/shenzhou/nsh/defconfig
@@ -172,7 +172,7 @@ CONFIG_STM32_JTAG_FULL_ENABLE=y
#
# Ethernet MAC configuration
#
-CONFIG_STM32_PHYADDR=1
+CONFIG_STM32_PHYADDR=0
# CONFIG_STM32_MII is not set
CONFIG_STM32_AUTONEG=y
CONFIG_STM32_PHYSR=17
diff --git a/nuttx/drivers/net/enc28j60.h b/nuttx/drivers/net/enc28j60.h
index 6f7f8f4652..6a0553a95d 100644
--- a/nuttx/drivers/net/enc28j60.h
+++ b/nuttx/drivers/net/enc28j60.h
@@ -78,7 +78,7 @@
*
* The last five locations (0x1b to 0x1f) of all banks point to a common set
* of registers: EIE, EIR, ESTAT, ECON2 and ECON1. These are key registers
- * usedin controlling and monitoring the operation of the device. Their
+ * used in controlling and monitoring the operation of the device. Their
* common mapping allows easy access without switching the bank.
*
* Control registers for the ENC28J60 are generically grouped as ETH, MAC and
From e2b2cc34504dfb36ca9d06065ed7046efbfc7d78 Mon Sep 17 00:00:00 2001
From: patacongo
Date: Mon, 24 Sep 2012 15:51:48 +0000
Subject: [PATCH 16/31] Fixes STM32F107 DMA issue
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5182 42af7a65-404d-4744-a932-0658087f49c3
---
nuttx/ChangeLog | 4 ++++
nuttx/arch/arm/src/stm32/chip/stm32_eth.h | 7 ++++--
nuttx/arch/arm/src/stm32/stm32_eth.c | 16 +++++++++----
nuttx/arch/arm/src/stm32/stm32_idle.c | 23 ++++++++++++++++++-
nuttx/configs/fire-stm32v2/nsh/defconfig | 4 ++--
nuttx/configs/shenzhou/nsh/defconfig | 4 ++--
.../configs/stm3240g-eval/discover/defconfig | 4 ++--
nuttx/configs/stm3240g-eval/xmlrpc/defconfig | 4 ++--
8 files changed, 50 insertions(+), 16 deletions(-)
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index 42110fd794..eb9680aefa 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 0b5ef18ca7..a4a109d016 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 ab9cac209a..2e892c9e54 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 791a79429c..0b69ff6485 100644
--- a/nuttx/arch/arm/src/stm32/stm32_idle.c
+++ b/nuttx/arch/arm/src/stm32/stm32_idle.c
@@ -45,6 +45,7 @@
#include
+#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 0802af3c94..d6aaae05a2 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 313f9f57be..0a699d334d 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 81a5b3c910..71dce1028b 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 5c70327b9c..cd80ea618d 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
From cafa22293a223e129d6d5ea3bc081fe07e1313be Mon Sep 17 00:00:00 2001
From: patacongo
Date: Mon, 24 Sep 2012 18:57:38 +0000
Subject: [PATCH 17/31] Corrections for SD card on Shenzhou board
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5183 42af7a65-404d-4744-a932-0658087f49c3
---
nuttx/Documentation/NuttX.html | 13 +++++++++----
nuttx/arch/arm/src/stm32/stm32_idle.c | 6 ++++--
nuttx/configs/shenzhou/README.txt | 13 +++++++++++--
nuttx/configs/shenzhou/nsh/defconfig | 10 +++++-----
.../configs/shenzhou/src/shenzhou-internal.h | 2 +-
nuttx/configs/shenzhou/src/up_mmcsd.c | 2 +-
nuttx/configs/shenzhou/src/up_nsh.c | 4 ++--
nuttx/configs/shenzhou/src/up_spi.c | 19 ++++++++++---------
nuttx/drivers/Kconfig | 2 +-
9 files changed, 44 insertions(+), 27 deletions(-)
diff --git a/nuttx/Documentation/NuttX.html b/nuttx/Documentation/NuttX.html
index b51b5e7b32..84e0024ef8 100644
--- a/nuttx/Documentation/NuttX.html
+++ b/nuttx/Documentation/NuttX.html
@@ -1789,7 +1789,7 @@
Not all features have been verified.
Support for FAT file system on an an SD card had been verified.
The ENC28J60 network is functional (but required lifting the chip select pin on the W25x16 part).
- Customizations for the v3 version of the Wildfire board a selectable (but untested).
+ Customizations for the v3 version of the Wildfire board are selectable (but untested).
@@ -1820,15 +1820,20 @@
STATUS:
Configurations for the basic OS test and NSH are available and verified.
+ Networking is functional.
- Shenzhou
- Work is underway as of this writing to port NuttX to the Shenzhou development board (See www.armjishu.com) featuring the STMicro STM32F107VCT MCU.
- If all goes according to plan, this port should be verified and avaialble in NuttX-6.22.
+ Shenzhou IV
+ Work is underway as of this writing to port NuttX to the Shenzhou IV development board (See www.armjishu.com) featuring the STMicro STM32F107VCT MCU.
+ If all goes according to plan, this port should be verified and available in NuttX-6.22.
STATUS:
In progress.
+ The following have been verified:
+ (1) Basic Cortex-M3 port,
+ (2) Ethernet,
+ (3) On-board LEDs