RZ-G/debug tricks: Difference between revisions

From Renesas.info
No edit summary
Line 24: Line 24:
* You can use the "compatible" name listed in the device tree, and grep, in order to find the location of the device driver file.
* You can use the "compatible" name listed in the device tree, and grep, in order to find the location of the device driver file.
* Do you search starting in the "drivers" directory (to avoid all the matches that will be found in other device tree files)
* Do you search starting in the "drivers" directory (to avoid all the matches that will be found in other device tree files)
* For example, to find the UART driver:
* '''Example: Find the Watchdog Timer Driver'''
<pre>
** RZ/G2L Device Tree: rz_linux-cip/arch/arm64/boot/dts/renesas/'''r9a07g044.dtsi''' <html><pre>
$ cd drivers
wdt0: watchdog@12800800 {
$ grep -R "renesas,sci" *
compatible = "renesas,r9a07g044-wdt",
</pre>
    <span><font color=red>"renesas,rzg2l-wdt";</font></span>
reg = <0 0x12800800 0 0x400>;
clocks = <&cpg CPG_MOD R9A07G044_WDT0_PCLK>,
<&cpg CPG_MOD R9A07G044_WDT0_CLK>;
clock-names = "pclk", "oscclk";
interrupts = &lt;GIC_SPI 49 IRQ_TYPE_LEVEL_HIGH>,
    &lt;GIC_SPI 50 IRQ_TYPE_LEVEL_HIGH>;
interrupt-names = "wdt", "perrout";
resets = <&cpg R9A07G044_WDT0_PRESETN>;
power-domains = <&cpg>;
status = "disabled";
};
</pre></html>
** Use the grep command: <html><pre>
<span><b>$ grep -R "renesas,rzg2l-wdt" *</b></span>
arch/arm64/boot/dts/renesas/r9a07g044.dtsi:     "renesas,rzg2l-wdt";
arch/arm64/boot/dts/renesas/r9a07g044.dtsi:     "renesas,rzg2l-wdt";
arch/arm64/boot/dts/renesas/r9a07g044.dtsi:     "renesas,rzg2l-wdt";
arch/arm64/boot/dts/renesas/r9a07g043.dtsi:     "renesas,rzg2l-wdt";
arch/arm64/boot/dts/renesas/r9a07g043.dtsi:     "renesas,rzg2l-wdt";
arch/arm64/boot/dts/renesas/r9a07g054.dtsi:     "renesas,rzg2l-wdt";
arch/arm64/boot/dts/renesas/r9a07g054.dtsi:     "renesas,rzg2l-wdt";
arch/arm64/boot/dts/renesas/r9a07g054.dtsi:     "renesas,rzg2l-wdt";
Documentation/devicetree/bindings/watchdog/renesas,wdt.yaml:          - const: renesas,rzg2l-wdt    # RZ/G2L
Documentation/devicetree/bindings/watchdog/renesas,wdt.yaml:              - renesas,rzg2l-wdt
<span><font color=red>drivers/watchdog/rzg2l_wdt.c: { .compatible = "renesas,rzg2l-wdt", },</font></span>
scripts/dtc/include-prefixes/arm64/renesas/r9a07g044.dtsi:     "renesas,rzg2l-wdt";
scripts/dtc/include-prefixes/arm64/renesas/r9a07g044.dtsi:     "renesas,rzg2l-wdt";
scripts/dtc/include-prefixes/arm64/renesas/r9a07g044.dtsi:     "renesas,rzg2l-wdt";
scripts/dtc/include-prefixes/arm64/renesas/r9a07g043.dtsi:     "renesas,rzg2l-wdt";
scripts/dtc/include-prefixes/arm64/renesas/r9a07g043.dtsi:     "renesas,rzg2l-wdt";
scripts/dtc/include-prefixes/arm64/renesas/r9a07g054.dtsi:     "renesas,rzg2l-wdt";
scripts/dtc/include-prefixes/arm64/renesas/r9a07g054.dtsi:     "renesas,rzg2l-wdt";
scripts/dtc/include-prefixes/arm64/renesas/r9a07g054.dtsi:     "renesas,rzg2l-wdt";
</pre></html>
 
