{"id":124,"date":"2018-02-05T15:40:34","date_gmt":"2018-02-05T23:40:34","guid":{"rendered":"https:\/\/sysprogs.com\/tutorials\/?p=124"},"modified":"2018-02-05T15:40:34","modified_gmt":"2018-02-05T23:40:34","slug":"debugging-linux-kernel-on-i-mx6-over-ethrnet-with-visual-studio","status":"publish","type":"post","link":"https:\/\/sysprogs.com\/VisualKernel\/tutorials\/imx6\/kgdboe\/","title":{"rendered":"Debugging Linux Kernel on i.MX6 over Ethrnet with Visual Studio"},"content":{"rendered":"<p>This tutorial shows how to use VisualKernel to debug your Linux kernel running on an i.MX6 board over Ethernet. Before you begin, install\u00a0<a href=\"http:\/\/visualkernel.com\/download\/\">VisualKernel 2.1<\/a>\u00a0or later.<\/p>\n<ol>\n<li>Before you begin, build a debug-enabled kernel for your device by following\u00a0<a href=\"http:\/\/sysprogs.com\/VisualKernel\/tutorials\/imx6\/buildkernel\/\">this tutorial<\/a>. Enable the CONFIG_NETPOLL, CONFIG_KGDB, CONFIG_TRACEPOINT and CONFIG_FTRACE settings in your kernel as described\u00a0<a href=\"http:\/\/visualkernel.com\/kgdboe\/imx6.php\">here<\/a>\u00a0to ensure the KGDBoE module has all the necessary functionality it requires.<\/li>\n<li>Start Visual Studio and select File-&gt;New Project-&gt;VisualKernel-&gt;Linux Kernel Module Wizard:<img decoding=\"async\" src=\"http:\/\/sysprogs.com\/VisualKernel\/legacy_tutorials\/imx6\/kgdboe\/img\/01-prjname.png\" width=\"700\" \/><\/li>\n<li>Proceed with the default &#8220;Create a new kernel module&#8221; selection:<img decoding=\"async\" src=\"http:\/\/sysprogs.com\/VisualKernel\/legacy_tutorials\/imx6\/kgdboe\/img\/02-modname.png\" \/><\/li>\n<li>Select your i.MX6 board as the targeted Linux computer and choose the machine where you built the kernel as the additional Linux computer to build the module. Ensure you uncheck the &#8220;detect and install headers and symbols&#8221; checkbox as the kernel was built manually:<img decoding=\"async\" src=\"http:\/\/sysprogs.com\/VisualKernel\/legacy_tutorials\/imx6\/kgdboe\/img\/03-target.png\" width=\"701\" \/><\/li>\n<li>On the next page select the directory with the kernel sources as the Kernel header directory and enter the cross-compiler settings as shown below. Then select &#8220;Install symbols for another kernel&#8221; to begin the process of importing the kernel symbols for VisualKernel:<img decoding=\"async\" src=\"http:\/\/sysprogs.com\/VisualKernel\/legacy_tutorials\/imx6\/kgdboe\/img\/04-inst.png\" width=\"700\" \/><\/li>\n<li>In the symbol import wizard select &#8220;Specify kernel symbols and sources manually&#8221;:<img decoding=\"async\" src=\"http:\/\/sysprogs.com\/VisualKernel\/legacy_tutorials\/imx6\/kgdboe\/img\/05-manual.png\" width=\"606\" \/><\/li>\n<li>Then enter the locations of the kernel binary, kernel source directory and the GDB binary from the Linaro toolchain as shown below:<img decoding=\"async\" src=\"http:\/\/sysprogs.com\/VisualKernel\/legacy_tutorials\/imx6\/kgdboe\/img\/06-data.png\" width=\"696\" \/><\/li>\n<li>Press &#8220;Finish&#8221; to import the symbols and click &#8220;Next&#8221; to open the source settings page. Proceed with the default source location settings by pressing &#8220;Next &#8220;once more:<img decoding=\"async\" src=\"http:\/\/sysprogs.com\/VisualKernel\/legacy_tutorials\/imx6\/kgdboe\/img\/08-sources.png\" width=\"682\" \/><\/li>\n<li>On the Debug Settings page select &#8220;debug over network&#8221; and click Finish:<img decoding=\"async\" src=\"http:\/\/sysprogs.com\/VisualKernel\/legacy_tutorials\/imx6\/kgdboe\/img\/09-debug.png\" width=\"682\" \/><\/li>\n<li>Press Ctrl-Shift-B to automatically upload your sources to the Linux machine used for building and build it there:<img decoding=\"async\" src=\"http:\/\/sysprogs.com\/VisualKernel\/legacy_tutorials\/imx6\/kgdboe\/img\/10-build.png\" width=\"700\" \/><\/li>\n<li>Ensure that the board and the Linux machine used for building the module are located in the same subnet, set a breakpoint at the init() function and press F5 to start debugging. VisualKernel will automatically build and deploy the KGDBoE module needed for ethernet-based debugging:<img decoding=\"async\" src=\"http:\/\/sysprogs.com\/VisualKernel\/legacy_tutorials\/imx6\/kgdboe\/img\/kgdboe.png\" width=\"470\" \/><\/li>\n<li>Once the debug connection is establshed, VisualKernel will load your module, load the symbols for it and the breakpoint you set will automatically trigger:<img decoding=\"async\" src=\"http:\/\/sysprogs.com\/VisualKernel\/legacy_tutorials\/imx6\/kgdboe\/img\/11-bkpt.png\" width=\"700\" \/>From this point on, you can debug your module as if you were debugging a normal Windows program &#8211; breakpoints, call stack and output window will work as usual.<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to use VisualKernel to debug your Linux kernel running on an i.MX6 board over Ethernet. Before<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[39],"tags":[40,29],"_links":{"self":[{"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/posts\/124"}],"collection":[{"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/comments?post=124"}],"version-history":[{"count":1,"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/posts\/124\/revisions"}],"predecessor-version":[{"id":125,"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/posts\/124\/revisions\/125"}],"wp:attachment":[{"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/media?parent=124"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/categories?post=124"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sysprogs.com\/tutorials\/wp-json\/wp\/v2\/tags?post=124"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}