Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The method of burning program to SoC: PB, SBA, AC in external debug #1057

Open
zhangdujiao opened this issue Apr 24, 2024 · 4 comments
Open

Comments

@zhangdujiao
Copy link

For the external debug, before debugging starts, GDB needs to load the program into memory or flash. At this time, is it also done through the three methods mentioned: PB, SBA, AC. However, PB needs to work together with AC to access memory, and AC can only be used when the core enters the debug mode (during program burning, the core should not have entered the debug mode, right?).
So, in this scenario, can the program only be burned through SBA?

@aap-sc
Copy link
Collaborator

aap-sc commented Apr 24, 2024

@zhangdujiao your question is more about debug spec than OpenOCD. To double-check it's better to ask this question there: https://github.com/riscv/riscv-debug-spec.

My understanding of the situation is below.
Debug Specification defines several facilities to access memory, namely the spec defines 3 ways to access memory:

  1. Program Buffer. Requires the hart to be in Debug Mode.
  2. Abstract Access Memory Command. Optionally, this does not require the hart to be in Debug Mode according to the spec. Quoting the spec:
Debug Modules may optionally implement this command and may support read and write access to
memory locations when the selected hart is running or halted. If this command supports memory
accesses while the hart is running, it must also support memory accesses while the hart is halted.
  1. System Bus Access.
A debugger can access memory from a hart’s point of view using a Program Buffer or the Abstract
Access Memory command. (Both these features are optional.) A Debug Module may also include a
System Bus Access block to provide memory access without involving a hart, regardless of whether
Program Buffer is implemented. 

Few additional notes:

  1. Writing flash memory is typically done via dedicated driver. I can't comment on the specifics of how this implemented (maybe someone else will), my guess is that it still uses hart to interact with the controller. Better check documentation or upstream openocd mailing list, since this is not necessarily a riscv-specific question.
  2. There was also a somewhat similar question a while ago Openocd: write to memory with dmi_write before init #1038

@zhangdujiao
Copy link
Author

Thank you very much for your detailed answers and corrections.
During the initialization process of debug, after loading the configuration file (with reset halt command last) of OpenOCD, the core enters the debug mode automatically, is that correct?

@aap-sc
Copy link
Collaborator

aap-sc commented Apr 24, 2024

During the initialization process of debug, after loading the configuration file (with reset halt command last) of OpenOCD, the core enters the debug mode automatically, is that correct?

Yes. If the reset halt command is the last one you have, your harts should be halted once processing of initialization script completes.

@zhangdujiao
Copy link
Author

many thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants