summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDean Glazeski <dnglaze@gmail.com>2009-11-16 13:40:46 -0600
committerDavid Brownell <dbrownell@users.sourceforge.net>2009-12-03 17:29:42 -0800
commitcf2cb0fc84d262069282a7363944663c8d2505d3 (patch)
tree4ea071448800da62e97e1ffde8c15c628bb42fd6 /src
parent66985bb30619c412984a2cfa1c0b3c4a324dbe78 (diff)
downloadopenocd_libswd-cf2cb0fc84d262069282a7363944663c8d2505d3.tar.gz
openocd_libswd-cf2cb0fc84d262069282a7363944663c8d2505d3.tar.bz2
openocd_libswd-cf2cb0fc84d262069282a7363944663c8d2505d3.tar.xz
openocd_libswd-cf2cb0fc84d262069282a7363944663c8d2505d3.zip
Make ARM NAND I/O operations aware of last op
Updates the ARM NAND I/O code to look at and update the op field of arm_nand_data to reflect the last operation performed. It uses this field to copy the correct code to the target in the case where the struct is used for reads and writes. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Diffstat (limited to 'src')
-rw-r--r--src/flash/arm_nandio.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/flash/arm_nandio.c b/src/flash/arm_nandio.c
index fdf2109b..1b43b5f1 100644
--- a/src/flash/arm_nandio.c
+++ b/src/flash/arm_nandio.c
@@ -40,7 +40,8 @@
* @param area Pointer to a pointer to a working area to copy code to
* @return Success or failure of the operation
*/
-int arm_code_to_working_area(struct target *target, const uint32_t *code, unsigned code_size,
+int arm_code_to_working_area(struct target *target,
+ const uint32_t *code, unsigned code_size,
unsigned additional, struct working_area **area)
{
uint8_t code_buf[code_size];
@@ -48,6 +49,11 @@ int arm_code_to_working_area(struct target *target, const uint32_t *code, unsign
int retval;
unsigned size = code_size + additional;
+ /* REVISIT this assumes size doesn't ever change.
+ * That's usually correct; but there are boards with
+ * both large and small page chips, where it won't be...
+ */
+
/* make sure we have a working area */
if (NULL == *area) {
retval = target_alloc_working_area(target, size, area);
@@ -109,7 +115,7 @@ int arm_nandwrite(struct arm_nand_data *nand, uint8_t *data, int size)
0xe1200070, /* e: bkpt #0 */
};
- if (!nand->copy_area) {
+ if (nand->op != ARM_NAND_WRITE || !nand->copy_area) {
retval = arm_code_to_working_area(target, code, sizeof(code),
nand->chunk_size, &nand->copy_area);
if (retval != ERROR_OK) {
@@ -117,6 +123,8 @@ int arm_nandwrite(struct arm_nand_data *nand, uint8_t *data, int size)
}
}
+ nand->op = ARM_NAND_WRITE;
+
/* copy data to work area */
target_buf = nand->copy_area->address + sizeof(code);
retval = target_bulk_write_memory(target, target_buf, size / 4, data);
@@ -192,7 +200,7 @@ int arm_nandread(struct arm_nand_data *nand, uint8_t *data, uint32_t size)
};
/* create the copy area if not yet available */
- if (!nand->copy_area) {
+ if (nand->op != ARM_NAND_READ || !nand->copy_area) {
retval = arm_code_to_working_area(target, code, sizeof(code),
nand->chunk_size, &nand->copy_area);
if (retval != ERROR_OK) {
@@ -200,6 +208,7 @@ int arm_nandread(struct arm_nand_data *nand, uint8_t *data, uint32_t size)
}
}
+ nand->op = ARM_NAND_READ;
target_buf = nand->copy_area->address + sizeof(code);
/* set up algorithm and parameters */
@@ -223,7 +232,7 @@ int arm_nandread(struct arm_nand_data *nand, uint8_t *data, uint32_t size)
retval = target_run_algorithm(target, 0, NULL, 3, reg_params,
nand->copy_area->address, exit, 1000, &algo);
if (retval != ERROR_OK)
- LOG_ERROR("error executing hosted NAND write");
+ LOG_ERROR("error executing hosted NAND read");
destroy_reg_param(&reg_params[0]);
destroy_reg_param(&reg_params[1]);