# Resume execution with GRMON 'detach'

**URL:** <https://discourse.grlib.community/t/resume-execution-with-grmon-detach/410>\
**Category:** General - Software\
**Created:** [2 May 2024 08:48 UTC](https://discourse.grlib.community/t/resume-execution-with-grmon-detach/410 "2024-05-02T08:48:24Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![WEI](https://avatars.discourse-cdn.com/v4/letter/w/90ced4/32.png) [@WEI](https://discourse.grlib.community/u/WEI)\
**Post date:** [2 May 2024 08:48 UTC](https://discourse.grlib.community/t/resume-execution-with-grmon-detach/410/1 "2024-05-02T08:48:24Z")

</div>

Hi, arvid  
Can the ‘detach’ command be applied to the NOEL based system?

---

<div class="post-metadata">

**Author:** ![WEI](https://avatars.discourse-cdn.com/v4/letter/w/90ced4/32.png) [@WEI](https://discourse.grlib.community/u/WEI)\
**Post date:** [6 May 2024 00:37 UTC](https://discourse.grlib.community/t/resume-execution-with-grmon-detach/410/2 "2024-05-06T00:37:04Z")

</div>

```auto
grmon3> detach
  Unknown failure!

grmon3> attach
  CPU 0: Interrupted!
          0x80004cb6: 10500073 wfi <fw_platform_init+394>
  CPU 1: Interrupted!
          0x80000436: 4289 li t0, 2 <_wait_for_boot_hart+0>
  CPU 2: Interrupted!
          0x80000448: 0203c3b3 div t2, t2, zero
  CPU 3: Interrupted!
          0x80000438: 00040317 auipc t1, 0x40

grmon3> detach
  Unknown failure!

```

---

<div class="post-metadata">

**Author:** ![arvid](https://dub1.discourse-cdn.com/flex017/user_avatar/discourse.grlib.community/arvid/32/12_2.png) [@arvid](https://discourse.grlib.community/u/arvid)\
**Post date:** [6 May 2024 05:47 UTC](https://discourse.grlib.community/t/resume-execution-with-grmon-detach/410/3 "2024-05-06T05:47:41Z")

</div>

Hello Wei!

The detach command became broken in 3.3.8. I have already have a fix for it that will be included in the next release.

I plan to make a new release before end of may.

Best regards,  
Arvid

---

<div class="post-metadata">

**Author:** ![WEI](https://avatars.discourse-cdn.com/v4/letter/w/90ced4/32.png) [@WEI](https://discourse.grlib.community/u/WEI)\
**Post date:** [7 May 2024 00:36 UTC](https://discourse.grlib.community/t/resume-execution-with-grmon-detach/410/4 "2024-05-07T00:36:04Z")

</div>

Thank you very much. I’m so ready.

---

<div class="post-metadata">

**Author:** ![arvid](https://dub1.discourse-cdn.com/flex017/user_avatar/discourse.grlib.community/arvid/32/12_2.png) [@arvid](https://discourse.grlib.community/u/arvid)\
**Post date:** [16 May 2024 18:00 UTC](https://discourse.grlib.community/t/resume-execution-with-grmon-detach/410/5 "2024-05-16T18:00:51Z")

</div>

Hello Wei,

GRMON 3.3.11 is now available.

Best regards,  
Arvid

---

<div class="post-metadata">

**Author:** ![WEI](https://avatars.discourse-cdn.com/v4/letter/w/90ced4/32.png) [@WEI](https://discourse.grlib.community/u/WEI)\
**Post date:** [20 May 2024 03:35 UTC](https://discourse.grlib.community/t/resume-execution-with-grmon-detach/410/6 "2024-05-20T03:35:40Z")

</div>

Hello arvid, Thank you for the update.

I tried the new version of grmon, but it still doesn’t seem to work as expected. The following is my try, I am not sure if I have used the command correctly.

When I do the following

```auto
grmon3> lo gaisler-buildroot-2024.02-1.0/output/images/fw_payload.elf
grmon3> run

```

The terminal can see the correct execution information

```auto
OpenSBI v1.4
   _________  _________
  / __\ /____ | _ \_ _|
 | | | |_ _____ _ __| (___ | |_) || |
 | | | | '_ \ / _ \ '_ \ \___ \| _ < | |
 | |__| | |_) |__/ | | | ____ ) | |_) || |_
  \ ____/| .__ / \ ___|_| |_|_____ /| ____/_____ |
        | |
        |_|

```

When I do the following

```auto
grmon3> lo gaisler-buildroot-2024.02-1.0/output/images/fw_payload.elf
grmon3> detach

grmon3> cpu
   cpu 0: detached active
   cpu 1: detached
   cpu 2: detached
   cpu 3: detached

```

The command have detached GRMON successfully, but the terminal cannot see any information.

It seems that the ‘detach’ command has not resumed execution on enabled CPUs.

---

<div class="post-metadata">

**Author:** ![arvid](https://dub1.discourse-cdn.com/flex017/user_avatar/discourse.grlib.community/arvid/32/12_2.png) [@arvid](https://discourse.grlib.community/u/arvid)\
**Post date:** [20 May 2024 08:07 UTC](https://discourse.grlib.community/t/resume-execution-with-grmon-detach/410/7 "2024-05-20T08:07:03Z")

</div>

Hello Wei,

It works for me when I try with a simple hello world application (see output below)

When you do detach, it will just resume from the current state. Neither load nor detach will setup entry point, stack pointers or any other initializations. Calling detach directly after load will only work if you have a bootloader and the PC register is currently pointing to it.

“load ; reset; detach” should work.

```auto
$ grmon -digilent

  GRMON debug monitor v3.3.11 64-bit eval version

  Copyright (C) 2024 Frontgrade Gaisler - All rights reserved.
  For latest updates, go to https://www.gaisler.com/
  Comments or bug-reports to support@gaisler.com

  This eval version will expire on 15/11/2024

JTAG chain (1): xcku040
  Device ID: 0x287
  GRLIB build version: 4282
  Detected frequency: 100.0 MHz

  Component Vendor
  NOEL-V RISC-V Processor Frontgrade Gaisler
  NOEL-V RISC-V Processor Frontgrade Gaisler
  NOEL-V RISC-V Processor Frontgrade Gaisler
  NOEL-V RISC-V Processor Frontgrade Gaisler
...
grmon3> forward enable uart0
  I/O forwarding to uart0 enabled

grmon3> load ~/reps/hello/bin/rv64imafdc/hello; bp main; run;
                 0 .text 13.9kB / 13.9kB [===============>] 100%
              37d0 .rodata 192B [===============>] 100%
              3890 .init_array 8B [===============>] 100%
              3898 .fini_array 8B [===============>] 100%
              38a0 .data 2.2kB / 2.2kB [===============>] 100%
              4160 .sdata 80B [===============>] 100%
              41b0 .eh_frame 4B [===============>] 100%
  Total size: 16.42kB (611.42kbit/s)
  Entry point 0x00000000
  Image /home/arvid/reps/hello/bin/rv64imafdc/hello loaded
  Software breakpoint 1 at <main>
  CPU 0: Breakpoint 1 hit
          0x0000045a: 1141 addi sp, sp, -16 <main+0>
  CPU 1: Interrupted!
          0x00000050: 0ff0000f fence iorw, iorw <_start+80>
  CPU 2: Interrupted!
          0x00000050: 0ff0000f fence iorw, iorw <_start+80>
  CPU 3: Interrupted!
          0x00000050: 0ff0000f fence iorw, iorw <_start+80>

grmon3> detach; forward start;
Hello world!

grmon3> attach
  CPU 0: Breakpoint 1 hit
          0x00000194: fcc2 sd a6, 120(sp) <__bcc_trap_table+36>
  CPU 1: Interrupted!
          0x00000054: fe031ce3 bnez t1, 0x4c <_start+84>
  CPU 2: Interrupted!
          0x00000054: fe031ce3 bnez t1, 0x4c <_start+84>
  CPU 3: Interrupted!
          0x00000054: fe031ce3 bnez t1, 0x4c <_start+84>

```

---

<div class="post-metadata">

**Author:** ![WEI](https://avatars.discourse-cdn.com/v4/letter/w/90ced4/32.png) [@WEI](https://discourse.grlib.community/u/WEI)\
**Post date:** [20 May 2024 10:14 UTC](https://discourse.grlib.community/t/resume-execution-with-grmon-detach/410/8 "2024-05-20T10:14:24Z")

</div>

Hi, arvid

In my test, DTB loading was involved.

The problem should be that the ‘detach’ command does not load DTB like the ‘run’ command. When I execute the ‘dtb load’ before ‘detach’, everything works normally.
