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.

OMAPL138B-EP: GPIO LED Blink example on C6748 with Linux running on ARM

Part Number: OMAPL138B-EP
Other Parts Discussed in Thread: OMAPL138, TMDSLCDK138

Hi,

I'm running modified GPIO LED blink example from pdk_omapl138_1_0_10 on the C6748 core using remoteproc. And it looks like the DSP core is throttled by the Linux on the ARM core.

We are using:

1. TMDSLCDK138 board revision A7A

2. PROCESSOR-SDK-LINUX-OMAPL138 version 06_00_00_07

3. Custom device tree - 5127.device_tree.zip

4. Platform memory setup

5. *.cfg configuration file

/* Load all required BIOS/XDC runtime packages */
var Memory                      =   xdc.useModule('xdc.runtime.Memory');
var BIOS                        =   xdc.useModule('ti.sysbios.BIOS');
var HeapBuf                     =   xdc.useModule('ti.sysbios.heaps.HeapBuf');
var Log                         =   xdc.useModule('xdc.runtime.Log');
var Task                        =   xdc.useModule('ti.sysbios.knl.Task');
var Semaphore                   =   xdc.useModule('ti.sysbios.knl.Semaphore');
var Hwi                         =   xdc.useModule('ti.sysbios.family.c64p.Hwi');
var ECM                         =   xdc.useModule('ti.sysbios.family.c64p.EventCombiner');
var core                        =   xdc.useModule('ti.sysbios.hal.Core');
var Cache       				=   xdc.useModule ("ti.sysbios.hal.Cache");
var HeapMem = xdc.useModule('ti.sysbios.heaps.HeapMem');

var devType = "omapl138"

/* Load the OSAL package */ 
var osType = "tirtos"
var Osal = xdc.useModule('ti.osal.Settings');
Osal.osType = osType;
Osal.socType = devType;

/*use CSL package*/
var Csl = xdc.loadPackage('ti.csl');
Csl.Settings.deviceType = devType;

/* Load the Board package and set the board name */
var Board = xdc.loadPackage('ti.board');
Board.Settings.boardName = "lcdkOMAPL138";

/* Load Profiling package */
/*var Utils = xdc.loadPackage('ti.utils.profiling');*/

/* Load the gpio package */
var Gpio = xdc.loadPackage('ti.drv.gpio');
Gpio.Settings.enableProfiling = false;    
Gpio.Settings.socType = devType;

/* Load the uart package */
var Uart = xdc.useModule('ti.drv.uart.Settings');
Uart.socType = devType;

/* Load the I2C package  - required by board */
var I2c = xdc.loadPackage('ti.drv.i2c');
I2c.Settings.socType = devType;

var System                      =   xdc.useModule('xdc.runtime.System');
SysStd                          =   xdc.useModule('xdc.runtime.SysStd');
System.SupportProxy             =   SysStd;

/* Load and use the CSL packages */
var Csl                         = xdc.useModule('ti.csl.Settings');
Csl.deviceType                  = devType;


/* No runtime stack checking is performed */
Task.checkStackFlag             = false;


/* Reduce the number of task priorities */
Task.numPriorities              = 4;

/* ================ Task configuration ================ */
var task0Params                 = new Task.Params();
task0Params.instance.name       = "echo";
task0Params.stackSize           = 0x1000;
Program.global.echo             = Task.create("&gpio_test", task0Params);

/* This is the default memory heap. */
/*
Memory.defaultHeapInstance      =   Program.global.heap0;

Program.sectMap["systemHeap"]   =   Program.platform.stackMemory;
Program.sectMap[".fardata:benchmarking"] = new Program.SectionSpec();
Program.sectMap[".fardata:benchmarking"].loadSegment = "APP_CACHED_DATA_BLK2_MEM";

Program.sectMap[".text:_c_int00"]                 = new Program.SectionSpec();
Program.sectMap[".text:_c_int00"].loadSegment     = "APP_CACHED_DATA_BLK1_MEM";
*/
/****** IPC - Shared Memory Settings ********/
/* IPC packages */

var memmap                      = Program.cpu.memoryMap;

/*Startup = xdc.useModule('xdc.runtime.Startup');
Startup.firstFxns.$add('&myStartupFxn');*/

/* Enable BIOS Task Scheduler */
BIOS.taskEnabled                =   true;

/*
 * Enable Event Groups here and registering of ISR for specific GEM INTC is done
 * using EventCombiner_dispatchPlug() and Hwi_eventMap() APIs
 */
