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.

AM3358: Adding driver through XGCONF

Part Number: AM3358
Other Parts Discussed in Thread: SYSBIOS,

What step should I follow? I use XDCscript Editor to add it to cfg file. Task_create return NULL! Here is my cfg file

var Defaults = xdc.useModule('xdc.runtime.Defaults');

var Diags = xdc.useModule('xdc.runtime.Diags');

var Error = xdc.useModule('xdc.runtime.Error');

var Log = xdc.useModule('xdc.runtime.Log');

var LoggerBuf = xdc.useModule('xdc.runtime.LoggerBuf');

var Main = xdc.useModule('xdc.runtime.Main');

var Memory = xdc.useModule('xdc.runtime.Memory')

var SysMin = xdc.useModule('xdc.runtime.SysMin');

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

var Text = xdc.useModule('xdc.runtime.Text');

var Clock = xdc.useModule('ti.sysbios.knl.Clock');

var Swi = xdc.useModule('ti.sysbios.knl.Swi');

var Task = xdc.useModule('ti.sysbios.knl.Task');

var Semaphore = xdc.useModule('ti.sysbios.knl.Semaphore');

var Mailbox = xdc.useModule('ti.sysbios.knl.Mailbox');

var Hwi = xdc.useModule('ti.sysbios.hal.Hwi');

var Timer = xdc.useModule('ti.sysbios.hal.Timer');

var HeapMem = xdc.useModule('ti.sysbios.heaps.HeapMem');

var Edma = xdc.loadPackage ("ti.sdo.edma3.drv.sample");

var drv = xdc.loadPackage ("ti.sdo.edma3.drv");

var rm = xdc.loadPackage ("ti.sdo.edma3.rm");

/* ================ BIOS configuration ================ */

var BIOS = xdc.useModule('ti.sysbios.BIOS');

/*

* Build a custom SYS/BIOS library from sources.

*/

BIOS.libType = BIOS.LibType_Custom;

BIOS.customCCOpts = BIOS.customCCOpts.replace(" -g ","");

BIOS.assertsEnabled = false;

BIOS.logsEnabled = false;

BIOS.swiEnabled = false;

/*

* The BIOS module will create the default heap for the system.

* Specify the size of this default heap.

*/

BIOS.heapSize = 0x8000;

Swi.common$.namedInstance = true;

Program.sectionsExclude = ".*";

Clock.tickPeriod = 1000;

Hwi.dispatcherSwiSupport = true;

Hwi.dispatcherTaskSupport = true;

Hwi.dispatcherAutoNestingSupport = true;

Task.enableIdleTask = false;

Task.initStackFlag = false;

Task.checkStackFlag = false;

/* ================ Driver configuration ================ */

/* Load the Osal package */

var osType = "tirtos";

var Osal = xdc.loadPackage('ti.osal');

Osal.Settings.osType = osType;

/*use CSL package*/

var socType = "am335x";

var Csl = xdc.loadPackage('ti.csl');

Csl.Settings.deviceType = socType;

/* Load the driver packages, starting with mcasp */

var McASP = xdc.loadPackage('ti.drv.mcasp');

McASP.Settings.socType = socType;

/* Load the spi package */

var Spi = xdc.loadPackage('ti.drv.spi');

Spi.Settings.socType = socType;

/* Load the I2C package */

var I2C = xdc.loadPackage('ti.drv.i2c');

I2C.Settings.socType = socType;

/* Load the uart package */

var Uart = xdc.loadPackage('ti.drv.uart');

Uart.Settings.socType = socType;

/* Load the board package */

var Board = xdc.loadPackage('ti.board');

Board.Settings.boardName = "bbbAM335x";

/* Load Profiling package */

var Utils = xdc.loadPackage('ti.utils.profiling');

/* Load the gpio package */

var Gpio = xdc.loadPackage('ti.drv.gpio');

Gpio.Settings.socType = socType;

Gpio.Settings.enableProfiling = true;

/* ================ Cache and MMU configuration ================ */

var Cache = xdc.useModule('ti.sysbios.family.arm.a8.Cache');

Cache.enableCache = true;

var Mmu = xdc.useModule('ti.sysbios.family.arm.a8.Mmu');

Mmu.enableMMU = true;

/* Force peripheral section to be NON cacheable strongly-ordered memory */

