Hi,

I came across this yesterday whilst using OpenOCD to try and reflash a
PIC32MX. The git head appears to be broken when applying the
word-by-word writing algorithm, due to the fact that the register names
used are r0 through r31, instead of the synonyms defined by the MIPS
assembler.

As such, when src/flash/nor/pic32mx.c:pix32mx_write_block() tries to set
the value of an "a0" register, it fails with a BUG: unknown register
"a0". Changing a0/a1/a2 to r4/r5/r6 (the underlying hardware registers)
in this function causes everything to function as expected. I've
attached a patch that fixes this.

This was tested on two PIC32MX250F128B chips, one in a minimal
programming circuit and one in a prototype circuit.

Let me know I can provide any further information!

Thanks for the wonderful project,

- ethereal
From e55a9de5362f7adcb611cf118e94deb39c25af8a Mon Sep 17 00:00:00 2001
From: ethereal <[email protected]>
Date: Fri, 29 Jan 2016 12:13:37 -0800
Subject: [PATCH] Fixed PIC32MX algorithm interface code to use reg_param
 register names.

---
 src/flash/nor/pic32mx.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/flash/nor/pic32mx.c b/src/flash/nor/pic32mx.c
index 5e82ba6..25fc4f7 100644
--- a/src/flash/nor/pic32mx.c
+++ b/src/flash/nor/pic32mx.c
@@ -472,9 +472,11 @@ static int pic32mx_write_block(struct flash_bank *bank, const uint8_t *buffer,
 	mips32_info.common_magic = MIPS32_COMMON_MAGIC;
 	mips32_info.isa_mode = MIPS32_ISA_MIPS32;
 
-	init_reg_param(&reg_params[0], "a0", 32, PARAM_IN_OUT);
-	init_reg_param(&reg_params[1], "a1", 32, PARAM_OUT);
-	init_reg_param(&reg_params[2], "a2", 32, PARAM_OUT);
+    /* The assembly uses a0/a1/a2 here, but we have the rX variants in our
+     * reg_param data structures. */
+	init_reg_param(&reg_params[0], "r4", 32, PARAM_IN_OUT);
+	init_reg_param(&reg_params[1], "r5", 32, PARAM_OUT);
+	init_reg_param(&reg_params[2], "r6", 32, PARAM_OUT);
 
 	int row_offset = offset % row_size;
 	uint8_t *new_buffer = NULL;
-- 
2.7.0

------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to