brintos

brintos / linux-shallow public Read only

0
0
Text · 4.1 KiB · d69f24c Raw
94 lines · plain
1.. SPDX-License-Identifier: GPL-2.02 3=============================================4Linux Kernel GPIO based sloppy logic analyzer5=============================================6 7:Author: Wolfram Sang8 9Introduction10============11 12This document briefly describes how to run the GPIO based in-kernel sloppy13logic analyzer running on an isolated CPU.14 15The sloppy logic analyzer will utilize a few GPIO lines in input mode on a16system to rapidly sample these digital lines, which will, if the Nyquist17criteria is met, result in a time series log with approximate waveforms as they18appeared on these lines. One way to use it is to analyze external traffic19connected to these GPIO lines with wires (i.e. digital probes), acting as a20common logic analyzer.21 22Another feature is to snoop on on-chip peripherals if the I/O cells of these23peripherals can be used in GPIO input mode at the same time as they are being24used as inputs or outputs for the peripheral. That means you could e.g. snoop25I2C traffic without any wiring (if your hardware supports it). In the pin26control subsystem such pin controllers are called "non-strict": a certain pin27can be used with a certain peripheral and as a GPIO input line at the same28time.29 30Note that this is a last resort analyzer which can be affected by latencies,31non-deterministic code paths and non-maskable interrupts. It is called 'sloppy'32for a reason. However, for e.g. remote development, it may be useful to get a33first view and aid further debugging.34 35Setup36=====37 38Your kernel must have CONFIG_DEBUG_FS and CONFIG_CPUSETS enabled. Ideally, your39runtime environment does not utilize cpusets otherwise, then isolation of a CPU40core is easiest. If you do need cpusets, check that helper script for the41sloppy logic analyzer does not interfere with your other settings.42 43Tell the kernel which GPIOs are used as probes. For a Device Tree based system,44you need to use the following bindings. Because these bindings are only for45debugging, there is no official schema::46 47    i2c-analyzer {48            compatible = "gpio-sloppy-logic-analyzer";49            probe-gpios = <&gpio6 21 GPIO_OPEN_DRAIN>, <&gpio6 4 GPIO_OPEN_DRAIN>;50            probe-names = "SCL", "SDA";51    };52 53Note that you must provide a name for every GPIO specified. Currently a54maximum of 8 probes are supported. 32 are likely possible but are not55implemented yet.56 57Usage58=====59 60The logic analyzer is configurable via files in debugfs. However, it is61strongly recommended to not use them directly, but to use the script62``tools/gpio/gpio-sloppy-logic-analyzer``. Besides checking parameters more63extensively, it will isolate the CPU core so you will have the least64disturbance while measuring.65 66The script has a help option explaining the parameters. For the above DT67snippet which analyzes an I2C bus at 400kHz on a Renesas Salvator-XS board, the68following settings are used: The isolated CPU shall be CPU1 because it is a big69core in a big.LITTLE setup. Because CPU1 is the default, we don't need a70parameter. The bus speed is 400kHz. So, the sampling theorem says we need to71sample at least at 800kHz. However, falling edges of both signals in an I2C72start condition happen faster, so we need a higher sampling frequency, e.g.73``-s 1500000`` for 1.5MHz. Also, we don't want to sample right away but wait74for a start condition on an idle bus. So, we need to set a trigger to a falling75edge on SDA while SCL stays high, i.e. ``-t 1H+2F``. Last is the duration, let76us assume 15ms here which results in the parameter ``-d 15000``. So,77altogether::78 79    gpio-sloppy-logic-analyzer -s 1500000 -t 1H+2F -d 1500080 81Note that the process will return you back to the prompt but a sub-process is82still sampling in the background. Unless this has finished, you will not find a83result file in the current or specified directory. For the above example, we84will then need to trigger I2C communication::85 86    i2cdetect -y -r <your bus number>87 88Result is a .sr file to be consumed with PulseView or sigrok-cli from the free89`sigrok`_ project. It is a zip file which also contains the binary sample data90which may be consumed by other software. The filename is the logic analyzer91instance name plus a since-epoch timestamp.92 93.. _sigrok: https://sigrok.org/94