TM Linux Kernel Debug using Code Warrior Marius
TM Linux Kernel Debug using Code. Warrior Marius Grigoras Freescale, the Freescale logo, Alti. Vec, C-5, Code. TEST, Code. Warrior, Cold. Fire, C-Ware, t he Energy Efficient Solutions logo, mobile. GT, Power. QUICC, Qor. IQ, Star. Core and Symphony are trademarks of Freescale Semiconductor, Inc. , Reg. U. S. Pat. & Tm. Off. Bee. Kit, Bee. Stack, Cold. Fire+, Core. Net, Flexis, Kinetis, MXC, Platform in a Package, Processor Expert, Qor. IQ Qonverge, Qorivva, QUICC Engine, SMARTMOS, Turbo. Link, Vorti. Qa and Xtrinsic are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.
Agenda Requirements • CW setup • • Kernel Debug Kernel Attach − Kernel Download − Kernel Modules • U-boot + Kernel Debug using only one project • Linux Kernel CW Support Analysis − TM 2 Freescale, the Freescale logo, Alti. Vec, C-5, Code. TEST, Code. Warrior, Cold. Fire, C-Ware, the Energy Efficient Solutions logo, mobile. GT, Power. QUICC, Qor. IQ, Star. Core and Symphony are trademarks of Freescale Semiconductor, Inc. , Reg. U. S. Pat. & Tm. Off. Bee. Kit, Bee. Stack, Cold. Fire+, Core. Net, Flexis, Kinetis, MXC, Platform in a Package, Processor Expert, Qor. IQ Qonverge, Qorivva, QUICC Engine, SMARTMOS, Turbo. Link, Vorti. Qa and Xtrinsic are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.
Requirements • SDK 1. 4 (need to be installed and compiled for your target) − Note that the kernel need to be compiled with CW support § bitbake virtual/kernel –c menuconfig § Select from Kernel hacking option -> Include Code. Warrior kernel debugging § This option is mandatory _only_ for low-end cores (e 300 c 1/c 2/c 3, e 500 v 1/2) − u-boot − RCW − Fman_ucode − u. Image − vmlinux − RAMDISK (rootfs) − DTB TM 3 Freescale, the Freescale logo, Alti. Vec, C-5, Code. TEST, Code. Warrior, Cold. Fire, C-Ware, the Energy Efficient Solutions logo, mobile. GT, Power. QUICC, Qor. IQ, Star. Core and Symphony are trademarks of Freescale Semiconductor, Inc. , Reg. U. S. Pat. & Tm. Off. Bee. Kit, Bee. Stack, Cold. Fire+, Core. Net, Flexis, Kinetis, MXC, Platform in a Package, Processor Expert, Qor. IQ Qonverge, Qorivva, QUICC Engine, SMARTMOS, Turbo. Link, Vorti. Qa and Xtrinsic are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.
CW setup (1) CW to be installed from here (both Windows and Linux are available) • the vmlinux elf file (contains debug symbols) will be imported in CW -> this will generate a new project that will contain both Attach and Download targets • Steps to make a new Linux_Kernel CW project for P 4080 DS: • § § § § Right click -> Import -> Code. Warrior Executable Importer Next -> Set up a project’s name Next -> Select the vmlinux image (be sure to select all files *) Next -> Select P 4080 Processor, Bareboard Application toolchain and Linux Kernel OS Next -> Select P 4080 DS Board, both Download and Attach launches and the desired JTAG Connection (this can be usbtap, etap, gtap and so on) Next -> Select Core 0 Finish TM 4 Freescale, the Freescale logo, Alti. Vec, C-5, Code. TEST, Code. Warrior, Cold. Fire, C-Ware, the Energy Efficient Solutions logo, mobile. GT, Power. QUICC, Qor. IQ, Star. Core and Symphony are trademarks of Freescale Semiconductor, Inc. , Reg. U. S. Pat. & Tm. Off. Bee. Kit, Bee. Stack, Cold. Fire+, Core. Net, Flexis, Kinetis, MXC, Platform in a Package, Processor Expert, Qor. IQ Qonverge, Qorivva, QUICC Engine, SMARTMOS, Turbo. Link, Vorti. Qa and Xtrinsic are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.
CW setup (2) • Mandatory debug settings: − From Debug Configuration select all the cores for both Attach and Debug Configurations TM 5 Freescale, the Freescale logo, Alti. Vec, C-5, Code. TEST, Code. Warrior, Cold. Fire, C-Ware, the Energy Efficient Solutions logo, mobile. GT, Power. QUICC, Qor. IQ, Star. Core and Symphony are trademarks of Freescale Semiconductor, Inc. , Reg. U. S. Pat. & Tm. Off. Bee. Kit, Bee. Stack, Cold. Fire+, Core. Net, Flexis, Kinetis, MXC, Platform in a Package, Processor Expert, Qor. IQ Qonverge, Qorivva, QUICC Engine, SMARTMOS, Turbo. Link, Vorti. Qa and Xtrinsic are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.
CW setup (3) • Only for Download target: − From Debugger -> OS Awareness tab need to set up the RAMDISK and DTB addresses: § For RAMDISK select *. rootfs. ext 2. gz file § For DTB – need to be used the updated DTB by u-boot, _NOT_ the DTB provided by SDK. Necessary steps: • Attach to u-boot with Kernel_Attach_Configuration • From Debugger Shell (Window->Show View-> Debugger Shell) set a hw bp at 0 x 0 using next command: bp hw 0 x 0 • Start kernel from u-boot console • Debugger stops at 0 x 0 • Last 2 lines from u-boot console shows where Ramdisk and DTB had been loaded. • Example: • • − Loading Ramdisk to 2 e 65 b 000, end 2 ffff 654. . . OK − Loading Device Tree to 03 fe 0000, end 03 fffa 6 b. . . OK Save the DTB file from Debugger Shell using: − save -b 0 x 03 fe 0000. . 0 x 03 fffa 6 b DTB_FILE_NAME − The DTB file will be saved in your Workspace folder Resume and disconnect TM 6 Freescale, the Freescale logo, Alti. Vec, C-5, Code. TEST, Code. Warrior, Cold. Fire, C-Ware, the Energy Efficient Solutions logo, mobile. GT, Power. QUICC, Qor. IQ, Star. Core and Symphony are trademarks of Freescale Semiconductor, Inc. , Reg. U. S. Pat. & Tm. Off. Bee. Kit, Bee. Stack, Cold. Fire+, Core. Net, Flexis, Kinetis, MXC, Platform in a Package, Processor Expert, Qor. IQ Qonverge, Qorivva, QUICC Engine, SMARTMOS, Turbo. Link, Vorti. Qa and Xtrinsic are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.
CW setup (4) • In the final this should be like: TM 7 Freescale, the Freescale logo, Alti. Vec, C-5, Code. TEST, Code. Warrior, Cold. Fire, C-Ware, the Energy Efficient Solutions logo, mobile. GT, Power. QUICC, Qor. IQ, Star. Core and Symphony are trademarks of Freescale Semiconductor, Inc. , Reg. U. S. Pat. & Tm. Off. Bee. Kit, Bee. Stack, Cold. Fire+, Core. Net, Flexis, Kinetis, MXC, Platform in a Package, Processor Expert, Qor. IQ Qonverge, Qorivva, QUICC Engine, SMARTMOS, Turbo. Link, Vorti. Qa and Xtrinsic are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.
CW setup (5) For both Download and Connect targets: • From OS Awareness, Debug Tab need to Enable the Memory Translation with next memory ranges for early-debug capabilities: • • For 64 bits kernel the virtual addr must be on 64 bits -> 0 xc 00000000 TM 8 Freescale, the Freescale logo, Alti. Vec, C-5, Code. TEST, Code. Warrior, Cold. Fire, C-Ware, the Energy Efficient Solutions logo, mobile. GT, Power. QUICC, Qor. IQ, Star. Core and Symphony are trademarks of Freescale Semiconductor, Inc. , Reg. U. S. Pat. & Tm. Off. Bee. Kit, Bee. Stack, Cold. Fire+, Core. Net, Flexis, Kinetis, MXC, Platform in a Package, Processor Expert, Qor. IQ Qonverge, Qorivva, QUICC Engine, SMARTMOS, Turbo. Link, Vorti. Qa and Xtrinsic are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.
CW setup (6) For both Download and Connect targets: • From OS Awareness, Modules Tab need to enable the modules detection capability: • TM 9 Freescale, the Freescale logo, Alti. Vec, C-5, Code. TEST, Code. Warrior, Cold. Fire, C-Ware, the Energy Efficient Solutions logo, mobile. GT, Power. QUICC, Qor. IQ, Star. Core and Symphony are trademarks of Freescale Semiconductor, Inc. , Reg. U. S. Pat. & Tm. Off. Bee. Kit, Bee. Stack, Cold. Fire+, Core. Net, Flexis, Kinetis, MXC, Platform in a Package, Processor Expert, Qor. IQ Qonverge, Qorivva, QUICC Engine, SMARTMOS, Turbo. Link, Vorti. Qa and Xtrinsic are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.
Linux OS Awarness • Freescale Code. Warrior: Full Linux Debugger • Integrated Linux Kernel and Userspace Debugger • No kernel changes required • Multicore 32/64 bits • Deep MMU understanding including Linux page table • Per core threads and user space processes display • Loadable modules full debug • System Information Freescale Target JTAG Probe Code. Warrior TM 10 Freescale, the Freescale logo, Alti. Vec, C-5, Code. TEST, Code. Warrior, Cold. Fire, C-Ware, the Energy Efficient Solutions logo, mobile. GT, Power. QUICC, Qor. IQ, Star. Core and Symphony are trademarks of Freescale Semiconductor, Inc. , Reg. U. S. Pat. & Tm. Off. Bee. Kit, Bee. Stack, Cold. Fire+, Core. Net, Flexis, Kinetis, MXC, Platform in a Package, Processor Expert, Qor. IQ Qonverge, Qorivva, QUICC Engine, SMARTMOS, Turbo. Link, Vorti. Qa and Xtrinsic are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.
Kernel Debug - Attach 1. Using Linux_Kernel_Attach launch attach to u-boot 2. From Debugger Shell set a hw bp at 0 x 0 using next command: bp hw 0 x 0 3. Start kernel from u-boot console 4. Debugger stops at 0 x 0 (kernel entry point) - If you don’t need early kernel debug jump to step 6 5. Early Kernel Debug 5. 1. setpicloadaddr 0 x 0 (in Debugger Shell) 5. 2. set up the source mapping (use ‘Locate file’ button) 6. Kernel Debug from start_kernel symbol: 6. 1. bp start_kernel (in Debugger Shell) 6. 2. Run 6. 3. Debugger stops at start_kernel symbol 6. 4. set up the source mapping (use ‘Locate file’ button) TM 11 Freescale, the Freescale logo, Alti. Vec, C-5, Code. TEST, Code. Warrior, Cold. Fire, C-Ware, the Energy Efficient Solutions logo, mobile. GT, Power. QUICC, Qor. IQ, Star. Core and Symphony are trademarks of Freescale Semiconductor, Inc. , Reg. U. S. Pat. & Tm. Off. Bee. Kit, Bee. Stack, Cold. Fire+, Core. Net, Flexis, Kinetis, MXC, Platform in a Package, Processor Expert, Qor. IQ Qonverge, Qorivva, QUICC Engine, SMARTMOS, Turbo. Link, Vorti. Qa and Xtrinsic are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.
Kernel Debug – Download (1) Just launch the Linux_Kernel_Download connection configured in the previous steps (@CW setup) • CW will detect all 8 cores and these will be up and running • Very useful when the network support or/and Flash Programmer support via CW are disabled/unworking • But will add massive overhead for download operation over JTAG (~ 5 minutes) • • Conclusion: if we have network or FP support via CW the quickest way is to use the Attach connection TM 12 Freescale, the Freescale logo, Alti. Vec, C-5, Code. TEST, Code. Warrior, Cold. Fire, C-Ware, the Energy Efficient Solutions logo, mobile. GT, Power. QUICC, Qor. IQ, Star. Core and Symphony are trademarks of Freescale Semiconductor, Inc. , Reg. U. S. Pat. & Tm. Off. Bee. Kit, Bee. Stack, Cold. Fire+, Core. Net, Flexis, Kinetis, MXC, Platform in a Package, Processor Expert, Qor. IQ Qonverge, Qorivva, QUICC Engine, SMARTMOS, Turbo. Link, Vorti. Qa and Xtrinsic are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.
Kernel Debug – Download (2) For each code change, just overwrite the vmlinux in your CW project • CW will show next warning in Console view if build dates between u. Image (running on target) and vmlinux (from CW) are different (very useful for Attach connection when you can forget to keep the sync between u. Image and vmlinux) • TM 13 Freescale, the Freescale logo, Alti. Vec, C-5, Code. TEST, Code. Warrior, Cold. Fire, C-Ware, the Energy Efficient Solutions logo, mobile. GT, Power. QUICC, Qor. IQ, Star. Core and Symphony are trademarks of Freescale Semiconductor, Inc. , Reg. U. S. Pat. & Tm. Off. Bee. Kit, Bee. Stack, Cold. Fire+, Core. Net, Flexis, Kinetis, MXC, Platform in a Package, Processor Expert, Qor. IQ Qonverge, Qorivva, QUICC Engine, SMARTMOS, Turbo. Link, Vorti. Qa and Xtrinsic are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.
Kernel Modules Debug (1) Using the same Attach or Download target with Modules detection capability ON • CW detects any insmod operation • − It’s mandatory to have the path mapping between vmlinux and kernel sources already resolved, because CW puts a bp to do_init_module() function and needs to find the according debug symbol for it After a module is inserted a pop-up window will be triggered for locating the debug symbols (picture from next slide) • You can use <System> view (Windows -> Show view -> System Browser) to see information about Kernel version, modules and threads running on each core • “Symbolics Loaded” attribute will be set to false if debug symbols are not loaded • Also using the right-click on module, you can use the menu to Unload/Load/Reload the debug symbols • TM 14 Freescale, the Freescale logo, Alti. Vec, C-5, Code. TEST, Code. Warrior, Cold. Fire, C-Ware, the Energy Efficient Solutions logo, mobile. GT, Power. QUICC, Qor. IQ, Star. Core and Symphony are trademarks of Freescale Semiconductor, Inc. , Reg. U. S. Pat. & Tm. Off. Bee. Kit, Bee. Stack, Cold. Fire+, Core. Net, Flexis, Kinetis, MXC, Platform in a Package, Processor Expert, Qor. IQ Qonverge, Qorivva, QUICC Engine, SMARTMOS, Turbo. Link, Vorti. Qa and Xtrinsic are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.
TM 15 Freescale, the Freescale logo, Alti. Vec, C-5, Code. TEST, Code. Warrior, Cold. Fire, C-Ware, the Energy Efficient Solutions logo, mobile. GT, Power. QUICC, Qor. IQ, Star. Core and Symphony are trademarks of Freescale Semiconductor, Inc. , Reg. U. S. Pat. & Tm. Off. Bee. Kit, Bee. Stack, Cold. Fire+, Core. Net, Flexis, Kinetis, MXC, Platform in a Package, Processor Expert, Qor. IQ Qonverge, Qorivva, QUICC Engine, SMARTMOS, Turbo. Link, Vorti. Qa and Xtrinsic are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.
Kernel Modules Debug (2) You can debug modules and set BPs to module_init(), module_exit() or any other function • You can set up BPs for modules only from sources ! • TM 16 Freescale, the Freescale logo, Alti. Vec, C-5, Code. TEST, Code. Warrior, Cold. Fire, C-Ware, the Energy Efficient Solutions logo, mobile. GT, Power. QUICC, Qor. IQ, Star. Core and Symphony are trademarks of Freescale Semiconductor, Inc. , Reg. U. S. Pat. & Tm. Off. Bee. Kit, Bee. Stack, Cold. Fire+, Core. Net, Flexis, Kinetis, MXC, Platform in a Package, Processor Expert, Qor. IQ Qonverge, Qorivva, QUICC Engine, SMARTMOS, Turbo. Link, Vorti. Qa and Xtrinsic are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.
U-boot + Kernel Debug using only one project (1) • Starting from Linux Kernel Attach target added the u-boot elf file to Other Executables (Debugger tab) TM 17 Freescale, the Freescale logo, Alti. Vec, C-5, Code. TEST, Code. Warrior, Cold. Fire, C-Ware, the Energy Efficient Solutions logo, mobile. GT, Power. QUICC, Qor. IQ, Star. Core and Symphony are trademarks of Freescale Semiconductor, Inc. , Reg. U. S. Pat. & Tm. Off. Bee. Kit, Bee. Stack, Cold. Fire+, Core. Net, Flexis, Kinetis, MXC, Platform in a Package, Processor Expert, Qor. IQ Qonverge, Qorivva, QUICC Engine, SMARTMOS, Turbo. Link, Vorti. Qa and Xtrinsic are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.
U-boot + Kernel Debug using only one project (2) After attach, hit the reset button using system reset checked and no initialization file • From Debugger shell set the PIC for u-boot elf • − setpicloadaddr u-boot 0 xfff 80000 CW will request the path mapping for u-boot source files • Now you can make u-boot debug in all stages until u-boot will be relocated to DDR • − Depends by u-boot relocation address you’ll need to reset or to update the PIC according • Set a hw BP at 0 x 0 (kernel entry point) from debugger shell: − bp –hw 0 x 0 You can resume the u-boot hitting • Start the kernel from serial terminal • The entry point’s bp will be hit (CW will stop at 0 x 0) • From Debugger shell set the PIC for vmlinux elf • − setpicloadaddr vmlinux 0 x 0 CW will request the path mapping for vmlinux source files • Now you can make Linux Kernel debug • After Linux relocation you’ll need to reset the PIC • − setpicloadaddr vmlinux reset TM 18 Freescale, the Freescale logo, Alti. Vec, C-5, Code. TEST, Code. Warrior, Cold. Fire, C-Ware, the Energy Efficient Solutions logo, mobile. GT, Power. QUICC, Qor. IQ, Star. Core and Symphony are trademarks of Freescale Semiconductor, Inc. , Reg. U. S. Pat. & Tm. Off. Bee. Kit, Bee. Stack, Cold. Fire+, Core. Net, Flexis, Kinetis, MXC, Platform in a Package, Processor Expert, Qor. IQ Qonverge, Qorivva, QUICC Engine, SMARTMOS, Turbo. Link, Vorti. Qa and Xtrinsic are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.
Linux Kernel CW Support Analysis - Kernel threads stack frames Process view (ps ax) Scheduling status Kernel + user space Full Debugger - Source code - Disassemble - Registers - Breakpoints - Stack - Variables view TM 19 Freescale, the Freescale logo, Alti. Vec, C-5, Code. TEST, Code. Warrior, Cold. Fire, C-Ware, the Energy Efficient Solutions logo, mobile. GT, Power. QUICC, Qor. IQ, Star. Core and Symphony are trademarks of Freescale Semiconductor, Inc. , Reg. U. S. Pat. & Tm. Off. Bee. Kit, Bee. Stack, Cold. Fire+, Core. Net, Flexis, Kinetis, MXC, Platform in a Package, Processor Expert, Qor. IQ Qonverge, Qorivva, QUICC Engine, SMARTMOS, Turbo. Link, Vorti. Qa and Xtrinsic are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.
Thank you Questions ? § CONTACT Marius Grigoras marius. grigoras@freescale. com TM 20 Freescale, the Freescale logo, Alti. Vec, C-5, Code. TEST, Code. Warrior, Cold. Fire, C-Ware, the Energy Efficient Solutions logo, mobile. GT, Power. QUICC, Qor. IQ, Star. Core and Symphony are trademarks of Freescale Semiconductor, Inc. , Reg. U. S. Pat. & Tm. Off. Bee. Kit, Bee. Stack, Cold. Fire+, Core. Net, Flexis, Kinetis, MXC, Platform in a Package, Processor Expert, Qor. IQ Qonverge, Qorivva, QUICC Engine, SMARTMOS, Turbo. Link, Vorti. Qa and Xtrinsic are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © 2011 Freescale Semiconductor, Inc.
- Slides: 20