Jetson xavier nx kernel version 32.7.4, added output to the driver, dmesg can not see the output

jetson xavier nx kernel version 32.7.4, the printk printout was added to the driver GPI-tegra186.c. After the system started, the debugging information still could not be displayed using dmesg.
image

dmesg |grep log

image

file:
Linux_for_Tegra/source/Linux_for_Tegra/source/public/kernel/nvidia/drivers/gpio/gpio-tegra186.c

Remember trying this before, you can see debugging information in dmesg, I don’t know why this is

I don’ t know, but are you certain your content is actually loaded? Did you add this to a module, or did you add this to the main kernel? How did you install the module or kernel? What CONFIG_LOCALVERSION was used, and what is the output of “uname -r”?

gpio-tegra186.c is the original file in the kernel where I added debugging information to the init function. I found that dmesg did not output the information I want, it was OK before, I don’t know what changed to cause such a problem. The gpio-tegra186.c compiled file is loaded into the kernel

You probably know what I mean. Let me say it again.


I downloaded the official kernel source file and edited the gpio-tegra186.c file in the following path.

vi Linux_for_Tegra/source/public/kernel/nvidia/drivers/gpio/gpio-tegra186.c

This is just a modification of the tegra_gpio_init function to see the log output in dmesg.


Compile and flash…


After the system is turned on, I use dmesg to check and find that I do not have the output I want. When compiling the kernel for the first time some time ago, you can see the output of your own Settings. Is this the kernel not loaded? Or what’s the reason?

These questions still need to be answered due to not knowing if your kernel is actually loaded:

  • What CONFIG_LOCALVERSION was used?
  • What is the output of “uname -r”?
  • Did you install just a module, or did you install the kernel too?

CONFIG_LOCALVERSION is 4.9.337

After the system is started, the uname -r
command is displayed
image

The driver is installed in the kernel

你是怎麼flash的?你確定你新compile的kernel有被load起來嗎?

sudo dmesg | grep “Linux version”

看一下kernel image的編譯時間

在开发板上运行

utopia@utopia-desktop:~$ dmesg |grep "Linux version"
[    0.000000] Linux version 4.9.337-tegra (root@wel-Default-string) (gcc version 7.3.1 20180425 [linaro-7.3-2018.05 revision d29120a424ecfbc167ef90065c0eeb7f91977701] (Linaro GCC 7.3-2018.05) ) #2 SMP PREEMPT Mon Dec 25 15:13:59 CST 2023

https://www.kernel.org/doc/html/next/core-api/printk-basics.html
那大概是你沒有指定debug level之類的

我好像知道原因了,是我内核没刷新进去。我看了一下时间不对,问一下flash内核的方法是什么,我怕和我的方法不一致

把device上的/boot/Image這個檔案換掉就好

我修改编译成ko的驱动文件,然后烧录系统,发现没有输出。是因为没有加载成功吗?

你build成external module的話只換kernel當然沒用…
把新build出來的driver裝到/lib/modules/$(uname -r)/

我将编译好的ko文件安装到根文件系统目录中

make ARCH=arm64 O=$v modules_install INSTALL_MOD_PATH=$DIR/Linux_for_Tegra/rootfs/

然后是制包

sudo ./tools/kernel_flash/l4t_initrd_flash.sh --external-device nvme0n1p1 -c ./tools/kernel_flash/flash_l4t_nvme.xml -S 230GiB  --external-only --showlogs --no-flash jetson-xavier-nx-devkit nvme0n1p1

烧录

sudo ./tools/kernel_flash/l4t_initrd_flash.sh --external-device nvme0n1p1 -c ./tools/kernel_flash/flash_l4t_nvme.xml -S 230GiB  --erase-all --external-only  --showlogs --flash-only jetson-xavier-nx-devkit nvme0n1p1

最后系统开机后无法查看相应的dmesg输出

這個你有檢查過?
還有你其實可以用USB drive之類的方式把檔案丟進device就好,每次都整機重燒很浪費時間

我做过试验,自己写一个驱动文件然后编译成ko文件,放到系统中可以看到输出。应该不是printk输出等级的问题

还有就是我修改option.c中的probe函数,仍然是无法查看到输出。

kernel-4.9/drivers/usb/serial/option.c

添加调试信息

kernel/kernel-4.9/drivers/usb/serial/usb_wwan.c

移动到系统中,替换原来的ko文件
image

dmesg没有输出调试信息
image

你有手動把driver load起來嗎?
所以你第一個GPIO的成功了?

我替换之后重启,在dmesg中并没有看到调试信息。上面GPIO的那个是编译到内核中的驱动,这个是可以的。但是编译成ko文件的无法查看到输出,如果是我自己写的驱动文件,然后加载ko文件,在终端上是可以看到输出的。所以我的疑惑是为什么对官方源码的驱动文件添加调试信息,并没有出来。还是说驱动并没有加载成功

lsmod先檢查一下,沒有的話就用modprobe手動load起來
這應該是很基本的Linux kernel driver的知識