Project

General

Profile

Adding IPC to TI RTOS template app with CCS

(!) NOTE: Work in progress (i.e. TODO)

References:
https://software-dl.ti.com/processor-sdk-rtos/esd/docs/06_03_00_106/rtos/index_examples_demos.html#template-application-workshop
https://software-dl.ti.com/processor-sdk-rtos/esd/docs/06_03_00_106/rtos/index_how_to_guides.html#adding-ipc-to-an-existing-ti-rtos-application-on-slave-cores

Install tools

  • Install Code Composer 9.3.0 or newer (tested with 10.1.0)
  • Download and install PROCESSOR-SDK-RTOS-AM57X (tested with 06_03_00_106) from the https://www.ti.com/tool/PROCESSOR-SDK-AM57X
  • Before using the Processor SDK, we must install its components into Code Composer Studio (CCS). Typically – if you chose to install the Software Development Kit (SDK) into the default $HOME/ti or C:\ti location – CCS will automatically detect the new products the next time it is opened and prompt you to install them. If you are not prompted to install the new products, you can do so manually through the Window –> Preferences –> Code Composer Studio –> Products menu. This menu will allow you define product discovery paths and rediscover, install, and unistall products.
    For more info on setting up CCS. Check out Setup CCS for EVM and Processor-SDK RTOS

Example project

TODO Internal link:
https://gitlab.syr.criticallink.com/soms/mitysom-am57x/rtos_template_app_am572x_c66_with_ipc/-/tree/master

