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.

TDA4VE-Q1: Block in turnning on USER_LED1 of GPIO Expander2 in mcu2_0 firmware

Part Number: TDA4VE-Q1


Tool/software:

Hi TI experts,

I use TDA4VE EVM (J721S2 SOM + CPB) which is running in Linux + RTOS mode with SDK version r85.

My purpose is to turn on USER_LED1, which is connected to GPIO Expeader2 Port2:PIN6 (P26) when display port 0 (DP0_PWR_SW_EN) is turned on.

I add below code in vision_apps/utils/dss/src/app_dss_soc.c

void appDssConfigureDP(void)
{
    Board_STATUS b_status;
    Board_IoExpCfg_t ioExpCfg;

    appLogPrintf("DSS: Turning on DP_PWR pin for eDP adapters ... !!!\n");

    #if defined (SOC_J721E)
    ioExpCfg.i2cInst     = 1U;
    #elif defined (SOC_J721S2) || defined (SOC_J784S4)
    ioExpCfg.i2cInst     = 4U;
    #endif
    ioExpCfg.socDomain   = BOARD_SOC_DOMAIN_MAIN;
    ioExpCfg.slaveAddr   = 0x20;
    ioExpCfg.enableIntr  = false;
    ioExpCfg.ioExpType   = ONE_PORT_IOEXP;
    ioExpCfg.portNum     = PORTNUM_0;
    ioExpCfg.pinNum      = PIN_NUM_0;
    ioExpCfg.signalLevel = GPIO_SIGNAL_LEVEL_HIGH;

    b_status = Board_control(BOARD_CTRL_CMD_SET_IO_EXP_PIN_OUT, (void *)(&ioExpCfg));

    #if defined (SOC_J721S2) || defined (SOC_J784S4)
    appLogWaitMsecs(500u);
    #endif

+   #if defined (SOC_J721S2)
+   appLogPrintf("DSS: Turning on USER_LED1 ... !!!\n");
+   ioExpCfg.i2cInst     = 0U;   // BOARD_I2C_IOEXP_DEVICE2_INSTANCE
+   ioExpCfg.socDomain   = BOARD_SOC_DOMAIN_MAIN;
+   ioExpCfg.slaveAddr   = 0x22U;   // BOARD_I2C_IOEXP_DEVICE2_ADDR
+   ioExpCfg.enableIntr  = false;
+   ioExpCfg.ioExpType   = THREE_PORT_IOEXP;
+   ioExpCfg.portNum     = PORTNUM_2;
+   ioExpCfg.pinNum      = PIN_NUM_6;
+   ioExpCfg.signalLevel = GPIO_SIGNAL_LEVEL_HIGH;
+   b_status = Board_control(BOARD_CTRL_CMD_SET_IO_EXP_PIN_OUT, (void *)(&ioExpCfg));
+   appLogWaitMsecs(500u);
+   #endif

    if (b_status == BOARD_SOK)
    {
        appLogPrintf("DSS: Turning on DP_PWR pin for eDP adapters ... Done!!!\n");
    }
...

But I found that the MCU2 firmware gets stuck in Board_control() when controlling GPIO Expander2..

I have noticed that some of the pins of GPIO Expander2, such as GPIO_uSD_PWR_EN, are controlled by A72 Linux.

I am wondering if it is possible to control GPIO Expander2 pins in the MCU2 RTOS firmware as well? and how?

Please advise, thank you.

Regards,

Christopher

  • Hi,

    I also added the following code in vision_apps/utils/misc/src/app_pinmux_j721s2.c and updated vx_app_rtos_linux_mcu2_0.out.

    However, it still doesn't work and gets stuck in Board_control() when controlling GPIO Expander2

    ...
    
    static pinmuxPerCfg_t gI2c0PinCfg[] =
    {
        /* MyI2C0 -> I2C0_SCL -> AH25 */
        {
            PIN_I2C0_SCL, PIN_MODE(0) | \
            ((PIN_PULL_DISABLE | PIN_INPUT_ENABLE) & (~PIN_PULL_DIRECTION))
        },
        /* MyI2C0 -> I2C0_SDA -> AE24 */
        {
            PIN_I2C0_SDA, PIN_MODE(0) | \
            ((PIN_PULL_DISABLE | PIN_INPUT_ENABLE) & (~PIN_PULL_DIRECTION))
        },
        {PINMUX_END}
    };
    
    static pinmuxModuleCfg_t gDispPinCfg[] =
    {
        {0, TRUE, gI2c4PinCfg},
        {1, TRUE, gI2c0PinCfg},
        {PINMUX_END}
    };
    
    ...
    
    void appSetPinmux(app_pinmux_cfg_t *cfg)
    {
        if (NULL != cfg)
        {
            if (TRUE == cfg->enable_i2c)
            {
                /* Enable Pinmux for I2C4 and I2C0 */
                gDispPinCfg[0].doPinConfig = TRUE;
            }
            else
            {
                /* Disable Pinmux for I2C4 and I2C0 */
                gDispPinCfg[0].doPinConfig = FALSE;
            }
        }
    
        Board_pinmuxUpdate(gBasicDemoPinmuxDataInfo,
                           BOARD_SOC_DOMAIN_MAIN);
    }
    
    

    Regards,
    Christopher

  • Hi Christopher,

    Did you run this GPIO example as a standalone application in R5F? Are you seeing issue in this case as well?

    Regards,

    Nikhil

  • Hi Nikhil,

    No, I haven't tried the standalone GPIO example yet. I'll find time to do that.

    Regarding the modification above to turn the user LED on, did I miss something or do something wrong?

    Thanks.

    Regards,

    Christopher

  • Hi,

    The above looks fine, but I would suggest running standalone GPIO first, to ensure that you have a working code on R5 core before integration with vision_apps.

    Regards,

    Nikhil

  • Hi Nikhil,

    I utilized the MCASP_DeviceLoopback_TestApp in the RTOS SDK and added the following code to turn on the user LED.

    Modify the code in pdk_j721s2_08_05_00_36/packages/ti/drv/mcasp/example/j721s2/src/audio_evmInit.c

    --- a/pdk_j721s2_08_05_00_36/packages/ti/drv/mcasp/example/j721s2/src/audio_evmInit.c
    +++ b/pdk_j721s2_08_05_00_36/packages/ti/drv/mcasp/example/j721s2/src/audio_evmInit.c
    @@ -98,6 +98,8 @@ uint32_t vaOffset = 0;
     void IoExpanderConfig(void);
     #endif
     
    +void IoExpanderConfig_forULED(void);
    +
     #include <stdlib.h>
     #include <ti/drv/gpio/GPIO.h>
     #include <ti/csl/soc.h>
    @@ -173,6 +175,9 @@ void configureAudio(void)
         IoExpanderConfig();
     #endif
         
    +    MCASP_log("Turn on the USER LED\n");
    +    IoExpanderConfig_forULED();
    +
         /* Configure AUDIO_REFCLK1 as output */
         HW_WR_REG32(0x01082E4, 0x8000);
         
    @@ -208,6 +213,28 @@ void McASP_Enable(void)
     
     extern I2C_Handle gIoExpI2cHandle;
     
    +void IoExpanderConfig_forULED(void)
    +{
    +    Board_IoExpCfg_t ioExpCfg;
    +
    +    /* Set USER LED to LOW */
    +    ioExpCfg.slaveAddr   = BOARD_I2C_IOEXP_DEVICE2_ADDR;
    +    ioExpCfg.i2cInst     = BOARD_I2C_IOEXP_DEVICE2_INSTANCE;
    +    ioExpCfg.socDomain   = BOARD_SOC_DOMAIN_MAIN;
    +    ioExpCfg.enableIntr  = false;
    +    ioExpCfg.ioExpType   = THREE_PORT_IOEXP;
    +    ioExpCfg.portNum     = PORTNUM_2;
    +    ioExpCfg.pinNum      = PIN_NUM_6;
    +    ioExpCfg.signalLevel = GPIO_SIGNAL_LEVEL_LOW;
    +    status = Board_control(BOARD_CTRL_CMD_SET_IO_EXP_PIN_OUT, (void *)&ioExpCfg);
    +    if(status != BOARD_SOK)
    +    {
    +        MCASP_log("\n Board setting data to 3 port IO expander failed\n");
    +    }else {
    +        MCASP_log("\n user led is turning on now\n");
    +    }
    +}
    +
     void IoExpanderConfig(void)
    

    Build the firmware by : make -s -j BUILD_PROFILE=release BOARD=j721s2_evm CORE=mcu2_0 MCASP_DeviceLoopback_TestApp_freertos

    Then load the standalone firmware in u-boot: 

    The LED lights up successfully.

    So I still have no idea why it doesn't work after integrating with vision_apps..

    Thanks.

    Regards,

    Christopher

  • Hi Christopher,

    The I2C that you are using in vision_apps, is the same disabled from Linux?

    In Linux SDK we have an overlay k3-j721s2-vision-apps.dtso in {PSDKLA}/board-support/ti-linux-kernel-xxx/arch/arm64/boot/dts/ti/ folder

    Here you can see the i2c disabled for the ones used on R5 core. Can you check if you have added this i2c node here?

    Regenerate the dtbo and replace the same in rootfs partition on SD card for this to come into effect.

    Regards,

    Nikhil

  • Hi Nikhil,

    I2C0, which is used for IOEXP2 can not be disabled in Linux since it also control SD card power enable pin (GPIO_USD_PWR_EN).

    if I2C0 is disalbed in DTS overlay, the linux will get stuck while booting..

    So, does it mean that if an I2C bus is controlled in Linux, it can not be controlled in RTOS as well?

    Thanks.

    Regards,

    Christopher

  • Hi Christopher,

    Yes, you are correct, since it is same expander pin with two different ports, it should not be configured at both the ends, which could result in reconfigurations.

    Regards,

    Nikhil Dasan

  • Hi Nikhil,

    Thank you for the explanation.

    We will try to control the user LED on the Linux side.

    Thanks and regards,

    Christopher