Hi Mike,


From: Mike Leach
Sent: Tuesday, 11 June, 8:39 PM
Subject: Re: Request for Guidance in Using sysFS for Coresight in HiKey960 (Cortex A53/A73)
To: Student - Ng Yi Zher Jeremy
Cc: Leo Yan, Coresight ML


Hi Jeremy,

On Tue, 11 Jun 2019 at 04:36, Student - Ng Yi Zher Jeremy
<jeremy_ng@mymail.sutd.edu.sg> wrote:
>
> Dear Leo Yan Sir,
>
> Thank you for your message. Please look at inline comments for reply.
> ________________________________
> From: Leo Yan <leo.yan@linaro.org>
> Sent: 10 June 2019 17:32
> To: Student - Ng Yi Zher Jeremy
> Cc: Mathieu Poirier; Suzuki K Poulose; Coresight ML
> Subject: Re: Request for Guidance in Using sysFS for Coresight in HiKey960 (Cortex A53/A73)
>
> Hi Jeremy,
>
> Please see several quick inline comments.
>
> On Mon, Jun 10, 2019 at 08:49:48AM +0000, Student - Ng Yi Zher Jeremy wrote:
>
>
> [...]
>
> > ```bash
> > -rw-r--r-- 1 root root 4096 1970-01-01 00:11 ecc40000.etm/addr_start
> > hikey960:/sys/bus/coresight/devices # echo d10583ff > ecc40000.etm/addr_start
> > 1|hikey960:/sys/bus/coresight/devices # cat ecc40000.etm/addr_start
> > cat: ecc40000.etm/addr_start: Operation not permitted
> > ```
>
> After read the code, I think you need firstly to specify addr_idx:
>
>   echo 3 > ecc40000.etm/addr_idx
>   echo d10583ff > ecc40000.etm/addr_start
>   cat ecc40000.etm/addr_start
>

0xd10583ff does not look like a valid address - the bottom bit / two
bits must be 0 for a Thumb2 / AArch32/64 address.
Looking at the previous objdump you did, I think you are misreading it...

