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: Using TVM for TIDL model export, And Using dlr inference shows Could not load DLR Model

Part Number: TDA4VM

I try to export pointcloud model using TVM into TIDL model, and I export successfully, and generated eploy_lib.so and so on.

Then, I use edgeai-tidl-tools example dlr to run model inference, and I got an error.

root@tda4vm-sk:/workspace/TI/awesome_tda4/tvm_import/runtime/edgeai-tidl-tools# ./bin/Release/dlr_runtime -f /workspace/TI/awesome_tda4/tvm_import/panolidar_export/ -i /workspace/TI/awesome_tda4/pytorch_tidl/images/0_3.bmp -v 1 -c 1

***** Display run Config: start *****
verbose level set to: 1
accelerated mode set to: 1
device mem set to: 1
loop count set to: 1
model path set to:
model artifacts path set to: /workspace/TI/awesome_tda4/tvm_import/panolidar_export/
image path set to: /workspace/TI/awesome_tda4/pytorch_tidl/images/0_3.bmp
device_type set to: cpu
labels path set to: test_data/labels.txt
num of threads set to: 4
num of results set to: 5
num of warmup runs set to: 2

***** Display run Config: end *****
APP: Init ... !!!
MEM: Init ... !!!
MEM: Initialized DMA HEAP (fd=4) !!!
MEM: Init ... Done !!!
IPC: Init ... !!!
IPC: Init ... Done !!!
REMOTE_SERVICE: Init ... !!!
REMOTE_SERVICE: Init ... Done !!!
  2413.533403 s: GTC Frequency = 200 MHz
APP: Init ... Done !!!
  2413.533529 s:  VX_ZONE_INIT:Enabled
  2413.533540 s:  VX_ZONE_ERROR:Enabled
  2413.533587 s:  VX_ZONE_WARNING:Enabled
  2413.534158 s:  VX_ZONE_INIT:[tivxInitLocal:130] Initialization Done !!!
  2413.534458 s:  VX_ZONE_INIT:[tivxHostInitLocal:86] Initialization Done for HOST !!!
  2413.559158 s:  VX_ZONE_ERROR:[ownContextSendCmd:815] Command ack message returned failure cmd_status: -1
  2413.559178 s:  VX_ZONE_ERROR:[ownContextSendCmd:851] tivxEventWait() failed.
  2413.559274 s:  VX_ZONE_ERROR:[ownNodeKernelInit:538] Target kernel, TIVX_CMD_NODE_CREATE failed for node TVMNode
  2413.559288 s:  VX_ZONE_ERROR:[ownNodeKernelInit:539] Please be sure the target callbacks have been registered for this core
  2413.559335 s:  VX_ZONE_ERROR:[ownNodeKernelInit:540] If the target callbacks have been registered, please ensure no errors are occurring within the create callback of this kernel
  2413.559371 s:  VX_ZONE_ERROR:[ownGraphNodeKernelInit:583] kernel init for node 0, kernel com.ti.tvm ... failed !!!
  2413.559445 s:  VX_ZONE_ERROR:[vxVerifyGraph:2055] Node kernel init failed
  2413.559456 s:  VX_ZONE_ERROR:[vxVerifyGraph:2109] Graph verify failed
TVM_RT_OVX: ERROR: Verifying TVM graph ... Failed !!!
TVM_RT_OVX: ERROR: Verify OpenVX graph failed
  2413.561191 s:  VX_ZONE_INIT:[tivxHostDeInitLocal:100] De-Initialization Done for HOST !!!
  2413.565665 s:  VX_ZONE_INIT:[tivxDeInitLocal:193] De-Initialization Done !!!
APP: Deinit ... !!!
REMOTE_SERVICE: Deinit ... !!!
REMOTE_SERVICE: Deinit ... Done !!!
IPC: Deinit ... !!!
IPC: DeInit ... Done !!!
MEM: Deinit ... !!!
MEM: Alloc's: 10 alloc's of 26024488 bytes
MEM: Free's : 10 free's  of 26024488 bytes
MEM: Open's : 0 allocs  of 0 bytes
MEM: Deinit ... Done !!!
APP: Deinit ... Done !!!
[03:06:56] ../src/dlr.cc:343: Error: [03:06:56] ../3rdparty/tvm/src/runtime/contrib/tidl/tidl_runtime.cc:639: Failed to initialize TVMRT for c7xgraph 0

Stack trace:
  [bt] (0) /usr/lib/python3.8/site-packages/dlr/libdlr.so(+0xfcf84) [0xffffa006cf84]
  [bt] (1) /usr/lib/python3.8/site-packages/dlr/libdlr.so(+0x2bbf0) [0xffff9ff9bbf0]
  [bt] (2) /usr/lib/python3.8/site-packages/dlr/libdlr.so(+0xc39e8) [0xffffa00339e8]
  [bt] (3) /usr/lib/python3.8/site-packages/dlr/libdlr.so(+0xfd694) [0xffffa006d694]
  [bt] (4) /usr/lib/python3.8/site-packages/dlr/libdlr.so(+0x6ad98) [0xffff9ffdad98]
  [bt] (5) /usr/lib/python3.8/site-packages/dlr/libdlr.so(+0xfd694) [0xffffa006d694]
  [bt] (6) /usr/lib/python3.8/site-packages/dlr/libdlr.so(+0x141b58) [0xffffa00b1b58]
  [bt] (7) /usr/lib/python3.8/site-packages/dlr/libdlr.so(+0x145eb0) [0xffffa00b5eb0]
  [bt] (8) /usr/lib/python3.8/site-packages/dlr/libdlr.so(+0x147be0) [0xffffa00b7be0]


[03:06:56.000.000000]:ERROR:[runInference:0101] Could not load DLR Model
[03:06:56.000.000028]:ERROR:[main:0409] Failed to run runInference

And I use /opt/vx_app_arm_remote_log.out to get detail error, I got 

[C7x_1 ]   2413.558809 s: << D L O A D >> ERROR: relocation overflow at vaddr 42fc9b4, rtype=28 reloc_value=fffffffffc665fc0
[C7x_1 ]   2413.558965 s:  VX_ZONE_ERROR:[tivxKernelTVMCreate:271] ERROR: Dsp dynamic loader failed.

