Skip to content

Avoid resetting the target when loading an elf #32

Answered by fcuzzocrea
fcuzzocrea asked this question in How to
Discussion options

You must be logged in to vote

Just a brief update to let you know that I was able to achieve my goal using ebreak.
Probably it is just an hack, but maybe could be useful for someone else in future.

Basically I have created a wait_for_debugger() function:

void wait_for_debugger(HLS_DATA* hls, MODE_CHOICE mode_choice,
                       uint64_t next_addr)
{
    /* Store current hardid */
    uint32_t hartid = read_csr(mhartid);

    /* Restore PLIC to known state */
    __disable_irq();
    PLIC_init();

    /* Disable all interrupts: */
    write_csr(mie, 0);

    switch (mode_choice) {
    default:
    case M_MODE:
        /**
         * User application execution should now start and never return
         * here…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by hughbreslin
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
How to
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #11 on June 02, 2022 10:13.