jgsun's blog Embedded Linux Software

EDK2 DebbugLib PrintLevel 配置实例


Overview

By default, three printlevel of DEBUG function in edk2\QcomModulePkg\Library\avb\VerifiedBoot.c get printed, they are EFI_D_WARN, DEBUG_INFO and EFI_D_ERROR, this picece of paper will tell us how to let EFI_D_VERBOSE get printed too at startup.

  AVBVersion = GetAVBVersion ();
  DEBUG ((EFI_D_VERBOSE, "[EFI_D_VERBOSE]:AVB version %d\n", AVBVersion));

image

about EDK2 https://www.tianocore.org/

The EFI_D_VERBOSE Macro define

bootable\bootloader\edk2\MdePkg\Include\Library\DebugLib.h

#define DEBUG_WARN      0x00000002  // Warnings
#define DEBUG_INFO      0x00000040  // Informational debug messages
#define DEBUG_VERBOSE   0x00400000  // Detailed debug messages that may significantly impact boot performance
#define DEBUG_ERROR     0x80000000  // Error

#define EFI_D_WARN      DEBUG_WARN
#define EFI_D_INFO      DEBUG_INFO
#define EFI_D_VERBOSE   DEBUG_VERBOSE
#define EFI_D_ERROR     DEBUG_ERROR

Change PcdDebugPrintErrorLevel from QcomModulePkg/QcomModulePkg.dsc

Set the corresponding bit of DEBUG_VERBOSE in PcdDebugPrintErrorLevel, it’s 0x00400000.

jgsun@jgsun-machine:edk2$ git diff
diff --git a/QcomModulePkg/Library/avb/VerifiedBoot.c b/QcomModulePkg/Library/avb/VerifiedBoot.c
index b90c5fbfe..aa64aeddb 100644
--- a/QcomModulePkg/Library/avb/VerifiedBoot.c
+++ b/QcomModulePkg/Library/avb/VerifiedBoot.c
@@ -1465,7 +1465,8 @@ LoadImageAndAuth (BootInfo *Info, BOOLEAN HibernationResume)
   }
 
   AVBVersion = GetAVBVersion ();
-  DEBUG ((EFI_D_VERBOSE, "AVB version %d\n", AVBVersion));
+  DEBUG ((EFI_D_VERBOSE, "[EFI_D_VERBOSE]:AVB version %d\n", AVBVersion));
+  DEBUG ((EFI_D_INFO, "[EFI_D_INFO]:AVB version %d\n", AVBVersion));
 
   /* Load and Authenticate */
   switch (AVBVersion) {
diff --git a/QcomModulePkg/QcomModulePkg.dsc b/QcomModulePkg/QcomModulePkg.dsc
index 934d1f248..76e9492c7 100644
--- a/QcomModulePkg/QcomModulePkg.dsc
+++ b/QcomModulePkg/QcomModulePkg.dsc
@@ -209,7 +209,7 @@
   !elseif $(USER_BUILD_VARIANT) == 0
        gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2f
   !endif
-  gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80000042
+  gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80400042
   gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x06
   gQcomTokenSpaceGuid.EnableDisplayMenu|$(ENABLE_DISPLAY_MENU)

build and flash abl image

jgsun@jgsun-machine:build$ bitbake edk2 -c cleansstate
jgsun@jgsun-machine:build$ bitbake edk2
jgsun@jgsun-machine:image$ fastboot devices -l
b9ea5d92               fastboot usb:1-2
jgsun@jgsun-machine:image$ fastboot flash abl abl.elf
jgsun@jgsun-machine:image$ fastboot reboot

Check the boot log

Here, we can see the EFI_D_VERBOSE gets printed.

230 Booting from slot (_a)
 231 Booting Into Mission Mode
 232 MultiSlot true, partition name boot_a
 233 [EFI_D_VERBOSE]:AVB version 0
 234 [EFI_D_INFO]:AVB version 0
 235 Loading Image Start : 1134 ms
 236 Loading Image Done : 1134 ms
 237 Total Image Read size : 4096 Bytes

Reference


下一篇 tmux

Comments

Content