diff --git a/ChangeLog b/ChangeLog
index c91093852f1..5c8b5c53532 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2155,4 +2155,8 @@
do not work with R61580 LCD.
* configs/pic32-starterkit: Beginning of a configuratin for the Microchip
PIC32 Ethernet Starter Kit.
+ * lib/stdio/lib_fclose.c: fclose() always returns an error (EOF) when it
+ closes a read-only file. This is because it calls flush() which will
+ fail on read-only files. No harm is done other that a bad value is
+ returned.
diff --git a/Documentation/README.html b/Documentation/README.html
index 2cd1908c436..c8b740c23de 100755
--- a/Documentation/README.html
+++ b/Documentation/README.html
@@ -8,7 +8,7 @@
NuttX README Files
- Last Updated: September 21, 2011
+ Last Updated: October 10, 2011
|
@@ -126,11 +126,12 @@
| | | `- README.txt
| | |- pcblogic-pic32mx/
| | | `- README.txt
+ | | |- pic32-starterkit/
+ | | | `- README.txt
| | |- pjrc-8051/
| | | |- include/README.txt
| | | |- src/README.txt
| | | `- README.txt
-
| | |- qemu-i486/
| | | |- include/README.txt
| | | |- src/README.txt
diff --git a/README.txt b/README.txt
index fe94337c48b..63f78cd213f 100755
--- a/README.txt
+++ b/README.txt
@@ -413,6 +413,8 @@ nuttx
| | `- README.txt
| |- pcblogic-pic32mx/
| | `- README.txt
+ | |- pic32-starterkit/
+ | | `- README.txt
| |- pjrc-8051/
| | |- include/README.txt
| | |- src/README.txt
diff --git a/arch/mips/src/pic32mx/pic32mx-irq.c b/arch/mips/src/pic32mx/pic32mx-irq.c
index 75f7367ff92..98c554c7842 100644
--- a/arch/mips/src/pic32mx/pic32mx-irq.c
+++ b/arch/mips/src/pic32mx/pic32mx-irq.c
@@ -97,7 +97,7 @@ void up_irqinitialize(void)
putreg32(0xffff, PIC32MX_INT_IEC0CLR);
putreg32(0xffff, PIC32MX_INT_IEC1CLR);
-#ifdef PIC32MX_INT_IEC1CLR
+#ifdef PIC32MX_INT_IEC2CLR
putreg32(0xffff, PIC32MX_INT_IEC2CLR);
#endif
diff --git a/configs/README.txt b/configs/README.txt
index c18bde32105..f19fa28eea5 100644
--- a/configs/README.txt
+++ b/configs/README.txt
@@ -1321,7 +1321,14 @@ configs/pcblogic-pic32mx
STATUS: Code complete but testing has been stalled due to tool related problems
(PICkit 2 does not work with the PIC32).
-confgis/qemu-i486
+configs/pic32-starterkit
+
+ This README file discusses the port of NuttX to the Microchip PIC32 Ethernet
+ Starter Kit (DM320004) with the Multimedia Expansion Board (MEB, DM320005).
+ Advanced USB Storage. See www.microchip.com for further information.
+
+configs/qemu-i486
+
Port of NuttX to QEMU in i486 mode. This port will also run on real i486
hardwared (Google the Bifferboard).
diff --git a/lib/stdio/lib_fclose.c b/lib/stdio/lib_fclose.c
index 06f970e11ed..8cecb8af3c9 100644
--- a/lib/stdio/lib_fclose.c
+++ b/lib/stdio/lib_fclose.c
@@ -2,7 +2,7 @@
* lib/stdio/lib_fclose.c
*
* Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt
+ * Author: Gregory Nutt
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -41,6 +41,7 @@
#include
#include
+#include
#include
#include
@@ -70,29 +71,36 @@ int fclose(FAR FILE *stream)
{
int err = EINVAL;
int ret = ERROR;
+ int status;
/* Verify that a stream was provided. */
if (stream)
{
- /* Flush the stream */
-
- ret = lib_fflush(stream, true);
- err = errno;
-
- /* Close the underlying file descriptor */
-
- if (stream->fs_filedes > 0)
+ /* Check that the underlying file descriptor corresponds to an an open
+ * file.
+ */
+
+ ret = OK;
+ if (stream->fs_filedes >= 0)
{
- /* Close the file and save the return status */
+ /* If the stream was opened for writing, then flush the stream */
- int status = close(stream->fs_filedes);
+ if ((stream->fs_oflags & O_WROK) != 0)
+ {
+ ret = lib_fflush(stream, true);
+ err = errno;
+ }
- /* If close() returns an error but flush() did not then make
- * sure that we return the close() error condition.
+ /* Close the underlying file descriptor and save the return status */
+
+ status = close(stream->fs_filedes);
+
+ /* If close() returns an error but flush() did not then make sure
+ * that we return the close() error condition.
*/
- if (ret == 0)
+ if (ret == OK)
{
ret = status;
err = errno;
diff --git a/lib/stdio/lib_libfflush.c b/lib/stdio/lib_libfflush.c
index 3e9de538ab6..ddfc6c8ff67 100644
--- a/lib/stdio/lib_libfflush.c
+++ b/lib/stdio/lib_libfflush.c
@@ -2,7 +2,7 @@
* lib/stdio/lib_libfflush.c
*
* Copyright (C) 2007, 2008, 2011 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt
+ * Author: Gregory Nutt
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions