Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Facilitate kernel debugging #59

Open
Koston-0xDEADBEEF opened this issue Feb 2, 2025 · 2 comments
Open

Facilitate kernel debugging #59

Koston-0xDEADBEEF opened this issue Feb 2, 2025 · 2 comments

Comments

@Koston-0xDEADBEEF
Copy link

As part of MiSTer-devel/Main_MiSTer#962 I need to look into Linux USB stack and attached USB device behaviour. I can do latter on another machine, but since MiSTer uses an older kernel, different USB host controller and custom code in the stack, debugging it only really makes sense on the real thing.

It's been a long time since I last had to debug Linux kernel code, and it has always been a rather unpleasant experience. To avoid wasting a lot of time, I could use some advice:

  • Is there a serviceable kernel debugger with a remote stub and capability to single step CPU instructions?
  • Does any of the dynamic tracing frameworks in Linux actually work and do anything useful in this context?
  • How do I build and install custom kernels for MiSTer?

I've tried compiling usbmon traffic capturing driver as a module, but something in the build is still different from the official kernel, as insmod(8) refuses to load it.

Koston-0xDEADBEEF added a commit to Koston-0xDEADBEEF/Linux-Kernel_MiSTer that referenced this issue Feb 2, 2025
Used to capture/monitor low-level USB traffic. For details, see
Documentation/usb/usbmon.rst

This increases zImage size by 10880 bytes.
@Koston-0xDEADBEEF
Copy link
Author

  • How do I build and install custom kernels for MiSTer?

Seems it's doable without messing with bootloader or any init scripts. That's very nice.

Not sure if this is exactly correct, but it works at least:

typeset -a mkargs=(
    ARCH=arm
    CROSS_COMPILE=arm-none-linux-gnueabihf-
    LOCALVERSION=-MiSTer
    KBUILD_DEFCONFIG=MiSTer_defconfig
)
make defconfig $mkargs
make zImage $mkargs
make modules $mkargs
make dtbs $mkargs
cat arch/arm/boot/zImage arch/arm/boot/dts/socfpga_cyclone5_de10_nano.dtb > zImage_dtb

@Koston-0xDEADBEEF
Copy link
Author

Is there a serviceable kernel debugger with a remote stub and capability to single step CPU instructions?

KGDB over serial works at least nominally, but the hardware has some watchdog feature enabled which halts the system shortly after breaking execution. I've been so far unable to find/disable the watchdog and would appreciate pointers where to look.

@Koston-0xDEADBEEF Koston-0xDEADBEEF changed the title Facilitate USB debugging Facilitate kernel debugging Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant