|
| 1 | +# Setup Windbg KdCom |
| 2 | +::: tip Tips |
| 3 | +Sugguest using KdNet for better experience if you can not access your device's uart pins easily. |
| 4 | +KdCom does not support rdp over it. |
| 5 | +::: |
| 6 | + |
| 7 | +## Preparation |
| 8 | + - A dev board, or any device with uart test points |
| 9 | + - An UART->USB bridge, or on board bridge.(Notice: Qualcomm use 1.8V as VDDIO) |
| 10 | + - Debugging slave installed windows |
| 11 | + - Debugging host installed [Windbg Preview](https://apps.microsoft.com/detail/9pgjgd53tn86) |
| 12 | + |
| 13 | +## Setup BCD |
| 14 | + - Mount ESP Partition on you phone with root permission in adb shell or termux. |
| 15 | + + Simply jump this step if you are using USB mass storage mode. |
| 16 | + ```bash |
| 17 | + # Execute on phone |
| 18 | + mkdir /dev/esp_mnt |
| 19 | + mount /dev/block/by-name/esp /dev/esp_mnt |
| 20 | + ``` |
| 21 | + - Copy BCD to your host computer. |
| 22 | + + If you are using UMS, find the BCD file and copy it to D: or anywhere you want in explorer. |
| 23 | + + Copy to /sdcard |
| 24 | + ```bash |
| 25 | + # Execute on phone |
| 26 | + cp /dev/esp_mnt/EFI/Microsoft/Boot/BCD /sdcard |
| 27 | + ``` |
| 28 | + + Pull to computer. |
| 29 | + ```powershell |
| 30 | + # Execute on computer, assuming installed adb. |
| 31 | + # Assuming copy to D:, you can set any path you want. |
| 32 | + adb pull /sdcard/BCD D:\ |
| 33 | + ``` |
| 34 | + - Open an **administrator** terminal and set bcd configurations. |
| 35 | + ```powershell |
| 36 | + cd D:\ |
| 37 | + bcdedit /store BCD /set "{default}" testsigning on |
| 38 | + bcdedit /store BCD /set "{default}" nointegritychecks on |
| 39 | + bcdedit /store BCD /set "{default}" debug on |
| 40 | + bcdedit /store BCD /dbgsettings serial baudrate:115200 debugport:1 |
| 41 | + ``` |
| 42 | + - Push BCD back to your phone. |
| 43 | + + If you are using UMS, simply replace the original BCD file. |
| 44 | + ```powershell |
| 45 | + # Execute on computer |
| 46 | + adb push BCD /sdcard |
| 47 | + # Delete BCD after pushing |
| 48 | + del D:\BCD |
| 49 | + ``` |
| 50 | + ```bash |
| 51 | + # Execute on phone |
| 52 | + # Backup nomal BCD |
| 53 | + cp /dev/esp_mnt/EFI/Microsoft/Boot/BCD /dev/esp_mnt/EFI/Microsoft/Boot/NMBCD |
| 54 | + # Backup kdnet enabled BCD |
| 55 | + cp /sdcard/BCD /dev/esp_mnt/EFI/Microsoft/Boot/DBGBCD |
| 56 | + # Replace active BCD |
| 57 | + cp /sdcard/BCD /dev/esp_mnt/EFI/Microsoft/Boot/BCD |
| 58 | + ``` |
| 59 | + |
| 60 | +## Setup KdCom in Windbg |
| 61 | + - Open device manager on your computer. |
| 62 | + - Connect UART->USB bridge to computer, and check the `COMXX` Number under `Serial` section in device manager |
| 63 | + - Open Windbg Preview, Click **File** button on the top left corner. |
| 64 | + - Click `Attach to kernel` under `Start debugging`(default section). |
| 65 | + - Choose `COM` section |
| 66 | + + Fill `Baud Rate` with `115200` |
| 67 | + + Fill `Port` with `COMXX`, which you saw in device manager |
| 68 | + + Others keep default |
| 69 | + - Click `OK` button and windbg will start waiting for connection. |
| 70 | + |
| 71 | + |
| 72 | +## Connect KdCom |
| 73 | + - Ensuing DBG2 configuration is correct(No need worry because the address in dbg2 was fixed generally here). |
| 74 | + - Reboot your phone, and connect it to computer with a usb cable. |
| 75 | + ```powershell |
| 76 | + # Execute on computer, boot uefi |
| 77 | + fastboot boot uefi.img |
| 78 | + ``` |
| 79 | + - Phone booting windows and hang up for several seconds, you can see windbg print logs if successfully connected. |
| 80 | + |
| 81 | +::: tip Notice |
| 82 | + - You can close Windbg and open a serial tool like PuTTY or SecureCRT to check if the phone printed some unrecognized messages while windows booting. If it isn't that means BCD configurations were wrong |
| 83 | +::: |
0 commit comments