Check for abstractcs.busy, not just CMDERR_BUSY
This fixes a race condition when reading/writing memory.
This commit is contained in:
parent
a8cf04b839
commit
c431c0eb25
|
@ -1378,6 +1378,8 @@ static int read_memory(struct target *target, uint32_t address,
|
||||||
// catches the case where no writes went through at all.
|
// catches the case where no writes went through at all.
|
||||||
|
|
||||||
uint32_t abstractcs = dmi_read(target, DMI_ABSTRACTCS);
|
uint32_t abstractcs = dmi_read(target, DMI_ABSTRACTCS);
|
||||||
|
while (get_field(abstractcs, DMI_ABSTRACTCS_BUSY))
|
||||||
|
abstractcs = dmi_read(target, DMI_ABSTRACTCS);
|
||||||
switch (get_field(abstractcs, DMI_ABSTRACTCS_CMDERR)) {
|
switch (get_field(abstractcs, DMI_ABSTRACTCS_CMDERR)) {
|
||||||
case CMDERR_NONE:
|
case CMDERR_NONE:
|
||||||
LOG_DEBUG("successful (partial?) memory write");
|
LOG_DEBUG("successful (partial?) memory write");
|
||||||
|
@ -1560,6 +1562,8 @@ static int write_memory(struct target *target, uint32_t address,
|
||||||
// catches the case where no writes went through at all.
|
// catches the case where no writes went through at all.
|
||||||
|
|
||||||
uint32_t abstractcs = dmi_read(target, DMI_ABSTRACTCS);
|
uint32_t abstractcs = dmi_read(target, DMI_ABSTRACTCS);
|
||||||
|
while (get_field(abstractcs, DMI_ABSTRACTCS_BUSY))
|
||||||
|
abstractcs = dmi_read(target, DMI_ABSTRACTCS);
|
||||||
switch (get_field(abstractcs, DMI_ABSTRACTCS_CMDERR)) {
|
switch (get_field(abstractcs, DMI_ABSTRACTCS_CMDERR)) {
|
||||||
case CMDERR_NONE:
|
case CMDERR_NONE:
|
||||||
LOG_DEBUG("successful (partial?) memory write");
|
LOG_DEBUG("successful (partial?) memory write");
|
||||||
|
|
Loading…
Reference in New Issue