RZ-G/debug tricks: Difference between revisions

From Renesas.info
Line 63: Line 63:
scripts/dtc/include-prefixes/arm64/renesas/r9a07g054.dtsi: ย  ย  "renesas,rzg2l-wdt";
scripts/dtc/include-prefixes/arm64/renesas/r9a07g054.dtsi: ย  ย  "renesas,rzg2l-wdt";
</pre></html>
</pre></html>
** The very bottom of file '''drivers/watchdog/rzg2l_wdt.c''' <html><pre>
static const struct of_device_id rzg2l_wdt_ids[] = {
{ .compatible = <span><font color=red>"renesas,rzg2l-wdt"</font></span>, },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, rzg2l_wdt_ids);


* '''Example: Find the UART Driver'''
static struct platform_driver rzg2l_wdt_driver = {
** RZ/G2L Device Tree: rz_linux-cip/arch/arm64/boot/dts/renesas/'''r9a07g044.dtsi''' <html><pre>
.driver = {
scif0: serial@1004b800 {
.name = "rzg2l_wdt",
compatible = <span><font color=red>"renesas,scif-r9a07g044"</font></span>;
.of_match_table = rzg2l_wdt_ids,
reg = <0 0x1004b800 0 0x400>;
},
interrupts = &lt;GIC_SPI 380 IRQ_TYPE_LEVEL_HIGH>,
.probe = rzg2l_wdt_probe,
ย  ย  &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>
module_platform_driver(rzg2l_wdt_driver);
** Use the grep command: <html><pre>
ย 
<span><b>$ cd drivers</b></span>
MODULE_DESCRIPTION("Renesas RZ/G2L WDT Watchdog Driver");
<span><b>$ grep -R "renesas,scif-r9a07g044" *</b></span>
MODULE_AUTHOR("Biju Das <biju.das.jz@bp.renesas.com>");
MODULE_LICENSE("GPL v2");
</pre></html>
</pre></html>

Revision as of 15:30, 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";
      
    • The very bottom of file drivers/watchdog/rzg2l_wdt.c
      static const struct of_device_id rzg2l_wdt_ids[] = {
      	{ .compatible = "renesas,rzg2l-wdt", },
      	{ /* sentinel */ }
      };
      MODULE_DEVICE_TABLE(of, rzg2l_wdt_ids);
      
      static struct platform_driver rzg2l_wdt_driver = {
      	.driver = {
      		.name = "rzg2l_wdt",
      		.of_match_table = rzg2l_wdt_ids,
      	},
      	.probe = rzg2l_wdt_probe,
      };
      module_platform_driver(rzg2l_wdt_driver);
      
      MODULE_DESCRIPTION("Renesas RZ/G2L WDT Watchdog Driver");
      MODULE_AUTHOR("Biju Das ");
      MODULE_LICENSE("GPL v2");