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.

RTOS/AM5728: base on am5728, print periodically on ipu1

Part Number: AM5728
Other Parts Discussed in Thread: SYSBIOS

Tool/software: TI-RTOS

Hi,base on rtos and am5728,I want to use ipu1 to access dmtimer for printing periodically.After compile the project successfully, I ran the project, unfortunate,it was a exeption occur,which the reason seem like when calling the interface Timer_create ,what  should i do to solve the exception,and  the code snippest is below:

/*
 * Copyright (c) 2013-2014, Texas Instruments Incorporated
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * *  Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * *  Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * *  Neither the name of Texas Instruments Incorporated nor the names of
 *    its contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/*
 *  ======== main_Ipu1.c ========
 *
 */

/* xdctools header files */
#include <xdc/std.h>
#include <xdc/runtime/Diags.h>
#include <xdc/runtime/Error.h>
#include <xdc/runtime/Log.h>
#include <xdc/runtime/System.h>

/* package header files */
#include <ti/ipc/Ipc.h>
#include <ti/ipc/MultiProc.h>
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/ipc/remoteproc/Resource.h>
#include <ti/sysbios/timers/dmtimer/Timer.h>

/* local header files */
#include "Server.h"
#include "rsc_table_ipu1.h"

Void myIsr(UArg arg)
{
	System_printf("myIsr arg = %d\n", (Int)arg);
	System_exit(0);
}


/* private functions */
static Void smain(UArg arg0, UArg arg1);


/*
 *  ======== main ========
 */
Int main(Int argc, Char* argv[])
{
	Timer_Params timerParams;
	Timer_Handle myTimer;
	Error_Block eb;
	Error_init(&eb);
	Timer_Params_init(&timerParams);
	//timerParams.period = 10; 
	timerParams.periodType = Timer_PeriodType_MICROSECS;
	//timerParams.extFreq.lo = 27000000; /* 27 MHz */
	//timerParams.extFreq.hi = 0;
	//timerParams.arg = 1;
	
	myTimer = Timer_create(Timer_ANY, myIsr, &timerParams, &eb);
	if (myTimer == NULL) 
	{
		Log_print0(Diags_INFO,"Timer create failed");	
		System_abort("Timer create failed");
	}
	else
	{
		Log_print0(Diags_INFO,"Timer create success");
		Timer_delete(myTimer);
	}

    /* start scheduler, this never returns */
    BIOS_start();

    /* should never get here */
    Log_print0(Diags_EXIT, "<-- main:");
    return (0);
}


/*
 *  ======== smain ========
 */
Void smain(UArg arg0, UArg arg1)
{
    Int                 status = 0;
    Error_Block         eb;
    Bool                running = TRUE;

    Log_print0(Diags_ENTRY | Diags_INFO, "--> smain:");

    Error_init(&eb);

    /* initialize modules */
    Server_init();

    /* turn on Diags_INFO trace */
    Diags_setMask("Server+F");

    /* loop forever */
    while (running) {
        /* Attach to other slave */
        do {
            status = Ipc_attach(MultiProc_getId("DSP1"));
            Task_sleep(1);
        } while (status == Ipc_E_NOTREADY);

        if (status < 0) {
            Log_print0(Diags_INFO,"smain: attach failed");
            status = -1;
            goto leave;
        }

        /* BEGIN server phase */

        /* server setup phase */
        status = Server_create();

        if (status < 0) {
            goto leave;
        }

        /* server execute phase */
        status = Server_exec();

        if (status < 0) {
            goto leave;
        }

        /* server shutdown phase */
        status = Server_delete();

        if (status < 0) {
            goto leave;
        }

        /* END server phase */

        /* Detach from other slave */
        do {
            status = Ipc_detach(MultiProc_getId("DSP1"));
        } while (status == Ipc_E_NOTREADY);

        if (status < 0) {
            Log_print0(Diags_INFO,"smain: detach failed");
            goto leave;
        }

    } /* while (running) */

    /* finalize modules */
    Server_exit();

leave:
    Log_print1(Diags_EXIT, "<-- smain: %d", (IArg)status);
    return;
}
1004.Ipu1.cfg

after running my project,I check the status on ipu1 by the shell command:cat /sys/kernel/debug/remoteproc/remoteproc0/trace0,and the resulte is:

root@AM57xx-Tronlong:~# cat /sys/kernel/debug/remoteproc/remoteproc0/trace0
[0][ 0.000] 19 Resource entries at 0x3000
[0][ 0.000] [t=0x000ef279] ti.sysbios.family.arm.m3.Hwi: ERROR: line 1121: E_hardFault: FORCED
[0][ 0.000] ti.sysbios.family.arm.m3.Hwi: line 1121: E_hardFault: FORCED
[0][ 0.000] [t=0x001183ed] ti.sysbios.family.arm.m3.Hwi: ERROR: line 1198: E_busFault: PRECISERR: Immediate Bus Fault, exact addr known, address: 68034048
[0][ 0.000] ti.sysbios.family.arm.m3.Hwi: line 1198: E_busFault: PRECISERR: Immediate Bus Fault, exact addr known, address: 68034048
[0][ 0.000] Exception occurred in background thread at PC = 0x0001bad2.
[0][ 0.000] Core 0: Exception occurred in ThreadType_Main.
[0][ 0.000] Main name: main(), handle: 0x0.
[0][ 0.000] Main stack base: 0x8006e624.
[0][ 0.000] Main stack size: 0x1000.
[0][ 0.000] R0 = 0x68034000 R8 = 0x00000020
[0][ 0.000] R1 = 0x00000000 R9 = 0x00027984
[0][ 0.000] R2 = 0x00000002 R10 = 0x00000000
[0][ 0.000] R3 = 0x00000001 R11 = 0x8006f5a4
[0][ 0.000] R4 = 0x00000002 R12 = 0x8006f4d4
[0][ 0.000] R5 = 0x00000048 SP(R13) = 0x8006f470
[0][ 0.000] R6 = 0x8006f5ec LR(R14) = 0x00017f5d
[0][ 0.000] R7 = 0x00000000 PC(R15) = 0x0001bad2
[0][ 0.000] PSR = 0x61000200
[0][ 0.000] ICSR = 0x00400803
[0][ 0.000] MMFSR = 0x00
[0][ 0.000] BFSR = 0x82
[0][ 0.000] UFSR = 0x0000
[0][ 0.000] HFSR = 0x40000000
[0][ 0.000] DFSR = 0x00000000
[0][ 0.000] MMAR = 0x68034048
[0][ 0.000] BFAR = 0x68034048
[0][ 0.000] AFSR = 0x00000000
[0][ 0.000] Terminating execution...

  • The RTOS team have been notified. They will respond here.
  • jianbing,

    As you have 'var dmTimer = xdc.useModule('ti.sysbios.timers.dmtimer.Timer');' at line 150, have you tried to replace

    var Timer = xdc.useModule('ti.sysbios.timers.dmtimer.Timer');
    var timerParams = new Timer.Params();

    with
    var timerParams = new dmTimer.Params();

    Regards,
    Garrett
  • i have two questions:

    Q1:let me complement it,what the example that i modified was base on the example:ipc_3_47_01_00\examples\DRA7XX_linux_elf\ex41_forwardmsg. I had changed the ipu1.cfg like below,but, the result is the same to before,it didn't solve the exception,i'm not sure if my configuration is correct.

    8130.Ipu1.cfg

    Q2:in rtos,if i want to use dmtimer,is't necessary that i must configuate the .cfg file and use in .c file together? can I use the dmtimer  in .c file only and whithout .cfg?

  • jiangbing,

    >>Immediate Bus Fault, exact addr known, address: 68034048
    The address 68034048 (-0x20000000) is the timer 3 register TWPS. Do you have any access to the timer 3 in your code? If you change timer ID in your config or c code, does the address remain the same?

    Also can you try to replace
    /* dmTimer 6 mapped to GPT7 */
    dmTimer.timerSettings[6].baseAddr = 0x68034000;
    /* dmTimer 7 mapped to GPT8 */
    dmTimer.timerSettings[7].baseAddr = 0x68036000;

    with
    /* dmTimer 6 mapped to GPT7 */
    dmTimer.timerSettings[6].baseAddr = 0x68822400;
    /* dmTimer 7 mapped to GPT8 */
    dmTimer.timerSettings[7].baseAddr = 0x68822600;


    Yes, you should be able to use timer in either .cfg or c file. see sys-bios user guide (SPRUEX3T) section 8.3 timer module - configuration example and runtime example.

    Regards,
    Garrett
  • i had try it,however,it still can't use the dmtimer .finally, I try another way to realize the timing function,that is use clock tick directly,

    here the snippest code:

    Clock_Params clkParams;

    Clock_Params_init(&clkParams);
    clkParams.period = 20;
    clkParams.startFlag = TRUE;
    Clock_create(clk0Fxn, 20, &clkParams, NULL);

    and clkParams.period = 20; would configurate the timing period as one millisecond, it means that every 50 microsecond a clkParams.period.

    it was realize my requirement, but i want to know where to confiurate period for the  clkParams.period ,thank you.

    and here's my entire code:

    7140.Ipu1.cfg1754.IpuAmmu.cfg

    /*
     * Copyright (c) 2013-2014, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     */
    
    /*
     *  ======== main_Ipu1.c ========
     *
     */
    
    /* xdctools header files */
    #include <xdc/std.h>
    #include <xdc/runtime/Diags.h>
    #include <xdc/runtime/Error.h>
    #include <xdc/runtime/Log.h>
    #include <xdc/runtime/System.h>
    
    /* package header files */
    #include <ti/ipc/Ipc.h>
    #include <ti/ipc/MultiProc.h>
    #include <ti/sysbios/BIOS.h>
    #include <ti/sysbios/knl/Task.h>
    #include <ti/ipc/remoteproc/Resource.h>
    #include <ti/sysbios/timers/dmtimer/Timer.h>
    #include <ti/sysbios/knl/Clock.h>
    
    
    /* local header files */
    #include "rsc_table_ipu1.h"
    
    uint32_t *ptr;
    
    
    Void clk0Fxn(UArg arg0)
    {
        static uint32_t status = 0;
    	*ptr = status;
    	status = ~status;
    }
    
    /*
     *  ======== main ========
     */
    Int main(Int argc, Char* argv[])
    {
    	Log_print0(Diags_INFO,"mian----");	
    
    	uint32_t gpio_addr = 0x0;
    	if (Resource_physToVirt(0x4A0036F0, &gpio_addr) != Resource_S_SUCCESS) 
    	{
    		Log_print0(Diags_INFO, "led_addr map failed");
    	}
    
    	Log_print1(Diags_INFO, "---gpio_addr = 0x%x", gpio_addr);
    
    	ptr = (uint32_t*)gpio_addr;
       
        Clock_Params clkParams;
    
        Clock_Params_init(&clkParams);
        clkParams.period = 20;
        clkParams.startFlag = TRUE;
        Clock_create(clk0Fxn, 20, &clkParams, NULL);
    
        /* start scheduler, this never returns */
        BIOS_start();
    
        /* should never get here */
        Log_print0(Diags_EXIT, "<-- main:");
        return (0);
    }
    
    

  • Hi Jianbing,

    You need set BIOS.cpuFreq.lo in ipu1.cfg file for configuring clock ticks to make the tick period accurate.

    Regards,
    Garrett
  • what's the detail to configurate it ?

  • Jianbing,

    It should be something like BIOS.cpuFreq.lo=200000000 if ipu1 is running at 200MHz.

    Regards,
    Garrett
  • thank you so much, i'll refer it.