var exception =	xdc.useModule('ti.sysbios.family.c64p.Exception');
exception.enablePrint = true;

/*
 *  @(#) ti.sysbios.genx; 2, 0, 0, 0,275; 4-29-2009 15:45:06; /db/vtree/library/trees/avala/avala-k25x/src/
 */

var xdc_runtime_SysMin = xdc.useModule('xdc.runtime.SysMin');
xdc_runtime_SysMin.bufSize = 0x8000;

/* Override the default resource table with my own */
var Resource = xdc.useModule('ti.ipc.remoteproc.Resource');
Resource.loadSegment = "DDR"

6. Modified main_led_blink.c file

/* XDCtools Header files */
#include <xdc/std.h>
#include <xdc/runtime/System.h>
#include <xdc/runtime/Error.h>

/* BIOS Header files */
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>

#include <stdio.h>

/* TI-RTOS Header files */
#include <ti/drv/gpio/GPIO.h>
#include <ti/drv/gpio/soc/GPIO_soc.h>

#include "GPIO_board.h"

#include <ti/board/board.h>

/**********************************************************************
 ************************** Macros ************************************
 **********************************************************************/
#define DELAY_VALUE       (10U)   /* 10 msec */

/**********************************************************************
 ************************** Internal functions ************************
 **********************************************************************/

/* Delay function */
void AppDelay(unsigned int delayVal);

/* Callback function */
void AppGpioCallbackFxn(void);

/*
 *  ======== Board_initI2C ========
 */
static void Board_initGPIO(void)
{
    Board_initCfg boardCfg;
    GPIO_v0_HwAttrs gpio_cfg;

    /* Get the default SPI init configurations */
    GPIO_socGetInitCfg(GPIO_LED0_PORT_NUM, &gpio_cfg);

    /* Setup GPIO interrupt configurations */
    GPIO_socSetBankInt(GPIO_LED0_PORT_NUM, GPIO_LED0_PIN_NUM, NULL);

    boardCfg = BOARD_INIT_PINMUX_CONFIG |
        BOARD_INIT_MODULE_CLOCK;

    Board_init(boardCfg);
}

/**********************************************************************
 ************************** Global Variables **************************
 **********************************************************************/
volatile uint32_t gpio_intr_triggered = 0;
uint32_t gpioBaseAddr;
uint32_t gpioPin;

/*
 *  ======== test function ========
 */

void gpio_test(UArg arg0, UArg arg1)
{
    /* GPIO initialization */
    GPIO_init();

    /* Set the callback function */
    GPIO_setCallback(USER_LED0, AppGpioCallbackFxn);

    /* Enable GPIO interrupt on the specific gpio pin */
    GPIO_enableInt(USER_LED0);

    /* Write high to gpio pin to control LED1 */
    GPIO_write((USER_LED1), GPIO_PIN_VAL_HIGH);
    AppDelay(DELAY_VALUE);

    while(1)
    {
        GPIO_toggle(USER_LED0);
        AppDelay(DELAY_VALUE);
    }
}

/*
 *  ======== main ========
 */
int main(void)
{
    /* Call board init functions */
    Board_initGPIO();

    /* Start BIOS */
    BIOS_start();
    return (0);
}


/*
 *  ======== AppDelay ========
 */
void AppDelay(unsigned int delayVal)
{
    Osal_delay(delayVal);
}

/*
 *  ======== AppLoopDelay ========
 */
void AppLoopDelay(uint32_t delayVal)
{
    volatile uint32_t i;

    for (i = 0; i < (delayVal * 1000); i++)
        ;
}

/*
 *  ======== Callback function ========
 */
void AppGpioCallbackFxn(void)
{
    /* Toggle LED1 */
    GPIO_toggle(USER_LED1);
    AppLoopDelay(DELAY_VALUE);
    gpio_intr_triggered = 1;
}

7. Here is the *.out file - 5736.GPIO_LedBlink_lcdkOMAPL138_c674xTestProject.zip

After remoteproc boots the DSP core and the DSP is running the code, LEDs are blink, but not as expected. When Linux is booting, they blink fast, when Linux prompts login line they begin to blink slower. If I press and hold any key on the keyboard connected to the USB HOST they begin to blink faster. Actually, it looks like if I keep ARM core busy the LEDs are blink faster, with “stress –cpu 1 –timeout 10” for example.

Here is the screenshots from oscilloscope. Yellow line is LED D5 voltage. Blue line is LED D4 voltage.

Linux is idle. The LEDs are blink slower.

