LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 10-20-2021, 01:52 PM   #1
almaz1c
LQ Newbie
 
Registered: Oct 2021
Posts: 2

Rep: Reputation: Disabled
Kernel won't boot under debugger


Hello. Having Linux (OpenWrt) running hardware working like a charm.
CPU - is NXP's IMX6ULL.
This CPU has JTAG interface and supported by J-Link debugger.
Got U-boot booting well under JTAG debugger but having troubles with linux kernel.
Using
Code:
vmlinux
compiled with
Code:
CONFIG_DEBUG_INFO=y
and
Code:
CONFIG_DEBUG_KERNEL=y
.
Here is entry point of kernel starting screenshoot
I am able to walk through the code step by step until
Code:
__enable_mmu
function.
Here are four steps before execution stucks: 1, 2, 3 and 4.

e.g. on execution
Code:
mcr	p15, 0, r4, c2, c0, 0		@ load page table pointer
line of code it stucks. Registers state on each step shown on the right side of screenshot. Don't know anything about assembler so can't understand what is wrong.

Because of facing such issue under debugging I am pretty sure that something not initialized properly. Some things to be initialized by u-boot during production flow, e.g. on booting kernel after U-boot initialized and passes execution to the kernel.
Trying to find what is page table pointer, trying to understand what register should store what value without luck. Could someone please give me a hint how can I handle that issue? Probably how to initialize page table pointer properly?
 
Old 10-24-2021, 10:02 AM   #2
DarrenDrapkin
Member
 
Registered: Aug 2014
Location: Leeds, England
Distribution: Slackware x86 64 version 15.0
Posts: 127
Blog Entries: 3

Rep: Reputation: 27
I am not a big-league kernel hacker, but I having seen your screenshot, I can suggest the following. The function you are commencing with has a comment over it, that says that it will not work with MMU enabled. You will have to step over the function enabling MMU in order to continue debugging.
As to why this is, can someone else comment?
 
Old 10-26-2021, 05:07 AM   #3
almaz1c
LQ Newbie
 
Registered: Oct 2021
Posts: 2

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by DarrenDrapkin View Post
I am not a big-league kernel hacker, but I having seen your screenshot, I can suggest the following. The function you are commencing with has a comment over it, that says that it will not work with MMU enabled. You will have to step over the function enabling MMU in order to continue debugging.
As to why this is, can someone else comment?
Thank you for reply.
Got kernel partially debuggable. The trick was in adding u-boot image in memory too, set PC counter there and let u-boot pass initialization procedure. Then it loads kernel and here I am catching breakpoint at first kernel instructions:

Code:
target remote localhost:2331
monitor reset
monitor halt
monitor sleep 200
load
display /x $pc
b __hyp_stub_install
b start_kernel
add-symbol-file u-boot 0x87800000
set $pc = 0x87800000
display /x $pc
c
Now I am fighting with
Code:
-O2
optimization level. Seems Kernel won't compile with
Code:
-O0
so trying to compile it with
Code:
-Og
. Without luck, unfortunately.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Debugger won't break at breakpoints in qt creator jeypeyy Linux - Software 1 04-12-2013 03:48 PM
malloc() only works under the gdb debugger. Unicks Linux - Kernel 1 07-03-2009 01:28 AM
Program being run under debugger kristolearn Linux - Newbie 0 03-31-2009 01:09 PM
Kernel Debugger - how arunachalam Linux - Software 1 07-21-2008 01:09 AM
Kernel debugger legolas_t Programming 1 06-28-2004 09:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 10:07 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration