0

I've created a nonvolatile UEFI variable via Linux efivarfs interface. I can get the value of the variable with efivar command line. But when I try to get the value of that variable during boot phase via EDK2 GetVariable2() I got "Not Found" error.

Here is the .dec file and C++ snippet:

[Guids]
  gEfiMyTestGuid            = {0x11c564cd, 0xb9f2, 0x4eb8, {0x94, 0x62, 0xe0, 0xba, 0x74, 0x56, 0x42, 0x36}}
  extern EFI_GUID   gEfiMyTestGuid;

  ....
  ....

  VOID       *Data;
  UINTN      DataSize;
  EFI_STATUS Status;

  
  Status = GetVariable2 (L"test", &gEfiMyTestGuid, &Data,
             &DataSize);
  if (EFI_ERROR (Status)) {
    Print (L"Failure error: %r\n", Status);
    return Status;
  }
Ali Shirvani
  • 533
  • 6
  • 15
  • 1
    Have you set the EFI_VARIABLE_BOOTSERVICE_ACCESS attribute? – MiSimon Jul 31 '21 at 20:02
  • @MiSimon Thanks for your comment, yes I've set that attribute. According to the efivars output the variable has "Non-Volatile", "Boot Service Access" and "Runtime Service Access" attributes. – Ali Shirvani Aug 01 '21 at 02:29
  • 1
    Can you post the efivar command that you are using? – MiSimon Aug 01 '21 at 06:58
  • Thanks @MiSimon, I found the problem, there is a typo in GUIDs. Here is the command that I used: efivars -p -n 11c564cdb9f24eb89462e0ba74564236-test. Thanks – Ali Shirvani Aug 01 '21 at 07:22
  • 1
    Note that `GetVariable2` is not part of the UEFI specification and therefore there is no guarantee that a particular firmware implementation will implement it. `GetVariable2` is essentially a wrapper around `GetVariable`, which is part of the specification, that handles the buffer allocation as needed for the variable. – fpmurphy Aug 03 '21 at 05:36

0 Answers0