Red arrows pointing to the place where the “down” key has been pressed and hold. The LEDs began to blink faster.

 

Is there any way to fix this?

  • Hi, Vasily,

    Could you elaborate a bit more on the modified example on what has been modified? Also, is the behavior the same when running unmodified LED blinking example?

    Rex

  • Hi, Rex,

    My bad, I should have started from this. The behavior of unmodified LED blinking example is impossible to test with remoteproc, it have to be modified if I understood it correctly. But yes, with following few steps this behavior can be reproduced with clean LED blink example.

    The example is "GPIO_LedBlink_lcdkOMAPL138_c674xTestProject" from pdk_omapl138_1_0_10 package. CCS is Version: 9.1.0.00010 .


    Steps:

    1. Make new platform (Project -> RTSC tools -> Platform -> New) with the name contains "OMAPL138", "OMAPL138_NEW" for example, with the following parameters:

    2. Add following lines to gpio_test.cfg:

    var xdc_runtime_SysMin = xdc.useModule('xdc.runtime.SysMin');
    var Resource = xdc.useModule('ti.ipc.remoteproc.Resource');
    Resource.loadSegment = "DDR";

    3. Change the line 90 in main_led_blink.c from 

    #define DELAY_VALUE (500U) /* 500 msec */

    to

    #define DELAY_VALUE (50U) /* 50 msec */

    it will make the effect more noticeable.

    4. Build the project and run it with remoteproc.

  • Hi, Rex, 

    Do you have any news? Please tell if I can help somehow, this issue made us stop in the middle of development. 

  • Hi, Vasily,

    Sorry, I have been busy and have not had any chance to look at the issue. I meant to check the GPIO used for LED, but barely got time to download the SDK. I'll see if I can get some time to look at it this week.

    Rex

  • Hi, Vasily,

    I am sorry that I don't have much time to spend on this one as I would like to on debugging the issue. I suspect the GPIO on the ARM side may be interfere with that on DSP. I would like to suggest you to check if there is any duplication on the GPIO or interrupt configuration.

    Rex

  • Hi, Rex,

    you are right. The problem is that TI RTOS by default trying to use Timer0 while Linux uses it already. So the answer to my question is no, Linux does not throttling the DSP core.

    Anyway, it's a bit tricky to make examples to work properly, I must admit. Those examples works just fine when one use them on TI RTOS standalone with no Linux on the ARM side. But for OMAPL138 it very unlikely scenario in my humble opinion. It is obvious that newbie will try to load Linux and TI RTOS examples at the same time and he will expect this to work out of the box. Can you please tell it to the team or person in charge?

    To make this example work properly I added following lines to the .cfg file in order for TI RTOS to start using Timer2 inatead of Timer0:

    var Clock = xdc.useModule('ti.sysbios.knl.Clock');
    Clock.timerId = 2;    // this changes the default Timer used by BIOS to 2.

    We need to make sure that TI RTOS does not uses UART also, so it will not crush the Linux output. To do this I changed this lines in Board_initGPIO() function in main_led_blink_gpio.c like that:

    //    boardCfg = BOARD_INIT_PINMUX_CONFIG |
    //        BOARD_INIT_MODULE_CLOCK |
    //        BOARD_INIT_UART_STDIO;
    
        boardCfg = BOARD_INIT_PINMUX_CONFIG |
            BOARD_INIT_MODULE_CLOCK;
    

    and deleted every GPIO_log() functions as well. 

    I left only one line in the Board_moduleClockInit() function in lcdkOMAPL138_clock.c to avoid any other interference with Linux:

    Board_moduleClockEnable(CSL_PSC_GPIO);

    After that we have to recompile the PDK as described here http://software-dl.ti.com/processor-sdk-rtos/esd/docs/latest/rtos/index_overview.html#rebuild-pdk and rebuild the project.

    Im not sure if i did everything right, correct me then please. Thanks, Rex.

  • Hi, Vasily,

    When Linux is running, the IPC examples in Linux SDK are the ones to show its funcitonality. The examples  in RTOS SDK are meant to run under RTOS setup. Theoretically, they will run with Linux on ARM, but were not tested under that setup. There may be resource conflict.which wasn't considered at the time when they were designed for RTOS only.

    Thanks to your detailed description and appreciate your contribution. Your post will help other users when working on the same project. I'll have DSP expert to review your changes and get back if he thinks a better way for it. 

    Rex

  • Hi, Vasily,

    The DSP expert reviewed the changes and they look good. Thanks!

    Rex