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.

TDA4VM: HWI hook problem in sysbios

Part Number: TDA4VM
Other Parts Discussed in Thread: SYSBIOS

I try to use hwi hook in sysbios and I can get the hwi hook callback. 

1. When I use Hwi_Handle_name(hwi_handle) to get hwi name, I get "unknown-instance-name". How can I get correct hwi name?

2.Now if I want to monitor multiple hwi, I need to create multiple hook(register, begin, end, etc.) groups. Can I use one hook group to get all hwi information?

thanks

  • Hi,

    Which version of SYSBIOS is this? 

    Gates Qi said:
    When I use Hwi_Handle_name(hwi_handle) to get hwi name, I get "unknown-instance-name". How can I get correct hwi name?

    Can you look at https://e2e.ti.com/support/legacy_forums/embedded/tirtos/f/355/t/438102, this should solve your issue as listed in 1. Please see the include file and the sysbios cfg file you are using as mentioned in the thread.

    Gates Qi said:
    Now if I want to monitor multiple hwi, I need to create multiple hook(register, begin, end, etc.) groups. Can I use one hook group to get all hwi information?

    Please explain more on this. Are you looking for a single hook function which gives you stats on all the Hwi? Or you want to reuse the same hook functions for all the different Hwi? Do look at another useful E2E thread - https://e2e.ti.com/support/legacy_forums/embedded/tirtos/f/355/t/501548 

    Regards,

    Karan

  • Hi karan, For question 2, I want to reuse the same hook functions for all the different Hwi. And also, if sysbios has api to get all hwi status, it may help me too. Thanks
  • For question 1, I test in MCU3_1:

    In cfg file: Var Hwi = xdc.useModule('ti.sysbios.family.arm.v7r.keystone3.Hwi')

    For include file: include <ti/sysbios/family/arm/v7r/keystone3/Hwi.h>

    But in end hook function, the return of Hwi_Handle_name is still "unknown-instance-name".

  • Hi,

    Can you send the bios cfg file and the relevant snippets from the code?

    Regards,

    Karan

  • Hi karan,

    mcu3_1.cfg:

    xdc.loadCapsule("bios_common.cfg");
    
    var Core         = xdc.useModule('ti.sysbios.family.arm.v7r.keystone3.Core');
    Core.id = 1;
    
    var Cache = xdc.useModule('ti.sysbios.family.arm.v7r.Cache');
    Cache.enableCache = true;
    
    var Hwi = xdc.useModule('ti.sysbios.family.arm.v7r.keystone3.Hwi');
    Hwi.vimBaseAddress = 0x0ff80000;
    
    
    /* DMTimer #x - in general, address is 0x024x0000 where x is timer # */
    var Timer = xdc.useModule('ti.sysbios.timers.dmtimer.Timer');
    Timer.checkFrequency = false;
    Timer.timerSettings[0].baseAddr = 0x024f0000;
    Timer.timerSettings[0].intNum = 171;
    
    var Clock = xdc.useModule('ti.sysbios.knl.Clock');
    Clock.timerId = 0;
    
    xdc.print("# !!!  Clock TimerId [" + Clock.timerId + "] @ 0x" + Timer.timerSettings[0].baseAddr.toString(16) + " and interrupt " + Timer.timerSettings[0].intNum + " !!!" );
    
    /*
     * Initialize MPU and enable it
     *
     * Note: MPU must be enabled and properly configured for caching to work.
     */
    xdc.loadCapsule("r5_mpu.xs");
    
    var Startup = xdc.useModule('xdc.runtime.Startup');
    Startup.firstFxns[Startup.firstFxns.length++] = '&appUtilsSetDLFOBitInACTRLReg';
    
    /* pull in Timestamp to print time in hook functions */
    xdc.useModule('xdc.runtime.Timestamp');
    
    
    /* Hook Set 1 */
    Hwi.addHookSet({
    registerFxn: '&myRegister1',
    createFxn: '&myCreate1',
    beginFxn: '&myBegin1',
    endFxn: '&myEnd1',
    });
    
    
    /* Hook Set 2 */
    Hwi.addHookSet({
    registerFxn: '&myRegister2',
    createFxn: '&myCreate2',
    beginFxn: '&myBegin2',
    endFxn: '&myEnd2',
    });
    

    c code in main.c file:

    /* ======== myEnd2 ========
    * invoked after Timer Hwi func */
    Void myEnd2(Hwi_Handle hwi)
    {
        // Ptr pEnv;
        // pEnv = Hwi_getHookContext(hwi, myHookSetId1);
    
        xdc_runtime_Types_FreqHz freq1;
        Timestamp_getFreq(&freq1);
        end2 = (uint32_t)Timestamp_get32();
        System_printf("hook2 name:%s freq=%u dt=%u\n", Hwi_Handle_name(hwi), freq1.lo, (end2 -start2));
    
        // System_printf("myEnd1: pEnv = 0x%x, time = %u\n", pEnv, Timestamp_get32());
        Hwi_setHookContext(hwi, myHookSetId2, (Ptr)0xc0de1);
    }
    
    

    terminal output:

    hook2 name:{unknown-instance-name} freq=1000000000 dt=21992
    hook2 name:{unknown-instance-name} freq=1000000000 dt=37031
    

  • Hi karan, Is there any update?

  • Hi Gates,

    The problem is that you are not giving the Hwi instances a name. You need to do the following

    1. In the .cfg file, make sure instance names are enabled.

    var Defaults = xdc.useModule('xdc.runtime.Defaults');
    Defaults.common$.namedInstance = true;

    2. You supply a unique (and persistent) name when creating the Hwi.

    hwiParams.instance->name = "foo";

    Todd

  • Hi Todd,

    Does hwi have default name in PDK, such as IPC mailbox hwi? Because most of hwi drivers are developed by TI .

  • Gates,

    By default, Hwi do not get a name (to save footprint). I'm not sure if the drivers/components in the PDK name their Hwis. I'll let one of the PDK engineers chime in about that.

    Todd

  • Hi,

    If you use the HwiP_Handle HwiP_create(int32_t interruptNum, HwiP_Fxn hwiFxn, const HwiP_Params *params) in pdk/packages/ti/osal/src/tirtos/HwiP_tirtos.c

    The name gets passed in params->name and gets assigned as  hwiParams.instance->name = params->name;

    Regards,

    Karan

  • Hi karan,

    1.

    In the .cfg file, I add:

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

    Defaults.common$.namedInstance = true;
    2.

    I set hwiParams.instance->name to a fixed value in HwiP_create function in file pdk/packages/ti/osal/src/tirtos/HwiP_tirtos.c, for example:

    hwiParams.instance->name = "ddd";

    3.

    Now I get  "empty-instance-name" by Hwi_Handle_Name(hwi).  And also I find the value of hwi is not fixed for specific hook.

    Hwi_Handle_name(hwi)
  • Can you provide one example? thanks

  • Hi,

    I looked at the existing SDK and whatever you are trying to do for Hwi, there is an example which does the same for a task. Can you take this reference? And if this doesn't work please share the code base of your example, atleast the relevant sections so that I can reproduce the issue locally and provide more pointed answers.

    For the task example: (SSDK 6.02)

    src: psdk_rtos_auto_j7_06_02_00_21/pdk/packages/ti/drv/cpsw/examples/cpsw_apputils/cpsw_apputils_rtos.c

    cfg: psdk_rtos_auto_j7_06_02_00_21/pdk/packages/ti/drv/cpsw/examples/build/j721e/sysbios_r5f.cfg

    Regards,

    Karan