summaryrefslogtreecommitdiff
path: root/src/flash/nand.c
diff options
context:
space:
mode:
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2009-04-02 21:22:14 +0000
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2009-04-02 21:22:14 +0000
commit3f427b90e062a5bae22322986b6053d64f831234 (patch)
tree010778c74fbc2e40c98943ad1d9bbfb19f8580ea /src/flash/nand.c
parent9a6c3cc87f5f9b01f0f4d57bb81fb3de4f533f23 (diff)
downloadopenocd+libswd-3f427b90e062a5bae22322986b6053d64f831234.tar.gz
openocd+libswd-3f427b90e062a5bae22322986b6053d64f831234.tar.bz2
openocd+libswd-3f427b90e062a5bae22322986b6053d64f831234.tar.xz
openocd+libswd-3f427b90e062a5bae22322986b6053d64f831234.zip
Nicolas Pitre nico at cam.org This at least should make the "nand info" command a little more useful.
git-svn-id: svn://svn.berlios.de/openocd/trunk@1443 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/flash/nand.c')
-rw-r--r--src/flash/nand.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/flash/nand.c b/src/flash/nand.c
index 2b3b5170..7946e344 100644
--- a/src/flash/nand.c
+++ b/src/flash/nand.c
@@ -689,6 +689,8 @@ int nand_erase(struct nand_device_s *device, int first_block, int last_block)
LOG_ERROR("erase operation didn't pass, status: 0x%2.2x", status);
return ERROR_NAND_OPERATION_FAILED;
}
+
+ device->blocks[i].is_erased = 1;
}
return ERROR_OK;
@@ -770,9 +772,15 @@ int nand_write_plain(struct nand_device_s *device, u32 address, u8 *data, u32 da
int nand_write_page(struct nand_device_s *device, u32 page, u8 *data, u32 data_size, u8 *oob, u32 oob_size)
{
+ u32 block;
+
if (!device->device)
return ERROR_NAND_DEVICE_NOT_PROBED;
+ block = page / (device->erase_size / device->page_size);
+ if (device->blocks[block].is_erased == 1)
+ device->blocks[block].is_erased = 0;
+
if (device->use_raw || device->controller->write_page == NULL)
return nand_write_page_raw(device, page, data, data_size, oob, oob_size);
else