<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>change log for rtems (2011-09-22)</title>
</head>
<body text='#000000' bgcolor='#ffffff'>
<a name='cs1'></a>
<table border='0' cellspacing='0' cellpadding='5' width='100%' bgcolor='#eeeeee'>
<tr><td colspan='3' bgcolor='#dddddd'>
<font color='#bb2222'><strong>sh</strong></font>
</td></tr>
<tr><td colspan='3' bgcolor='#dddddd'><pre>2011-09-22 Sebastian Huber <sebastian.huber@embedded-brains.de>
* make/custom/lpc32xx.inc: Workaround for GCC bug 50106.
* include/lpc32xx.h: Fixed register map for NAND MLC.
* include/boot.h: Declare lpc32xx_set_boot_block_bad().
* misc/boot.c: Define lpc32xx_set_boot_block_bad().
* include/nand-mlc.h, misc/nand-mlc-erase-block-safe.c,
misc/nand-mlc-read-blocks.c, misc/nand-mlc-write-blocks.c,
misc/nand-mlc.c: Changed bad block handling. Support for non-aligned
data. Documentation.
</pre></td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/c/src/lib/libbsp/arm/lpc32xx/ChangeLog.diff?r1=text&tr1=1.37&r2=text&tr2=1.38&diff_format=h">M</a></td><td width='1%'>1.38</td><td width='100%'>c/src/lib/libbsp/arm/lpc32xx/ChangeLog</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/c/src/lib/libbsp/arm/lpc32xx/include/boot.h.diff?r1=text&tr1=1.2&r2=text&tr2=1.3&diff_format=h">M</a></td><td width='1%'>1.3</td><td width='100%'>c/src/lib/libbsp/arm/lpc32xx/include/boot.h</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/c/src/lib/libbsp/arm/lpc32xx/include/lpc32xx.h.diff?r1=text&tr1=1.13&r2=text&tr2=1.14&diff_format=h">M</a></td><td width='1%'>1.14</td><td width='100%'>c/src/lib/libbsp/arm/lpc32xx/include/lpc32xx.h</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/c/src/lib/libbsp/arm/lpc32xx/include/nand-mlc.h.diff?r1=text&tr1=1.5&r2=text&tr2=1.6&diff_format=h">M</a></td><td width='1%'>1.6</td><td width='100%'>c/src/lib/libbsp/arm/lpc32xx/include/nand-mlc.h</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/c/src/lib/libbsp/arm/lpc32xx/make/custom/lpc32xx.inc.diff?r1=text&tr1=1.1&r2=text&tr2=1.2&diff_format=h">M</a></td><td width='1%'>1.2</td><td width='100%'>c/src/lib/libbsp/arm/lpc32xx/make/custom/lpc32xx.inc</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/c/src/lib/libbsp/arm/lpc32xx/misc/boot.c.diff?r1=text&tr1=1.1&r2=text&tr2=1.2&diff_format=h">M</a></td><td width='1%'>1.2</td><td width='100%'>c/src/lib/libbsp/arm/lpc32xx/misc/boot.c</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/c/src/lib/libbsp/arm/lpc32xx/misc/nand-mlc-erase-block-safe.c.diff?r1=text&tr1=1.2&r2=text&tr2=1.3&diff_format=h">M</a></td><td width='1%'>1.3</td><td width='100%'>c/src/lib/libbsp/arm/lpc32xx/misc/nand-mlc-erase-block-safe.c</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/c/src/lib/libbsp/arm/lpc32xx/misc/nand-mlc-read-blocks.c.diff?r1=text&tr1=1.1&r2=text&tr2=1.2&diff_format=h">M</a></td><td width='1%'>1.2</td><td width='100%'>c/src/lib/libbsp/arm/lpc32xx/misc/nand-mlc-read-blocks.c</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/c/src/lib/libbsp/arm/lpc32xx/misc/nand-mlc-write-blocks.c.diff?r1=text&tr1=1.3&r2=text&tr2=1.4&diff_format=h">M</a></td><td width='1%'>1.4</td><td width='100%'>c/src/lib/libbsp/arm/lpc32xx/misc/nand-mlc-write-blocks.c</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/c/src/lib/libbsp/arm/lpc32xx/misc/nand-mlc.c.diff?r1=text&tr1=1.2&r2=text&tr2=1.3&diff_format=h">M</a></td><td width='1%'>1.3</td><td width='100%'>c/src/lib/libbsp/arm/lpc32xx/misc/nand-mlc.c</td></tr>
</table>
<pre>
<font color='#006600'>diff -u rtems/c/src/lib/libbsp/arm/lpc32xx/ChangeLog:1.37 rtems/c/src/lib/libbsp/arm/lpc32xx/ChangeLog:1.38
--- rtems/c/src/lib/libbsp/arm/lpc32xx/ChangeLog:1.37 Mon Aug 8 07:33:22 2011
+++ rtems/c/src/lib/libbsp/arm/lpc32xx/ChangeLog Thu Sep 22 02:09:07 2011
</font><font color='#997700'>@@ -1,3 +1,14 @@
</font><font color='#000088'>+2011-09-22 Sebastian Huber <sebastian.huber@embedded-brains.de>
+
+ * make/custom/lpc32xx.inc: Workaround for GCC bug 50106.
+ * include/lpc32xx.h: Fixed register map for NAND MLC.
+ * include/boot.h: Declare lpc32xx_set_boot_block_bad().
+ * misc/boot.c: Define lpc32xx_set_boot_block_bad().
+ * include/nand-mlc.h, misc/nand-mlc-erase-block-safe.c,
+ misc/nand-mlc-read-blocks.c, misc/nand-mlc-write-blocks.c,
+ misc/nand-mlc.c: Changed bad block handling. Support for non-aligned
+ data. Documentation.
+
</font> 2011-08-08 Sebastian Huber <sebastian.huber@embedded-brains.de>
* misc/i2c.c: Bugfix.
<font color='#006600'>diff -u rtems/c/src/lib/libbsp/arm/lpc32xx/include/boot.h:1.2 rtems/c/src/lib/libbsp/arm/lpc32xx/include/boot.h:1.3
--- rtems/c/src/lib/libbsp/arm/lpc32xx/include/boot.h:1.2 Mon Mar 28 04:00:00 2011
+++ rtems/c/src/lib/libbsp/arm/lpc32xx/include/boot.h Thu Sep 22 02:09:07 2011
</font><font color='#997700'>@@ -101,6 +101,10 @@
</font> uint8_t page_count
);
<font color='#000088'>+void lpc32xx_set_boot_block_bad(
+ lpc32xx_boot_block *boot_block
+);
+
</font> /** @} */
#ifdef __cplusplus
<font color='#006600'>diff -u rtems/c/src/lib/libbsp/arm/lpc32xx/include/lpc32xx.h:1.13 rtems/c/src/lib/libbsp/arm/lpc32xx/include/lpc32xx.h:1.14
--- rtems/c/src/lib/libbsp/arm/lpc32xx/include/lpc32xx.h:1.13 Thu May 19 07:11:36 2011
+++ rtems/c/src/lib/libbsp/arm/lpc32xx/include/lpc32xx.h Thu Sep 22 02:09:07 2011
</font><font color='#997700'>@@ -526,6 +526,7 @@
</font> uint32_t time;
uint32_t irq_mr;
uint32_t irq_sr;
<font color='#000088'>+ uint32_t reserved_2;
</font> uint32_t lock_pr;
uint32_t isr;
uint32_t ceh;
<font color='#006600'>diff -u rtems/c/src/lib/libbsp/arm/lpc32xx/include/nand-mlc.h:1.5 rtems/c/src/lib/libbsp/arm/lpc32xx/include/nand-mlc.h:1.6
--- rtems/c/src/lib/libbsp/arm/lpc32xx/include/nand-mlc.h:1.5 Mon Jul 4 04:26:19 2011
+++ rtems/c/src/lib/libbsp/arm/lpc32xx/include/nand-mlc.h Thu Sep 22 02:09:07 2011
</font><font color='#997700'>@@ -74,6 +74,8 @@
</font> #define MLC_SMALL_PAGE_SIZE 528
#define MLC_SMALL_DATA_SIZE 512
#define MLC_SMALL_SPARE_SIZE 16
<font color='#000088'>+#define MLC_SMALL_USER_SPARE_SIZE 6
+#define MLC_SMALL_ECC_SPARE_SIZE 10
</font> #define MLC_SMALL_DATA_WORD_COUNT (MLC_SMALL_DATA_SIZE / 4)
#define MLC_SMALL_SPARE_WORD_COUNT (MLC_SMALL_SPARE_SIZE / 4)
#define MLC_SMALL_PAGES_PER_LARGE_PAGE 4
<font color='#997700'>@@ -136,6 +138,7 @@
</font> */
#define MLC_ISR_DECODER_FAILURE BSP_BIT32(6)
<font color='#000088'>+#define MLC_ISR_SYMBOL_ERRORS(reg) BSP_FLD32GET(reg, 4, 5)
</font> #define MLC_ISR_ERRORS_DETECTED BSP_BIT32(3)
#define MLC_ISR_ECC_READY BSP_BIT32(2)
#define MLC_ISR_CONTROLLER_READY BSP_BIT32(1)
<font color='#997700'>@@ -166,21 +169,6 @@
</font>
/** @} */
<font color='#880000'>-#define MLC_BAD_BLOCK_MASK ((uint32_t) 0xff00)
-
-/**
- * @brief Bad block mark.
- *<span style="background-color: #FF0000"> </span>
- * We define our own bad block mark to be able to recognize the blocks that
- * have been marked bad during operation later.
- */
-#define MLC_BAD_BLOCK_MARK ((uint32_t) 0xbadb)
-
-/**
- * @brief The bytes 4 and 5 are reserved for bad block handling.
- */
-#define MLC_RESERVED ((uint32_t) 0xffff)
-
</font> /**
* @name NAND Status Register
*
<font color='#997700'>@@ -209,22 +197,29 @@
</font>
/**
* @brief Selects small pages (512 Bytes user data and 16 Bytes spare data)
<font color='#880000'>- * or large pages (2048 Bytes user data and 64 Bytes spare data).
</font><font color='#000088'>+ * or large pages (2048 Bytes user data and 64 Bytes spare data) if not set.
</font> */
#define MLC_SMALL_PAGES 0x1U
/**
<font color='#880000'>- * @Brief Selects 3/4 address cycles for small pages/large pages or 4/5
- * address cycles.
</font><font color='#000088'>+ * @Brief Selects 4/5 address cycles for small/large pages or 3/4 address
+ * cycles if not set.
</font> */
#define MLC_MANY_ADDRESS_CYCLES 0x2U
/**
<font color='#880000'>- * @brief Selects 64 or 128 pages per block in case of large pages.
</font><font color='#000088'>+ * @brief Selects 64 pages per block or 128 pages per block if not set.
+ *
+ * This flag is only valid for large pages.
</font> */
#define MLC_NORMAL_BLOCKS 0x4U
/**
<font color='#000088'>+ * @brief Selects 16-bit IO width or 8-bit IO width if not set.
+ */
+#define MLC_IO_WIDTH_16_BIT 0x8U
+
+/**
</font> * @brief Initializes the MLC NAND controller according to @a cfg.
*/
void lpc32xx_mlc_init(const lpc32xx_mlc_config *cfg);
<font color='#997700'>@@ -235,6 +230,8 @@
</font>
uint32_t lpc32xx_mlc_block_count(void);
<font color='#000088'>+uint32_t lpc32xx_mlc_io_width(void);
+
</font> void lpc32xx_mlc_write_protection(
uint32_t page_index_low,
uint32_t page_index_high
<font color='#997700'>@@ -245,9 +242,11 @@
</font> /**
* @brief Reads the page with index @a page_index.
*
<font color='#880000'>- * 32-bit reads will be performed.
</font><font color='#000088'>+ * Bytes 6 to 15 of the spare area will contain the ECC.
</font> *
<font color='#880000'>- * Bytes 7 to 15 of the spare area will contain the ECC.
</font><font color='#000088'>+ * If the read is successful, then the @a symbol_error_count will contain the
+ * number of detected symbol errors (0, 1, 2, 3, or 4), else the value will be
+ * 0xffffffff. The @a symbol_error_count pointer may be @c NULL.
</font> *
* @retval RTEMS_SUCCESSFUL Successful operation.
* @retval RTEMS_INVALID_ID Invalid @a page_index value.
<font color='#997700'>@@ -255,16 +254,35 @@
</font> */
rtems_status_code lpc32xx_mlc_read_page(
uint32_t page_index,
<font color='#880000'>- uint32_t *data,
- uint32_t *spare
</font><font color='#000088'>+ void *data,
+ void *spare,
+ uint32_t *symbol_error_count
</font> );
/**
<font color='#000088'>+ * @brief Checks if the block with index @a block_index is valid.
+ *
+ * The initial valid block information of the manufacturer will be used.
+ * Unfortunatly there seems to be no standard for this. A block will be
+ * considered as bad if the first or second page of this block does not contain
+ * 0xff at the 6th byte of the spare area. This should work for flashes with
+ * small pages and a 8-bit IO width.
+ *
+ * @retval RTEMS_SUCCESSFUL The block is valid.
+ * @retval RTEMS_INVALID_ID Invalid @a block_index value.
+ * @retval RTEMS_IO_ERROR Uncorrectable bit error.
+ * @retval RTEMS_INCORRECT_STATE The block is bad.
+ * @retval RTEMS_NOT_IMPLEMENTED No implementation available for this flash
+ * type.
+ */
+rtems_status_code lpc32xx_mlc_is_valid_block(uint32_t block_index);
+
+/**
</font> * @brief Erases the block with index @a block_index.
*
* @retval RTEMS_SUCCESSFUL Successful operation.
* @retval RTEMS_INVALID_ID Invalid @a block_index value.
<font color='#880000'>- * @retval RTEMS_IO_ERROR Erase error.
</font><font color='#000088'>+ * @retval RTEMS_UNSATISFIED Erase error.
</font> */
rtems_status_code lpc32xx_mlc_erase_block(uint32_t block_index);
<font color='#997700'>@@ -272,13 +290,14 @@
</font> * @brief Erases the block with index @a block_index.
*
* In case of an erase error all pages and the spare areas of this block are
<font color='#880000'>- * programmed with zero values. This will mark the first and second page as
- * bad.
</font><font color='#000088'>+ * programmed with zero values. This will hopefully mark the block as bad.
</font> *
* @retval RTEMS_SUCCESSFUL Successful operation.
<font color='#880000'>- * @retval RTEMS_INCORRECT_STATE The first or second page of this block is bad.
</font><font color='#000088'>+ * @retval RTEMS_INCORRECT_STATE The block is bad.
</font> * @retval RTEMS_INVALID_ID Invalid @a block_index value.
<font color='#880000'>- * @retval RTEMS_IO_ERROR Erase error.
</font><font color='#000088'>+ * @retval RTEMS_UNSATISFIED Erase error.
+ * @retval RTEMS_NOT_IMPLEMENTED No implementation available for this flash
+ * type.
</font> */
rtems_status_code lpc32xx_mlc_erase_block_safe(uint32_t block_index);
<font color='#997700'>@@ -307,10 +326,8 @@
</font> /**
* @brief Writes the page with index @a page_index.
*
<font color='#880000'>- * 32-bit writes will be performed.
- *
- * Bytes 7 to 15 of the spare area will be used for the automatically generated
- * ECC.
</font><font color='#000088'>+ * Only the bytes 0 to 5 of the spare area can be used for user data, the bytes
+ * 6 to 15 will be used for the automatically generated ECC.
</font> *
* @retval RTEMS_SUCCESSFUL Successful operation.
* @retval RTEMS_INVALID_ID Invalid @a page_index value.
<font color='#997700'>@@ -318,8 +335,8 @@
</font> */
rtems_status_code lpc32xx_mlc_write_page_with_ecc(
uint32_t page_index,
<font color='#880000'>- const uint32_t *data,
- const uint32_t *spare
</font><font color='#000088'>+ const void *data,
+ const void *spare
</font> );
/**
<font color='#997700'>@@ -377,17 +394,8 @@
</font>
static inline bool lpc32xx_mlc_is_bad_page(const uint32_t *spare)
{
<font color='#880000'>- return (spare [1] & MLC_BAD_BLOCK_MASK) != MLC_BAD_BLOCK_MASK;
-}
-
-static inline void lpc32xx_mlc_set_bad_page(uint32_t *spare)
-{
- spare [1] = MLC_BAD_BLOCK_MARK;
-}
-
-static inline void lpc32xx_mlc_set_reserved(uint32_t *spare)
-{
- spare [1] = MLC_RESERVED;
</font><font color='#000088'>+ uint32_t valid_block_mask = 0xff00;
+ return (spare [1] & valid_block_mask) != valid_block_mask;
</font> }
/** @} */
<font color='#006600'>diff -u rtems/c/src/lib/libbsp/arm/lpc32xx/make/custom/lpc32xx.inc:1.1 rtems/c/src/lib/libbsp/arm/lpc32xx/make/custom/lpc32xx.inc:1.2
--- rtems/c/src/lib/libbsp/arm/lpc32xx/make/custom/lpc32xx.inc:1.1 Thu May 20 08:15:35 2010
+++ rtems/c/src/lib/libbsp/arm/lpc32xx/make/custom/lpc32xx.inc Thu Sep 22 02:09:07 2011
</font><font color='#997700'>@@ -11,4 +11,4 @@
</font> CPU_CFLAGS = -mstructure-size-boundary=8 -mcpu=arm926ej-s -mfpu=vfp -mfloat-abi=soft -mthumb \
-fno-schedule-insns2
<font color='#880000'>-CFLAGS_OPTIMIZE_V = -Os -g
</font><font color='#000088'>+CFLAGS_OPTIMIZE_V = -O2 -g
</font>
<font color='#006600'>diff -u rtems/c/src/lib/libbsp/arm/lpc32xx/misc/boot.c:1.1 rtems/c/src/lib/libbsp/arm/lpc32xx/misc/boot.c:1.2
--- rtems/c/src/lib/libbsp/arm/lpc32xx/misc/boot.c:1.1 Wed Jun 23 03:27:57 2010
+++ rtems/c/src/lib/libbsp/arm/lpc32xx/misc/boot.c Thu Sep 22 02:09:07 2011
</font><font color='#997700'>@@ -52,3 +52,10 @@
</font>
boot_block->field.d12 = 0xaa;
}
<font color='#000088'>+
+void lpc32xx_set_boot_block_bad(
+ lpc32xx_boot_block *boot_block
+)
+{
+ boot_block->field.d12 = 0;
+}
</font>
<font color='#006600'>diff -u rtems/c/src/lib/libbsp/arm/lpc32xx/misc/nand-mlc-erase-block-safe.c:1.2 rtems/c/src/lib/libbsp/arm/lpc32xx/misc/nand-mlc-erase-block-safe.c:1.3
--- rtems/c/src/lib/libbsp/arm/lpc32xx/misc/nand-mlc-erase-block-safe.c:1.2 Mon Jul 4 04:26:19 2011
+++ rtems/c/src/lib/libbsp/arm/lpc32xx/misc/nand-mlc-erase-block-safe.c Thu Sep 22 02:09:07 2011
</font><font color='#997700'>@@ -40,20 +40,53 @@
</font> }
}
<font color='#880000'>-static bool is_bad_page(
</font><font color='#000088'>+static rtems_status_code is_valid_page(
</font> uint32_t page_begin,
uint32_t page_offset
)
{
<font color='#000088'>+ rtems_status_code sc = RTEMS_SUCCESSFUL;
</font> uint32_t spare [MLC_LARGE_SPARE_WORD_COUNT];
memset(spare, 0, MLC_LARGE_SPARE_SIZE);
<font color='#880000'>- lpc32xx_mlc_read_page(
</font><font color='#000088'>+
+ sc = lpc32xx_mlc_read_page(
</font> page_begin + page_offset,
lpc32xx_magic_zero_begin,
<font color='#880000'>- spare
</font><font color='#000088'>+ spare,
+ NULL
</font> );
<font color='#880000'>- return lpc32xx_mlc_is_bad_page(spare);
</font><font color='#000088'>+ if (sc == RTEMS_SUCCESSFUL) {
+ if (lpc32xx_mlc_is_bad_page(spare)) {
+ sc = RTEMS_INCORRECT_STATE;
+ }
+ }
+
+ return sc;
+}
+
+static rtems_status_code is_valid_block(uint32_t page_begin)
+{
+ rtems_status_code sc = RTEMS_SUCCESSFUL;
+
+ if (lpc32xx_mlc_page_size() == 512 && lpc32xx_mlc_io_width() == 8) {
+ sc = is_valid_page(page_begin, 0);
+ if (sc == RTEMS_SUCCESSFUL) {
+ sc = is_valid_page(page_begin, 1);
+ }
+ } else {
+ sc = RTEMS_NOT_IMPLEMENTED;
+ }
+
+ return sc;
+}
+
+rtems_status_code lpc32xx_mlc_is_valid_block(uint32_t block_index)
+{
+ uint32_t pages_per_block = lpc32xx_mlc_pages_per_block();
+ uint32_t page_begin = block_index * pages_per_block;
+
+ return is_valid_block(page_begin);
</font> }
rtems_status_code lpc32xx_mlc_erase_block_safe_3(
<font color='#997700'>@@ -64,22 +97,15 @@
</font> {
rtems_status_code sc = RTEMS_SUCCESSFUL;
<font color='#880000'>- if (is_bad_page(page_begin, 0)) {
- return RTEMS_INCORRECT_STATE;
- }
-
- if (is_bad_page(page_begin, 1)) {
- return RTEMS_INCORRECT_STATE;
- }
-
- sc = lpc32xx_mlc_erase_block(block_index);
- if (sc != RTEMS_SUCCESSFUL) {
- lpc32xx_mlc_zero_pages(page_begin, page_end);
-
- return RTEMS_IO_ERROR;
</font><font color='#000088'>+ sc = is_valid_block(page_begin);
+ if (sc == RTEMS_SUCCESSFUL) {
+ sc = lpc32xx_mlc_erase_block(block_index);
+ if (sc == RTEMS_UNSATISFIED) {
+ lpc32xx_mlc_zero_pages(page_begin, page_end);
+ }
</font> }
<font color='#880000'>- return RTEMS_SUCCESSFUL;
</font><font color='#000088'>+ return sc;
</font> }
rtems_status_code lpc32xx_mlc_erase_block_safe(uint32_t block_index)
<font color='#006600'>diff -u rtems/c/src/lib/libbsp/arm/lpc32xx/misc/nand-mlc-read-blocks.c:1.1 rtems/c/src/lib/libbsp/arm/lpc32xx/misc/nand-mlc-read-blocks.c:1.2
--- rtems/c/src/lib/libbsp/arm/lpc32xx/misc/nand-mlc-read-blocks.c:1.1 Wed Jun 23 03:27:57 2010
+++ rtems/c/src/lib/libbsp/arm/lpc32xx/misc/nand-mlc-read-blocks.c Thu Sep 22 02:09:07 2011
</font><font color='#997700'>@@ -36,7 +36,7 @@
</font> memset(page_spare, 0, MLC_LARGE_SPARE_SIZE);
}
<font color='#880000'>- sc = lpc32xx_mlc_read_page(page_index, page_data, page_spare);
</font><font color='#000088'>+ sc = lpc32xx_mlc_read_page(page_index, page_data, page_spare, NULL);
</font> if (possible_bad_page && lpc32xx_mlc_is_bad_page(page_spare)) {
return RTEMS_UNSATISFIED;
} else if (sc == RTEMS_SUCCESSFUL) {
<font color='#006600'>diff -u rtems/c/src/lib/libbsp/arm/lpc32xx/misc/nand-mlc-write-blocks.c:1.3 rtems/c/src/lib/libbsp/arm/lpc32xx/misc/nand-mlc-write-blocks.c:1.4
--- rtems/c/src/lib/libbsp/arm/lpc32xx/misc/nand-mlc-write-blocks.c:1.3 Mon Jul 4 04:26:19 2011
+++ rtems/c/src/lib/libbsp/arm/lpc32xx/misc/nand-mlc-write-blocks.c Thu Sep 22 02:09:07 2011
</font><font color='#997700'>@@ -84,7 +84,7 @@
</font> ones_spare
);
if (sc != RTEMS_SUCCESSFUL) {
<font color='#880000'>- lpc32xx_mlc_erase_block_safe_3(block, page_begin, page_end);
</font><font color='#000088'>+ lpc32xx_mlc_erase_block(block);
</font> lpc32xx_mlc_zero_pages(page_begin, page_end);
current = last;
continue;
<font color='#006600'>diff -u rtems/c/src/lib/libbsp/arm/lpc32xx/misc/nand-mlc.c:1.2 rtems/c/src/lib/libbsp/arm/lpc32xx/misc/nand-mlc.c:1.3
--- rtems/c/src/lib/libbsp/arm/lpc32xx/misc/nand-mlc.c:1.2 Mon Mar 28 04:00:00 2011
+++ rtems/c/src/lib/libbsp/arm/lpc32xx/misc/nand-mlc.c Thu Sep 22 02:09:07 2011
</font><font color='#997700'>@@ -7,12 +7,13 @@
</font> */
/*
<font color='#880000'>- * Copyright (c) 2010
- * embedded brains GmbH
- * Obere Lagerstr. 30
- * D-82178 Puchheim
- * Germany
- * <rtems@embedded-brains.de>
</font><font color='#000088'>+ * Copyright (c) 2010-2011 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Obere Lagerstr. 30
+ * 82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
</font> *
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
<font color='#997700'>@@ -72,6 +73,15 @@
</font> return mlc_block_count;
}
<font color='#000088'>+uint32_t lpc32xx_mlc_io_width(void)
+{
+ if ((mlc_flags & MLC_IO_WIDTH_16_BIT) == 0) {
+ return 8;
+ } else {
+ return 16;
+ }
+}
+
</font> static void mlc_unlock(void)
{
mlc->lock_pr = MLC_UNLOCK_PROT;
<font color='#997700'>@@ -193,10 +203,16 @@
</font> mlc->icr |= MLC_ICR_SOFT_WRITE_PROT;
}
<font color='#000088'>+bool is_word_aligned(const void *data, const void *spare)
+{
+ return (((uintptr_t) data) | ((uintptr_t) spare)) % 4 == 0;
+}
+
</font> rtems_status_code lpc32xx_mlc_read_page(
uint32_t page_index,
<font color='#880000'>- uint32_t *data,
- uint32_t *spare
</font><font color='#000088'>+ void *data,
+ void *spare,
+ uint32_t *symbol_error_count_ptr
</font> )
{
rtems_status_code sc = RTEMS_SUCCESSFUL;
<font color='#997700'>@@ -204,6 +220,10 @@
</font> size_t sp = 0;
size_t i = 0;
uint32_t isr = 0;
<font color='#000088'>+ uint32_t symbol_error_count = 0xffffffff;
+ bool aligned = is_word_aligned(data, spare);
+ uint8_t *current_data = data;
+ uint8_t *current_spare = spare;
</font>
if (page_index >= mlc_page_count) {
return RTEMS_INVALID_ID;
<font color='#997700'>@@ -218,35 +238,65 @@
</font> mlc_wait(MLC_ISR_NAND_READY);
for (sp = 0; sc == RTEMS_SUCCESSFUL && sp < small_pages_count; ++sp) {
<font color='#000088'>+ uint32_t *aligned_data = (uint32_t *) current_data;
+ uint32_t *aligned_spare = (uint32_t *) current_spare;
+
</font> mlc->ecc_dec = 0;
<font color='#880000'>- for (i = 0; i < MLC_SMALL_DATA_WORD_COUNT; ++i) {
- data [i] = mlc->data.w32;
- }
- for (i = 0; i < MLC_SMALL_SPARE_WORD_COUNT; ++i) {
- spare [i] = mlc->data.w32;
</font><font color='#000088'>+ if (aligned) {
+ for (i = 0; i < MLC_SMALL_DATA_WORD_COUNT; ++i) {
+ aligned_data [i] = mlc->data.w32;
+ }
+ for (i = 0; i < MLC_SMALL_SPARE_WORD_COUNT; ++i) {
+ aligned_spare [i] = mlc->data.w32;
+ }
+ } else {
+ for (i = 0; i < MLC_SMALL_DATA_SIZE; ++i) {
+ current_data [i] = mlc->data.w8;
+ }
+ for (i = 0; i < MLC_SMALL_SPARE_SIZE; ++i) {
+ current_spare [i] = mlc->data.w8;
+ }
</font> }
mlc_wait(MLC_ISR_ECC_READY);
isr = mlc->isr;
<font color='#880000'>- if ((isr & MLC_ISR_ERRORS_DETECTED) != 0) {
</font><font color='#000088'>+ if ((isr & MLC_ISR_ERRORS_DETECTED) == 0) {
+ symbol_error_count = 0;
+ } else {
</font> if ((isr & MLC_ISR_DECODER_FAILURE) == 0) {
<font color='#880000'>- mlc->rubp = 0;
- for (i = 0; i < MLC_SMALL_DATA_WORD_COUNT; ++i) {
- data [i] = mlc->buff.w32;
- }
- mlc->robp = 0;
- for (i = 0; i < MLC_SMALL_SPARE_WORD_COUNT; ++i) {
- spare [i] = mlc->buff.w32;
</font><font color='#000088'>+ symbol_error_count = MLC_ISR_SYMBOL_ERRORS(isr);
+ if (aligned) {
+ mlc->rubp = 0;
+ for (i = 0; i < MLC_SMALL_DATA_WORD_COUNT; ++i) {
+ aligned_data [i] = mlc->buff.w32;
+ }
+ mlc->robp = 0;
+ for (i = 0; i < MLC_SMALL_SPARE_WORD_COUNT; ++i) {
+ aligned_spare [i] = mlc->buff.w32;
+ }
+ } else {
+ mlc->rubp = 0;
+ for (i = 0; i < MLC_SMALL_DATA_SIZE; ++i) {
+ current_data [i] = mlc->buff.w8;
+ }
+ mlc->robp = 0;
+ for (i = 0; i < MLC_SMALL_SPARE_SIZE; ++i) {
+ current_spare [i] = mlc->buff.w8;
+ }
</font> }
} else {
sc = RTEMS_IO_ERROR;
}
}
<font color='#880000'>- data += MLC_SMALL_DATA_WORD_COUNT;
- spare += MLC_SMALL_SPARE_WORD_COUNT;
</font><font color='#000088'>+ current_data += MLC_SMALL_DATA_SIZE;
+ current_spare += MLC_SMALL_SPARE_SIZE;
+ }
+
+ if (symbol_error_count_ptr != NULL) {
+ *symbol_error_count_ptr = symbol_error_count;
</font> }
return sc;
<font color='#997700'>@@ -268,7 +318,7 @@
</font>
rtems_status_code lpc32xx_mlc_erase_block(uint32_t block_index)
{
<font color='#880000'>- rtems_status_code sc = RTEMS_IO_ERROR;
</font><font color='#000088'>+ rtems_status_code sc = RTEMS_UNSATISFIED;
</font>
if (block_index >= mlc_block_count) {
return RTEMS_INVALID_ID;
<font color='#997700'>@@ -288,14 +338,18 @@
</font>
rtems_status_code lpc32xx_mlc_write_page_with_ecc(
uint32_t page_index,
<font color='#880000'>- const uint32_t *data,
- const uint32_t *spare
</font><font color='#000088'>+ const void *data,
+ const void *spare
</font> )
{
rtems_status_code sc = RTEMS_IO_ERROR;
<font color='#880000'>- size_t small_pages_count = mlc_small_pages() ? 1 : MLC_SMALL_PAGES_PER_LARGE_PAGE;
</font><font color='#000088'>+ size_t small_pages_count = mlc_small_pages() ?
+ 1 : MLC_SMALL_PAGES_PER_LARGE_PAGE;
</font> size_t sp = 0;
size_t i = 0;
<font color='#000088'>+ bool aligned = is_word_aligned(data, spare);
+ const uint8_t *current_data = data;
+ const uint8_t *current_spare = spare;
</font>
if (page_index >= mlc_page_count) {
return RTEMS_INVALID_ID;
<font color='#997700'>@@ -308,17 +362,29 @@
</font> for (sp = 0; sp < small_pages_count; ++sp) {
mlc->ecc_enc = 0;
<font color='#880000'>- for (i = 0; i < MLC_SMALL_DATA_WORD_COUNT; ++i) {
- mlc->data.w32 = data [i];
</font><font color='#000088'>+ if (aligned) {
+ const uint32_t *aligned_data = (const uint32_t *) current_data;
+ const uint32_t *aligned_spare = (const uint32_t *) current_spare;
+
+ for (i = 0; i < MLC_SMALL_DATA_WORD_COUNT; ++i) {
+ mlc->data.w32 = aligned_data [i];
+ }
+ mlc->data.w32 = aligned_spare [0];
+ mlc->data.w16 = (uint16_t) aligned_spare [1];
+ } else {
+ for (i = 0; i < MLC_SMALL_DATA_SIZE; ++i) {
+ mlc->data.w8 = current_data [i];
+ }
+ for (i = 0; i < MLC_SMALL_USER_SPARE_SIZE; ++i) {
+ mlc->data.w8 = current_spare [i];
+ }
</font> }
<font color='#880000'>- mlc->data.w32 = spare [0];
- mlc->data.w16 = (uint16_t) spare [1];
</font> mlc->wpr = 0;
mlc_wait(MLC_ISR_CONTROLLER_READY);
<font color='#880000'>- data += MLC_SMALL_DATA_WORD_COUNT;
- spare += MLC_SMALL_SPARE_WORD_COUNT;
</font><font color='#000088'>+ current_data += MLC_SMALL_DATA_SIZE;
+ current_spare += MLC_SMALL_SPARE_SIZE;
</font> }
mlc->cmd = 0x10;
</pre>
<p> </p>
<p>--<br />
<small>Generated by <a href="http://www.codewiz.org/projects/index.html#loginfo">Deluxe Loginfo</a> 2.122 by Bernardo Innocenti <bernie@develer.com></small></p>
</body>
</html>