Menu

#150 Restart when running from RAM

Next release
closed-fixed
None
5
2015-02-28
2014-12-28
belerafon
No

There are a problem with "Reset target and restart debugging" button. I use simples project in RAM for STM32F4 and use OpenOCD debugging.
When I use standart configuration with "Load Executable" checkbox in Startup tab, then Debug session starts ok and I can debug my software. Configuration screens: one and two. When I need to reset target (from suspended mode, for example when PC stay in main() function) I press "Reset target and restart debugging" button and there are nothing: target goes to "running" mode, and OpenOCD print in console:

Warn : WARNING! The target is already running. All changes GDB did to registers will be discarded! Waiting for target to halt.

when I want to do anything with this, for example press "Suspend" button, I have got error in gdb console:

Program received signal SIGINT, Interrupt.
0x08002862 in ?? ()

then I simply stoped debug session by pressing Terminate and start new debugging to work next. Result - "Reset target and restart debugging" button do not work at all.

But I have good configuration. For this I unchecked "Load Executable" checkbox in Startup tab, set "Pre-run reset." and wrote some commands below:

monitor reset halt
file ${workspace_loc}\asd\Debug\asd.elf
load
ni

where asd.elf is my output file - configuration screen.
After this I can use "Reset target and restart debugging" button and it works! But after first pressing I have got some annoing message "The choosen operation is not enabled", but at next pressing it works fine.

Maybe exists a way to make working "Reset target and restart debugging" button with typically config without additional commands?

Discussion