* '''Example: Find the UART Driver'''
** RZ/G2L Device Tree: rz_linux-cip/arch/arm64/boot/dts/renesas/'''r9a07g044.dtsi''' <html><pre>
scif0: serial@1004b800 {
compatible = <span><font color=red>"renesas,scif-r9a07g044"</font></span>;
reg = <0 0x1004b800 0 0x400>;
interrupts = &lt;GIC_SPI 380 IRQ_TYPE_LEVEL_HIGH>,
    &lt;GIC_SPI 382 IRQ_TYPE_LEVEL_HIGH>,
    &lt;GIC_SPI 383 IRQ_TYPE_LEVEL_HIGH>,
    &lt;GIC_SPI 381 IRQ_TYPE_LEVEL_HIGH>,
    &lt;GIC_SPI 384 IRQ_TYPE_LEVEL_HIGH>,
    &lt;GIC_SPI 384 IRQ_TYPE_LEVEL_HIGH>;
interrupt-names = "eri", "rxi", "txi",
  "bri", "dri", "tei";
clocks = <&cpg CPG_MOD R9A07G044_SCIF0_CLK_PCK>;
clock-names = "fck";
power-domains = <&cpg>;
resets = <&cpg R9A07G044_SCIF0_RST_SYSTEM_N>;
status = "disabled";
};
</pre></html>
** Use the grep command: <html><pre>
<span><b>$ cd drivers</b></span>
<span><b>$ grep -R "renesas,scif-r9a07g044" *</b></span>
</pre></html>

Revision as of 15:26, 15 August 2023


This page contains many helpful suggestions for debugging issue with the Linux kernel.

Common Tools

  • grep : The kernel has thousands of files. The grep tool is the most powerful way to find what you are looking for. Use the -R to search recursively . Remember that grep is case sensitive by default, so use -i if you need it to ignore case.
    • And example to find a function name start_kernel: $ grep -r "start_kernel"
  • find : Sometimes someone will give you just a filename, and the find command can help you find where that file is. Also, it find is very helpful when combined with grep.
    • For example, if you just want to search header files: $ find * -name "*.h" | grep purple

Error Messages

  • Many times an error message will be printed out. This happens a lot for a device driver that has trouble initializing during boot.
  • Your first step should be to find what source code file is print that message
  • Simply use the grep command with -R option and search for that error message.

Error Codes

  • If a error message prints out an error code, for example "-110", you should look up what the error code means.
  • You can find a list of the error code numbers mean in file include/uapi/asm-generic/errno-base.h
  • Since the code will use the #defrine name (not the actual number), you can then search driver file for when that error code/name is returned.

