RZ-G/debug tricks: Difference between revisions

From Renesas.info
(Created page with "{{DISPLAYTITLE:Linux Debug Tricks}} This page contains many helpful suggestions for debugging issue with the Linux kernel. =Most 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: <font color=blue>$ grep -r "...")
 
No edit summary
Line 3: Line 3:
This page contains many helpful suggestions for debugging issue with the Linux kernel.
This page contains many helpful suggestions for debugging issue with the Linux kernel.


=Most common tools=
=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.
* '''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:  <font color=blue>$ grep -r "start_kernel"</font>
** And example to find a function name start_kernel:  <font color=blue>$ grep -r "start_kernel"</font>
Line 14: Line 14:
* Simply use the grep command with -R option and search for that error message.
* Simply use the grep command with -R option and search for that error message.


=Error Code=
=Error Codes=
* If a error message prints out an error code, for example "-110", you should look up what the error code means.
* 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 [https://elixir.bootlin.com/linux/v5.10/source/include/uapi/asm-generic/errno-base.h include/uapi/asm-generic/errno-base.h]
* You can find a list of the error code numbers mean in file [https://elixir.bootlin.com/linux/v5.10/source/include/uapi/asm-generic/errno-base.h include/uapi/asm-generic/errno-base.h]

Revision as of 15:01, 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)
  • For example, to find the UART driver:
$ cd drivers
$ grep -R "renesas,sci" *