Why the bootloader will crash, when I use i2c read/write operation in uefi on Qualcomm qcs platform?

246 Views Asked by At

I'm able to control gpio in uefi right now, so there's no problem that I can control physical layer. Meanwhile, It succeed to open I2C_instance via. qualcomm I2cApiLib. But when I use I2C_read/write in my code, the bootloader will crash when boot-up.

Crash log are as follow:

enter image description here

Sample Code:

EFI_STATUS
EFIAPI
BootLEDMain(IN EFI_HANDLE ImageHandle,
        IN EFI_SYSTEM_TABLE *SystemTable)
{
  DEBUG((EFI_D_ERROR, "------BootLED APPLICATION TEST------\n"));

  i2c_status istatus = I2C_SUCCESS;

  VOID      *i2c_handle      = NULL;
  UINT32    bytes_read       = 0;
  uint8     readbuf          = 0;
  //UINT32    bytes_written    = 0;
  //uint8     writebuf         = 0x01;

  i2c_config cfg;
  cfg.bus_frequency_khz = 400;
  cfg.slave_address = 0x77;
  cfg.slave_address_type = I2C_07_BIT_SLAVE_ADDRESS;

  istatus = i2c_open((i2c_instance) (I2C_INSTANCE_003), &i2c_handle);
  if (I2C_SUCCESS != istatus)
  {
    DEBUG((EFI_D_ERROR, "Failed to initialize I2C %d\n", istatus));
    goto error;
  }
  else
  {
    DEBUG((EFI_D_ERROR, "Succeed to open I2C\n"));
  }

  istatus = i2c_read (i2c_handle, &cfg, 0x45, 1, &readbuf, 1, &bytes_read, 2500);
  if (I2C_SUCCESS != istatus)
  {
    DEBUG((EFI_D_ERROR, "Read Failed %d\n", (uint32) istatus));
    goto error;
  }
  else
  {
    DEBUG((EFI_D_ERROR, "Succeed to Read\n"));
  }
      .
      .
      .

Could you guys who has a little bit knowledge of qualcomm uefi explain the reason why, Thanks. Comment what details you guys need or want to know.

1

There are 1 best solutions below

0
On

From your crash log, the Exception Syndrome Register (ESR) says that you are taking a 'Translation fault, level 3' from an instruction trying to write to a location.

The Fault Address Register (FAR) says that the faulting address is 0x078b700c.

I have no idea what codebase you are working on, but presumably you will have to make sure MMU mappings are created for the i2c controller.