Windows CE Blog |

Mar/09

24

Disabling Debug Port in kernel mode

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 PXA270 Computer on Module 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.

Disabling Debug Port for ARM

For the ARM BSPs, the implementation of following three functions determines the usage of debug ports.

OEMDebugInit
OEMDebugWriteByte
OEMDebugReaByte

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.

Disabling Debug Port for X86

For X86 Bsps, the usage of debug ports is determined in OEMInitDebugSerial function which is located in “\%_WIN_DIR%\PUBLIC\COMMON\OAK\CSP\X86\OAL\debug.c” file. In some BSPs, this function might have been implemented inside the BSP itself. Add the following line in OEMInitDebugSerial function as follows:

pBootArgs->ucComPort = 0;

void OEMInitDebugSerial(void)

{

pBootArgs = (BOOT_ARGS *) ((ULONG)(*(PBYTE *)BOOT_ARG_PTR_LOCATION) | 0×80000000);

if ( ! pBootArgs->ucBaudDivisor )

{

pBootArgs->ucBaudDivisor = 6; // Default to 19.2 if nothing specified.

}

pBootArgs->ucComPort = 0; //– add this line

switch ( pBootArgs->ucComPort )

{

case 1:

IoPortBase = (PUCHAR)COM1_BASE;

break;

………….

}

}

Now the debug port can be used as a COM port in kernel by modifying the serial driver and adding appropriate registry settings.

· ·

5 comments

  • John · March 30, 2009 at 4:20 pm

    Is it possible to have the debug port enabled/disabled in the application level ?

    Reply

    • Suresh Madhu · March 30, 2009 at 6:42 pm

      No, only the bootloader can use it as debug port.
      As I had already mentioned in the blog, we cannot change it dynamically

      Reply

  • John · March 31, 2009 at 11:10 am

    It would be good to have the debug port especially for field testing, At the same time that can also be disabled through an application and used as serial port for connecting external device such as RFID reader etc. Is it not possible to disable through IOCTL ?

    Reply

    • Suresh Madhu · April 1, 2009 at 10:27 am

      Yes. That can be done by calling kernelIoControl from the application. For that the corresponding IOCTLs must be implemented in the OEMIOControl function. And also the loading and unloading of serial driver must be taken care in that.

      Reply

  • [project]Port android to meizu M8 - Page 15 - Meizu Me · September 30, 2009 at 12:37 pm

    [...] just wanted to share this Disabling Debug Port in kernel mode 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 COM 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. Disabling Debug Port for ARM For the ARM BSPs, the implementation of following three functions determines the usage of debug ports. OEMDebugInit OEMDebugWriteByte OEMDebugReaByte 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. Could be interesting to know that someone with enough knowledge could use the debug for lets say… external storage,external keyboard,.. or other application driven tools. The last thing could be more interesting to us. if we could kill debug and use it to write away the original flash/nand/drives… we could easier try to mod the eboot? [...]

    Reply

Leave a Reply

<<

>>

Theme Design by devolux.nh2.me