This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SK-AM62: SK-AM62 Android NDK GPIO read.

Part Number: SK-AM62

Dear TI Team,

I am currently working with SK-AM62 and running Android on it. I am seeking information on how to use GPIO (General Purpose Input/Output) and I2C (Inter-Integrated Circuit) functionality with the Android NDK (Native Development Kit) and the associated drivers for the board.

Specifically, I would appreciate it if you could provide me with guidance on the following:

  1. Steps or documentation for integrating GPIO and I2C drivers into an Android NDK project.
  2. Any header files or libraries required for accessing GPIO and I2C from native C/C++ code.
  3. Instructions on how to compile the necessary drivers for the Android NDK.
  4. Examples or sample code demonstrating the usage of GPIO and I2C in an Android NDK project.
  5. If drivers are not available, please let me know another way to read gpio and i2c in android.
  6. Recommendations on alternative methods or interfaces that could be utilized to interact with GPIO and I2C pins on AM62 in an Android application.

I look forward to your prompt response and thank you in advance for your help.

  • Hi Athul,

    It really depends which underlying hardware you interact with. Some examples:
    - an accelerometer sensor would be implemented as an iio device and android would expose that sensor via the sensor HAL.
    - an audio codec would be exposed as an alsa device and the audio HAL would control it

    Using "raw" access (via i2c or GPIO) via userspace is not really recommended. The linux kernel has abstractions for most device types.

    For debugging purposes (for example board bringup) it is possible though.

    For i2c, the following commands are available in the am62x image: i2cdetect i2cdump i2cget i2cset

    For gpio, you can use gpiolib. They are not provided by default in build, but here is a small guide to add it:
    From your Android build folder, run:

    cd external
    mkdir libgpiod
    git clone https://github.com/technexion-android/platform_external_libgpiod.git libgpiod


    Then, in device/ti/am62x/device.mk, add: 
    PRODUCT_PACKAGES += gpioinfo gpioget gpioset


    To answer more specifically each question:

    1. This should be done in a standard linux way. See the official kernel documentation https://www.kernel.org/doc/html/latest/ 

    2. Again, it is recommended to go through the various Android HALs to access each specific hardware

    3 and 4. See response to 2)

    5. See response about i2cget and gpiolib

    6. Recommendations are to use standard android abstractions and then have your app use the android SDK to change things. See https://source.android.com/docs/core/architecture 

    Hope that helps.