Attached patch flashes str710 correctly. This is a fixed version of
David's patch.
(gdb) target remote 10.0.0.136:3333
Remote debugging using 10.0.0.136:3333
0xe6056fa8 in ?? ()
(gdb) info mem
Using memory regions provided by the target.
Num Enb Low Addr High Addr Attrs
0 y 0x00000000 0x40000000 rw nocache
1 y 0x40000000 0x40008000 flash blocksize 0x2000 nocache
2 y 0x40008000 0x40010000 flash blocksize 0x8000 nocache
3 y 0x40010000 0x40040000 flash blocksize 0x10000 nocache
4 y 0x40040000 0x400c0000 rw nocache
5 y 0x400c0000 0x400c4000 flash blocksize 0x2000 nocache
6 y 0x400c4000 0x100000000 rw nocache
(gdb) monitor flash info 0
#0 : str7x at 0x40000000, size 0x00040000, buswidth 0, chipwidth 0
# 0: 0x00000000 (0x2000 8kB) protected
# 1: 0x00002000 (0x2000 8kB) protected
# 2: 0x00004000 (0x2000 8kB) protected
# 3: 0x00006000 (0x2000 8kB) protected
# 4: 0x00008000 (0x8000 32kB) protected
# 5: 0x00010000 (0x10000 64kB) protected
# 6: 0x00020000 (0x10000 64kB) protected
# 7: 0x00030000 (0x10000 64kB) protected
str7x flash driver info
(gdb) monitor reset init
jtag_speed 6400 => JTAG clk=0.010000
10 kHz
JTAG tap: str710.cpu tap/device found: 0x3f0f0f0f (mfg: 0x787, part:
0xf0f0, ver: 0x3)
srst pulls trst - can not reset into halted mode. Issuing halt after reset.
target state: halted
target halted in ARM state due to debug-request, current mode: Supervisor
cpsr: 0x000000d3 pc: 0xe604d308
jtag_speed 10 => JTAG clk=6.400000
6400 kHz
NOTE! DCC downloads have not been enabled, defaulting to slow memory
writes. Type 'help dcc'.
(gdb) load
Loading section .text, size 0x1e4 lma 0x40000000
Loading section .vectors, size 0x40 lma 0x400001e4
Loading section .rodata, size 0xd2f8 lma 0x40000224
Start address 0x40000000, load size 54556
Transfer rate: 6 KB/sec, 7793 bytes/write.
(gdb) monitor verify_image /ram/test_rom.elf
verified 54556 bytes in 0.630000s (84.567 kb/s)
(gdb) monitor flash erase_address 0x40000000 0x40000
erased address 0x40000000 (length 262144) in 3.290000s (77.812 kb/s)
(gdb) monitor verify_image /ram/test_rom.elf
checksum mismatch - attempting binary compare
Verify operation failed address 0x40000000. Was 0xff instead of 0x00
Command handler execution failed
in procedure 'verify_image' called at file "command.c", line 647
called at file "command.c", line 361
(gdb) load
Loading section .text, size 0x1e4 lma 0x40000000
Loading section .vectors, size 0x40 lma 0x400001e4
Loading section .rodata, size 0xd2f8 lma 0x40000224
Start address 0x40000000, load size 54556
Transfer rate: 23 KB/sec, 7793 bytes/write.
(gdb) monitor verify_image /ram/test_rom.elf
verified 54556 bytes in 0.640000s (83.246 kb/s)
--
Øyvind Harboe
US toll free 1-866-980-3434 / International +47 51 63 25 00
http://www.zylin.com/zy1000.html
ARM7 ARM9 ARM11 XScale Cortex
JTAG debugger and flash programmer
From 011a0537c19b7a89017ba425cdcbf7afc1d744a0 Mon Sep 17 00:00:00 2001
From: David Brownell <[email protected]>
Date: Tue, 19 Jan 2010 22:48:11 -0800
Subject: [PATCH] gdb_server: correctly report flash sector sizes
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Report each region of same-size sectors separately, instead
of incorrectly reporting that every sector has the same size.
This fixes a longstanding bug, exposed by other recent bugfixes
in flash handling.
Tested on str710 which has varying sector sizes.
Signed-off-by: Øyvind Harboe <[email protected]>
---
src/server/gdb_server.c | 81 +++++++++++++++++++++++++++++------------------
1 files changed, 50 insertions(+), 31 deletions(-)
diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c
index 6ed7243..3d28b76 100644
--- a/src/server/gdb_server.c
+++ b/src/server/gdb_server.c
@@ -1613,22 +1613,6 @@ static int decode_xfer_read(char *buf, char **annex, int *ofs, unsigned int *len
return 0;
}
-static int gdb_calc_blocksize(struct flash_bank *bank)
-{
- uint32_t i;
- uint32_t block_size = 0xffffffff;
-
- /* loop through all sectors and return smallest sector size */
-
- for (i = 0; i < (uint32_t)bank->num_sectors; i++)
- {
- if (bank->sectors[i].size < block_size)
- block_size = bank->sectors[i].size;
- }
-
- return block_size;
-}
-
static int compare_bank (const void * a, const void * b)
{
struct flash_bank *b1, *b2;
@@ -1666,7 +1650,6 @@ static int gdb_memory_map(struct connection *connection,
int offset;
int length;
char *separator;
- int blocksize;
uint32_t ram_start = 0;
int i;
@@ -1701,29 +1684,65 @@ static int gdb_memory_map(struct connection *connection,
compare_bank);
for (i = 0; i < flash_get_bank_count(); i++) {
+ int j;
+ unsigned sector_size = 0;
+ uint32_t start, end;
+
p = banks[i];
+ start = p->base;
+ end = p->base + p->size;
if (ram_start < p->base)
xml_printf(&retval, &xml, &pos, &size,
"<memory type=\"ram\" start=\"0x%x\" "
"length=\"0x%x\"/>\n",
- ram_start, p->base-ram_start);
+ ram_start, p->base - ram_start);
- /* If device has uneven sector sizes, eg. str7, lpc
- * we pass the smallest sector size to gdb memory map
- *
- * FIXME Don't lie about flash regions with different
- * sector sizes; just tell GDB about each region as
- * if it were a separate flash device.
+ /* Report adjacent groups of same-size sectors. So for
+ * example top boot CFI flash will list an initial region
+ * with several large sectors (maybe 128KB) and several
+ * smaller ones at the end (maybe 32KB). STR7 will have
+ * regions with 8KB, 32KB, and 64KB sectors; etc.
*/
- blocksize = gdb_calc_blocksize(p);
+ for (j = 0; j < p->num_sectors; j++) {
+
+ /* start a new group of sectors */
+ if (sector_size == 0) {
+ start = p->base + p->sectors[j].offset;
+ xml_printf(&retval, &xml, &pos, &size,
+ "<memory type=\"flash\" "
+ "start=\"0x%x\" ",
+ start);
+ sector_size = p->sectors[j].size;
+ }
+
+ unsigned block_size;
+ bool done_block = false;
+
+ if (j == p->num_sectors -1) {
+ /* terminate the last group of sectors */
+ block_size = (p->base + p->size) - start;
+ done_block = true;
+ } else if (p->sectors[j + 1].size != sector_size) {
+ /* finish a group of sectors */
+ block_size = (p->base + p->sectors[j + 1].offset) - start,
+ done_block = true;
+ }
+
+ if (done_block) {
+ xml_printf(&retval, &xml, &pos, &size,
+ "length=\"0x%x\">\n"
+ "<property name=\"blocksize\">"
+ "0x%x</property>\n"
+ "</memory>\n",
+ block_size,
+ sector_size);
+ sector_size = 0;
+ }
+
+ /* else we continue a group we started */
+ }
- xml_printf(&retval, &xml, &pos, &size,
- "<memory type=\"flash\" start=\"0x%x\" "
- "length=\"0x%x\">\n" \
- "<property name=\"blocksize\">0x%x</property>\n" \
- "</memory>\n", \
- p->base, p->size, blocksize);
ram_start = p->base + p->size;
}
--
1.6.3.3
_______________________________________________
Openocd-development mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/openocd-development