...
00000000000009e8 <main>:
 9e8: d10583ff  sub sp, sp, #0x160
 9ec: f900a3fc  str x28, [sp,#320]

here 0000000009e8 is the relative address for the symbol 'main'

the line:

9e8: d10583ff  sub sp, sp, #0x160
is in order <relative address>: <op_code> <disassembly>
So the value d10583ff represents the opcode, not the address of the
instruction. This can only be discovered by determining the program
load address and adding in the offset to <main>

Regards

Mike

This is embarrassing. Thank you very much for pointing that out! That could be the reason. I will give it a try tomorrow and update here.



> I did this as per instructed here and I was able to now read the `addr_start` file. However, there is still no trace found when I run the program.
>
> I will like to clarify that addr_start is referring to the instruction address and not the PC counter.
>
> > I thought it was not important that the Operation was 'not permitted'. Nonetheless, I continued with the tutorial as depicted [here](https://github.com/torvalds/linux/blob/master/Documentation/trace/coresight.txt). One thing I will like to note is that my `rwp` did move when i initially activated the sink and source. However, the 2nd time i checked the `rwp`, it went back `0x0`, the same position as that of my `rrp`.
> >
> > Regardless, I run the program in another kernel, performed CPU affinity to the program to point at the CPU in which the ETM is activated (in this case, CPU0). While the program is running, i looked at the `rwp/rrp` and see that neither of the pointers are moving. I thought perhaps if i perform `dd` operation, I might be able to get something.
> >
> > I performed `dd if=/dev/ec036000.etf of=/data/cs.bin bs=1M` but my device crashed and reboot itself without saving any files.
>
> Could you try below commands before dd command?
>
>   echo 1 > /sys/bus/coresight/devices/ec036000.etf
>   # Enable ETM for CPU0
>   echo 1 > /sys/bus/coresight/devices/ecc40000.etm/enable_source
>   dd if=/dev/ec036000.etf of=/data/cs.bin bs=1M
>
> I did this command as per usual. I even tried enabling different ETFs and alternating enable ETR to see if there are any difference. There is still no movement in my `rwp`. Even if it did (at the start), when i perform `dd` command, it reads:
>
> ```
> hikey960:/sys/bus/coresight/devices # dd if=/dev/ec036000.etf of=/data/cs.bin bs=1M
> 0+1 records in
> 0+1 records out
> 32 bytes (32 B) copied, 0.000517 s, 60 K/s
> ```
>
> I have attached the encoded trace file (cs.bin), decoded trace file (cs.log_e) and the decoded min trace file (just the addresses line: addr_e.log) in this mail. I used ptm2human API for decoding (link here: https://github.com/hwangcc23/ptm2human).
>
> What puzzled me, furthermore, is that it seems i can never perform `dd` on ec80200.etf. Performing that command on that memory address tends to crash the AOSP in Hikey960.
>
>
> Please note, you need firstly configure the address range, and then
> enable the ETM and sink.  If afterwards change the address range
> again, you need disable etf/etm and re-enable etf/etm so can set
> address range configuration into registers properly.
>
> I thought i should detail the entire process for your expertise advise:
>
> ```
> root@intern-nzyj:/data/cstrace# adb shell
> hikey960:/ # cd sys/bus/coresight/devices/
> hikey960:/sys/bus/coresight/devices # echo 3 > ecc40000.etm/addr_idx
> hikey960:/sys/bus/coresight/devices # echo d10583ff > ecc40000.etm/addr_start
> hikey960:/sys/bus/coresight/devices # echo d65f03c0 > ecc40000.etm/addr_stop
> 1|hikey960:/sys/bus/coresight/devices # echo 0 ffffffffffffffffff > ecc40000.etm/addr_range
> 1|hikey960:/sys/bus/coresight/devices # echo 1 > ec036000.etf/enable_sink
> hikey960:/sys/bus/coresight/devices # echo 1 > ecc40000.etm/enable_source
> hikey960:/sys/bus/coresight/devices # cat ec036000.etf/mgmt/rwp
> 0x7b0
> hikey960:/sys/bus/coresight/devices # cat ec036000.etf/mgmt/rrp
> 0x7b0
> hikey960:/sys/bus/coresight/devices # cat ec036000.etf/mgmt/sts
> 0x1
> hikey960:/sys/bus/coresight/devices # cat ec036000.etf/mgmt/ctl
> 0x1
> hikey960:/sys/bus/coresight/devices # cat ec036000.etf/mgmt/rwp
> 0x7b0
> hikey960:/sys/bus/coresight/devices # cat ec036000.etf/mgmt/rwp
> 0x7b0
> hikey960:/sys/bus/coresight/devices # taskset -p 8577
> pid 8577's current affinity mask: 1
> hikey960:/sys/bus/coresight/devices # taskset -p 8577
> taskset: failed to get 8577's affinity: No such process
> 1|hikey960:/sys/bus/coresight/devices # cat ec036000.etf/mgmt/rwp
> 0x7b0
> hikey960:/sys/bus/coresight/devices # cat ec036000.etf/mgmt/rrp
> 0x7b0
> hikey960:/sys/bus/coresight/devices # dd if=/dev/ec036000.etf of=/data/cs.bin bs=1M
> 0+1 records in
> 0+1 records out
> 4096 bytes (4.0 K) copied, 0.001610 s, 2.4 M/s
> hikey960:/sys/bus/coresight/devices # exit
> root@intern-nzyj:/data/cstrace# adb pull /data/cs.bin
> /data/cs.bin: 1 file pulled. 0.1 MB/s (4096 bytes in 0.046s)
> root@intern-nzyj:/data/cstrace# /src/ptm2human/ptm2human -e -i cs.bin > cs.log_e
> ```
>
> I don't try at my side, if have any question or issue, please report
> back so I can test on Hikey960.
>
> Thanks,
> Leo Yan
>
> Thank you very much for your kind responses and patience!
>
> The above message may contain confidential and/or proprietary information that is exempt from disclosure under applicable law and is intended for receipt and use solely by the addressee(s) named above. If you are not the intended recipient, you are hereby notified that any use, dissemination, distribution, or copying of this message, or any attachment, is strictly prohibited. If you have received this email in error, please inform the sender immediately by reply e-mail or telephone, reversing the charge if necessary. Please delete the message thereafter. Thank you.
>
> _______________________________________________
> CoreSight mailing list
> CoreSight@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/coresight



--
Mike Leach
Principal Engineer, ARM Ltd.
Manchester Design Centre. UK
Cheers,
Jeremy

The above message may contain confidential and/or proprietary information that is exempt from disclosure under applicable law and is intended for receipt and use solely by the addressee(s) named above. If you are not the intended recipient, you are hereby notified that any use, dissemination, distribution, or copying of this message, or any attachment, is strictly prohibited. If you have received this email in error, please inform the sender immediately by reply e-mail or telephone, reversing the charge if necessary. Please delete the message thereafter. Thank you.