Thank you for the updated steps Leo!

On Fri, Mar 19, 2021 at 12:39 AM Leo Yan <leo.yan@linaro.org> wrote:
Hi Enes,

On Wed, Mar 17, 2021 at 06:56:10PM -0400, Enes Göktaş wrote:
> Hello,
>
> I would like to test the System Trace Macrocell (STM) on db410c and tried
> following the steps at [1]. I am using linux kernel
> version 5.9.0-qcomlt-arm64 and I believe the steps described in the linked
> post are for an earlier version of the kernel.
>
> I tried those steps (but slightly adjusted so it is conform to the sysfs
> path on 5.9.0-qcomlt-arm64) and it fails when trying to link:
> *$ echo 802000.stm > **/sys/class/stm_source/ftrace/stm_source_link*
> bash: echo: write error: Invalid argument
> *$ echo stm > **/sys/class/stm_source/ftrace/stm_source_link*
> bash: echo: write error: Invalid argument
> *$ echo stm0 > **/sys/class/stm_source/ftrace/stm_source_link*
> bash: echo: write error: Invalid argument
>
> I'd be happy to test the steps on a working version of the kernel. Does
> anyone know for which kernel version the steps in [1] are?
> I'd also be grateful if someone has the right steps to test STM with ftrace
> on the recent kernel versions.

I think you encouter the issue for STM has changed to use configfs.

Firstly you need to check what's the STM device name by reading the
folder /sys/bus/coresight/devices:

  # ls /sys/bus/coresight/devices/
  etm0  etm1  etm2  etm3  funnel0  funnel1  replicator0  stm0  tmc_etf0  tmc_etr0  tpiu0

So you could see with the mainline kernel, the STM device name is
"stm0", please note "802000.stm" is an old naming convension.

Then, need to set up configFS so that you could specify which data
stream for STM (e.g. console, ftrace, etc).  Below is an example to
set ftrace function tracing for STM:

# Enable hardware path (STM -> ETF or, you could set STM -> ETR)
1. echo 1 > /sys/bus/coresight/devices/tmc_etf0/enable_sink
2. echo 1 > /sys/bus/coresight/devices/stm0/enable_source

# Config STM functionality for Ftrace
3. mkdir -p /config
4. mount -t configfs none /config
5. mkdir /config/stp-policy/stm0.policy
6. mkdir /config/stp-policy/stm0.policy/ftrace
7. echo stm0 > /sys/class/stm_source/ftrace/stm_source_link

# Enable Ftrace function tracing
8. echo function > /sys/kernel/debug/tracing/current_tracer
9. echo '*' > /sys/kernel/debug/tracing/set_ftrace_filter

Thanks,
Leo