1 2 > >> (Page 1 of 2)
  • Liviu Ionescu (ilg)

    I guess I understand your request, you need the Run commands to be executed at Restart, right?

     
  • Liviu Ionescu (ilg)

    • status: open --> open-accepted
    • assigned_to: Liviu Ionescu (ilg)
     
  • belerafon

    belerafon - 2014-12-28

    No, I request for work "out of box" without any special commands. My commands is workaround because standart configuration is not work with Restart for unknown for me reasons.

     
  • Liviu Ionescu (ilg)

    the standard configuration is tuned for running from flash, and the Restart button was intended as a shortcut to avoid rewriting the flash

    when running from ram you need to reload the app after each reset, as you did in your configuration, and this is not supported in the current standard configuration.

    although for other ARM cores that do not have internal flash running from ram is ok, I fail to understand why someone would prefer it for Cortex-M cores with internal flash.

    I'll study the Restart specifics when running from ram, and see what solutions are available.

     
  • Liviu Ionescu (ilg)

    • summary: "Reset target and restart debugging" button does not work --> Restart when running from RAM
     
  • Liviu Ionescu (ilg)

    please review your ticket and if the subject is indeed related to Restart when running from RAM, update it accordingly.

    if some of the problems apply to the standard configuration running from flash, please try to isolate them and describe them as clear as possible.

     
  • belerafon

    belerafon - 2014-12-28

    ARM cores that do not have internal flash

    My ARM (STM32F407 launchpad) have internal flash memory but I prefer debug in RAM because it's more safety and do not utilize flash rewrite cycles.

    if some of the problems apply to the standard configuration running from flash

    Now I configure project to run from flash but problems remain with Restart button and with standart configuration.

    To try investigate them I go to "OpenOCD gdb traces" console and found commands that performed when I press Restart button. This is

    monitor halt
    tbreak main
    monitor reset
    continue

    I tried to perform this commands manually in OpenOCD gdb console when target standing on some breakpoint. I got same reaction that after Restart button: target has been restarted but do not stopped in "main" breakpoint.

    Then I tried next commands on same conditions:

    monitor reset halt
    tbreak main
    continue

    and this commands works fine - target make a reset and go to main.

    Then I tried next:

    monitor halt
    monitor reset
    monitor halt
    tbreak main
    continue

    but this do not stopped target in main breakpoint too.

    I do not know why but correct restarting performed only after "monitor reset halt" in my case.

    Of course this solution can work only with flash but for RAM debugging needed other recipe. Maybe you create additionally checkbox "Reload program on reset" in settings? And RAM-users can check it, FLASH-users can uncheck...

     
  • Liviu Ionescu (ilg)

    I tried next commands ... and this commands works fine ...

    ok, it looks like the break must be set after reset (a safe way, after all).

    the reason it was set before is that the openocd plug-in was done with copy/paste from the j-link plug-in, and j-link does not forget breakpoints during reset.

    anyway, I updated all debug plug-ins to this, including the Start tab in the interface.

    I also checked and at during Restart all commands in the Run section are applied, so I renamed the section as Run/Restart.

    the new version is available on updates-test; comments are welcome.

    regarding the suggestion to reload program at restart, yes, I also considered this, and I'll probably implement it tomorrow.

     
  • belerafon

    belerafon - 2014-12-28

    No, it doesn't work. Now you make:

    monitor halt
    monitor reset
    tbreak main
    continue

    but working way is

    monitor reset halt
    tbreak main
    continue

    I think this because after "monitor reset" target automatically runs. And break can't be set. Command "monitor reset halt" do as reset, as halt simultaneous. And then break can be setted. To prove this I do in console "monitor reset", after this try "continue" and GDB say that target is running:

    450,871 144-interpreter-exec console "monitor reset"
    450,889 144^done
    450,889 (gdb)
    466,957 145-exec-continue --thread 1
    466,961 145^running
    466,961 *running,thread-id="all"
    466,961 (gdb)
    466,963 @"WARNING! The target is already running. All changes GDB did to registers will be discarded\ ! Waiting for target to halt.\n"

    Maybe this is OpenOCD - specific, maybe my target or JTAG-specific, but in my case work only "monitor reset halt".

     
  • Liviu Ionescu (ilg)

    No, it doesn't work. Now you make:
    monitor halt
    monitor reset <-- ???
    tbreak main
    continue

    'monitor reset' only? no I do 'monitor reset <type>'. what does the field 'Type:' read in your case?

     
  • belerafon

    belerafon - 2014-12-29

    oh, yes! I have set "Pre-run reset." checkbox and have got

    monitor halt
    monitor reset halt
    tbreak main
    continue

    it works now! Maybe interface is not so clear - the tooltip on this checkbox says what this is second reset. I thought that enough first reset and type of this first reset is "halt".

     
  • Liviu Ionescu (ilg)

    it works now!

    great!

    could you check in this configuration if you manually add a 'load' line in the large field does it also solve the restart when running from ram?

    if so, I'll add the 'Reload on Restart' button.

     
  • belerafon

    belerafon - 2014-12-29

    "load" is not work because it want a file path. Previously called "load" is not stores filename. "load" without filepath work only after "file" command.
    I have added filepath for "load" and have run program from RAM, but it not go to main because I have got next commands sequence:

    monitor reset halt
    monitor halt
    tbreak main
    load D:\Eclipse_GCC_ARM_wks\asd\Debug\asd.elf
    continue

    I think break can't work after loading a program. I have checked what next commands is ok:

    monitor reset halt
    monitor halt
    load D:\Eclipse_GCC_ARM_wks\asd\Debug\asd.elf
    tbreak main
    continue

    You need to call "tbreak" necessarily after "load".

     
  • Liviu Ionescu (ilg)

    ok, then I'll move tbreak just before continue.

    I'll make these changes and publish a new version shortly.

     
  • Liviu Ionescu (ilg)

    I finally opted for a slightly different solution, I added a 'Debug in RAM' button. when set, it always loads the elf after each reset.

    I also moved tbreak just before continue.

    please let me know if it works in your configuration too.

     
  • belerafon

    belerafon - 2014-12-29

    Yes! This is works fine as in RAM, as in Flash! Thanks!

     
  • Liviu Ionescu (ilg)

    you're welcome!

    thank you for helping improve the plug-ins.

     
  • Liviu Ionescu (ilg)

    there was some significant code restructuring, also affecting openocd backslash processing.

    could you retest the latest beta?

     
  • belerafon

    belerafon - 2014-12-31

    Now it is broken. I try to load to RAM with "Load executable" checkbox and without any additional commands. There are errors in GDB trace console:

    049,007 &"load D:\\Eclipse_GCC_ARM_wks\\asd\\Debug\\asd.elf\n"
    049,010 &"D:Eclipse_GCC_ARM_wksasdDebugasd.elf: No such file or directory.\n"

    openocd backslash processing is broken now for standard loading way.

     
  • Liviu Ionescu (ilg)

    this windows backslash issue was a nightmare :-(

    to my surprise, the double slash patch was required for J-Link and QEMU too, otherwise manually entering load commands was not possible, so the culprit might not be the openocd tcl interpreter, but the eclipse & gdb.

    could you retest the version 2.5.2-201501031434 available from updates-test?

     
  • belerafon

    belerafon - 2015-01-03

    Now it works. I have tested "Load executable" checkbox and loading by additional comands with one backslash.

     
  • Liviu Ionescu (ilg)

    ok, thank you.

     
  • belerafon

    belerafon - 2015-01-12

    There are new small bug what appear after last update-test. When i create new OpenOCD configuration the text field "C/C++ Application" is empty now, while "Project" contains correct project name. In old version of plugin both fields have filled automatically. Most likely problem appears after

    some significant code restructuring

     
    • Liviu Ionescu (ilg)

      please be sure you selected the elf you want to debug before creating any debug launch configuration.

       
  • belerafon

    belerafon - 2015-01-12

    Yes, it helps - I have compiled project, and elf-file is exists but Eclipse can't see it because i have not refresh Eclipse's "Project Explorer". After I do "Refresh", elf-file appears in "Project Explorer" and all is ok now, excuse me for worry.

     
1 2 > >> (Page 1 of 2)