R37 on R62

Hardware related problems and workarounds

R37 on R62

Postby upcFrost » Mon Apr 24, 2017 4:38 pm

Hi,

Tripped upon this problem while debugging wtf LLVM-compiled eprime example doesn't work. Can someone plz check what's going on with the following code (device side).

Code: Select all
int main(void) {
__asm__ __volatile__("mov r37, 0x1234");
__asm__ __volatile__("mov r62, 0x5678");
return 0;
}


When i'm running this code, mov r37,0x1234 for some reason sets not only r37, but also r62. mov r62, 0x5678 does virtually nothing, so in the end i'm getting 0x1234 in both r37 and r62.

Just to check if it's only my board, or someone else has the same issue.

p.s. Sorry for not writing the whole nice code and asking to use gdb. I'm just not exactly sure where the problem might be. For example, will it appear if I'll use e_write (will check it later).

p.p.s. As i'm using e-gdb et mass, and i was unable to find any complete manual on this forum, just a short note how to run the code:
  • Copy host side from any example (e.g. from dotproduct)
  • Paste this code into the device side C file, overwriting it
  • Add -g modifier to the example's build.sh to the host-side compilation line
  • Run build.sh
  • Check host-side code and find e_start_group() or e_start() line, I'll call it LINENUM
  • Check run.sh for run args, I'll call them ARGS
  • Run host-side as follows: gdb --eval-command="break main.c:LINENUM" --args ./e_task.elf ARGS
  • Type r and press enter to run to the break point
  • Start e-server (just e-server in some other session/screen/terminal)
  • Start e-gdb (yes, third screen/terminal) with the following command
    Code: Select all
    e-gdb --init-eval-command="target extended-remote :51000" --eval-command="set pagination off" --eval-command="set non-stop on" --eval-command="thread 1" --eval-command="set scheduler-locking on" --eval-command="load" --eval-command="break main" --eval-command="layout asm" e_task.elf
  • Type c and press Enter to run to the main function
  • Step over with 'nexti'
  • Check reg values with 'info reg r37'
Current LLVM backend for Epiphany: https://github.com/upcFrost/Epiphany. Commits and code reviews are welcome
upcFrost
 
Posts: 37
Joined: Wed May 28, 2014 6:37 am
Location: Moscow, Russia

Re: R37 on R62

Postby olajep » Tue Apr 25, 2017 10:26 am

Hi upcFrost,

Which version of Parabuntu / ESDK are you using?
Major changes to gdb in 2016.11

Not sure what's wrong but will investigate.

A couple of ideas:
When you access a general purpose register you must make sure that the core is halted, otherwise strange things can happen.
You might be getting stale register values. Use flushregs to flush gdb's internal register cache

Epiphany gdb tutorial here:
https://github.com/parallella/parallell ... b-tutorial

For this type of work I think it is more convenient to use the simulator:

Either standalone:
Code: Select all
$ e-run --e-external-fetch --trace ./a.out 2>&1 | less


... or via gdb
Code: Select all
$ e-gdb ./a.out -ex "target sim" -ex "sim e-coreid 0x808" -ex "sim e-rows 1" -ex "sim e-cols 1" -ex "sim e-external-fetch"
Reading symbols from ./a.out...(no debugging symbols found)...done.
Connected to the simulator.
(gdb) load
Loading section ivt_reset, size 0x4 lma 0x0
Loading section loader_cfg, size 0x10 lma 0x58
...
Loading section .rodata, size 0x8 lma 0x9d0
Start address 0x0
Transfer rate: 18256 bits in <1 sec.
(gdb) start
Temporary breakpoint 1 at 0x940
Starting program: /home/parallella/tmp/r37/a.out

Temporary breakpoint 1, 0x00000940 in main ()
(gdb) disassemble
Dump of assembler code for function main:
   0x00000938 <+0>:   str fp,[sp],-0x2
   0x0000093c <+4>:   mov fp,sp
=> 0x00000940 <+8>:   mov r37,0x1234
   0x00000944 <+12>:   mov r62,0x5678
   0x00000948 <+16>:   mov r0,0x0
   0x0000094a <+18>:   ldr fp,[sp,+0x2]
   0x0000094e <+22>:   add sp,sp,8
   0x00000952 <+26>:   rts
End of assembler dump.
(gdb) si
0x00000944 in main ()
(gdb) disassemble
Dump of assembler code for function main:
   0x00000938 <+0>:   str fp,[sp],-0x2
   0x0000093c <+4>:   mov fp,sp
   0x00000940 <+8>:   mov r37,0x1234
=> 0x00000944 <+12>:   mov r62,0x5678
   0x00000948 <+16>:   mov r0,0x0
   0x0000094a <+18>:   ldr fp,[sp,+0x2]
   0x0000094e <+22>:   add sp,sp,8
   0x00000952 <+26>:   rts
