Package: openocd Version: 0.9.0 Tags: patch openocd fails to program the Intel TE28F160 flash memory attached to the AR7 (MIPS core) in a Solwise SAR600E router (the AR7 is also used in many other routers) with the error "Unknown architecture". There are two reasons for the failure.
The first reason is that the architecture problem only prevents block writing. It does not prevent word-at-a-time writing (granted this is horrendously slow, but it is a lot better than nothing). The openocd code does in fact contain a fallback to word-at-a-time writing for the case that block writing is not possible, but with a MIPS target it fails to trigger the fallback. The second reason is that the code for word-at-a-time writing doesn't actually work as supplied, because part of the logic is scrambled (although that same logic appears correct and unscrambled in several other places, including just a few lines further on from the error). Attached is a patch to (a) ensure that the fallback does get triggered, and (b) unscramble the scrambled bit of code. -- Pigeon Be kind to pigeons - - Pigeon's Nest: http://pigeonsnest.co.uk/ GPG key: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x21C61F7F
diff -Naur openocd-0.9.0.orig/src/flash/nor/cfi.c openocd-0.9.0/src/flash/nor/cfi.c --- openocd-0.9.0.orig/src/flash/nor/cfi.c 2014-03-29 17:55:12.000000000 +0100 +++ openocd-0.9.0/src/flash/nor/cfi.c 2016-12-31 18:48:48.884400377 +0100 @@ -1212,8 +1212,12 @@ arm_algo.core_mode = ARM_MODE_SVC; arm_algo.core_state = ARM_STATE_ARM; } else { - LOG_ERROR("Unknown architecture"); - return ERROR_FAIL; + if (strncmp(target_type_name(target), "mips_m4k", 8) == 0) { + return (ERROR_TARGET_RESOURCE_NOT_AVAILABLE); + } else { + LOG_ERROR("Unknown architecture"); + return ERROR_FAIL; + } } cfi_intel_clear_status_register(bank); @@ -1989,7 +1993,9 @@ uint8_t status; retval = cfi_intel_wait_status_busy(bank, cfi_info->word_write_timeout, &status); - if (retval != 0x80) { + if (retval != ERROR_OK) + return retval; + if (status != 0x80) { retval = cfi_send_command(bank, 0xff, flash_address(bank, 0, 0x0)); if (retval != ERROR_OK) return retval;
signature.asc
Description: Digital signature