We are trying to debug an OpenWrt linux kernel (V5.4.143). I am following the steps from the Armv8_Targeting_Manual.pdf section 8.3.2 about how to debug a linux kernel.
I make sure that the kernel is being compiled with debug symbols. I import the vmlinux file, though there are also vmlinux.elf and vmlinux.debug files in a lower directory.
I setup all the options as they are shown in the document and then hit debug.
After doing this I don't get the same screen to browse for source code and it is not stopping at my initial breakpoint (0x8008000). I can pause the debugger but it seems like it is lost somewhere.
Any ideas or help?
thank you, I will ty that. I did see that forum question but it seemed like the same instructions i was following. I will try your suggestion and get back to you.
In the instructions it uses "BitBake" do we need to use that to get debugging working?
Please add "nokaslr" in bootargs as the following in u-boot.
=> setenv bootargs "console=ttyS0,115200 root=/dev/ram0 earlycon=uart8250,mmio,0x21c0500 nokaslr"
For Linux Kernel debugging, you could refer to the attached document in the following link.
OK, I tried following that document, which is basically the same thing as what i had done. I also tried the nokaslr.
However, I can't actually even try the steps because as soon I hit debug in codewarrrior I can't type anything in the UBoot console. It seems frozen like the JTAG has taken control. Codewarrior says that it is running but if I hit "Suspend" it doesn't really look like it is suspending anything.
We have been using the JTAG to program the flash so I know it works that much at least.
On the target board, after setting up u-boot and entering into u-boot prompt. In CodeWarrior IDE,
click “Debug” to connect to the target board to attach to u-boot. After CodeWarrior connect to the
target board, please click “Suspend” button in CodeWarrior IDE to stop the running u-boot, and
enter “break _text” in the gdb console to set the breakpoint at the start of Linux Kernel.
Then in CodeWarrior IDE resume the program, in the target console, type the command under u-boot prompt to boot up Linux Kernel.
Here are the steps i take, following your directions, and the outcomes that I see.
- Go into u-boot and stop it from booting to the kernel
- load kernel image into RAM
- Connect to the device by clicking "debug", NOTE: the middle window seems to indicate we are broke at some address 0x87b8cc5c.
- Click Suspend in Codewarrior. NOTE: The suspend button is greyed out but the resume button is not enabled.
- After about 20 seconds An error box comes up.
- At this point I am stuck since I cannot type in the u-boot terminal or resume the processor.
Please configure Debugger and Startup panels carefully following the document which I mentioned. After connecting to the target and click suspend button, you should get the IDE similar as the following.
Thank you for taking time to help. However, I must be missing a step becasue I have repeated the steps you outline in your document, several times, and I still cannot get it to debug the linux kernel.
Do I need to use a special u-boot? I am using the u-boot from our distribution OpenWrt.
I get to the uboot command. Attach with the debugger and it stops but it apears to be lost. I can set the break point and resume but I cannot then type anything into u-boot. It is frozen.
I get the following in the debug console after attaching.
No need special u-boot.
Please type "enter" to enter u-boot prompt "=>".
Then connect and attach CodeWarrior to u-boot, after click "suspend" button, please set the breakpoints in the debugger console, then click Resume in CW IDE, you could enter commands under u-boot prompt "=>".
Probably you could send your CW workspace without source code to me, I use it to do verification on my side.
OK, I am going to need more detailed directions then
I only have one workspace, the one I sent you. The project I was using to debug shows up in the project explorer as shown below. It was created by following the document you pointed me to. I "Imported" the vmlinux image I want to debug and set up the project as specified in the document. What is it you want me to send you?
Attached you will find exported Debug and Project settings
I didn't find problem in your project configuration.
I create a test project for you, I attached the workspace as the attachment, please save and unzip it.
Please open CodeWarrior IDE and specify the workspace path as <path>/debug_kernel.
Then connect to your target board from Run->Debug Configurations->ls1046->Debug, click "suspend" button to stop u-boot, then click "Resume" button to check whether u-boot can work normally.
In addition, please use the latest CodeWarrior for ARMv8 11.5.5.
Please download and install CW4NET_v2020.06 from the following link.
Please download the pack from the following link and install it from Help->Install New Software->Add->Archive.
I followed your instructions in your latest reply. I boot to u-boot console. I can attach with the debuger and suspend execution. I get what looks like valid assembly code. I can then hit resume and continue.
Now what? Does that help you know why I can't do that same thing with my vmlinux project?
One note, It does not ask me for any debug symbols or u-boot files when I stop execution. Is this expected?
Please download the attach Linux debug project.
Please open CodeWarrior IDE and specify the workspace as <your path>/debug_linux.
Then copy your vmlinux file in folder debug_linux.
Then connect to the target board, click "suspend" button in CodeWarrior IDE, type "break _text" in debug console, click "resume" button in CW IDE, continue to boot Linux Kernel in u-boot.
Ok, following steps.
First issue is codewarrior keeps giving me the following error after I close it, restart it, and then choose the workspace.
Now, once I reinstall CW for the 3rd time I proceed to follow your instructions.
The project would not find my vmlinux, even after copying it to the debug_linux folder. This is because the vmlinux in the project had an absolute path to its location on ypingwang's machine. I changed the properties of the the vmlinux file in the Project Explorer tab to point to my vmlinux file.
Then I connected to the target with uboot stopped at its prompt.
I see the following error in the debug console (see picture below). Seems like it is not going to work.
I add the breakpoint and hit resume. At this point uboot is frozen and I cannot launch the kernel
Sorry, but I seem to be at the same spot I was before. Am I missing something?
Please connect CodeWarrior project to the target board, then suspend the target board and resume the processor to check whether u-boot can still work without setting the break point in CodeWarrior IDE.
When I connect with the u-boot work space you gave us to try (debug_kernel) I can connect, suspend and then resume u-boot with no problems.
If i use the vmlinux debug workspace (debug_linux) you or I create then when I connect I get the gdb error mentioned above and u-boot is frozen. I cannot resume because I can't suspend.
Another note that might be important is that we put a switch on our board connected to the CLK_OUT pin so that on power up we could switch between the processor using the Hard Coded RCW word or the RCW programmed in QSPI flash. For us to program the QSPI flash we have to have the switch in the position that enables the Hard Coded RCW. Once we program the flash we have to switch it to the possition to use the flash RCW word in order to boot u-boot. Maybe this has something to do with it?
If this Attached method doesn't work on your target board.
Please try to use the download method, please refer to "8.3 Linux kernel debug" in C:\Freescale\CW4NET_v2020.06\CW_ARMv8\ARMv8\Help\PDF\ARMv8_Targeting_Manual.pdf.