End of assembler dump.
(gdb) p/x $r37
$1 = 0x1234
(gdb) si
0x00000948 in main ()
(gdb) p/x $r62
$2 = 0x5678
(gdb) c
Continuing.
[Inferior 1 (process 42000) exited normally]
(gdb) q



Epiphany multicore simulator mode tutorial here:
https://github.com/parallella/parallell ... r-tutorial

Epiphany single process mode readme:
https://github.com/adapteva/epiphany-bi ... ME.esim.md




Really happy to see the progress you are making on the LLVM backend!
// Ola
_start = 266470723;
olajep
 
Posts: 136
Joined: Mon Dec 17, 2012 3:24 am
Location: Sweden

Re: R37 on R62

Postby olajep » Tue Apr 25, 2017 10:44 am

...

Bug comfirmed
most likely a bug in e-server

Session:

Start e-server in one console:
Code: Select all
$ e-server --multiprocess
Using the HDF file: /opt/adapteva/esdk.2016.11/bsps/parallella_E16G3_1GB/parallella_E16G3_1GB.xml
Listening for RSP on port 51000


debug session:
Code: Select all
$ e-gdb ./a.out
Reading symbols from ./a.out...(no debugging symbols found)...done.
(gdb) set pagination off
(gdb) set non-stop on
(gdb) target extended-remote :51000
Remote debugging using :51000
(gdb) info os processes
pid        user       command    cores     
1          root                  0000,0001,0002,0003,0100,0101,0102,0103,0200,0201,0202,0203,0300,0301,0302,0303
(gdb) attach 1
Attaching to program: /home/parallella/tmp/r37/a.out, process 1
[New Thread 1.101]
...
[New Thread 1.404]
0x00000000 in _start ()
(gdb)
Thread 1 stopped.
0x00000000 in _start ()
...
Thread 16 stopped.
0x00000000 in _start ()
#
(gdb) thread 1
[Switching to thread 1 (Thread 1.101)]
#0  0x00000000 in _start ()
(gdb) load
Loading section ivt_reset, size 0x4 lma 0x0
...
Loading section .rodata, size 0x8 lma 0x9d0
Start address 0x0, load size 2282
Transfer rate: 139 KB/sec, 152 bytes/write.
(gdb) b main
Breakpoint 1 at 0x940
(gdb) c
Continuing.

Thread 1 hit Breakpoint 1, 0x00000940 in main ()
(gdb) disassemble
Dump of assembler code for function main:
   0x00000938 <+0>:   str fp,[sp],-0x2
   0x0000093c <+4>:   mov fp,sp
=> 0x00000940 <+8>:   mov r37,0x1234
   0x00000944 <+12>:   mov r62,0x5678
   0x00000948 <+16>:   mov r0,0x0
   0x0000094a <+18>:   ldr fp,[sp,+0x2]
   0x0000094e <+22>:   add sp,sp,8
   0x00000952 <+26>:   rts
End of assembler dump.
(gdb) p/x $r37
$1 = 0x5221eac
(gdb) si
0x00000944 in main ()
(gdb) p/x $r37
$2 = 0x1234
(gdb) p/x $r62
$3 = 0x1234
(gdb) p/x $r63
$4 = 0x32138742
(gdb) p/x $r62
$5 = 0x1234
(gdb) si
0x00000948 in main ()
(gdb) p/x $r62
$6 = 0x1234
(gdb) p/x $r37
$7 = 0x1234
(gdb) flushregs
Register cache flushed.
(gdb) p/x $r37
$8 = 0x1234
(gdb) p/x $r62
$9 = 0x1234
(gdb) ^Z
[1]+  Stopped                 e-gdb ./a.out


Use e-dump-regs to verify reg values
Code: Select all
$ e-dump-regs  0 0 | grep "r37\|r62"
r37            0x00001234
r62            0x00005678


So there's a bug in e-server or in e-gdb

To be continued...

// Ola

edit: found it. e-server bug. r50-r62 aliases to r25 - r37. copy paste bug.
_start = 266470723;
olajep
 
Posts: 136
Joined: Mon Dec 17, 2012 3:24 am
Location: Sweden

Re: R37 on R62

Postby upcFrost » Tue Apr 25, 2017 11:57 am

So there's a bug in e-server or in e-gdb


phew, thanks. i freaked out that my board went broken.
Actually, after jumping around with those regs, it turned out that this problem exists for r60-r63.

For this type of work I think it is more convenient to use the simulator


Thanks, I'll check it out. I don't remember why, but it was not working for me before for some reason (like, few years ago)
Current LLVM backend for Epiphany: https://github.com/upcFrost/Epiphany. Commits and code reviews are welcome
upcFrost
 
Posts: 37
Joined: Wed May 28, 2014 6:37 am
Location: Moscow, Russia


Return to Troubleshooting

Who is online

Users browsing this forum: No registered users and 2 guests