Hi, there is a bug in "src/flash/nor/cfi.c" that, fortunately, doesn't have any effect at run-time. The proper order of arguments for the command "flash bank" is - chip_width as CMD_ARGV[3] - bus_width as CMD_ARGV[4] Such arguments are already parsed in "src/flash/nor/tcl.c" "handle_flash_bank_command()" and put in a data structure. The cfi specific code for "flash bank" partially parses command line again, but erroneously swaps the 2 arguments. At run-time there is no error because both value are only used for range check and, by chance, the range is same.
The first patch in attachment fixes the order of the 2 arguments. I cannot find any reason to parse the command arguments twice. So, I have added a second patch that removes the redundant re-parse of the command line. Comments are welcome. Best Regards, Antonio Borneo
From 7fbe87bd5e8f891b71145b9f1adcad072b9b9682 Mon Sep 17 00:00:00 2001 From: Antonio Borneo <borneo.anto...@gmail.com> Date: Wed, 14 Apr 2010 16:32:30 +0800 Subject: [PATCH] NOR/CFI: fix order of arguments check Syntax of "flash bank" command requires: - chip_width as CMD_ARGV[3] - bus_width as CMD_ARGV[4] Actual code swaps the arguments. Bug has no run time impact since wrong variables are only used to check value and both are checked against same constraint. Signed-off-by: Antonio Borneo <borneo.anto...@gmail.com> --- src/flash/nor/cfi.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/flash/nor/cfi.c b/src/flash/nor/cfi.c index 4dad7b6..325dce9 100644 --- a/src/flash/nor/cfi.c +++ b/src/flash/nor/cfi.c @@ -599,8 +599,8 @@ FLASH_BANK_COMMAND_HANDLER(cfi_flash_bank_command) } uint16_t chip_width, bus_width; - COMMAND_PARSE_NUMBER(u16, CMD_ARGV[3], bus_width); - COMMAND_PARSE_NUMBER(u16, CMD_ARGV[4], chip_width); + COMMAND_PARSE_NUMBER(u16, CMD_ARGV[3], chip_width); + COMMAND_PARSE_NUMBER(u16, CMD_ARGV[4], bus_width); if ((chip_width > CFI_MAX_CHIP_WIDTH) || (bus_width > CFI_MAX_BUS_WIDTH)) -- 1.5.2.2
From 2f525c3462985a77a1b6a845fd0d6449358580fb Mon Sep 17 00:00:00 2001 From: Antonio Borneo <borneo.anto...@gmail.com> Date: Wed, 14 Apr 2010 16:51:16 +0800 Subject: [PATCH] NOR/CFI: remove redundant code Arguments for "flash bank" command are already parsed and put in "bank" struct. Removed code to parse them again. Signed-off-by: Antonio Borneo <borneo.anto...@gmail.com> --- src/flash/nor/cfi.c | 8 ++------ 1 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/flash/nor/cfi.c b/src/flash/nor/cfi.c index 325dce9..a64d78f 100644 --- a/src/flash/nor/cfi.c +++ b/src/flash/nor/cfi.c @@ -598,12 +598,8 @@ FLASH_BANK_COMMAND_HANDLER(cfi_flash_bank_command) return ERROR_FLASH_BANK_INVALID; } - uint16_t chip_width, bus_width; - COMMAND_PARSE_NUMBER(u16, CMD_ARGV[3], chip_width); - COMMAND_PARSE_NUMBER(u16, CMD_ARGV[4], bus_width); - - if ((chip_width > CFI_MAX_CHIP_WIDTH) - || (bus_width > CFI_MAX_BUS_WIDTH)) + if ((bank->chip_width > CFI_MAX_CHIP_WIDTH) + || (bank->bus_width > CFI_MAX_BUS_WIDTH)) { LOG_ERROR("chip and bus width have to specified in bytes"); return ERROR_FLASH_BANK_INVALID; -- 1.5.2.2
_______________________________________________ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development