Finding the Device Driver File

  • When adding or configuring a driver to your system, you will probably be editing the Device Tree.
  • If there is an issue with that driver or peripheral, you will need to find the source code for the driver
  • You can use the "compatible" name listed in the device tree, and grep, in order to find the location of the device driver file.
  • Do you search starting in the "drivers" directory (to avoid all the matches that will be found in other device tree files)
  • Example: Find the Watchdog Timer Driver
    • RZ/G2L Device Tree: rz_linux-cip/arch/arm64/boot/dts/renesas/r9a07g044.dtsi
      wdt0: watchdog@12800800 {
      	compatible = "renesas,r9a07g044-wdt",
      		     "renesas,rzg2l-wdt";
      	reg = <0 0x12800800 0 0x400>;
      	clocks = <&cpg CPG_MOD R9A07G044_WDT0_PCLK>,
      		 <&cpg CPG_MOD R9A07G044_WDT0_CLK>;
      	clock-names = "pclk", "oscclk";
      	interrupts = <GIC_SPI 49 IRQ_TYPE_LEVEL_HIGH>,
      		     <GIC_SPI 50 IRQ_TYPE_LEVEL_HIGH>;
      	interrupt-names = "wdt", "perrout";
      	resets = <&cpg R9A07G044_WDT0_PRESETN>;
      	power-domains = <&cpg>;
      	status = "disabled";
      };
      
    • Use the grep command:
      $ grep -R "renesas,rzg2l-wdt" *
      arch/arm64/boot/dts/renesas/r9a07g044.dtsi:				     "renesas,rzg2l-wdt";
      arch/arm64/boot/dts/renesas/r9a07g044.dtsi:				     "renesas,rzg2l-wdt";
      arch/arm64/boot/dts/renesas/r9a07g044.dtsi:				     "renesas,rzg2l-wdt";
      arch/arm64/boot/dts/renesas/r9a07g043.dtsi:				     "renesas,rzg2l-wdt";
      arch/arm64/boot/dts/renesas/r9a07g043.dtsi:				     "renesas,rzg2l-wdt";
      arch/arm64/boot/dts/renesas/r9a07g054.dtsi:				     "renesas,rzg2l-wdt";
      arch/arm64/boot/dts/renesas/r9a07g054.dtsi:				     "renesas,rzg2l-wdt";
      arch/arm64/boot/dts/renesas/r9a07g054.dtsi:				     "renesas,rzg2l-wdt";
      Documentation/devicetree/bindings/watchdog/renesas,wdt.yaml:          - const: renesas,rzg2l-wdt     # RZ/G2L
      Documentation/devicetree/bindings/watchdog/renesas,wdt.yaml:              - renesas,rzg2l-wdt
      drivers/watchdog/rzg2l_wdt.c:	{ .compatible = "renesas,rzg2l-wdt", },
      scripts/dtc/include-prefixes/arm64/renesas/r9a07g044.dtsi:				     "renesas,rzg2l-wdt";
      scripts/dtc/include-prefixes/arm64/renesas/r9a07g044.dtsi:				     "renesas,rzg2l-wdt";
      scripts/dtc/include-prefixes/arm64/renesas/r9a07g044.dtsi:				     "renesas,rzg2l-wdt";
      scripts/dtc/include-prefixes/arm64/renesas/r9a07g043.dtsi:				     "renesas,rzg2l-wdt";
      scripts/dtc/include-prefixes/arm64/renesas/r9a07g043.dtsi:				     "renesas,rzg2l-wdt";
      scripts/dtc/include-prefixes/arm64/renesas/r9a07g054.dtsi:				     "renesas,rzg2l-wdt";
      scripts/dtc/include-prefixes/arm64/renesas/r9a07g054.dtsi:				     "renesas,rzg2l-wdt";
      scripts/dtc/include-prefixes/arm64/renesas/r9a07g054.dtsi:				     "renesas,rzg2l-wdt";
      
  • Example: Find the UART Driver
    • RZ/G2L Device Tree: rz_linux-cip/arch/arm64/boot/dts/renesas/r9a07g044.dtsi
      scif0: serial@1004b800 {
      	compatible = "renesas,scif-r9a07g044";
      	reg = <0 0x1004b800 0 0x400>;
      	interrupts = <GIC_SPI 380 IRQ_TYPE_LEVEL_HIGH>,
      		     <GIC_SPI 382 IRQ_TYPE_LEVEL_HIGH>,
      		     <GIC_SPI 383 IRQ_TYPE_LEVEL_HIGH>,
      		     <GIC_SPI 381 IRQ_TYPE_LEVEL_HIGH>,
      		     <GIC_SPI 384 IRQ_TYPE_LEVEL_HIGH>,
      		     <GIC_SPI 384 IRQ_TYPE_LEVEL_HIGH>;
      	interrupt-names = "eri", "rxi", "txi",
      			  "bri", "dri", "tei";
      	clocks = <&cpg CPG_MOD R9A07G044_SCIF0_CLK_PCK>;
      	clock-names = "fck";
      	power-domains = <&cpg>;
      	resets = <&cpg R9A07G044_SCIF0_RST_SYSTEM_N>;
      	status = "disabled";
      };
      
    • Use the grep command:
      $ cd drivers
      $ grep -R "renesas,scif-r9a07g044" *