{"id":60,"date":"2009-03-24T07:15:17","date_gmt":"2009-03-24T12:15:17","guid":{"rendered":"http:\/\/www.e-consystems.com\/blog\/60\/"},"modified":"2023-08-15T12:31:59","modified_gmt":"2023-08-15T07:01:59","slug":"debugport","status":"publish","type":"post","link":"https:\/\/www.e-consystems.com\/blog\/windowsce\/debugport\/","title":{"rendered":"Disabling Debug Port in kernel mode"},"content":{"rendered":"<p style=\"text-align: justify;\">Developers may need one port for debugging in the development phase. But while in production phase, that debug port can be disabled and can be used as a COM port in kernel (i.e for Application). Generally, a <a title=\"PXA270\" href=\"https:\/\/www.e-consystems.com\/regulus.asp\">PXA270<\/a> <a title=\"Computer on Module\" href=\"https:\/\/www.e-consystems.com\/SOM-system-on-modules.asp\">Computer on Module<\/a> port can be used either as a debug port or as a COM port and cannot be used for both the purposes. The debug port is disabled only in the kernel level, so it can be still used for debugging in boot loader level. Disabling the debug port is a compiler time option and cannot be done dynamically. This blog explains how to disable the debug COM port in both ARM and X86 devices.<\/p>\n<p style=\"text-align: justify;\"><strong>Disabling Debug Port for ARM <\/strong><\/p>\n<p style=\"text-align: justify;\">For the ARM BSPs, the implementation of following three functions determines the usage of debug ports.<\/p>\n<p style=\"text-align: justify;\">OEMDebugInit<br \/>\nOEMDebugWriteByte<br \/>\nOEMDebugReaByte<\/p>\n<p style=\"text-align: justify;\">Leaving the above functions empty disables the debug port and that port can be used as a COM port in kernel by modifying the serial driver and adding appropriate registry settings.<\/p>\n<p style=\"text-align: justify;\"><strong>Disabling Debug Port for X86<br \/>\n<\/strong><\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify;\"><span style=\"font-size: 9pt;\">For X86 Bsps, the usage of debug ports is determined in OEMInitDebugSerial function which is located in \u201c<em>\\<\/em><\/span><em>%_WIN_DIR%<span style=\"font-size: 9pt;\">\\PUBLIC\\COMMON\\OAK\\CSP\\X86\\OAL\\debug.c<\/span><\/em><span style=\"font-size: 9pt;\">\u201d file. In some BSPs, this function might have been implemented inside the BSP itself. Add the following line in <em>OEMInitDebugSerial<\/em> function as follows:<\/span><\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify; text-indent: 0.5in;\"><em><span style=\"font-family: 'Courier New';\">pBootArgs-&gt;ucComPort = 0; <\/span><\/em><\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify;\"><em><span style=\"font-family: 'Courier New';\">void OEMInitDebugSerial(void)<\/span><\/em><\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify;\"><em><span style=\"font-family: 'Courier New';\">{<\/span><\/em><\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify; text-indent: 0.5in;\"><em><span style=\"font-family: 'Courier New';\">pBootArgs = (BOOT_ARGS *) ((ULONG)(*(PBYTE *)BOOT_ARG_PTR_LOCATION) | 0x80000000);<\/span><\/em><\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify; text-indent: 0.5in;\"><em><span style=\"font-family: 'Courier New';\">if ( ! pBootArgs-&gt;ucBaudDivisor ) <\/span><\/em><\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify; text-indent: 0.5in;\"><em><span style=\"font-family: 'Courier New';\">{<\/span><\/em><\/p>\n<p class=\"MsoNormal\" style=\"margin-left: 0.5in; text-align: justify; text-indent: 0.5in;\"><em><span style=\"font-family: 'Courier New';\">pBootArgs-&gt;ucBaudDivisor = 6; \/\/ Default to 19.2 if nothing specified.<\/span><\/em><\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify; text-indent: 0.5in;\"><em><span style=\"font-family: 'Courier New';\">}<\/span><\/em><\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify; text-indent: 0.5in;\"><em><span style=\"font-family: 'Courier New';\">pBootArgs-&gt;ucComPort = 0; \/\/&#8211; add this line<\/span><\/em><\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify; text-indent: 0.5in;\"><em><span style=\"font-family: 'Courier New';\">switch ( pBootArgs-&gt;ucComPort ) <\/span><\/em><\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify; text-indent: 0.5in;\"><em><span style=\"font-family: 'Courier New';\">{<\/span><\/em><\/p>\n<p class=\"MsoNormal\" style=\"margin-left: 0.5in; text-align: justify; text-indent: 0.5in;\"><em><span style=\"font-family: 'Courier New';\">case 1:<\/span><\/em><\/p>\n<p class=\"MsoNormal\" style=\"margin-left: 1in; text-align: justify; text-indent: 0.5in;\"><em><span style=\"font-family: 'Courier New';\">IoPortBase = (PUCHAR)COM1_BASE;<\/span><\/em><\/p>\n<p class=\"MsoNormal\" style=\"margin-left: 1in; text-indent: 0.5in; text-align: justify;\"><em><span style=\"font-family: 'Courier New';\">break;<\/span><\/em><\/p>\n<p class=\"MsoNormal\" style=\"margin-left: 0.5in; text-indent: 0.5in; text-align: justify;\"><em><span style=\"font-family: 'Courier New';\">\u2026\u2026\u2026\u2026.<\/span><\/em><\/p>\n<p class=\"MsoNormal\" style=\"text-indent: 0.5in; text-align: justify;\"><em><span style=\"font-family: 'Courier New';\">}<\/span><\/em><\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify;\"><em><span style=\"font-family: 'Courier New';\">}<\/span><\/em><\/p>\n<p class=\"MsoNormal\" style=\"text-align: justify;\">Now the debug port can be used as a COM port in kernel by modifying the serial driver and adding appropriate registry settings.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Developers may need one port for debugging in the development phase. But while in production&#8230;<\/p>\n","protected":false},"author":15,"featured_media":1258,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[190],"tags":[14,49,132],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.e-consystems.com\/blog\/windowsce\/wp-json\/wp\/v2\/posts\/60"}],"collection":[{"href":"https:\/\/www.e-consystems.com\/blog\/windowsce\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.e-consystems.com\/blog\/windowsce\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.e-consystems.com\/blog\/windowsce\/wp-json\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/www.e-consystems.com\/blog\/windowsce\/wp-json\/wp\/v2\/comments?post=60"}],"version-history":[{"count":5,"href":"https:\/\/www.e-consystems.com\/blog\/windowsce\/wp-json\/wp\/v2\/posts\/60\/revisions"}],"predecessor-version":[{"id":1922,"href":"https:\/\/www.e-consystems.com\/blog\/windowsce\/wp-json\/wp\/v2\/posts\/60\/revisions\/1922"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.e-consystems.com\/blog\/windowsce\/wp-json\/wp\/v2\/media\/1258"}],"wp:attachment":[{"href":"https:\/\/www.e-consystems.com\/blog\/windowsce\/wp-json\/wp\/v2\/media?parent=60"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.e-consystems.com\/blog\/windowsce\/wp-json\/wp\/v2\/categories?post=60"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.e-consystems.com\/blog\/windowsce\/wp-json\/wp\/v2\/tags?post=60"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}