var peripheralAttrs = {

type : Mmu.FirstLevelDesc_SECTION, // SECTION descriptor

tex: 0,

bufferable : false, // bufferable

cacheable : false, // cacheable

shareable : false, // shareable

noexecute : true, // not executable

};

/* Define the base address of the 1 Meg page the peripheral resides in. */

var peripheralBaseAddr = 0x44e00400;;

/* Configure the corresponding MMU page descriptor accordingly */

Mmu.setFirstLevelDescMeta(peripheralBaseAddr,

peripheralBaseAddr,

peripheralAttrs);

 

/* Define the base address of the 1 Meg page the peripheral resides in. */

var peripheralBaseAddr = 0x481a6000;

/* Configure the corresponding MMU page descriptor accordingly */

Mmu.setFirstLevelDescMeta(peripheralBaseAddr,

peripheralBaseAddr,

peripheralAttrs);

/*

* Uncomment this line to globally disable Asserts.

* All modules inherit the default from the 'Defaults' module. You

* can override these defaults on a per-module basis using Module.common$.

* Disabling Asserts will save code space and improve runtime performance.

*/

/*Defaults.common$.diags_ASSERT = Diags.ALWAYS_OFF; */

/*

* Uncomment this line to keep module names from being loaded on the target.

* The module name strings are placed in the .const section. Setting this

* parameter to false will save space in the .const section. Error and

* Assert messages will contain an "unknown module" prefix instead

* of the actual module name.

Defaults.common$.namedModule = false;

*/

/*

* Minimize exit handler array in System. The System module includes

* an array of functions that are registered with System_atexit() to be

* called by System_exit().

*/

System.maxAtexitHandlers = 4;

/*

* Uncomment this line to disable the Error print function.

* We lose error information when this is disabled since the errors are

* not printed. Disabling the raiseHook will save some code space if

* your app is not using System_printf() since the Error_print() function

* calls System_printf().

Error.raiseHook = null;

*/

/*

* Uncomment this line to keep Error, Assert, and Log strings from being

* loaded on the target. These strings are placed in the .const section.

* Setting this parameter to false will save space in the .const section.

* Error, Assert and Log message will print raw ids and args instead of

* a formatted message.

Text.isLoaded = false;

*/

/*

* Uncomment this line to disable the output of characters by SysMin

* when the program exits. SysMin writes characters to a circular buffer.

* This buffer can be viewed using the SysMin Output view in ROV.

SysMin.flushAtExit = false;

*/

/* System stack size (used by ISRs and Swis) */

Program.stack = 0x4000;

/* Circular buffer size for System_printf() */

SysMin.bufSize = 0x200;

/*

* Create and install logger for the whole system

*/

var loggerBufParams = new LoggerBuf.Params();

loggerBufParams.numEntries = 16;

var logger0 = LoggerBuf.create(loggerBufParams);

Defaults.common$.logger = logger0;

Main.common$.diags_INFO = Diags.ALWAYS_ON;

System.SupportProxy = SysMin;

var timer0Params = new Timer.Params();

timer0Params.instance.name = "timer0";

Program.global.timer0 = Timer.create(null, null, timer0Params);

