I’m using openocd very often to flash my STR7 developpement board. There is still at least one bug left: you can’t flash twice: you have to kill and restart openocd before using ‘flash write’ again, otherwise openocd fails with a ‘flash program error’.
The origin of the problem is the following:
-
str7x_info->write_algorithm is allocated only if it is NULL.
-
the program is flashed once, runs, and scraps RAM. So the algorithm is lost.
-
when one wants to flash write again, since str7x_info->write_algorithm is not NULL, RAM is not written again with algorithm data, and there is no more algorithm to run.
Fix, as a context diff to run in trunk/src/flash:
[bernard@linuxbf ~]$ cat /tmp/fix
*** str7x.c 2006-10-24 10:50:02.000000000 +0200
— /tmp/str7x.c 2006-10-24 10:47:17.000000000 +0200
*** 505,512 ****
if (buffer_size <= 256)
{
/* if we already allocated the writing code, but failed to get a buffer, free the algorithm */
! if (str7x_info->write_algorithm)
! target_free_working_area(target, str7x_info->wri te_algorithm);
WARNING(“no large enough working area available, can’t d o block memory writes”);
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
— 505,515 ----
if (buffer_size <= 256)
{
/* if we already allocated the writing code, but failed to get a buffer, free the algorithm */
! if (str7x_info->write_algorithm)
! {
! target_free_working_area(target, str7x_info->write_alg orithm);
! str7x_info->write_algorithm=NULL;
! }
WARNING(“no large enough working area available, can’t d o block memory writes”);
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
*** 558,563 ****
— 561,569 ----
destroy_reg_param(®_params[3]);
destroy_reg_param(®_params[4]);
-
target_free_working_area(target, str7x_info->write_algorithm);
-
str7x_info->write_algorithm=NULL;
return ERROR_OK;
}
[bernard@linuxbf ~]$