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.

Linux: How can i build CMEM.

Tool/software: Linux

Hi,

I'm trying to build CMEM on TI TDA2x board. 

i succeed to boot the board but there are not /proc/cmem. (makeconfig: tda2xx_evm_linux_all)

So, i tried to build CMEM following your OpenCL guide document.

First, i used command line to install cmemk.ko using ./load_ocl_kos.sh file.

However, it returns this error message.

--------------------------------------------------------------------------------------------------------------------------------------------

Opened log file: lad.txt

numProcessors = 5 id = 0 baseId = 0

[ 954.833540] CMEMK module: reference Linux version 4.4.84
Spawned daemon: /usr/bin/lad_dra7xx

[ 954.841886] CMEMK Error: Failed to request_mem_region(0xa9000000, 0x4000000)
insmod: ERROR: could not insert module /opt/vision_sdk/cmemk.ko: Bad address
insmod: ERROR: could not load module /opt/vision_sdk/debugss_kmodule.ko: No such file or directory
insmod: ERROR: could not load module /opt/vision_sdk/gdbserverproxy.ko: No such file or directory

--------------------------------------------------------------------------------------------------------------------------------------------

Second, i typed command maually not using shell script file. The command is below.

$ /sbin/insmod cmemk.ko pools=4x30000,2x500000 phys_start=0x0 phys_end=0x3000000

However, it also returns another error message.

--------------------------------------------------------------------------------------------------------------------------------------------

[ 1122.801825] CMEMK module: reference Linux version 4.4.84
[ 1122.807984] CMEMK Error: pools specified: must specify both phys_start and phys_end, exiting...
insmod: ERROR: could not insert module cmemk.ko: Invalid parameters

--------------------------------------------------------------------------------------------------------------------------------------------

Third, i tried to modify the device tree following guide. However, there isn't am57xx-evm-cmem.dtsi file.

So, i created that file and included into am57xx-evm.dts and build all again.

However, the /proc/cmem was also not shown.

Please let me know if there are any points that i missed.

Thanks in advance.

  • Hi,

    Please include the below entry in your kernel DTB.

    &reserved_mem {
    cmem_shared_region: cmem-memories@ac000000 {
    compatible="shared-dma-pool";
    reg = <0x00 0x9c000000 0x00 0x1000000>; // modify this address and size depending on your requirements. This examples allocates 16MB block from 0x9c000000 - 0x9d000000
    no-map;
    status="okay";
    };
    };

    / {
    cmem {
    compatible = "ti,cmem";
    #address-cells = <1>;
    #size-cells = <0>;
    status = "okay";
    cmem_block_0: cmem_block@0 {
    reg = <0>;
    memory-region = <&cmem_shared_region>;
    };
    };
    };

    After rebuilding the DTB you need to run insmod cmem.ko and it should work.

    Regards
    Shravan

  • Hi, Thanks for answering.

    As your reply, i checked my board uses dra7-evm-infoadas.dtb file and included that entry.

    Now, the command $ insmod cmemk.ko is executed normally and it showed this normal message.

    --------------------------------------------------------------------------------------------------------------------------------

    [ 798.131706] CMEMK module: reference Linux version 4.4.84
    [ 798.138752] allocated heap buffer 0xa9000000 of size 0x3000000
    [ 798.144659] cmemk initialized

    --------------------------------------------------------------------------------------------------------------------------------

    However, i couldn't see the cmem information when i put this command $ cat /proc/cmem.

    That command shows nothing and if i execute a program which it uses cmem, it returns this error message.

    --------------------------------------------------------------------------------------------------------------------------------

    [ 933.270113] CMEMK Error: ALLOCCACHED: invalid pool (0) passed.
    CMEM Error: allocPool: ioctl CMEM_IOCALLOCCACHED failed from pool 0: -1
    TIOCL FATAL: Failed to allocate 0x3000000 from CMEM block 0, allocated 0x0

    --------------------------------------------------------------------------------------------------------------------------------

    Please let me know what causes this problem.

    I'm using board dra7xx.

    Thank you again.

    Yoo

  • Hi Yoo,

    Edited the previous post with the change needed (Typo, it should be reserved_mem and not reserved_memory).

    Regards
    Shravan
  • Hi Sharavan,

    Yes, i corrected that and could see 'insmod cmemk.ko' operate normally.

    But, i faced another problem.

    $ cat /proc/cmem dosen't show any information about cmem.

    Does it indicates cmem is not actually allocated?

    The below is my dts file.

    --------------------------------------------------------------------------------------------------

    #include "dra7-evm.dts"

    #define DISABLE_PRCM(label) &label { ti,no-idle; ti,no-reset-on-init; }
    #define DISABLE_COMPLETE(label) &label { status = "disabled"; ti,no-idle; ti,no-reset-on-init; }
    #define LATE_ATTACH(label) &label { ti,late-attach; ti,no-idle; ti,no-reset-on-init; }

    /* modules used by BIOS, disable from Linux */
    DISABLE_COMPLETE(vip1);
    DISABLE_COMPLETE(vip2);
    DISABLE_COMPLETE(vip3);
    DISABLE_COMPLETE(i2c2);
    DISABLE_COMPLETE(wdt2);
    DISABLE_COMPLETE(vpe);
    DISABLE_COMPLETE(ocmcram1);
    DISABLE_COMPLETE(hdmi);
    DISABLE_COMPLETE(hdmi0);
    DISABLE_COMPLETE(dss);
    DISABLE_COMPLETE(dispc);

    /* modules shared between BIOS and Linux, Do not reset or cutoff clks */
    DISABLE_PRCM(gpio1);
    DISABLE_PRCM(gpio2);
    DISABLE_PRCM(gpio4);
    DISABLE_PRCM(gpio6);

    /* Linux uses first 32 channels, BIOS uses last 32 */
    &edma {
    dma-requests = <32>;
    };

    /* Update the CMA regions for Vision SDK binaries */
    &ipu2_cma_pool {
    reg = <0x0 0x99000000 0x0 0x5000000>;
    };

    &dsp1_cma_pool {
    reg = <0x0 0xa1000000 0x0 0x2000000>;
    };

    &ipu1_cma_pool {
    reg = <0x0 0x9e000000 0x0 0x2000000>;
    };

    &dsp2_cma_pool {
    reg = <0x0 0xa3000000 0x0 0x2000000>;
    };


    /* Additional memory regions required for Vision SDK
    * Keep this in sync with VSDK apps/build/tda2xx/mem_segment_definition_linux.xs
    */
    &reserved_mem {
    cmem_ocmc: cmem@40300000 {
    compatible = "shared-dma-pool";
    reg = <0x0 0x40300000 0x0 0x300000>;
    sram = <&ocmcram1>;
    no-map;
    status = "okay";
    };

    cmem_pool: cmem@A9000000 {
    compatible = "shared-dma-pool";
    reg = <0x0 0xA9000000 0x0 0x2000000>;
    no-map;
    status = "okay";
    };

    vsdk_sr1_mem: vsdk_sr1_mem@84000000 {
    compatible = "shared-dma-pool";
    reg = <0x0 0x84000000 0x0 0x13000000>;
    status = "okay";
    };

    vsdk_sr0_mem: vsdk_sr0_mem@A0000000 {
    compatible = "shared-dma-pool";
    reg = <0x0 0xA0000000 0x0 0x1000000>;
    status = "okay";
    };

    vsdk_eve_mem: vsdk_eve_mem@A5000000 {
    compatible = "shared-dma-pool";
    reg = <0x0 0xA5000000 0x0 0x4000000>;
    status = "okay";
    };

    cmem_shared_region: cmem-memories@ac000000 {
    compatible="shared-dma-pool";
    reg = <0x00 0xA9000000 0x00 0x3000000>; // modify this address and size depending on your requirements. This examples allocates 16MB block from 0x9c000000 - 0x9d000000
    no-map;
    status="okay";
    };
    };

    / {
    cmem {
    compatible = "ti,cmem";
    #address-cells = <1>;
    #size-cells = <0>;
    status = "okay";
    cmem_block_0: cmem_block@0 {
    reg = <0>;
    memory-region = <&cmem_shared_region>;
    };
    };
    };

    &ipu1 {
    /delete-property/ watchdog-timers;
    };

    &ipu2 {
    /delete-property/ watchdog-timers;
    timers= <&timer9> , <&timer11>;
    };

    &dsp1 {
    /delete-property/ watchdog-timers;
    };

    &dsp2 {
    /delete-property/ watchdog-timers;
    };

    --------------------------------------------------------------------------------------------------

    Thank you.

    Yoo

  • Hi Yoo,

    To check if cmem is correctly loaded you would need to run lsmod and check if cmem is listed as a module. If it is, you can assume the cmem module has successfully been inserted with pools/heaps reserved.


    Regards

    Shravan