Writing to I2C through UEFI application

Discussion in 'General Discussion' started by Ruvim P, Jul 27, 2022.

Tags:
  1. Ruvim P

    Ruvim P UDOOer

    Joined:
    Jul 27, 2022
    Messages:
    3
    Likes Received:
    1
    I am writing a program to talk to a device in the UEFI shell through Edk2. I've successfully been able to write and read to the bus through EFI_I2C_MASTER_PROTOCOL but for whatever reason at the end of every write it sends an extra byte of 0. I am wondering if it has to do with SmBus appending a byte for PEC but regardless is there any way to write without that extra byte?

    Thank you for your time, have a great day!
     
  2. gordontcp

    gordontcp UDOOer

    Joined:
    Aug 15, 2022
    Messages:
    1
    Likes Received:
    0
    Hi, how can you write and read to the bus through EFI_I2C_MASTER_PROTOCOL ? Is there any sample code? Does it need to set acpi table?
     
  3. Ruvim P

    Ruvim P UDOOer

    Joined:
    Jul 27, 2022
    Messages:
    3
    Likes Received:
    1
    I didn't have to set the acpi table. I was able to just call LocateHandleBuffer and OpenProtocol on the Udoo x86. Then I would use the StartRequest api with the parameters I prefer.

    i2c_master_protocol->StartRequest
     
  4. hEdnaBallantyne

    hEdnaBallantyne New Member

    Joined:
    Nov 8, 2022
    Messages:
    1
    Likes Received:
    0
    How can i write?
     
  5. Ruvim P

    Ruvim P UDOOer

    Joined:
    Jul 27, 2022
    Messages:
    3
    Likes Received:
    1
    You can write a UEFI application by using Edk2 on another platform and copying the binary executable to a thumb drive and execute it from the UEFI shell.

    To create the executable, you'll need to call open LocateHandleBuffer using the I2C master guid provided in Edk2. Then you'll want to go through the handle buffer and using the I2CMaster driver to send data by configuring
    i2c_master_protocol->StartRequest with the parameters found in the UEFI spec on UEFI.org.

    If you don't know how to get started on writing UEFI applications, I recommend going through the tianocore tutorial found on the tianocore GitHub.
     
    hEdnaBallantyne likes this.

Share This Page