And if I generate part of my model as follows, and I can generate model and inference model successfully.

So I want to know the reason of why the whole model can not be loaded by dlr.
  • And Sometimes, Error Msg is

    [C7x_1 ]  17278.755664 s: Could not Allocate memory for memtab 7 of size 330552060 in 17
    [C7x_1 ]  17278.755694 s: init_tidl_subgraph: alloc_mem_records failed

  • There are more detail Error info with "export TIDL_RT_DEBUG=3" :

  • Hi Yongchao,

        The model you are trying to run exceeded the available memory that C7x has.  On J721E, the default C7x_1 local heap size is 256MB.  You can look up this value in the psdk rtos vision_apps/platform/j721e/rtos/app_mem_map.h.  On other J7 variants, the default C7x heap size might be 128MB.

    -Yuan

  • /* DDR for c7x_1 for local heap [ size 256.00 MB ] */
    #define DDR_C7X_1_LOCAL_HEAP_ADDR (0x100000000u)
    #define DDR_C7X_1_LOCAL_HEAP_SIZE (0x10000000u)
    

    In File, vision_apps/platform/j721e/rtos/app_mem_map.h I see "DDR for c7x_1 for local heap [ size 256.00 MB ]". So Can I modify it to 1024MB for deploy my model? Or There are any other ways to deploy my model?

  • I modify the related file and I still can not alloc mem which is more than 256MB, My Steps are as follows:

    1. Modify ddr_mem_size_hi = 1*GB; in file gen_linker_mem_map.py

    2. python gen_linker_mem_map.py which will generate k3-j721e-rtos-memory-map.dtsi and c7x_1

    3. Rebuild the dtb and install into SD card

    4. Modify releated file in My project which include linker_mem_map.cmd, j721e_linker_freertos.cmd, main.c, app_mem_map.h

    5. Then compile my project and run in TDA4VM.

    So I wonder if There have some more detail steps to follow? and in c7x_1 file, there has other file generated. if those is necessary?

    The Compiler necessary file and dtsi is uploaded.

    vision_app_1g.zip

    k3-j721e-rtos-memory-map.dtsi.zip

  • Yongchao,
    Is the same log when can't alloc memory?

    I use this SDK ti-processor-sdk-rtos-j721e-evm-08_02_00_05 to try, seems it's normal

    First you need modify this on RTOS SDK

    From af9fc787f6619d2214c69bd25048c4a78239b0d7 Mon Sep 17 00:00:00 2001
    From: Dongkangjia <dongkangjia@ti.com>
    Date: Wed, 7 Sep 2022 21:18:07 +0800
    Subject: [PATCH] add c7 local heap
    
    ---
     vision_apps/platform/j721e/rtos/app_mem_map.h |   4 +-
     .../j721e/rtos/c7x_1/linker_mem_map.cmd       |   4 +-
     .../platform/j721e/rtos/gen_linker_mem_map.py |   8 +-
     .../j721e/rtos/k3-j721e-rtos-memory-map.dtsi  | 296 ++++++++++--------
     .../j721e/rtos/system_memory_map.html         |   4 +-
     5 files changed, 174 insertions(+), 142 deletions(-)
    
    diff --git a/vision_apps/platform/j721e/rtos/app_mem_map.h b/vision_apps/platform/j721e/rtos/app_mem_map.h
    index eec5c15a..993c9e00 100755
    --- a/vision_apps/platform/j721e/rtos/app_mem_map.h
    +++ b/vision_apps/platform/j721e/rtos/app_mem_map.h
    @@ -247,9 +247,9 @@
     #define INTERCORE_ETH_DATA_MEM_ADDR (0xFB800000u)
     #define INTERCORE_ETH_DATA_MEM_SIZE (0x01800000u)
     
    -/* DDR for c7x_1 for local heap [ size 256.00 MB ] */
    +/* DDR for c7x_1 for local heap [ size 512.00 MB ] */
     #define DDR_C7X_1_LOCAL_HEAP_ADDR (0x100000000u)
    -#define DDR_C7X_1_LOCAL_HEAP_SIZE (0x10000000u)
    +#define DDR_C7X_1_LOCAL_HEAP_SIZE (0x20000000u)
     
     
     #endif /* APP_MEM_MAP_H */
    diff --git a/vision_apps/platform/j721e/rtos/c7x_1/linker_mem_map.cmd b/vision_apps/platform/j721e/rtos/c7x_1/linker_mem_map.cmd
    index b86e9ae0..36fd7be3 100644
    --- a/vision_apps/platform/j721e/rtos/c7x_1/linker_mem_map.cmd
    +++ b/vision_apps/platform/j721e/rtos/c7x_1/linker_mem_map.cmd
    @@ -94,6 +94,6 @@ MEMORY
         DDR_SHARED_MEM                    : ORIGIN = 0xB8000000 , LENGTH = 0x20000000
         /* DDR for c7x_1 for Scratch Memory [ size 368.00 MB ] */
         DDR_C7X_1_SCRATCH        ( RWIX ) : ORIGIN = 0xE4000000 , LENGTH = 0x17000000
    -    /* DDR for c7x_1 for local heap [ size 256.00 MB ] */
    -    DDR_C7X_1_LOCAL_HEAP     ( RWIX ) : ORIGIN = 0x100000000 , LENGTH = 0x10000000
    +    /* DDR for c7x_1 for local heap [ size 512.00 MB ] */
    +    DDR_C7X_1_LOCAL_HEAP     ( RWIX ) : ORIGIN = 0x100000000 , LENGTH = 0x20000000
     }
    diff --git a/vision_apps/platform/j721e/rtos/gen_linker_mem_map.py b/vision_apps/platform/j721e/rtos/gen_linker_mem_map.py
    index fc73b4f6..56189e8c 100755
    --- a/vision_apps/platform/j721e/rtos/gen_linker_mem_map.py
    +++ b/vision_apps/platform/j721e/rtos/gen_linker_mem_map.py
    @@ -118,7 +118,7 @@ ddr_mem_size  = 1*GB + 432*MB; # Last 64MB is used by Linux
     
     ddr_mem_addr_hi_phy = 0x880000000;
     ddr_mem_addr_hi = 0x100000000;
    -ddr_mem_size_hi = 256*MB;
    +ddr_mem_size_hi = 512*MB;
     
     msmc_mem_addr = 0x70000000;
     main_ocram_mem_addr = 0x03600000;
    @@ -434,9 +434,7 @@ tiovx_log_rt_mem     = MemSection("TIOVX_LOG_RT_MEM" , "", tiovx_log_rt_mem_addr
     
     ipc_vring_mem      = MemSection("IPC_VRING_MEM"     , "", ipc_vring_mem_addr     , ipc_vring_mem_size     , "Memory for IPC Vring's. MUST be non-cached or cache-coherent");
     ipc_vring_mem.setDtsName("vision_apps_rtos_ipc_memory_region", "vision-apps-rtos-ipc-memory-region");
    -ipc_vring_mem.setAlignment(True)
    -ipc_vring_mem.setPrintCompatibility(False)
    -ipc_vring_mem.setOriginTag(False);
    +
     
     vision_apps_ddr_total  = MemSection("DDR_VISION_APPS_DTS", "", 0                      , 0                      , "DDR for Vision Apps for all sections, used for reserving memory in DTS file");
     vision_apps_ddr_total.concat(app_log_mem);
    @@ -472,7 +470,7 @@ c7x_1_ddr_local_heap_phy  = MemSection("DDR_C7X_1_LOCAL_HEAP", "RWIX", ddr_mem_a
     vision_apps_core_heaps_hi = MemSection("DDR_VISION_APPS_CORE_HEAPS_HI_DTS", "", 0, 0, "Vision Apps Core Heaps in 40bit address range of DDR");
     vision_apps_core_heaps_hi.concat(c7x_1_ddr_local_heap_phy);
     vision_apps_core_heaps_hi.setDtsName("vision_apps_core_heaps_hi", "vision-apps-core-heap-memory-hi");
    -vision_apps_core_heaps_hi.splitOrigin(True)
    +
     
     # This region is for ethernet firmware, multi-core, multi-cast feature
     intercore_eth_desc_mem = MemSection("INTERCORE_ETH_DESC_MEM", "", mcu2_1_ddr_intercore_eth_desc_addr, mcu2_1_ddr_intercore_eth_desc_size, "Inter-core ethernet shared desc queues. MUST be non-cached or cache-coherent");
    diff --git a/vision_apps/platform/j721e/rtos/k3-j721e-rtos-memory-map.dtsi b/vision_apps/platform/j721e/rtos/k3-j721e-rtos-memory-map.dtsi
    index 0f793ebb..d5f61def 100644
    --- a/vision_apps/platform/j721e/rtos/k3-j721e-rtos-memory-map.dtsi
    +++ b/vision_apps/platform/j721e/rtos/k3-j721e-rtos-memory-map.dtsi
    @@ -1,142 +1,176 @@
     
      
      /* 
    -  * IMPORTANT NOTE: Follow below instructions to apply the updated memory map to linux dtsi file, 
    +  * IMPORTANT NOTE: Follow below instructions to apply the updated memory map to linux dts/dtso/dtsi files, 
       * 
       * 1. Copy the memory sections, from the generated dts file, to the file shown below under reserved_memory: reserved-memory { ... } 
    -  *     ${LINUX_KERNEL_PATH}/arch/arm64/boot/dts/ti/k3-j721e-rtos-memory-map.dtsi
    +  *     ${LINUX_KERNEL_PATH}/arch/arm64/boot/dts/ti/k3-j721e-som-p0.dtsi
       * 
    -  * 2. Rebuild the dtb, dtbo from PSDK Linux install directory 
    -  *      make linux-dtbs 
    +  * 2. In file ${LINUX_KERNEL_PATH}/arch/arm64/boot/dts/ti/k3-j721e-vision-apps.dtso
    +  *   - Remove the references to the associated sections.  These sections will have "vision_apps-" appended
    +  *   - For example, if you are updating the section "mcu_r5fss0_core1_dma_memory_region", you will need to remove the following:
    +  *      1. &mcu_r5fss0_core1_dma_memory_region section disabled
    +  *      2. Reserving vision_apps_mcu_r5fss0_core1_dma_memory_region memory
    +  *      3. Setting vision_apps_mcu_r5fss0_core1_dma_memory_region memory region to mcu_r5fss0_core1 node
       * 
    -  * 3. Install the dtb, dtbo to the rootfs/boot folder on SD card 
    -  *      sudo make linux-dtbs_intall; sync 
    +  * 3. The entries are removed since the same are updated in k3-j721e-som-p0.dtsi, hence we should not have duplicate outdated one's 
       * 
    -   */
    +  * 4. Rebuild the dtb, dtbo and use the updated dtb, dtbo files 
    +  *    - In PSDK Linux install directory, doing below should build the dtb and dtbo 
    +  *         make linux-dtbs 
    +  *    - Copy the below updated dtb, dtbo files to "boot/" folder in your target linux SD card filesystem 
    +  *         arch/arm64/boot/dts/ti/k3-j721e-common-proc-board.dtb
    +  *         arch/arm64/boot/dts/ti/k3-j721e-vision-apps.dtbo
    +  */
     
     
    -	vision_apps_mcu_r5fss0_core0_dma_memory_region: vision-apps-r5f-dma-memory@a0000000 {
    -		compatible = "shared-dma-pool";
    -		reg = <0x00 0xa0000000 0x00 0x00100000>;
    -		no-map;
    -	};
    -	vision_apps_mcu_r5fss0_core0_memory_region: vision-apps-r5f-memory@a0100000 {
    -		compatible = "shared-dma-pool";
    -		reg = <0x00 0xa0100000 0x00 0x00f00000>;
    -		no-map;
    -	};
    -	vision_apps_mcu_r5fss0_core1_dma_memory_region: vision-apps-r5f-dma-memory@a1000000 {
    -		compatible = "shared-dma-pool";
    -		reg = <0x00 0xa1000000 0x00 0x00100000>;
    -		no-map;
    -	};
    -	vision_apps_mcu_r5fss0_core1_memory_region: vision-apps-r5f-memory@a1100000 {
    -		compatible = "shared-dma-pool";
    -		reg = <0x00 0xa1100000 0x00 0x00f00000>;
    -		no-map;
    -	};
    -	vision_apps_main_r5fss0_core0_dma_memory_region: vision-apps-r5f-dma-memory@a2000000 {
    -		compatible = "shared-dma-pool";
    -		reg = <0x00 0xa2000000 0x00 0x00100000>;
    -		no-map;
    -	};
    -	vision_apps_main_r5fss0_core0_memory_region: vision-apps-r5f-memory@a2100000 {
    -		compatible = "shared-dma-pool";
    -		reg = <0x00 0xa2100000 0x00 0x01f00000>;
    -		no-map;
    -	};
    -	vision_apps_main_r5fss0_core1_dma_memory_region: vision-apps-r5f-dma-memory@a4000000 {
    -		compatible = "shared-dma-pool";
    -		reg = <0x00 0xa4000000 0x00 0x00100000>;
    -		no-map;
    -	};
    -	vision_apps_main_r5fss0_core1_memory_region: vision-apps-r5f-memory@a4100000 {
    -		compatible = "shared-dma-pool";
    -		reg = <0x00 0xa4100000 0x00 0x01f00000>;
    -		no-map;
    -	};
    -	vision_apps_main_r5fss1_core0_dma_memory_region: vision-apps-r5f-dma-memory@a6000000 {
    -		compatible = "shared-dma-pool";
    -		reg = <0x00 0xa6000000 0x00 0x00100000>;
    -		no-map;
    -	};
    -	vision_apps_main_r5fss1_core0_memory_region: vision-apps-r5f-memory@a6100000 {
    -		compatible = "shared-dma-pool";
    -		reg = <0x00 0xa6100000 0x00 0x00f00000>;
    -		no-map;
    -	};
    -	vision_apps_main_r5fss1_core1_dma_memory_region: vision-apps-r5f-dma-memory@a7000000 {
    -		compatible = "shared-dma-pool";
    -		reg = <0x00 0xa7000000 0x00 0x00100000>;
    -		no-map;
    -	};
    -	vision_apps_main_r5fss1_core1_memory_region: vision-apps-r5f-memory@a7100000 {
    -		compatible = "shared-dma-pool";
    -		reg = <0x00 0xa7100000 0x00 0x00f00000>;
    -		no-map;
    -	};
    -	vision_apps_c66_1_dma_memory_region: vision-apps-c66-dma-memory@a8000000 {
    -		compatible = "shared-dma-pool";
    -		reg = <0x00 0xa8000000 0x00 0x00100000>;
    -		no-map;
    -	};
    -	vision_apps_c66_0_memory_region: vision-apps-c66-memory@a8100000 {
    -		compatible = "shared-dma-pool";
    -		reg = <0x00 0xa8100000 0x00 0x00f00000>;
    -		no-map;
    -	};
    -	vision_apps_c66_0_dma_memory_region: vision-apps-c66-dma-memory@a9000000 {
    -		compatible = "shared-dma-pool";
    -		reg = <0x00 0xa9000000 0x00 0x00100000>;
    -		no-map;
    -	};
    -	vision_apps_c66_1_memory_region: vision-apps-c66-memory@a9100000 {
    -		compatible = "shared-dma-pool";
    -		reg = <0x00 0xa9100000 0x00 0x00f00000>;
    -		no-map;
    -	};
    -	vision_apps_c71_0_dma_memory_region: vision-apps-c71-dma-memory@aa000000 {
    -		compatible = "shared-dma-pool";
    -		reg = <0x00 0xaa000000 0x00 0x00100000>;
    -		no-map;
    -	};
    -	vision_apps_c71_0_memory_region: vision-apps-c71-memory@aa100000 {
    -		compatible = "shared-dma-pool";
    -		reg = <0x00 0xaa100000 0x00 0x04f00000>;
    -		no-map;
    -	};
    -	vision_apps_rtos_ipc_memory_region: vision-apps-rtos-ipc-memory-region {
    -		reg = <0x00 0xb0000000 0x00 0x02000000>;
    -		alignment = <0x1000>;
    -		no-map;
    -	};
    -	vision_apps_memory_region: vision-apps-dma-memory@b2000000 {
    -		compatible = "shared-dma-pool";
    -		reg = <0x00 0xb2000000 0x00 0x06000000>;
    -		no-map;
    -	};
    -	vision_apps_shared_region: vision_apps_shared-memories {
    -		compatible = "dma-heap-carveout";
    -		reg = <0x00 0xb8000000 0x00 0x20000000>;
    -	};
    -	vision_apps_core_heaps_lo: vision-apps-core-heap-memory-lo@d8000000 {
    -		compatible = "shared-dma-pool";
    -		reg = <0x00 0xd8000000 0x00 0x23000000>;
    -		no-map;
    -	};
    -	vision_apps_main_r5fss0_core0_shared_memory_queue_region: vision-apps-r5f-virtual-eth-queues@fb000000 {
    -		compatible = "shared-dma-pool";
    -		reg = <0x00 0xfb000000 0x00 0x00800000>;
    -		no-map;
    -	};
    -	vision_apps_main_r5fss0_core0_shared_memory_bufpool_region: vision-apps-r5f-virtual-eth-buffers@fb800000 {
    -		compatible = "shared-dma-pool";
    -		reg = <0x00 0xfb800000 0x00 0x01800000>;
    -		no-map;
    -	};
    -	vision_apps_core_heaps_hi: vision-apps-core-heap-memory-hi@880000000 {
    -		compatible = "shared-dma-pool";
    -		reg = <0x08 0x80000000 0x00 0x10000000>;
    -		no-map;
    -	};
    +        vision_apps_mcu_r5fss0_core0_dma_memory_region: vision-apps-r5f-dma-memory@a0000000 {
    +            compatible = "shared-dma-pool";
    +            reg = <0x00 0xa0000000 0x00 0x00100000>;
    +            no-map;
    +        };
    +        
    +        vision_apps_mcu_r5fss0_core0_memory_region: vision-apps-r5f-memory@a0100000 {
    +            compatible = "shared-dma-pool";
    +            reg = <0x00 0xa0100000 0x00 0x00f00000>;
    +            no-map;
    +        };
    +        
    +        vision_apps_mcu_r5fss0_core1_dma_memory_region: vision-apps-r5f-dma-memory@a1000000 {
    +            compatible = "shared-dma-pool";
    +            reg = <0x00 0xa1000000 0x00 0x00100000>;
    +            no-map;
    +        };
    +        
    +        vision_apps_mcu_r5fss0_core1_memory_region: vision-apps-r5f-memory@a1100000 {
    +            compatible = "shared-dma-pool";
    +            reg = <0x00 0xa1100000 0x00 0x00f00000>;
    +            no-map;
    +        };
    +        
    +        vision_apps_main_r5fss0_core0_dma_memory_region: vision-apps-r5f-dma-memory@a2000000 {
    +            compatible = "shared-dma-pool";
    +            reg = <0x00 0xa2000000 0x00 0x00100000>;
    +            no-map;
    +        };
    +        
    +        vision_apps_main_r5fss0_core0_memory_region: vision-apps-r5f-memory@a2100000 {
    +            compatible = "shared-dma-pool";
    +            reg = <0x00 0xa2100000 0x00 0x01f00000>;
    +            no-map;
    +        };
    +        
    +        vision_apps_main_r5fss0_core1_dma_memory_region: vision-apps-r5f-dma-memory@a4000000 {
    +            compatible = "shared-dma-pool";
    +            reg = <0x00 0xa4000000 0x00 0x00100000>;
    +            no-map;
    +        };
    +        
    +        vision_apps_main_r5fss0_core1_memory_region: vision-apps-r5f-memory@a4100000 {
    +            compatible = "shared-dma-pool";
    +            reg = <0x00 0xa4100000 0x00 0x01f00000>;
    +            no-map;
    +        };
    +        
    +        vision_apps_main_r5fss1_core0_dma_memory_region: vision-apps-r5f-dma-memory@a6000000 {
    +            compatible = "shared-dma-pool";
    +            reg = <0x00 0xa6000000 0x00 0x00100000>;
    +            no-map;
    +        };
    +        
    +        vision_apps_main_r5fss1_core0_memory_region: vision-apps-r5f-memory@a6100000 {
    +            compatible = "shared-dma-pool";
    +            reg = <0x00 0xa6100000 0x00 0x00f00000>;
    +            no-map;
    +        };
    +        
    +        vision_apps_main_r5fss1_core1_dma_memory_region: vision-apps-r5f-dma-memory@a7000000 {
    +            compatible = "shared-dma-pool";
    +            reg = <0x00 0xa7000000 0x00 0x00100000>;
    +            no-map;
    +        };
    +        
    +        vision_apps_main_r5fss1_core1_memory_region: vision-apps-r5f-memory@a7100000 {
    +            compatible = "shared-dma-pool";
    +            reg = <0x00 0xa7100000 0x00 0x00f00000>;
    +            no-map;
    +        };
    +        
    +        vision_apps_c66_1_dma_memory_region: vision-apps-c66-dma-memory@a8000000 {
    +            compatible = "shared-dma-pool";
    +            reg = <0x00 0xa8000000 0x00 0x00100000>;
    +            no-map;
    +        };
    +        
    +        vision_apps_c66_0_memory_region: vision-apps-c66-memory@a8100000 {
    +            compatible = "shared-dma-pool";
    +            reg = <0x00 0xa8100000 0x00 0x00f00000>;
    +            no-map;
    +        };
    +        
    +        vision_apps_c66_0_dma_memory_region: vision-apps-c66-dma-memory@a9000000 {
    +            compatible = "shared-dma-pool";
    +            reg = <0x00 0xa9000000 0x00 0x00100000>;
    +            no-map;
    +        };
    +        
    +        vision_apps_c66_1_memory_region: vision-apps-c66-memory@a9100000 {
    +            compatible = "shared-dma-pool";
    +            reg = <0x00 0xa9100000 0x00 0x00f00000>;
    +            no-map;
    +        };
    +        
    +        vision_apps_c71_0_dma_memory_region: vision-apps-c71-dma-memory@aa000000 {
    +            compatible = "shared-dma-pool";
    +            reg = <0x00 0xaa000000 0x00 0x00100000>;
    +            no-map;
    +        };
    +        
    +        vision_apps_c71_0_memory_region: vision-apps-c71-memory@aa100000 {
    +            compatible = "shared-dma-pool";
    +            reg = <0x00 0xaa100000 0x00 0x04f00000>;
    +            no-map;
    +        };
    +        
    +        vision_apps_rtos_ipc_memory_region: vision-apps-rtos-ipc-memory-region@b0000000 {
    +            compatible = "shared-dma-pool";
    +            reg = <0x00 0xb0000000 0x00 0x02000000>;
    +            no-map;
    +        };
    +        
    +        vision_apps_memory_region: vision-apps-dma-memory@b2000000 {
    +            compatible = "shared-dma-pool";
    +            reg = <0x00 0xb2000000 0x00 0x06000000>;
    +            no-map;
    +        };
    +        
    +        vision_apps_shared_region: vision_apps_shared-memories {
    +            compatible = "dma-heap-carveout";
    +            reg = <0x00 0xb8000000 0x00 0x20000000>;
    +        };
    +        
    +        vision_apps_core_heaps_lo: vision-apps-core-heap-memory-lo@d8000000 {
    +            compatible = "shared-dma-pool";
    +            reg = <0x00 0xd8000000 0x00 0x23000000>;
    +            no-map;
    +        };
    +        
    +        vision_apps_main_r5fss0_core0_shared_memory_queue_region: vision-apps-r5f-virtual-eth-queues@fb000000 {
    +            compatible = "shared-dma-pool";
    +            reg = <0x00 0xfb000000 0x00 0x00800000>;
    +            no-map;
    +        };
    +        
    +        vision_apps_main_r5fss0_core0_shared_memory_bufpool_region: vision-apps-r5f-virtual-eth-buffers@fb800000 {
    +            compatible = "shared-dma-pool";
    +            reg = <0x00 0xfb800000 0x00 0x01800000>;
    +            no-map;
    +        };
    +        
    +        vision_apps_core_heaps_hi: vision-apps-core-heap-memory-hi@880000000 {
    +            compatible = "shared-dma-pool";
    +            reg = <0x00 0x880000000 0x00 0x20000000>;
    +            no-map;
    +        };
    +        
     
    diff --git a/vision_apps/platform/j721e/rtos/system_memory_map.html b/vision_apps/platform/j721e/rtos/system_memory_map.html
    index 7a7101d1..703bfe1c 100644
    --- a/vision_apps/platform/j721e/rtos/system_memory_map.html
    +++ b/vision_apps/platform/j721e/rtos/system_memory_map.html
    @@ -515,8 +515,8 @@
                 <tr>
                     <td class="tg-6sgx">DDR_C7X_1_LOCAL_HEAP</td>
                     <td class="tg-6sgx">0x100000000</td>
    -                <td class="tg-6sgx">0x10FFFFFFF</td>
    -                <td class="tg-6sgx">256.00 MB</td>
    +                <td class="tg-6sgx">0x11FFFFFFF</td>
    +                <td class="tg-6sgx">512.00 MB</td>
                     <td class="tg-6sgx">RWIX</td>
                     <td class="tg-6sgx">DDR for c7x_1 for local heap</td>
                 </tr>
    -- 
    2.17.1
    

    cd vision_apps

    make sdk -j8

    make linux_fs_install_sd

    Then you need follow this to modify the Linux SDK DTS

    ti-processor-sdk-linux-j7-evm-08_02_00_03/board-support/linux-5.10.100+gitAUTOINC+7a7a3af903-g7a7a3af903/arch/arm64/boot/dts/ti$ git diff k3-j721e-rtos-memory-map.dtsi
    diff --git a/board-support/linux-5.10.100+gitAUTOINC+7a7a3af903-g7a7a3af903/arch/arm64/boot/dts/ti/k3-j721e-rtos-memory-map.dtsi b/board-support/linux-5.10.100+gitAUTOINC+7a7a3af903-g7a7a3af903/arch/arm64/boot/dts/ti/k3-j721e-rtos-memory-map.dtsi
    index 3f5b7c4ca..8d026ee0b 100644
    --- a/board-support/linux-5.10.100+gitAUTOINC+7a7a3af903-g7a7a3af903/arch/arm64/boot/dts/ti/k3-j721e-rtos-memory-map.dtsi
    +++ b/board-support/linux-5.10.100+gitAUTOINC+7a7a3af903-g7a7a3af903/arch/arm64/boot/dts/ti/k3-j721e-rtos-memory-map.dtsi
    @@ -232,7 +232,7 @@
            };
            vision_apps_core_heaps_hi: vision-apps-core-heap-memory-hi@880000000 {
                    compatible = "shared-dma-pool";
    -               reg = <0x08 0x80000000 0x00 0x10000000>;
    +               reg = <0x08 0x80000000 0x00 0x20000000>;
                    no-map;
            };
     };

    At Linux sdk execute 

    make all -j24

    make install

    cp ./targetNFS/boot/* /media/$USER/roofts/boot

  • Hi Yongchao,

        Just want to give you another data point, besides what Kangjia said.

        I tested the following memory map for C7x, shrinked scratch heap from 368MB to 112MB, increased local heap from 256MB to 512MB, so that I kept the "ddr_mem_size_hi" the same.  "ddr_mem_size_hi" needs to reflect the total size of scratch heap and local heap.  See the diff.

    --- gen_linker_mem_map.py.orig	2022-09-06 17:27:52.348303742 -0500
    +++ gen_linker_mem_map.py	2022-09-07 10:29:31.448580699 -0500
    @@ -118,7 +118,7 @@
     
     ddr_mem_addr_hi_phy = 0x880000000;
     ddr_mem_addr_hi = 0x100000000;
    -ddr_mem_size_hi = 624*MB;
    +ddr_mem_size_hi = 624*MB; # now 112+512, previously 368+256
     
     msmc_mem_addr = 0x70000000;
     main_ocram_mem_addr = 0x03600000;
    @@ -284,10 +284,10 @@
     ddr_intercore_eth_data_size = 24*MB;
     
     c7x_1_ddr_scratch_addr     = ddr_mem_addr_hi;
    -c7x_1_ddr_scratch_size     = 368*MB;
    +c7x_1_ddr_scratch_size     = 112*MB;  #368*MB;
     
     c7x_1_ddr_local_heap_addr  = c7x_1_ddr_scratch_addr + c7x_1_ddr_scratch_size;
    -c7x_1_ddr_local_heap_size  = 256*MB;
    +c7x_1_ddr_local_heap_size  = 512*MB;  # 256*MB;
     
     #
     # Create memory section based on addr and size defined above, including
    

        Then you rebuild the sdk in vision_apps and install the updated linux filesystem.

        You can verify the updated change in the c7x firmware map file:

    vision_apps$ head -n 30 out/J7/C71/FREERTOS/release/vx_app_rtos_linux_c7x_1.out.map | tail -n 5
      DDR_SHARED_MEM        0000b8000000   20000000  00000000  20000000  RWIX
      DDR_C7X_1_SCRATCH     000100000000   07000000  07000000  00000000  RWIX
      DDR_C7X_1_LOCAL_HEAP  000107000000   20000000  20000000  00000000  RWIX
    

        "ddr_mem_size_hi" needs to be reflected in the overall system map in the device tree.  Note the size "0x27000000" in "shared-dma-pool" starting at 0x8_8000_0000.  Hence the instructions on rebuilding dtbs.

            vision_apps_core_heaps_hi: vision-apps-core-heap-memory-hi@880000000 {
                    compatible = "shared-dma-pool";
                    reg = <0x08 0x80000000 0x00 0x27000000>;
                    no-map;
            };
    

        Since I kept the overall "ddr_mem_size_hi" the same, I didn't need to update existing dtbs on EVM target filesystem.  If you modified the total size, make the corresponding change in the dtsi file, rebuild dtbs, and copy to your EVM.  Reboot.

        You can verify the carved out "shared-dam-pool" region on EVM by looking at /proc/iomem.  If you modified the total "ddr_mem_size_hi" for C7x, it should be reflected here after you rebuild the dtbs.

    # cat /proc/iomem | grep 880000000
    880000000-8a6ffffff : reserved
    

        Hope this helps.

    -Yuan

  • I Still can not alloc 1G memory after Modify the dtsi and rebuild visionapp, And I use vision_app basic_demo app_mem for alloc mem test <vx_app_arm_mem.out>, The error message is as follows, I alloc 350MB in APP_MEM_HEAP_DDR at each time. And it successes once only.

    root@tda4vm-sk:/opt/out/J7/A72/LINUX/release# ./vx_app_arm_mem.out
    APP: Init ... !!!
    MEM: Init ... !!!
    MEM: Initialized DMA HEAP (fd=4) !!!
    MEM: Init ... Done !!!
    IPC: Init ... !!!
    IPC: Init ... Done !!!
    REMOTE_SERVICE: Init ... !!!
    REMOTE_SERVICE: Init ... Done !!!
      1488.796528 s: GTC Frequency = 200 MHz
    APP: Init ... Done !!!
    APP_MEM: 0: Allocated memory @ 0xffff73960000 of size 367001600 bytes
    APP_MEM: 0: Translated virtual addr = 0xffff73960000 -> phyical addr = b8000000
    APP_MEM: 0: Exported dmaBufId 16 with offset 0
    MEM: ERROR: Alloc failed with status = 12 !!!
    APP_MEM: 1: ERROR: Unable to allocate memory size 367001600 bytes
    MEM: ERROR: Alloc failed with status = 12 !!!
    APP_MEM: 2: ERROR: Unable to allocate memory size 367001600 bytes
    MEM: ERROR: Alloc failed with status = 12 !!!
    APP_MEM: 3: ERROR: Unable to allocate memory size 367001600 bytes
    MEM: ERROR: Alloc failed with status = 12 !!!
    APP_MEM: 4: ERROR: Unable to allocate memory size 367001600 bytes
    MEM: ERROR: Alloc failed with status = 12 !!!
    APP_MEM: 5: ERROR: Unable to allocate memory size 367001600 bytes
    MEM: ERROR: Alloc failed with status = 12 !!!
    APP_MEM: 6: ERROR: Unable to allocate memory size 367001600 bytes
    MEM: ERROR: Alloc failed with status = 12 !!!
    APP_MEM: 7: ERROR: Unable to allocate memory size 367001600 bytes
    MEM: ERROR: Alloc failed with status = 12 !!!
    APP_MEM: 8: ERROR: Unable to allocate memory size 367001600 bytes
    MEM: ERROR: Alloc failed with status = 12 !!!
    APP_MEM: 9: ERROR: Unable to allocate memory size 367001600 bytes
    MEM: ERROR: Alloc failed with status = 12 !!!
    APP_MEM: 10: ERROR: Unable to allocate memory size 367001600 bytes
    MEM: ERROR: Alloc failed with status = 12 !!!
    APP_MEM: 11: ERROR: Unable to allocate memory size 367001600 bytes
    MEM: ERROR: Alloc failed with status = 12 !!!
    APP_MEM: 12: ERROR: Unable to allocate memory size 367001600 bytes
    MEM: ERROR: Alloc failed with status = 12 !!!
    APP_MEM: 13: ERROR: Unable to allocate memory size 367001600 bytes
    MEM: ERROR: Alloc failed with status = 12 !!!
    APP_MEM: 14: ERROR: Unable to allocate memory size 367001600 bytes
    MEM: ERROR: Alloc failed with status = 12 !!!
    APP_MEM: 15: ERROR: Unable to allocate memory size 367001600 bytes
    MEM: ERROR: Alloc failed with status = 12 !!!
    APP_MEM: 16: ERROR: Unable to allocate memory size 367001600 bytes
    MEM: ERROR: Alloc failed with status = 12 !!!
    APP_MEM: 17: ERROR: Unable to allocate memory size 367001600 bytes
    MEM: ERROR: Alloc failed with status = 12 !!!
    APP_MEM: 18: ERROR: Unable to allocate memory size 367001600 bytes
    MEM: ERROR: Alloc failed with status = 12 !!!
    APP_MEM: 19: ERROR: Unable to allocate memory size 367001600 bytes
    APP_MEM: elasped time for data processing is 204243 usecs
    APP_MEM: 0: Free'ed memory @ 0xffff73960000 of size 367001600 bytes
    APP: Deinit ... !!!
    REMOTE_SERVICE: Deinit ... !!!
    REMOTE_SERVICE: Deinit ... Done !!!
    IPC: Deinit ... !!!
    IPC: DeInit ... Done !!!
    MEM: Deinit ... !!!
    MEM: Alloc's: 1 alloc's of 367001600 bytes
    MEM: Free's : 1 free's  of 367001600 bytes
    MEM: Open's : 0 allocs  of 0 bytes
    MEM: Deinit ... Done !!!
    APP: Deinit ... Done !!!

    ddr_mem_addr_hi_phy = 0x880000000;
    ddr_mem_addr_hi = 0x100000000;
    #ddr_mem_size_hi = 256*MB;
    ddr_mem_size_hi = 1*GB;

    I Modify it to 1GB, and Run python gen_linker_mem_map.py, then I update dtsi

    and In my device, I check the DDR_LOCAL_HEAP has been updated by 

    root@tda4vm-sk:/opt/out/J7/A72/LINUX/release# hexdump /proc/device-tree/reserved-memory/vision-apps-core-heap-memory-hi@880000000/reg
    0000000 0000 0800 0080 0000 0000 0000 0040 0000
    0000010

    40xxxxxx means 1G for DDR Local Heap.

    Then I build vision_apps using make vision_apps -j4, and it will generate out file which ./vx_app_arm_mem.out inside.

    Then I coye the out file in TDA4VM device and I run ./vx_app_arm_mem.out , and The message shows as above.

    I heap the file ../../../C71/FREERTOS/release/vx_app_rtos_linux_c7x_1.out.map

    root@tda4vm-sk:/opt/out/J7/A72/LINUX/release# head -n 30 ../../../C71/FREERTOS/release/vx_app_rtos_linux_c7x_1.out.map
    ******************************************************************************
                         C7x Linker Unix v2.1.1
    ******************************************************************************
    >> Linked Fri Sep  9 09:12:15 2022
    
    OUTPUT FILE NAME:   </workspace/ti-processor-sdk-rtos-j721e-evm-08_02_00_05/vision_apps/out/J7/C71/FREERTOS/release/vx_app_rtos_linux_c7x_1.out>
    ENTRY POINT SYMBOL: "_c_int00_secure"  address: 0000aa200000
    
    
    MEMORY CONFIGURATION
    
             name            origin         length     used     unused   attr    fill
    ----------------------  ------------   --------  --------  --------  ----  --------
      L2RAM_C7x_1           000064800000   00070000  00070000  00000000  RWIX
      L1RAM_C7x_1           000064e00000   00004000  00004000  00000000  RWIX
      MSMC_C7x_1            000070020000   007c8000  007c8000  00000000  RWIX
      DDR_C7x_1_IPC         0000aa000000   00100000  00000000  00100000  RWIX
      DDR_C7x_1_RESOURCE_TA 0000aa100000   00000400  00000098  00000368  RWIX
      DDR_C7x_1_BOOT        0000aa200000   00000400  00000080  00000380  RWIX
      DDR_C7x_1_VECS        0000aa400000   00004000  00000880  00003780  RWIX
      DDR_C7x_1_SECURE_VECS 0000aa600000   00004000  00000880  00003780  RWIX
      DDR_C7x_1             0000aa604000   049fc000  00ff1092  03a0af6e  RWIX
      IPC_VRING_MEM         0000b0000000   02000000  02000000  00000000  RWIX
      APP_LOG_MEM           0000b2000000   00040000  00040000  00000000  RWIX
      TIOVX_OBJ_DESC_MEM    0000b2040000   03fa0000  00fc0000  02fe0000  RWIX
      DDR_SHARED_MEM        0000b8000000   20000000  00000000  20000000  RWIX
      DDR_C7X_1_SCRATCH     0000e4000000   17000000  17000000  00000000  RWIX
      DDR_C7X_1_LOCAL_HEAP  000100000000   40000000  40000000  00000000  RWIX

    So Why I can not alloc more memory?

  • The gen_linker_mem_map.py seems different with my.

    Meanwhile, Your DDR_C7X_1_SCRATCH is from 000100000000. However, My DDR_C7X_1_LOCAL_HEAP is from 000100000000

    root@tda4vm-sk:/opt/out/J7/A72/LINUX/release# head -n 30 ../../../C71/FREERTOS/release/vx_app_rtos_linux_c7x_1.out.map
    ******************************************************************************
                         C7x Linker Unix v2.1.1
    ******************************************************************************
    >> Linked Fri Sep  9 09:12:15 2022
    
    OUTPUT FILE NAME:   </workspace/ti-processor-sdk-rtos-j721e-evm-08_02_00_05/vision_apps/out/J7/C71/FREERTOS/release/vx_app_rtos_linux_c7x_1.out>
    ENTRY POINT SYMBOL: "_c_int00_secure"  address: 0000aa200000
    
    
    MEMORY CONFIGURATION
    
             name            origin         length     used     unused   attr    fill
    ----------------------  ------------   --------  --------  --------  ----  --------
      L2RAM_C7x_1           000064800000   00070000  00070000  00000000  RWIX
      L1RAM_C7x_1           000064e00000   00004000  00004000  00000000  RWIX
      MSMC_C7x_1            000070020000   007c8000  007c8000  00000000  RWIX
      DDR_C7x_1_IPC         0000aa000000   00100000  00000000  00100000  RWIX
      DDR_C7x_1_RESOURCE_TA 0000aa100000   00000400  00000098  00000368  RWIX
      DDR_C7x_1_BOOT        0000aa200000   00000400  00000080  00000380  RWIX
      DDR_C7x_1_VECS        0000aa400000   00004000  00000880  00003780  RWIX
      DDR_C7x_1_SECURE_VECS 0000aa600000   00004000  00000880  00003780  RWIX
      DDR_C7x_1             0000aa604000   049fc000  00ff1092  03a0af6e  RWIX
      IPC_VRING_MEM         0000b0000000   02000000  02000000  00000000  RWIX
      APP_LOG_MEM           0000b2000000   00040000  00040000  00000000  RWIX
      TIOVX_OBJ_DESC_MEM    0000b2040000   03fa0000  00fc0000  02fe0000  RWIX
      DDR_SHARED_MEM        0000b8000000   20000000  00000000  20000000  RWIX
      DDR_C7X_1_SCRATCH     0000e4000000   17000000  17000000  00000000  RWIX
      DDR_C7X_1_LOCAL_HEAP  000100000000   40000000  40000000  00000000  RWIX

    So it seems do not work

    gen_linker_mem_map.py.zip

  • I see.  I am working off the develop branches, seems that the memory map has changed since PSDK 8.2 release.

    But the mechanism for changing the memory map should work.  You may already have the updated 1GB C7x_1_local_heap up and running.

    vx_app_arm_mem.out is allocating memory from the "ddr_shared_mem" (512MB by default), not from "c7x_1_ddr_local_heap".  That's why your first 350MB allocated succeeded but the second one failed.

    The error message in your original post is the allocation failure from the "c7x_1_ddr_local_heap".  Now you may try your application again.

    Just to recap:

    - update memory map, rebuild sdk

    - check vx_app_rtos_linux_c7x_1.out.map, make sure the updated vx_app_rtos_linux_c7x_1.out is copied to EVM as the new C7x firmware

    - rebuild dtb/dtbo, copy to EVM /boot

    - reboot EVM, ensure the new reserved memory is in place (check /proc/iomem)

    - test your application

    -Yuan