CW4 Debug Linux Kernel on Ls1012a

cancel
Showing results for 
Search instead for 
Did you mean: 

CW4 Debug Linux Kernel on Ls1012a

1,313 Views
reginaldstjohn
Contributor II

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?

reginaldstjohn_0-1642112513786.png

 

0 Kudos
20 Replies

1,299 Views
reginaldstjohn
Contributor II

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?

0 Kudos

1,307 Views
yipingwang
NXP TechSupport
NXP TechSupport

Please add "nokaslr" in bootargs as the following in u-boot.

=> setenv bootargs "console=ttyS0,115200 root=/dev/ram0 earlycon=uart8250,mmio,0x21c0500 nokaslr"

=> saveenv

For Linux Kernel debugging, you could refer to the attached document in the following link.

https://community.nxp.com/t5/CodeWarrior-for-QorIQ-Knowledge/Use-CodeWarrior-for-ARMv8-to-Debug-U-bo...

0 Kudos

1,296 Views
reginaldstjohn
Contributor II

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.

0 Kudos

1,282 Views
yipingwang
NXP TechSupport
NXP TechSupport

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.

0 Kudos

1,274 Views
reginaldstjohn
Contributor II

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

reginaldstjohn_0-1642434147671.png

- Connect to the device by clicking "debug", NOTE: the middle window seems to indicate we are broke at some address 0x87b8cc5c.

reginaldstjohn_1-1642434230533.png

- Click Suspend in Codewarrior. NOTE: The suspend button is greyed out but the resume button is not enabled.

reginaldstjohn_3-1642434377376.png

 

- After about 20 seconds An error box comes up.

reginaldstjohn_2-1642434353714.png

- At this point I am stuck since I cannot type in the u-boot terminal or resume the processor.

 

0 Kudos

1,263 Views
yipingwang
NXP TechSupport
NXP TechSupport

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.

yipingwang_1-1642583840164.png

 

 

 

Tags (1)
0 Kudos

1,254 Views
reginaldstjohn
Contributor II

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.

reginaldstjohn_0-1642617734507.png

I get the following in the debug console after attaching.

reginaldstjohn_1-1642617946403.png

 

 

 

0 Kudos

1,231 Views
yipingwang
NXP TechSupport
NXP TechSupport

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.

0 Kudos

1,182 Views
reginaldstjohn
Contributor II

I cannot get to the u-boot prompt after resuming. The processor seems lost or frozen.

0 Kudos

1,176 Views
yipingwang
NXP TechSupport
NXP TechSupport

Would you please send your CW workspace without source code to me?

0 Kudos

1,166 Views
reginaldstjohn
Contributor II

private message sent

0 Kudos

1,154 Views
yipingwang
NXP TechSupport
NXP TechSupport

You workspace doesn't include CodeWarrior debug project. Please check it.

0 Kudos

1,145 Views
reginaldstjohn
Contributor II

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

reginaldstjohn_0-1643211887226.png

 

0 Kudos

1,138 Views
yipingwang
NXP TechSupport
NXP TechSupport

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.

https://drive.google.com/file/d/1Kjq1nLYrtIfWAHYrup5Cf-TTEJI9iWiu/view?usp=sharing

Please download the pack from the following link and install it from Help->Install New Software->Add->Archive.

https://drive.google.com/file/d/1ZHiYWDOhb27o0oD5Brqjn4_vJzRUCKoY/view?usp=sharing

 

0 Kudos

1,126 Views
reginaldstjohn
Contributor II

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?

0 Kudos

1,113 Views
yipingwang
NXP TechSupport
NXP TechSupport

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.

0 Kudos

1,091 Views
reginaldstjohn
Contributor II

Ok, following steps.

First issue is codewarrior keeps giving me the following error after I close it, restart it, and then choose the workspace.

reginaldstjohn_0-1643389709440.png

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.

reginaldstjohn_1-1643396389615.png

Then I connected to the target with uboot stopped at its prompt.

reginaldstjohn_2-1643396433017.png

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

reginaldstjohn_4-1643396688960.png

 

Sorry, but I seem to be at the same spot I was before. Am I missing something?

0 Kudos

978 Views
yipingwang
NXP TechSupport
NXP TechSupport

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.

0 Kudos

871 Views
reginaldstjohn
Contributor II

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?

0 Kudos

828 Views
yipingwang
NXP TechSupport
NXP TechSupport

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.

0 Kudos