# OpenCore Debug

{% hint style="info" %}
Dùng để gỡ lỗi khi boot OpenCore
{% endhint %}

## Chuyển đổi file

Tải bản opencore debug [tại đây](https://github.com/acidanthera/OpenCorePkg/releases)

<figure><img src="/files/2DmQ5dmssOofMZcDPSsQ" alt=""><figcaption></figcaption></figure>

B1: Chúng ta sẽ cần thay đổi những file sau ở `EFI` hiện tại của bạn và `EFI Debug`

* EFI/BOOT/
  * `BOOTx64.efi`
* EFI/OC/Drivers/
  * `OpenRuntime.efi`
  * `OpenCanopy.efi`(if you're using it)
* EFI/OC/
  * `OpenCore.efi`

<figure><img src="/files/nAc0Om284Vuj9kjHBEyZ" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Tốt nhất là không dùng OpenCanopy. Nếu như bắt buộc thì hãy đảm bảo tất cả driver cần thiết đều dùng của OpenCore Debug
{% endhint %}

## Config Changes <a href="#config-changes" id="config-changes"></a>

{% hint style="info" %}
Tiếp theo bây giờ các bạn mở config lên và đi đến mục `Misc > Debug`

{% endhint %}

### Misc > Debug <a href="#misc-debug" id="misc-debug"></a>

* **AppleDebug**: YES
  * cung cấp nhiều thông tin sửa lỗi hơn đặc biệt là khi boot trong quá trình cài đặt
* **ApplePanic**: YES
  * Điều này sẽ cho phép kernel panic được lưu vào log sử dụng nó kèm với `keepsyms=1` trong boot-arg.
* **DisableWatchdog**: YES
  * Disable UEFI watchdog, dùng khi opencore bị đứng do một số thứ không quan trọng.
* **Target**: `67`&#x20;
  * dùng để thiết lập các mode của target để dump lỗi&#x20;

| Value  | Comment                                     |
| ------ | ------------------------------------------- |
| `0x01` | Enable log                                  |
| `0x02` | Cho phép hiện lỗi trên màn hình             |
| `0x04` | Enable log cho Data Hub.                    |
| `0x08` | Enable log cho serial port (port connector) |
| `0x10` | Enable log biến UEFI                        |
| `0x20` | Enable log biến non-volatile UEFI           |
| `0x40` | Cho phép xuất log thành file                |

{% hint style="info" %}
Để tính toán giá trị target ta sẽ cộng các giá trị mà bạn cần thiết lại sau đó convert nó  từ hex ra decimal ví dụ ở dưới đây
{% endhint %}

* `0x01` — Enable Log
* `0x02` — Cho phép hiện lỗi trên màn hình
  * Nhớ rằng điều này sẽ làm tăng thời gian khởi động
* `0x40` — Cho phép xuất log thành file

`0x01` + `0x02` + `0x40` = `0x43`

`0x43` Chuyển nó thành decimal tại trang sau [đây](https://www.rapidtables.com/convert/number/hex-to-decimal.html) `67`

Chúng ta sẽ set Config theo mục sau `Misc` -> `Debug` -> `Target` -> `67`

* **DisplayLevel**: `2147483714`&#x20;
  * Used for setting what is logged

| Value        | Comment                                                        |
| ------------ | -------------------------------------------------------------- |
| `0x00000002` | DEBUG\_WARN trong các version OpenCore DEBUG, NOOPT, RELEASE.  |
| `0x00000040` | DEBUG\_INFO trong các version OpenCore DEBUG, NOOPT.           |
| `0x00400000` | DEBUG\_VERBOSE trong các version OpenCore custom builds.       |
| `0x80000000` | DEBUG\_ERROR trong các version OpenCore DEBUG, NOOPT, RELEASE. |

Bạn có thể tham khảo tại đây full list các option [DebugLib.h](https://github.com/tianocore/edk2/blob/UDK2018/MdePkg/Include/Library/DebugLib.h)

Sau đây là một option mà chúng tôi đề xuất cho bạn

* `0x00000002` — DEBUG\_WARN trong các version OpenCore DEBUG, NOOPT, RELEASE.
* `0x00000040` — DEBUG\_INFO trong các version OpenCore DEBUG, NOOPT.
* `0x80000000` — DEBUG\_ERROR trong các version OpenCore DEBUG, NOOPT, RELEASE.

Giống như  `Target`, chúng ta sẽ cộng các hex lại sau đó convert nó thành decimal:

`0x80000042` Convert thành decimal tại trang sau [đây ](https://www.rapidtables.com/convert/number/hex-to-decimal.html)`2147483714`

`Misc` -> `Debug` -> `DisplayLevel` -> `2147483714`

> Source tham khảo: <https://dortania.github.io/OpenCore-Install-Guide/troubleshooting/debug.html>&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://advance.heavietnam.com/general/opencore-debug.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
