Resume execution with GRMON 'detach'

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

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!

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

Thank you very much. I’m so ready.

Hello Wei,

GRMON 3.3.11 is now available.

Best regards,
Arvid

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

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

The terminal can see the correct execution information

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

When I do the following

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.

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.

$ 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>

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.