I have no clue what is going wrong? What should I do to fix it? My project use driver UART, SPI, maybe McASP, GPIO and I2C. Thanks

  • Hi Anping,

    I don't see anything obviously wrong with your .cfg file.

    I'm not clear on exactly what problem you're encountering.

    • You're not able to modify a .cfg file using XGCONF?
    • You don't know how to add information to the .cfg file for PRSDK LLDs?
    • You're able to modify a .cfg file using XGCONF, but the dynamic Task_create() function returns NULL at run-time?

    Regarding XGCONF: I use XGCONF at the start of a project to get the basic contents of the .cfg file. After that, I manually edit the .cfg file in a text editor.

    For examples of how to add RTOS LLDs to the .cfg file can be found in the LLD directories under the "example" and "test" sub directories. For example:

    • UART: pdk_am335x_1_0_15\packages\ti\drv\uart\test\am335x\armv7\bios
    • SPI: pdk_am335x_1_0_15\packages\ti\drv\spi\test\am335x\armv7\bios
    • McASP: pdk_am335x_1_0_15\packages\ti\drv\mcasp\example\evmAM335x\armv7\bios
    • GPIO: pdk_am335x_1_0_15\packages\ti\drv\gpio\test\led_blink\am335x\armv7\bios
    • I2C: pdk_am335x_1_0_15\packages\ti\drv\i2c\test\eeprom_read\am335x\armv7\bios

    There is also a tutorial on application development using PRSDK here: https://training.ti.com/application-development-using-processor-sdk-rtos. This covers some information on adding LLDs to the .cfg file.

    The Task_create() function is documented here: <PRSDK install folder>/bios_6_75_02_00/docs/cdoc/index.html.

    What parameters are you using for the Task creation function?

    Regards,
    Frank

  • Hi Frank

         I write my .cfg file by using TI example project .cfg file. My CCS project compile successfully. But the dynamic Task_create() function returns NULL at run-time. I have no clue about what is going wrong. I like to know what step I should follow to write .cfg file. I must solve Task_create() function returns NULL at run-time to test my project on BeagleBone Black. I am struggling on this for one week. Thank you for your help.

  • Anping,

    Thanks much for the clarification.

    My suggestion is you try an example from PRSDK for BBB which includes dynamic task creation using Task_create(). Once this is working, you can start adding additional features / drivers you need for your application. There is an I2C EEPROM read example for  BBB which would probably work for this purpose. To create the example for the ARM:

    > cd <PRSDK install folder>\pdk_am335x_1_0_15\packages
    > pdkprojectcreate AM335x bbbAM335x little i2c example arm

    The resulting CCS project will be placed here: pdk_am335x_1_0_15\packages\MyExampleProjects. You can import the CCS project, then build & execute on the BBB.

    Regards,
    Frank

  • Hi Frank

         I test your all 5 uart example projects on BeagleBone. Some works(Task_create() doesn't retuen NULL), other not. But I change taskParams.stackSize to small number, other work also. It doesn't work if I did same. I have no clue how to fix. Thanks

  • Anping,

    A few questions:

    • Are you initializing the task parameters structure with Task_Params_init()?
    • What other parameters are you setting to non-default values, and what are the settings (priority, etc.)?
    • Does Task_create() fail if you set the "params" function parameter to NULL?
    • Have you checked the error block return? Please see xdc.runtime.Error for information on the APIs.
    • As an experiment, have you tried changing to static task creation in the .cfg?
    • Where is your task stack being placed in memory?

    Have you tried incrementally adding your code to one of the BBB UART examples which you have working?

    Regards,
    Frank

  • Hi Frank

         Here is

    Int main()

    {

    System_printf("enter main()\n");

    Error_Block eb;

    Error_init(&eb);

    Board_initCfg boardCfg = BOARD_INIT_PINMUX_CONFIG |

    BOARD_INIT_MODULE_CLOCK |

    BOARD_INIT_UART_STDIO;

    Board_STATUS boardStatus = Board_init(boardCfg);

    if (boardStatus != BOARD_SOK)

    {

    return (0);

    }

    /* Initialize the task params */

    Task_Params taskParams;

    Task_Params_init(&taskParams);

    taskParams.stackSize = 1024;

    /* Set the task priority higher than the default priority (1) */

    taskParams.priority = 2;

    Task_Handle task = Task_create(taskFxn, &taskParams, &eb);

    if (task == NULL)

    {

    System_printf("Task_create() failed!\n");

    BIOS_exit(0);

    }

    start_app(); /* does not return */

    return(0);

    }

    I saw your uart example project .cfg file has

    var SemihostSupport = xdc.useModule('ti.sysbios.rts.gnu.SemiHostSupport');

    but if I add this line. My project compile failed. Here is what I get

    C:\Users\anping.chen\ti\workplace\dms-ops_guidance\src\sysbios\sysbios.aa8fg(gnu_SemiHostSupport.o): In function `ti_sysbios_rts_gnu_SemiHostSupport_startup(int0_t)':

    SemiHostSupport.c:(.text.ti_sysbios_rts_gnu_SemiHostSupport_startup__I+0x0): undefined reference to `initialise_monitor_handles'

    collect2.exe: error: ld returned 1 exit status

    My .cfg is almost same as UART_BasicExample_bbbAM335x_armTestProject's .cfg file except I have

    var Log = xdc.useModule('xdc.runtime.Log');

    var LoggerBuf = xdc.useModule('xdc.runtime.LoggerBuf');

    and

    /* Load the driver packages, starting with mcasp */

    var McASP = xdc.loadPackage('ti.drv.mcasp');

    McASP.Settings.socType = socType;

    /* Load the spi package */

    var Spi = xdc.loadPackage('ti.drv.spi');

    Spi.Settings.socType = socType;

    /* Load the I2C package */

    var I2C = xdc.loadPackage('ti.drv.i2c');

    I2C.Settings.socType = socType;

    /* Load Profiling package */

    var Utils = xdc.loadPackage('ti.utils.profiling');

    /* Load the gpio package */

    var Gpio = xdc.loadPackage('ti.drv.gpio');

    Gpio.Settings.socType = socType;

    Gpio.Settings.enableProfiling = true;

    and have not

    var SemihostSupport = xdc.useModule('ti.sysbios.rts.gnu.SemiHostSupport');

    Thanks

     

     

  • Part Number: AM3358

    var Csl = xdc.loadPackage('ti.csl');

    Csl.Settings.deviceType = socType;

    var Csl = xdc.useModule('ti.csl.Settings');

    Csl.deviceType = socType;

    when do I use useModule and when do I use loadPackage? Thanks

  • Anping,

    I don't see anything wrong with the code you've shared.

    Do you know where your heap & task stack are being placed in memory? Are they being placed in DDR? You should be able to determine this by checking your .map file.

    I'm wondering whether there is some problem with DDR initialization on BBB. As an experiment, can you modify your Board_init() parameters? I notice some differences between two of the UART examples for BBB. 

    1. UART_BasicExample_bbbAM335x_armExampleProject : C source in <PRSDK install folder>\pdk_am335x_1_0_15\packages\ti\drv\uart\example\sample\src\main_uart_example.c
    2. UART_FwExample_bbbAM335x_armExampleProject : C source in <PRSDK install folder>\pdk_am335x_1_0_15\packages\ti\drv\uart\example\firmware_example\src\main_uart_example.c.

    The second example is for UART using PRU FW. Comparing the main_uart_example.c for each project, I see the UART PRU FW project includes BOARD_INIT_DDR:

        boardCfg = BOARD_INIT_PLL | BOARD_INIT_MODULE_CLOCK | BOARD_INIT_DDR | BOARD_INIT_ICSS_PINMUX;

    Can you add this to your Board_init() parameters to see if it helps?

    Regards,
    Frank

    To create the two UART example projects for BBB:

    1. Ensure all RTSC components are discovered & installed within CCS. Launch CCS, Window->Preferences, Code Composer Studio->Products, click "Rediscover". Install all components which are part of AM335x PRSDK installation. Exit CCS.
    2. Open DOS prompt & execute these commands:
      > cd <PRSDK install folder>\pdk_am335x_1_0_15\packages
      > pdkprojectcreate AM335x bbbAM335x little uart example arm

    This will create the two UART projects for BBB in <PRSDK install folder>\pdk_am335x_1_0_15\packages\MyExampleProjects.

  • Hi Frank

         I add BOARD_INIT_PLL and BOARD_INIT_DDR

    boardCfg = BOARD_INIT_PINMUX_CONFIG |

    BOARD_INIT_MODULE_CLOCK |

    BOARD_INIT_PLL |

    BOARD_INIT_DDR |

    BOARD_INIT_UART_STDIO;

    It doesn't help! What this line do?

    var SemihostSupport = xdc.useModule('ti.sysbios.rts.gnu.SemiHostSupport');

     if I add this line. My project compile failed. Here is what I get

    C:\Users\anping.chen\ti\workplace\dms-ops_guidance\src\sysbios\sysbios.aa8fg(gnu_SemiHostSupport.o): In function `ti_sysbios_rts_gnu_SemiHostSupport_startup(int0_t)':

    SemiHostSupport.c:(.text.ti_sysbios_rts_gnu_SemiHostSupport_startup__I+0x0): undefined reference to `initialise_monitor_handles'

    collect2.exe: error: ld returned 1 exit status. How to fix it?

    can we use this line with

    var Log = xdc.useModule('xdc.runtime.Log');

    var LoggerBuf = xdc.useModule('xdc.runtime.LoggerBuf');

    at the same time? Thanks

  • Anping,

    Can you share a simple (as simple as possible) project (.zip file) which demonstrates the Task_create() failure?

    Please see the following page for information for adding Semihosting support:

    http://processors.wiki.ti.com/index.php/SYS/BIOS_with_GCC_(CortexA)#How_do_I_enable_Semi-Hosting_for_Cortex-A_GNU_targets_.3F

    Yes, it should be possible to use Semihosting support with SYSBIOS logging.

    Regards,
    Frank

  • Hi Frank

         I use UART_BasicExample_bbbAM335x_armTestProject's .cfg file in my project and comment out

    var SemihostSupport = xdc.useModule('ti.sysbios.rts.gnu.SemiHostSupport');

    and add

    var Mailbox = xdc.useModule('ti.sysbios.knl.Mailbox');

    var Log = xdc.useModule('xdc.runtime.Log');

    var LoggerBuf = xdc.useModule('xdc.runtime.LoggerBuf');

    var Edma = xdc.loadPackage ("ti.sdo.edma3.drv.sample");

    var drv = xdc.loadPackage ("ti.sdo.edma3.drv");

    var rm = xdc.loadPackage ("ti.sdo.edma3.rm");

    var Spi = xdc.loadPackage('ti.drv.spi');

    Spi.Settings.socType = socType;

    var McASP = xdc.loadPackage('ti.drv.mcasp');

    McASP.Settings.socType = socType;

    var Gpio = xdc.loadPackage('ti.drv.gpio');

    Gpio.Settings.socType = socType;

    Gpio.Settings.enableProfiling = true;

    Task_create() doesn't return NULL anymore! But

    spi_cfg.edmaHandle = MCSPIApp_edmaInit();

    failed. Do you know how to fix it? Thanks

     

     

  • static EDMA3_RM_Handle MCSPIApp_edmaInit(void)

    {

    if (g_SPI_EdmaHandle != NULL)

    {

    return (g_SPI_EdmaHandle);

    }

    uint32_t edma3Id = 0;

    EDMA3_DRV_Result edmaResult = EDMA3_DRV_E_INVALID_PARAM;

    g_SPI_EdmaHandle = (EDMA3_RM_Handle)edma3init(edma3Id, &edmaResult);

    if (edmaResult != EDMA3_DRV_SOK)

    {

    /* Report EDMA Error */

    System_printf("\nEDMA driver initialization FAIL\n");

    }

    else

    {

    System_printf("\nEDMA driver initialization PASS.\n");

    }

    return(g_SPI_EdmaHandle);

    }

    line g_SPI_EdmaHandle = (EDMA3_RM_Handle)edma3init(edma3Id, &edmaResult) failed! But edma3init is your function!. Thanks

  • Anping,

    >> failed. Do you know how to fix it?

    For this I recommend:

    1. Consulting the PRSDK documentation here: http://software-dl.ti.com/processor-sdk-rtos/esd/docs/06_00_00_07/rtos/index_device_drv.html#mcspi-qspi-ospi
    2. Looking through some of the SPI examples.

    MCSPIApp_edmaInit() is application-level integration code for using the SPI LLD. Did you copy this from one of the SPI tests/examples? E.g.:

    example/mcspi_slavemode/src/main_mcspi_slave_mode.c
    test/mcspi_serial_flash/src/main_mcspi_dma_serial_flash_read_write.c
    test/src/main_mcspi_test.c

    I see one example for BBB which includes this API:

    ./example/mcspi_slavemode/am335x/armv7/bios/MCSPI_SlaveMode_MasterExample_bbbAM335x_armExampleProject.txt
    ./example/mcspi_slavemode/am335x/armv7/bios/MCSPI_SlaveMode_SlaveExample_bbbAM335x_armExampleProject.txt

    This application is described in this section of the PRSDK docs: http://software-dl.ti.com/processor-sdk-rtos/esd/docs/06_00_00_07/rtos/index_device_drv.html#mcspi

    Please see the row for "MCSPI_slavemode example application".

    Regards,
    Frank

  • Hi Frank

         I use the code from

    ./example/mcspi_slavemode/am335x/armv7/bios/MCSPI_SlaveMode_MasterExample_bbbAM335x_armExampleProject.txt
    ./example/mcspi_slavemode/am335x/armv7/bios/MCSPI_SlaveMode_SlaveExample_bbbAM335x_armExampleProject

    I study these two examples many times. I don't know why edma3init(edma3Id, &edmaResult) failed! Thanks

  • Anping,

    Have you tried the OOB examples on BBB, and do they work for you?

    Have you checked the edmaResult error return status?

    Have you tried compiling the LLD in debug mode and stepping through the code to see where the failure occurs?  

    If you want to share a .zip file I might be able to better help, but results might be slow for such an exercise.

    Thanks,
    Frank