Skip to content

Memory burst writes with abstractauto can fail due to missing BUSY checks #1306

@nadime15

Description

@nadime15

When abstractauto (for dataX) is enabled, writing to a data register automatically triggers an abstract command. However, if a previous command is still executing (BUSY=1), the new command cannot start. Currently, openocd continues writing to data registers without checking BUSY, which results in ignored commands and lost updates.

For example, we enable abstractauto and issue a single abstract command (Access Register). Once it completes, writing to data0 triggers execution of that command again (CMD1). If we write to data0 again while this command (CMD1) is still executing, cmderr.BUSY is set, so the write is ignored. Once CMD1 finishes, BUSY is cleared (success), and execution continues.

See the logs showing continuous writes to data0 and data1.

Debug: 29678 1856715 batch.c:264 log_batch(): 41b w 02010413 @05 -> ?; 0i
Debug: 29679 1856715 batch.c:199 log_dmi_decoded(): write:
Debug: 29680 1856715 batch.c:264 log_batch(): 41b w 00813823 @04 -> ?; 169i
Debug: 29681 1856715 batch.c:199 log_dmi_decoded(): write:
Debug: 29682 1856715 batch.c:264 log_batch(): 41b w feb43023 @05 -> ?; 0i
Debug: 29683 1856715 batch.c:199 log_dmi_decoded(): write:
Debug: 29684 1856715 batch.c:264 log_batch(): 41b w fea43423 @04 -> ?; 169i
Debug: 29685 1856715 batch.c:199 log_dmi_decoded(): write:
Debug: 29686 1856715 batch.c:264 log_batch(): 41b w fe043783 @05 -> ?; 0i
Debug: 29687 1856715 batch.c:199 log_dmi_decoded(): write:
Debug: 29688 1856715 batch.c:264 log_batch(): 41b w fe843703 @04 -> ?; 169i
Debug: 29689 1856715 batch.c:199 log_dmi_decoded(): write:
Debug: 29690 1856715 batch.c:264 log_batch(): 41b w 00078513 @05 -> ?; 0i
Debug: 29691 1856715 batch.c:199 log_dmi_decoded(): write:
Debug: 29692 1856715 batch.c:264 log_batch(): 41b w 00f707b3 @04 -> ?; 169i
Debug: 29693 1856715 batch.c:199 log_dmi_decoded(): write:
Debug: 29694 1856715 batch.c:264 log_batch(): 41b w 01013403 @05 -> ?; 0i
Debug: 29695 1856715 batch.c:199 log_dmi_decoded(): write:
Debug: 29696 1856715 batch.c:264 log_batch(): 41b w 01813083 @04 -> ?; 169i

Half of the data is lost because writes to data0 and data1 are ignored while a previous abstract command is still executing.

In my opinion, this is caused by openocd not checking whether the hart is currently busy (BUSY=1) before writing to a data register. On real hardware, this may be a rare case since the core likely executes abstract commands faster than the jtag accesses, so it’s mainly a timing issue. However, openocd seems to assume that abstract commands complete faster than the writes to dataX (just an assumption from my end).

But I might miss something!

This is related to issue #587 and is unfortunately still relevant today.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions