I‘m using Jetson AGX orin 64G(J-Linux-R36.4),but I try to open the KGDB to debug the kernel, but serial was not ready before earlycon start.
how can I use kgdb in jetson?
because I have a mission for writing a buffer of unified to a file ,but return –14(bad address),it not trigger kernel crash ,so kernel dump is not work on it.
*** Please note that this reply is generated by LLM automatically ***
To enable KGDB on Jetson AGX Orin, you need to configure the kernel to use the serial console as the earlycon. Here are the steps to follow:
-
Configure the kernel: You need to configure the kernel to use the serial console as the earlycon. You can do this by adding the following parameters to the kernel command line:
earlycon=uart,mmio,0x02400000,115200n8 earlyprintk=uart,mmio,0x02400000,115200n8
These parameters tell the kernel to use the serial console at address `0x02400000` with a baud rate of `115200`.
2. **Build the kernel**: After configuring the kernel, you need to build it. You can do this by running the following command:
```bash
make -j$(nproc)
This command builds the kernel using multiple CPU cores.
-
Flash the kernel: After building the kernel, you need to flash it to the Jetson AGX Orin device. You can do this by running the following command:
./flash.sh jetson-agx-orin-devkit internal
This command flashes the kernel to the Jetson AGX Orin device.
4. **Connect to the serial console**: After flashing the kernel, you need to connect to the serial console. You can do this by using a serial console cable and a terminal emulator such as `minicom` or `screen`.
5. **Start KGDB**: After connecting to the serial console, you can start KGDB by running the following command:
```bash
kgdb -c /dev/ttyUSB0
This command starts KGDB and connects it to the serial console.
- Debug the kernel: After starting KGDB, you can debug the kernel by running various commands such as
break,continue,step, etc.
Regarding your issue with writing a buffer of unified memory to a file, it’s possible that the issue is related to the fact that unified memory is not mapped to a physical address. You can try using the ioremap function to map the unified memory to a physical address, and then write to that address.
Here is an example of how you can use ioremap to map unified memory to a physical address:
#include <linux/io.h>
// ...
void *buffer = kmalloc(PAGE_SIZE, GFP_KERNEL);
phys_addr_t phys_addr = virt_to_phys(buffer);
// Map the unified memory to a physical address
void __iomem *mapped_addr = ioremap(phys_addr, PAGE_SIZE);
// Write to the mapped address
memcpy_toio(mapped_addr, buffer, PAGE_SIZE);
// Unmap the physical address
iounmap(mapped_addr);
This code maps the unified memory to a physical address using ioremap, writes to the mapped address using memcpy_toio, and then unmaps the physical address using iounmap.
Note that this is just an example, and you may need to modify it to suit your specific use case. Additionally, you should ensure that the unified memory is properly allocated and freed to avoid memory leaks.
*** Please give the thumbs up if you get answers you like. Or provide feedback to help us improve the answer. ***
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.