Bug in cfi.c

I currently using a AT91R40008 and AT49BV322 with openocd.

Command ‘flash erase’ and ‘falsh write’ not works after revision 155.

Variable pri_ext->_unlock1 and pri_ext->_unlock2 not set.

It correct patch:

Index: cfi.c
===================================================================
--- cfi.c	(revision 210)
+++ cfi.c	(working copy)
@@ -98,7 +98,7 @@
 	{CFI_MFR_SST, 0x00D6, cfi_fixup_0002_unlock_addresses, &cfi_unlock_addresses[CFI_UNLOCK_5555_2AAA]},
 	{CFI_MFR_SST, 0x00D7, cfi_fixup_0002_unlock_addresses, &cfi_unlock_addresses[CFI_UNLOCK_5555_2AAA]},
 	{CFI_MFR_ATMEL, 0x00C8, cfi_fixup_atmel_reversed_erase_regions, NULL},
-	{CFI_MFR_ANY, CFI_ID_ANY, cfi_fixup_0002_erase_regions, NULL},
+	{CFI_MFR_ANY, CFI_ID_ANY, cfi_fixup_0002_erase_regions, &cfi_unlock_addresses[CFI_UNLOCK_555_2AA]},
 	{0, 0, NULL, NULL}
 };
 
@@ -1607,6 +1607,10 @@
 			cfi_info->erase_region_info[j] = swap;
 		}
 	}
+
+	cfi_unlock_addresses_t *unlock_addresses = param;
+	pri_ext->_unlock1 = unlock_addresses->unlock1;
+	pri_ext->_unlock2 = unlock_addresses->unlock2;
 }
 
 void cfi_fixup_0002_unlock_addresses(flash_bank_t *bank, void *param)

May be add in svn?

Andrej Taran

Hello Andrej,

thanks for the patch.

I’ve fixed this issue in my local tree, but haven’t had time to commit the changes to the SVN repository yet.

Best regards,

Dominic