DSP Validation on Beagleboard With Rowboat-Eclair-DSP

Overview: This article focuses on the validation of DSP on beagleboard with Rowboat-eclair. For more detail of building the binary code, please refer to http://code.google.com/p/rowboat/wiki/DSP.

1. Preparation
    apt-get install expect

2. Rowboat Envrionment Setup
    2.1 Checkout the source code from repository
    mkdir ~/rowboat-android-eclair
    cd ~/rowboat-android-eclair
    repo init -u git://gitorious.org/rowboat/manifest.git -m rowboat-eclair-dsp.xml
    repo sync

    cd ~/rowboat-android-eclair
    ./prepare
    make TARGET_PRODUCT=beagleboard BUILD_WITH_GST=true -C external/ti-dsp clean

    2.2 Patching the code:

    1) In the prebuild cs.x64P the CHNL option is disabled. So we disable the CHNL in the compilation of GPP code. It seems that this only affects the communication between DSP and GPP in 3.2, and does not affect video playback

        vi ~//rowboat-android-eclair/external/ti-dsp/Makefile
     -  DSPLINK_CONFIG := --platform=OMAP3530 --nodsp=1 --dspcfg_0=OMAP3530SHMEM --dspos_0=DSPBIOS5XX --gppos=OMAPLSP --comps=ponslrmc --trace=0
     +  DSPLINK_CONFIG := --platform=OMAP3530 --nodsp=1 --dspcfg_0=OMAP3530SHMEM --dspos_0=DSPBIOS5XX --gppos=OMAPLSP --comps=ponslrm --trace=0

    2) Customize the CMEM pool. For 1024*768 JPEG encode/decode test, it requires pool size of 1180248.
        vi ~/rowboat-android-eclair/vendor/ti/beagleboard/init.rc
      -  insmod /system/ti-dsp/cmemk.ko "phys_start=0x85800000 phys_end=0x86800000 pools=30x8192,8x131072,4x829440,1x5250000,1x1429440,1x256000 allowOverlap=1"
      + insmod /system/ti-dsp/cmemk.ko "phys_start=0x85800000 phys_end=0x86800000 pools=30x8192,8x131072,4x829440,1x5250000,1x1429440,1x256000,1x1180248 allowOverlap=1"
     
    2.3 Compile the code
    make TARGET_PRODUCT=beagleboard BUILD_WITH_GST=true dvsdk
  
    2.4 Copy the code to the root partition of the MMC card

    sudo cp -r root/* /media/root
    sudo cp -r system /media/root

    NOTE : While you can create an root filesystem with following steps, it is not recommended during development process because the creation of the rootfs.tar.bz2 is rather slow.
   
    cd ~/rowboat-android/out/target/product/beagleboard
    mkdir android_rootfs
    cp -r root/* android_rootfs
    cp -r system android_rootfs
    sudo ../../../../build/tools/mktarball.sh ../../../host/linux-x86/bin/fs_get_stats android_rootfs . rootfs rootfs.tar.bz2
        sudo tar jxfv rootfs.tar.bz2 --numeric-owner -C /media/root
        sudo unmount -a

    2.5 Beagleboard Configuration:
    setenv bootargs  'androidboot.console=ttyS2 console=tty0 console=ttyS2,115200n8 root=/dev/mmcblk0p2 rw init=/init rootwait omap-dss.def_disp=dvi omapfb.video_mode=1024x768MR-16@60  mdev -s mem=88M@0x80000000 mem=128M@0x88000000'

3. DSP Validation

    3.1 Communication between DSP and GPP
   
    mkdir ~/rowboat-android-eclair/out/target/product/beagleboard/root/lib
       
    Add following lines to the end of ~/rowboat-android/external/ti-dsp/Makefile :
    cp ~/rowboat-android-eclair/external/ti-dsp/dvsdk_3_00_02_44/dsplink_1_61_03/packages/dsplink/gpp/export/BIN/Linux/OMAP3530/DEBUG/*  $(ANDROID_ROOT_DIR)/out/target/product/$(TARGET_PRODUCT)/root/test -rf
    cp ~/rowboat-android-eclair/external/ti-dsp/dvsdk_3_00_02_44/dsplink_1_61_03/packages/dsplink/dsp/export/BIN/DspBios/OMAP3530/OMAP3530_0/DEBUG/* $(ANDROID_ROOT_DIR)/out/target/product/$(TARGET_PRODUCT)/root/test -rf
    cp ~/rowboat-android-eclair/external/ti-dsp/dvsdk_3_00_02_44/linuxlibs/lib/* $(ANDROID_ROOT_DIR)/out/target/product/$(TARGET_PRODUCT)/root/lib -rf
        cd ~/rowboat-android-eclair/external/ti-dsp/

    Reset the beagleboard, when the SD is mounted:
    cd /test
    ./messagegpp ./message.out 1000

    Normally you will see the following information printed out:
    ========== Sample Application : MESSAGE ==========
    Entered MESSAGE_Create ()
    Leaving MESSAGE_Create ()
    Entered MESSAGE_Execute ()
    Transferring 1000 iterations took 0 seconds 171753 microseconds.
    RoundTrip Time for 1 message is 171 microseconds.
    Leaving MESSAGE_Execute ()
    Entered MESSAGE_Delete ()
    Leaving MESSAGE_Delete ()
    ====================================================

    3.2 Video Loopback

        gst-launch-0.10 videotestsrc num-buffers=100 ! TIDmaiVideoSink accelFrameCopy=false videoOutput=dvi

    3.3 H.264 Encode and Decode

    H.264 encoding: gst-launch-0.10 -v videotestsrc num-buffers=200 ! TIVidenc1 codecName=h264enc engineName=codecServer ! filesink location=sample.264

    H.264 dencoding: gst-launch-0.10 -v filesrc location=sample.264  ! TIViddec2 codecName=h264dec engineName=codecServer ! TIDmaiVideoSink videoStd=VGA videoOutput=DVI accelFrameCopy=FALSE sync=false

    3.4 MPEG4 Encode and Decode
   
    MPEG4 encoding: gst-launch-0.10 -v videotestsrc num-buffers=200 ! TIVidenc1 codecName=mpeg4enc engineName=codecServer ! filesink location=sample.m4v

    MPEG4 dencoding: gst-launch-0.10 -v filesrc location=sample.m4v  ! TIViddec2 codecName=mpeg4dec engineName=codecServer ! TIDmaiVideoSink videoStd=VGA videoOutput=DVI accelFrameCopy=FALSE sync=false

    gst-launch-0.10 filesrc location=/sdcard/a.mp4 ! typefind ! qtdemux name=demux demux.video_00 ! queue ! TIViddec2 ! TIDmaiVideoSink  accelFrameCopy=false videoOutput=dvi

    3.5 JPEG Encode and Decode

    JPEG dencoding: gst-launch-0.10 filesrc location=/sdcard/Frog.jpg ! TIImgdec1 codecName=jpegdec engineName=codecServer  ! filesink location=Frog.uyvy
   
    JPEG encoding: gst-launch-0.10 filesrc location=Frog.uyvy ! TIImgenc1 resolution=1024x768 iColorSpace=UYVY oColorSpace=YUV420P qValue=75 ! filesink location=Frog2.jpeg

    3.6 Resize

    gst-launch-0.10 videotestsrc ! 'video/x-raw-yuv,width=352,height=288' ! TIVidResize ! 'video/x-raw-yuv,width=640,height=480' ! TIDmaiVideoSink videoStd=VGA videoOutput=dvi sync=false
   
    3.7 Sound Loopback

    gst-launch-0.10  audiotestsrc freq=1000 num-buffers=100 ! audioflingersink

    3.8 AAC Decode
   
    gst-launch-0.10 -v filesrc location=/sdcard/Wind.aac !  TIAuddec1 codecName=aachedec engineName=codecServer ! audioflingersink

4. Reference Links
    4.1 Rowboat: http://code.google.com/p/rowboat/wiki/DSP

    4.2 DSP Debugging:

    http://processors.wiki.ti.com/index.php/Enabling_trace_in_DSPLink
    http://processors.wiki.ti.com/index.php/Debugging_DSPLink_using_SET_FAILURE_REASON_prints
    http://processors.wiki.ti.com/index.php/Troubleshooting_DSPLink_configuration_issues
    Example: To decode errors: ~/rowboat-android-eclair/external/ti-dsp/dvsdk_3_00_02_44/dsplink_1_61_03/packages/dsplink/gpp/inc/usr
         To locate errors: /home/rhuang/rowboat-android-eclair/external/ti-dsp/dvsdk_3_00_02_44/dsplink_1_61_03/packages/dsplink/gpp/export/INCLUDE/Linux/OMAP3530/usr/_signature.h

        To enable gstreamer/codec engine/DMAI debugging:
        export GST_DEBUG=3
        export CE_DEBUG=3

    4.3
    http://processors.wiki.ti.com/index.php/Determining_DSPLink_shared_memory_size_requirements
    http://processors.wiki.ti.com/index.php/Changing_DSPLink_Memory_Map
    http://processors.wiki.ti.com/index.php/Changing_the_DVEVM_memory_map
    http://pixhawk.ethz.ch/tutorials/omap/dsplink/memorymap

    4.4 TI Gstreamer
    https://gstreamer.ti.com/gf/project/gstreamer_ti/forum/
    http://processors.wiki.ti.com/index.php/Example_GStreamer_Pipelines#OMAP35x

    4.5 OMAP3530 DSP Validation
    http://groups.google.com/group/rowboat/browse_thread/thread/b34f93186a2db9c9
    http://tw.myblog.yahoo.com/stevegigijoe/article?mid=181&prev=211&next=175&l=f&fid=7
    http://groups.google.com/group/rowboat/browse_thread/thread/b34f93186a2db9c9/46f2aa6dccc5046a?q=#46f2aa6dccc5046a
    http://ossie.wireless.vt.edu/trac/wiki/BeagleBoard_CodecEngine

5. Trouble Shooting

    5.1 Problem Symptom: PROC_load failed with DSP_EMEMORY error
    Possible cause: The DSP executable size is too big and heap memory is not available. Recheck the system heap size configuration. That is the pool allocation of CMEM.

    5.2 Problem symptom:
    # gst-launch-0.10 filesrc location=Frog.uyvy ! TIImgenc1 resolution=1024x768 iColorSpace=UYVY oColorSpace=YUV420P qValue=75 ! filesink location=Frog2.jpeg
    (gst-launch-0.10:998): GStreamer-WARNING **: Failed to load plugin '/system/plugins/libgstvideotestsrc.so': Cannot load library: get_lib_extents[706]:   997 - /system/plugins/libgstvideotestsrc.so is not a valid ELF object
    (gst-launch-0.10:997): GStreamer-WARNING **: Failed to load plugin '/system/plugins/libgstvideotestsrc.so': Cannot load library: get_lib_extents[706]:   997 - /system/plugins/libgstvideotestsrc.so is not a valid ELF object

    Solution: It seems that gstreamer is not stable sometimes. You need to reboot the beagleboard

    5.3 Dsp configuation mismatch

    # ./messagegpp ./message.out 10
    ========== Sample Application : MESSAGE ==========
    Entered MESSAGE_Create ()
    DSP-side configuration mismatch/failure
    0              -> success
    Positive value -> DSP-side failure code.
    (Uint32) -1    -> DSP-side component was not initialized.

        ProcId received : 0, Expected : 0
        DRV configuration status    [0x0]
        IPS configuration status    [0x0]
        POOL configuration status   [0x0]
        MPCS configuration status   [0x0]
        MPLIST configuration status [0x0]
        MQT configuration status    [0x0]
        DATA configuration status   [0xffffffff]   
        RINGIO configuration status [0x0]
    PROC_start () failed. Status = [0x80008052]
    Leaving MESSAGE_Create ()
    Entered MESSAGE_Delete ()
    Assertion failed (IS_VALID_MSGQ (msgqQueue)). File : msgq.c Line : 484
    MSGQ_release () failed. Status = [0x8000800b]
    Leaving MESSAGE_Delete ()

       Solution: The reason refer to http://processors.wiki.ti.com/index.php/Troubleshooting_DSPLink_configuration_issues. The problem is solved with step 2 in 2.2

6. Steps to compile the kernel only:
    $ cd ~/rowboat-android-eclair
    $ export PATH=${PWD}/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin:$PATH
    $ cd kernel/
    $ make ARCH=arm omap3_beagle_android_defconfig
    $ make ARCH=arm CROSS_COMPILE=arm-eabi- uImage -j2