Export (0) Print
Expand All

Setting Up Kernel-Mode Debugging over a Serial Cable Manually

Debugging Tools for Windows supports kernel debugging over a null-modem cable. Null-modem cables are serial cables that have been configured to send data between two serial ports. They are available at most computer stores. Do not confuse null-modem cables with standard serial cables. Standard serial cables do not connect serial ports to each other. For information about how null-modem cables are wired, see Null-Modem Cable Wiring.

This topic describes how to set up serial debugging manually. As an alternative to setting up serial debugging manually, you can do the setup using Microsoft Visual Studio. For more information, see Setting Up Kernel-Mode Debugging over a Serial Cable in Visual Studio.

The computer that runs the debugger is called the host computer, and the computer being debugged is called the target computer.

Setting Up the Target Computer

  1. On the target computer, open a Command Prompt window as Administrator, and enter the following commands, where n is the number of the COM port used for debugging on the target computer, and rate is the baud rate used for debugging:

    bcdedit /debug on
    bcdedit /dbgsettings serial debugport:n baudrate:rate

    Note  The baud rate must be the same on the host computer and target computer. The recommended rate is 115200.

  2. Reboot the target computer.

Starting the Debugging Session

Connect the null-modem cable to the COM ports that you have chosen for debugging on the host and target computers.

Using WinDbg

On the host computer, open WinDbg. On the File menu, choose Kernel Debug. In the Kernel Debugging dialog box, open the COM tab. In the Baud rate box, enter the rate you have chosen for debugging. In the Port box, enter COMn where n is the COM port number you have chosen for debugging on the host computer. Click OK.

You can also start a session with WinDbg by entering the following command in a Command Prompt window; n is the number of the COM port used for debugging on the host computer, and rate is the baud rate used for debugging:

windbg -k com:port=COMn,baud=rate

Using KD

On the host computer, open a Command Prompt window, and enter the following command, where n is the number of the COM port used for debugging on the host computer, and rate is the baud rate used for debugging:

kd -k com:port=COMn,baud=rate

Using Environment Variables

On the host computer, you can use environment variables to specify the COM port and the baud rate. Then you do not have to specify the port and baud rate each time you start a debugging session. To use environment variables to specify the COM port and baud rate, open a Command Prompt window and enter the following commands, where n is the number of the COM port used for debugging on the host computer, and rate is the baud rate used for debugging:

  • set _NT_DEBUG_PORT=COMn
  • set _NT_DEBUG_BAUD_RATE=rate

To start a debugging session, open a Command Prompt window, and enter one of the following commands:

  • kd
  • windbg

Troubleshooting Tips for Debugging over a Serial Cable

Specify correct COM port on both host and target

Determine the numbers of the COM ports you are using for debugging on the host and target computers. For example, suppose you have your null-modem cable connected to COM1 on the host computer and COM2 on the target computer.

On the target computer, open a Command Prompt window as Administrator, and enter bcdedit /dbgsettings. If you are using COM2 on the target computer, the output of bcdedit should show debugport 2.

On the host computer, specify the correct COM port when you start the debugger or when you set environment variables. If you are using COM1 on the host computer, use one of the following methods to specify the COM port.

  • In WinDbg, in the Kernel Debugging dialog box, enter COM1 in the Port box.
  • windbg -k com:port=COM1, ...
  • kd -k com:port=COM1, ...
  • set _NT_DEBUG_PORT=COM1

Baud rate must be the same on host and target

The baud rate used for debugging over a serial cable must be set to the same value on the host and target computers. For example, suppose you have chosen a baud rate of 115200.

On the target computer, open a Command Prompt window as Administrator, and enter bcdedit /dbgsettings. The output of bcdedit should show baudrate 115200.

On the host computer, specify the correct baud rate when you start the debugger or when you set environment variables. Use one of the following methods to specify a baud rate of 115200.

  • In WinDbg, in the Kernel Debugging dialog box, enter 115200 in the Baud rate box.
  • windbg -k ..., baud=115200
  • kd -k ..., baud=115200
  • set _NT_DEBUG_BAUD_RATE=115200

Null Modem Cable Wiring

The following tables show how null-modem cables are wired.

9-pin connector

Connector 1Connector 2Signals
23Tx - Rx
32Rx - Tx
78RTS - CTS
87CTS - RTS
41+6DTR - (CD+DSR)
1+64(CD+DSR) - DTR
55Signal ground

 

25-pin connector

Connector 1Connector 2Signals
23Tx - Rx
32Rx - Tx
45RTS - CTS
54CTS - RTS
620DSR - DTR
206DTR - DSR
77Signal ground

 

Signal Abbreviations

AbbreviationSignal
TxTransmit data
RxReceive data
RTSRequest to send
CTSClear to send
DTRData terminal ready
DSRData set ready
CDCarrier detect

 

Additional Information

For complete documentation of the bcdedit command, see Boot Options for Driver Testing and Debugging in the Windows Driver Kit (WDK) documentation.

Related topics

Setting Up Kernel-Mode Debugging Manually

 

 

Send comments about this topic to Microsoft

Show:
© 2014 Microsoft