Hello,
I want to capture and decode trace data on a Hikey620 (on Target) with OpenCSD and perf. I have been trying different kernels, compilers and compile options for weeks already, but I can not get it working. If anybody could take a look at my current build process or just provide me a tested combination of kernel, config and compiler, it would be very helpful.
I have to cross compile its kernel (and therefore also tools/perf) on a host computer. For that I use a docker container to ensure I have a clean and controlled system.
When compiling tools/perf I always get "libopencsd: [ OFF ]", and when executing "perf report" on target I get this error: 178 [0x268]: failed to process type: 70 Error: failed to process sample Therefore I suspect the building process of OpenCSD or tools/perf to be the problem. Trace collection without perf and OpenCSD works just fine.
My current build process is:
Installing OpenCSD on host: cd OpenCSD/decoder/build/linux/ make -f makefile.dev DEBUG=1 ARCH=arm64 make -f makefile.dev DEBUG=1 ARCH=arm64 install
Building kernel on host: cd coresight make -j8 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- Image modules hisilicon/hi6220-hikey.dtb O=./out make INSTALL_MOD_PATH=./modules modules_install O=./out
Building /tools/perf on host: mkdir coresight/out/perf make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -C tools/perf VF=1 CORESIGHT=1 O=/opt/hikey620/coresight/out/perf
Installing OpenCSD on target (Hikey620): cd OpenCSD/decoder/build/linux/ make -f makefile.dev make -f makefile.dev install
My compiler is the "gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu" from Linaro My kernel is the one from Mathieu Poirier: https://git.linaro.org/people/mathieu.poirier/coresight.git (5.1-rc3-cpu-wide-v3)
My .config was created by make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- defconfig but whith CoreSight and ARCH_MXC enabled: CONFIG_CORESIGHT=y CONFIG_CORESIGHT_LINKS_AND_SINKS=y CONFIG_CORESIGHT_LINK_AND_SINK_TMC=y CONFIG_CORESIGHT_CATU=y CONFIG_CORESIGHT_SINK_TPIU=y CONFIG_CORESIGHT_SINK_ETBV10=y CONFIG_CORESIGHT_SOURCE_ETM4X=y CONFIG_CORESIGHT_DYNAMIC_REPLICATOR=y CONFIG_CORESIGHT_STM=y CONFIG_CORESIGHT_CPU_DEBUG=y CONFIG_ARCH_MXC=y
Thanks,
Dominik Huber
Hi Dominik,
On Mon, Dec 07, 2020 at 05:06:37PM +0100, Dominik Huber wrote:
Hello,
I want to capture and decode trace data on a Hikey620 (on Target) with OpenCSD and perf. I have been trying different kernels, compilers and compile options for weeks already, but I can not get it working. If anybody could take a look at my current build process or just provide me a tested combination of kernel, config and compiler, it would be very helpful.
I have to cross compile its kernel (and therefore also tools/perf) on a host computer. For that I use a docker container to ensure I have a clean and controlled system.
When compiling tools/perf I always get "libopencsd: [ OFF ]", and when executing "perf report" on target I get this error: 178 [0x268]: failed to process type: 70 Error: failed to process sample Therefore I suspect the building process of OpenCSD or tools/perf to be the problem. Trace collection without perf and OpenCSD works just fine.
Yes, if you see the string "libopencsd: [ OFF ]", this means the OpenCSD lib has not been linked.
My current build process is:
Installing OpenCSD on host: cd OpenCSD/decoder/build/linux/ make -f makefile.dev DEBUG=1 ARCH=arm64 make -f makefile.dev DEBUG=1 ARCH=arm64 install
Since the OpenCSD lib will be linked with perf tool, the OpenCSD lib also need to be cross-compiled for Arm64:
# export CROSS_COMPILE=aarch64-linux-gnu- # cd OpenCSD/decoder/build/linux/ # make LINUX64=1 DEBUG=1
Then you could see the built libs are placed in the folder: OpenCSD/decoder/lib/builddir and headers are placed in the folder: OpenCSD/decoder/include.
Building kernel on host: cd coresight make -j8 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- Image modules hisilicon/hi6220-hikey.dtb O=./out make INSTALL_MOD_PATH=./modules modules_install O=./out
Building /tools/perf on host: mkdir coresight/out/perf make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -C tools/perf VF=1 CORESIGHT=1 O=/opt/hikey620/coresight/out/perf
For cross building perf tool, you need to specify the lib and header patch for OpenCSD, so the command should be:
# export ARCH=arm64 # export CROSS_COMPILE=aarch64-linux-gnu- # CSINCLUDES=$PATH_TO_OpenCSD/decoder/include \ CSLIBS=$PATH_TO_OpenCSD/decoder/lib/builddir \ make VF=1 DEBUG=1 CORESIGHT=1
Then I can see Perf's building config for libopencsd is "on":
... libopencsd: [ on ]
Then you need to copy libopencsd to the target board, the perf tool should can work on it.
Thanks, Leo
Installing OpenCSD on target (Hikey620): cd OpenCSD/decoder/build/linux/ make -f makefile.dev make -f makefile.dev install
My compiler is the "gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu" from Linaro My kernel is the one from Mathieu Poirier: https://git.linaro.org/people/mathieu.poirier/coresight.git (5.1-rc3-cpu-wide-v3)
My .config was created by make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- defconfig but whith CoreSight and ARCH_MXC enabled: CONFIG_CORESIGHT=y CONFIG_CORESIGHT_LINKS_AND_SINKS=y CONFIG_CORESIGHT_LINK_AND_SINK_TMC=y CONFIG_CORESIGHT_CATU=y CONFIG_CORESIGHT_SINK_TPIU=y CONFIG_CORESIGHT_SINK_ETBV10=y CONFIG_CORESIGHT_SOURCE_ETM4X=y CONFIG_CORESIGHT_DYNAMIC_REPLICATOR=y CONFIG_CORESIGHT_STM=y CONFIG_CORESIGHT_CPU_DEBUG=y CONFIG_ARCH_MXC=y
Thanks,
Dominik Huber
CoreSight mailing list CoreSight@lists.linaro.org https://lists.linaro.org/mailman/listinfo/coresight
Hi Leo, I edited my build process according to your tips and it really did enable opencsd. However, I had to use the "hikey" kernel repository [1] and the WERROR=0 flag. Then these commands got the job done for me:
# export CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 # cd /opt/hikey620/OpenCSD/decoder/build/linux # make LINUX64=1 DEBUG=1 -j8 # make LINUX64=1 DEBUG=1 install
# cd /opt/hikey620/coresight # make -j8 Image modules hisilicon/hi6220-hikey.dtb # make INSTALL_MOD_PATH=./modules modules_install
# export CSINCLUDES=/opt/hikey620/OpenCSD/decoder/include \ CSLIBS=/opt/hikey620/OpenCSD/decoder/lib/linux-arm64/dbg # make -C tools/perf VF=1 CORESIGHT=1 DEBUG=1 WERROR=0
For now i dont need the kernel from the "coresight" repository [2], so thank you very much for your advice.
Dominik
[1] https://git.linaro.org/people/manivannan.sadhasivam/hikey.git [2] https://git.linaro.org/people/mathieu.poirier/coresight.git
On 08/12/2020 09:09, Leo Yan wrote:
Hi Dominik,
On Mon, Dec 07, 2020 at 05:06:37PM +0100, Dominik Huber wrote:
Hello,
I want to capture and decode trace data on a Hikey620 (on Target) with OpenCSD and perf. I have been trying different kernels, compilers and compile options for weeks already, but I can not get it working. If anybody could take a look at my current build process or just provide me a tested combination of kernel, config and compiler, it would be very helpful.
I have to cross compile its kernel (and therefore also tools/perf) on a host computer. For that I use a docker container to ensure I have a clean and controlled system.
When compiling tools/perf I always get "libopencsd: [ OFF ]", and when executing "perf report" on target I get this error: 178 [0x268]: failed to process type: 70 Error: failed to process sample Therefore I suspect the building process of OpenCSD or tools/perf to be the problem. Trace collection without perf and OpenCSD works just fine.
Yes, if you see the string "libopencsd: [ OFF ]", this means the OpenCSD lib has not been linked.
My current build process is:
Installing OpenCSD on host: cd OpenCSD/decoder/build/linux/ make -f makefile.dev DEBUG=1 ARCH=arm64 make -f makefile.dev DEBUG=1 ARCH=arm64 install
Since the OpenCSD lib will be linked with perf tool, the OpenCSD lib also need to be cross-compiled for Arm64:
# export CROSS_COMPILE=aarch64-linux-gnu- # cd OpenCSD/decoder/build/linux/ # make LINUX64=1 DEBUG=1
Then you could see the built libs are placed in the folder: OpenCSD/decoder/lib/builddir and headers are placed in the folder: OpenCSD/decoder/include.
Building kernel on host: cd coresight make -j8 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- Image modules hisilicon/hi6220-hikey.dtb O=./out make INSTALL_MOD_PATH=./modules modules_install O=./out
Building /tools/perf on host: mkdir coresight/out/perf make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -C tools/perf VF=1 CORESIGHT=1 O=/opt/hikey620/coresight/out/perf
For cross building perf tool, you need to specify the lib and header patch for OpenCSD, so the command should be:
# export ARCH=arm64 # export CROSS_COMPILE=aarch64-linux-gnu- # CSINCLUDES=$PATH_TO_OpenCSD/decoder/include \ CSLIBS=$PATH_TO_OpenCSD/decoder/lib/builddir \ make VF=1 DEBUG=1 CORESIGHT=1
Then I can see Perf's building config for libopencsd is "on":
... libopencsd: [ on ]
Then you need to copy libopencsd to the target board, the perf tool should can work on it.
Thanks, Leo
Installing OpenCSD on target (Hikey620): cd OpenCSD/decoder/build/linux/ make -f makefile.dev make -f makefile.dev install
My compiler is the "gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu" from Linaro My kernel is the one from Mathieu Poirier: https://git.linaro.org/people/mathieu.poirier/coresight.git (5.1-rc3-cpu-wide-v3)
My .config was created by make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- defconfig but whith CoreSight and ARCH_MXC enabled: CONFIG_CORESIGHT=y CONFIG_CORESIGHT_LINKS_AND_SINKS=y CONFIG_CORESIGHT_LINK_AND_SINK_TMC=y CONFIG_CORESIGHT_CATU=y CONFIG_CORESIGHT_SINK_TPIU=y CONFIG_CORESIGHT_SINK_ETBV10=y CONFIG_CORESIGHT_SOURCE_ETM4X=y CONFIG_CORESIGHT_DYNAMIC_REPLICATOR=y CONFIG_CORESIGHT_STM=y CONFIG_CORESIGHT_CPU_DEBUG=y CONFIG_ARCH_MXC=y
Thanks,
Dominik Huber
CoreSight mailing list CoreSight@lists.linaro.org https://lists.linaro.org/mailman/listinfo/coresight
Hi Dominik,
On Tue, Dec 15, 2020 at 04:25:25PM +0100, Dominik Huber wrote:
Hi Leo, I edited my build process according to your tips and it really did enable opencsd. However, I had to use the "hikey" kernel repository [1] and the WERROR=0 flag. Then these commands got the job done for me:
# export CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 # cd /opt/hikey620/OpenCSD/decoder/build/linux # make LINUX64=1 DEBUG=1 -j8 # make LINUX64=1 DEBUG=1 install
# cd /opt/hikey620/coresight # make -j8 Image modules hisilicon/hi6220-hikey.dtb # make INSTALL_MOD_PATH=./modules modules_install
# export CSINCLUDES=/opt/hikey620/OpenCSD/decoder/include \ CSLIBS=/opt/hikey620/OpenCSD/decoder/lib/linux-arm64/dbg # make -C tools/perf VF=1 CORESIGHT=1 DEBUG=1 WERROR=0
For now i dont need the kernel from the "coresight" repository [2], so thank you very much for your advice.
Welcome! and glad it works.
To be honest, I am a bit concern you are using an old kernel version for CoreSight development, it's fine if you think the old perf / CoreSight driver can meet your requirement.
If you don't care about GPU/VPU and WIFI related stuffs on Hikey, most drivers have been landed in the mainline kernel, so in theory you could directly use the the mainline kernel [1] or CoreSight repository [2]. I don't use my Hikey board recently, but before I always used the mainline kernel + Debian (as Wookey suggested) on it for CoreSight related works.
Thanks, Leo
[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git [2] https://git.linaro.org/kernel/coresight.git/log/?h=next
On 2020-12-07 17:06 +0100, Dominik Huber wrote:
Hello,
I want to capture and decode trace data on a Hikey620 (on Target) with OpenCSD and perf. I have been trying different kernels, compilers and compile options for weeks already, but I can not get it working.
If anybody could take a look at my current build process or just provide me a tested combination of kernel, config and compiler, it would be very helpful.
One of the easiest ways to get a "tested combination of kernel, config and compiler" is to install debian on the device.
perf is already built with libopencsd support there so installing linux-perf will 'just work' for tracing. That has been true since mid 2018 in unstable, and since July 2019 in stable
In theory this is true for ubuntu too, but I'm not sure if it's enabled by default (checking, it looks like it isn't - I'd better get that fixed). Libopencsd has been available since april 2020 in focal(20.04LTS).
I'm not quite sure of the state of installer support for the hikey620 (Mine died so I don't have one to test). But some info here: https://wiki.debian.org/InstallingDebianOn/96Boards/HiKey If the board has UEFI then the installer should 'just work'.
Of course there may be reasons why you don't want this on your board but distros exist to save us doing all this sort of dicking about compiling things ourselves that we just want to use.
Wookey
Hi, Thank you for pointing that out. I do have a Debian. But neither on Linaro nor on LeMakers websites I could find a .img with Debian 10 buster ans so i assumed it would not be compatible with the hikey620. Now I have tried it out, and it indeed works. I would rather build it myself, but this might be an alternative. Is there a debug version of "linux-perf" as well?
Dominik
On 08/12/2020 14:48, Wookey wrote:
On 2020-12-07 17:06 +0100, Dominik Huber wrote:
Hello,
I want to capture and decode trace data on a Hikey620 (on Target) with OpenCSD and perf. I have been trying different kernels, compilers and compile options for weeks already, but I can not get it working. If anybody could take a look at my current build process or just provide me a tested combination of kernel, config and compiler, it would be very helpful.
One of the easiest ways to get a "tested combination of kernel, config and compiler" is to install debian on the device.
perf is already built with libopencsd support there so installing linux-perf will 'just work' for tracing. That has been true since mid 2018 in unstable, and since July 2019 in stable
In theory this is true for ubuntu too, but I'm not sure if it's enabled by default (checking, it looks like it isn't - I'd better get that fixed). Libopencsd has been available since april 2020 in focal(20.04LTS).
I'm not quite sure of the state of installer support for the hikey620 (Mine died so I don't have one to test). But some info here: https://wiki.debian.org/InstallingDebianOn/96Boards/HiKey If the board has UEFI then the installer should 'just work'.
Of course there may be reasons why you don't want this on your board but distros exist to save us doing all this sort of dicking about compiling things ourselves that we just want to use.
Wookey