Add IPC to RTOS template app

  • Import CCS Project (RTOS template app)
    • Project –> Import CCS Projects... menu.
    • Click Browse... to locate the template app which can be found at: processor_sdk_rtos_<platform>_<version>/demos/rtos_template_app/am572x/evmAM572X/C66.
    • Select "rtos_template_app_am572x_c66" project
    • Check "Copy projects into workspace"
      This will create a copy of the project in your CCS workspace.
    • Click Finish
  • Run build to ensure environment is setup correctly
  • Create copy of project so we can add ipc
    • Right click on "rtos_template_app_am572x_c66" project and select copy
    • Right click and select paste
    • Add "_with_ipc" to project name
    • Click Copy
  • Work with this copy and leave the other project for reference
  • Run build to ensure environment is setup correctly
  • In Project -> Properties
    • General/Products (Tab): Set Platform to "ti.platforms.evmDRA7XX:dsp1" (without quotes)
      Fixes:
      error: ti.trace.SysMin: "/home/hmedev/ti/ipc_3_43_02_04/packages/ti/trace/SysMin.xs", line 51: ti.trace.SysMin : .tracebuf section found, but not in Program.cpu.memoryMap
      Required by IPC. https://e2e.ti.com/support/processors/f/processors-forum/615167/rtos-am5728-spi-driver-for-m4-with-linux-host/2270701#2270701
    • General/Products (Tab): Click Add, select "Inter-processor Communication"
    • Build/C6000 Linker/Basic Options: "Specify output file name": ${ProjName}.xe66
      Linux expects DSP binaries to have xe66 extension, this is just a renamed .out file so its easy to tell between code for DSP and IPU processors
  • Navigate to C:\ti\ipc_3_43_02_04\examples\DRA7XX_linux_elf\ex02_messageq\shared and drag folder into the project under CCS Project Explorer. Select "Copy files and folders"
    TODO: This shared folder should eventually be common between DSP and ARM app
  • Copy in dsp1 files by dragging them to the project under CCS Project Explorer. Select "Copy files"
    C:\ti\ipc_3_43_02_04\examples\DRA7XX_linux_elf\ex02_messageq\dsp1\Dsp1.cfg
    C:\ti\ipc_3_43_02_04\examples\DRA7XX_linux_elf\ex02_messageq\dsp1\MainDsp1.c
    C:\ti\ipc_3_43_02_04\examples\DRA7XX_linux_elf\ex02_messageq\dsp1\Server.c
    C:\ti\ipc_3_43_02_04\examples\DRA7XX_linux_elf\ex02_messageq\dsp1\Server.h
  • Copy in custom resource table files by dragging them to the project under CCS Project Explorer. Select "Copy files"
    C:\ti\ipc_3_43_02_04\packages\ti\ipc\remoteproc\rsc_table_vayu_dsp.h
    C:\ti\ipc_3_43_02_04\packages\ti\ipc\remoteproc\rsc_types.h
    This step appears to be optional, without this the project fallsback to using the files in their original location. However doing this allows the rsc tables to be customized.
    • In the CCS project, rename rsc_table_vayu_dsp.h to rsc_table_vayu_dsp.c
    • Edit rsc_table_vayu_dsp.c, set this #define before it’s used to select PHYS_MEM_IPC_VRING value
      #define VAYU_DSP_1
      
    • Add this extern declaration prior to the symbol being used
      extern char ti_trace_SysMin_Module_State_0_outbuf__A;
      
  • Rename Dsp1.cfg to ipc.cfg
  • In ipc.cfg:
    • Change path to ipc.cfg.xs
      //var ipc_cfg = xdc.loadCapsule("../shared/ipc.cfg.xs");
      var ipc_cfg = xdc.loadCapsule("shared/ipc.cfg.xs");
      
    • Increase the system stack size
      //Program.stack = 0x1000;
      Program.stack = 0x8000;
      
    • Comment out the following. We’ll be calling this function directly from main.
      //BIOS.addUserStartupFunction('&IpcMgr_ipcStartup');
      
    • Comment out the entire TICK Clock section
      TODO: Why?
      /* --------------------------- TICK --------------------------------------*/
      // var Clock = xdc.useModule('ti.sysbios.knl.Clock');
      // Clock.tickSource = Clock.TickSource_NULL;
      // //Clock.tickSource = Clock.TickSource_USER;
      // /* Configure BIOS clock source as GPTimer5 */
      // //Clock.timerId = 0;
      //
      // var Timer = xdc.useModule('ti.sysbios.timers.dmtimer.Timer');
      //
      // /* Skip the Timer frequency verification check. Need to remove this later */
      // Timer.checkFrequency = false;
      //
      // /* Match this to the SYS_CLK frequency sourcing the dmTimers.
      //  * Not needed once the SYS/BIOS family settings is updated. */
      // Timer.intFreq.hi = 0;
      // Timer.intFreq.lo = 19200000;
      //
      // //var timerParams = new Timer.Params();
      // //timerParams.period = Clock.tickPeriod;
      // //timerParams.periodType = Timer.PeriodType_MICROSECS;
      // /* Switch off Software Reset to make the below settings effective */
      // //timerParams.tiocpCfg.softreset = 0x0;
      // /* Smart-idle wake-up-capable mode */
      // //timerParams.tiocpCfg.idlemode = 0x3;
      // /* Wake-up generation for Overflow */
      // //timerParams.twer.ovf_wup_ena = 0x1;
      // //Timer.create(Clock.timerId, Clock.doTick, timerParams);
      //
      // var Idle = xdc.useModule('ti.sysbios.knl.Idle');
      // var Deh = xdc.useModule('ti.deh.Deh');
      //
      // /* Must be placed before pwr mgmt */
      // Idle.addFunc('&ti_deh_Deh_idleBegin');
      // 
      // /* Configure BIOS clock source as GPTimer5 */
      // Clock.timerId = 4;
      ...
      /*
       * Add function to support Power Management in the Idle loop
       * Must be added after all other Idle functions
       */
      //Idle.addFunc('&IpcPower_idle');
      /*  ============================================================= */
      
      /* Create Timer module */
      //Timer.create(Clock.timerId, Clock.doTick, timerParams);
      
  • Load ipc.cfg before loading app.cfg in main.cfg
    /* Load the ipc specific config file */
    xdc.loadCapsule("ipc.cfg");
    
    /* Load the application specific config file */
    xdc.loadCapsule("app.cfg");
    
  • Ensure ipc.cfg is "Exclude from build" and main.cfg isn't by right clicking on files in Project Explorer
  • Edit Server.c
    //#include "../shared/AppCommon.h"
    #include "shared/AppCommon.h"
  • Rename MainDsp1.c to IpcMain.c
  • Edit IpcMain.c
    The app now has it’s own main(), so rename this one and get rid of args
    //Int main(Int argc, Char* argv[])
    Int ipc_main()
    {
    

    No longer using args so comment these lines
    //taskParams.arg0 = (UArg)argc;
    //taskParams.arg1 = (UArg)argv;
    

    BIOS_start() is done in the app main() so comment it out here
    /* start scheduler, this never returns */
    //BIOS_start();
    

    Comment this out
    //Log_print0(Diags_EXIT, "<-- main:");
    
  • Edit main.c
    Add the following external declarations
    extern Int ipc_main();
    extern Void IpcMgr_ipcStartup(Void);
    

    In main(), add a call to ipc_main() and IpcMgr_ipcStartup() just before BIOS_start()
    ipc_main();
    IpcMgr_ipcStartup();
    
    /* Start BIOS */
    BIOS_start();
    return (0);
    

    Comment out the line that calls Board_init(boardCfg). This call is in the original example because it assumes TI-RTOS is running on the Arm but in our case here, we are running Linux and this call is destructive so we comment it out.
        //status = Board_init(boardCfg);
        //if (status != BOARD_SOK) {
        //    appPrint("\n Error: Board_init failed: error %d", status);
        //}
        //appPrint("\n Board Init complete");
    
  • Edit app.c
    TODO Should we update any of these tasks to work? Gpio should be most feasible
        /* Create task to toggle led */
        // TODO Pick gpio for devkit
        //biosTaskCreate(gpio_toggle_led_task,
        //               "gpio_toggle_led_task",
        //               9, 4096);
    
        /* Create task to exercise uart */
        // TODO UART would need to be pinmuxed in u-boot and disabled in kernel
        //biosTaskCreate(uart_task,
        //               "uart_task",
        //               8, 4096);
    
        /* Create task to test spi interface */
        // TODO SPI would need to be pinmuxed in u-boot and disabled in kernel
        //biosTaskCreate(spi_test_task,
        //               "spi_test_task",
        //               6, 4096);
    
        /* Create task to test spi interface */
        // TODO eeprom code would need to be updated for CL factory config, risk of conflicting with kernel i2c calls though ...
        //biosTaskCreate(i2c_eeprom_read_and_display_task,
        //               "i2c_eeprom_read_and_display_task",
        //               7, 4096);
    

Build and run on devkit

  • Build project
  • Copy to devkit
    host $ scp rtos_template_app_am572x_c66_with_ipc/Debug/rtos_template_app_am572x_c66_with_ipc.xe66 root@<devkit_ip>:
    
  • Disable opencv service
    root@mitysom-am57x:~# systemctl status ti-mct-daemon.service
    root@mitysom-am57x:~# systemctl disable ti-mct-daemon.service
    
  • Symlink dsp1 firmware binary and reload dsp1 firmware
    root@mitysom-am57x:~# ln -sf /home/root/rtos_template_app_am572x_c66_with_ipc.xe66 /lib/firmware/dra7-dsp1-fw.xe66
    root@mitysom-am57x:~# echo 40800000.dsp > /sys/bus/platform/drivers/omap-rproc/unbind
    [ 3327.013418] remoteproc remoteproc2: stopped remote processor 40800000.dsp
    [ 3327.021226] remoteproc remoteproc2: releasing 40800000.dsp
    root@mitysom-am57x:~# echo 40800000.dsp > /sys/bus/platform/drivers/omap-rproc/bind
    [ 3330.396509] omap-rproc 40800000.dsp: ignoring dependency for device, assuming no driver
    [ 3330.404739] omap-rproc 40800000.dsp: ignoring dependency for device, assuming no driver
    [ 3330.414741] omap-rproc 40800000.dsp: assigned reserved memory node dsp1-memory@99000000
    [ 3330.423496] remoteproc remoteproc2: 40800000.dsp is available
    [ 3330.434656] remoteproc remoteproc2: powering up 40800000.dsp
    [ 3330.441268] remoteproc remoteproc2: Booting fw image dra7-dsp1-fw.xe66, size 5263440
    [ 3330.451637] omap-iommu 40d01000.mmu: 40d01000.mmu: version 3.0
    [ 3330.457562] omap-iommu 40d02000.mmu: 40d02000.mmu: version 3.0
    [ 3330.471625] virtio_rpmsg_bus virtio2: rpmsg host is online
    [ 3330.477266] remoteproc remoteproc2: registered virtio2 (type 7)
    [ 3330.483216] remoteproc remoteproc2: remote processor 40800000.dsp is now up
    [ 3330.492252] virtio_rpmsg_bus virtio2: creating channel rpmsg-proto addr 0x3d
    
  • Run messageq ARM demo app
    root@mitysom-am57x:~/ipc-starter/ex02_messageq# /usr/bin/ipc/examples/ex02_messageq/release/app_host DSP1
    --> main:
    --> Main_main:
    --> App_create:
    App_create: Host is ready
    <-- App_create:
    --> App_exec:
    App_exec: sending message 1
    App_exec: sending message 2
    App_exec: sending message 3
    App_exec: message received, sending message 4
    App_exec: message received, sending message 5
    App_exec: message received, sending message 6
    App_exec: message received, sending message 7
    App_exec: message received, sending message 8
    App_exec: message received, sending message 9
    App_exec: message received, sending message 10
    App_exec: message received, sending message 11
    App_exec: message received, sending message 12
    App_exec: message received, sending message 13
    App_exec: message received, sending message 14
    App_exec: message received, sending message 15
    App_exec: message received
    App_exec: message received
    App_exec: message received
    <-- App_exec: 0
    --> App_delete:
    <-- App_delete:
    <-- Main_main:
    <-- main:
    
  • Print dsp1 trace log
    root@mitysom-am57x:~# cat /sys/kernel/debug/remoteproc/remoteproc2/trace0
    [      0.000] 17 Resource entries at 0x95000000
    [      0.000] [t=0x00024032] {module#11}: --> main:
    [      0.000] registering rpmsg-proto:rpmsg-proto service on 61 with HOST
    [      0.000] [t=0x00053e3e] {module#11}: NameMap_sendMessage: HOST 53, port=61
    [      0.000] [t=0x0006db9c] {module#11}: --> smain:
    [      0.000] [t=0x000836be] Server: Server_create: server is ready
    [      0.000] [t=0x00090d50] Server: <-- Server_create: 0
    [      0.000] [t=0x0009b901] Server: --> Server_exec:
    [    124.946] [t=0x00000010:c1b97313] Server: Server_exec: processed cmd=0x0
    [    124.946] [t=0x00000010:c1bac781] Server: Server_exec: processed cmd=0x0
    [    124.946] [t=0x00000010:c1bc0488] Server: Server_exec: processed cmd=0x0
    [    124.947] [t=0x00000010:c1bdcc7c] Server: Server_exec: processed cmd=0x0
    [    124.947] [t=0x00000010:c1bf1436] Server: Server_exec: processed cmd=0x0
    [    124.947] [t=0x00000010:c1c0ace4] Server: Server_exec: processed cmd=0x0
    [    124.947] [t=0x00000010:c1c24c61] Server: Server_exec: processed cmd=0x0
    [    124.947] [t=0x00000010:c1c412ba] Server: Server_exec: processed cmd=0x0
    [    124.947] [t=0x00000010:c1c5b708] Server: Server_exec: processed cmd=0x0
    [    124.948] [t=0x00000010:c1c70a65] Server: Server_exec: processed cmd=0x0
    [    124.948] [t=0x00000010:c1c8a83e] Server: Server_exec: processed cmd=0x0
    [    124.948] [t=0x00000010:c1ca4ac1] Server: Server_exec: processed cmd=0x0
    [    124.948] [t=0x00000010:c1cc0ed1] Server: Server_exec: processed cmd=0x0
    [    124.948] [t=0x00000010:c1cdafda] Server: Server_exec: processed cmd=0x0
    [    124.948] [t=0x00000010:c1cef437] Server: Server_exec: processed cmd=0x2000000
    [    124.949] [t=0x00000010:c1d04ee4] Server: <-- Server_exec: 0
    [    124.949] [t=0x00000010:c1d13188] Server: --> Server_delete:
    [    124.949] [t=0x00000010:c1d261db] Server: <-- Server_delete: 0
    [    124.949] [t=0x00000010:c1d3da04] Server: Server_create: server is ready
    

FAQ:

  • If you get the following error, rebooting seemed to fix the issue
    root@mitysom-am57x:~# /usr/bin/ipc/examples/ex02_messageq/release/app_host DSP1
    --> main:
    Ipc_start: LAD_connect() failed: 4
    Ipc_start failed: status = -1
    <-- main:
    
  • Useful scripts
    root@mitysom-am57x:~# cat rebind_dsp1.sh
    #!/bin/bash
    
    echo 40800000.dsp > /sys/bus/platform/drivers/omap-rproc/unbind
    echo 40800000.dsp > /sys/bus/platform/drivers/omap-rproc/bind
    
    sleep 1
    
    ./trace_dsp1.sh
    root@mitysom-am57x:~# cat trace_dsp1.sh
    #!/bin/bash
    
    cat /sys/kernel/debug/remoteproc/remoteproc2/trace0
    

Go to top
Add picture from clipboard (Maximum size: 1 GB)