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.

TDA4VH-Q1: The Modification of System Memory Map caused build errors

Part Number: TDA4VH-Q1
Other Parts Discussed in Thread: TDA4VH

Hi,

We want to modify the System Memory Map on C7x kernal of TDA4VH.

The initial configuration is like below. And there is no build errors.

But if we want to increase some part of the memory, for example as the figure below, we increased the size of the C7x_1 local heap, all the address after it changed.

And when we build the firmware we got an error like the figure below.

We did some search in the source code but did not find the cause.

If we are not misunderstand, the C7x is a 64bit kernal, and the memory given could be larger than 2GB.

Can anyone help us with this problem?

Best regards,

Feng

  • file:///Z:/ti-processor-sdk-rtos-j784s4-evm-08_06_01_03/psdk_rtos/docs/user_guide/developer_notes_memory_map.html 

    https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1186433/faq-tda4vm-c7x-compiler-status-on-address-beyond---2gb 

    Did you read those two links and follow the instructions there? I think the 2nd ticket described in FAQ manner is exactly what you need to do to resolve this issue.  

  • We tried using “extern uint8_t g_ddr_local_mem[DDR_HEAP_MEM_SIZE]” inside appInit()  of vision_apps/platform/j784s4/rtos/common/app_init.c , and directly adopt the _symal (g_ddr_local_mem) report cannot find the _symal() function declaration,

    Terminal prompt  error: implicit declaration of function '_symval' is invalid in C99 [-Werror, -Wimplicit-function-declaration]

    and the problem cannot be solved through the following method:

    https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1241130/ti-clang-v2-1-3-lts-_symval-implicit-declaration/4692538?tisearch=e2e-sitesearch&keymatch=%23define%20LINKER_SYMBOL%20%28%28uintptr_t%29%26linker_symbol%29#4692538

    The following figure specifically mean using macros for replacement or control? Please provide a detailed explanation of the specific modification method. 

    Use LINKER_SYMBOL wherever you currently use _symval(linker_symbol)

    Thanks.

  • This ...

    directly adopt the _symal (g_ddr_local_mem) report cannot find the _symal() function declaration

    ... is because of a spelling error.  It is spelled _symval.  For details on using _symval with the C7000 compiler, please search the C7000 compiler manual for the sub-chapter titled Linker Symbols.

    This ...

    error: implicit declaration of function '_symval' is invalid in C99 [-Werror, -Wimplicit-function-declaration]

    ... happened while building with the C7000 compiler?  If so, for that source file, please follow the directions in the article How to Submit a Compiler Test Case.

    That problem, and the associated workaround, is specific to a different compiler named tiarmclang.  Please ignore it.

    Thanks and regards,

    -George

  • Thank you for your reply. The spelling of '_symal' above is incorrect here, and '_symval' is used in the code.

    I have read 12.6.1 to 12.6.6 of the C7000 compiler manual and tried the methods  in 12.6.4 and 12.6.6, but I have the following issues:

    1.How does this approach solve the problem of "error: implicit declaration of function '_symval' is invalid in C99"? In addition, we need to operate on the array "g_ddr_local_mem [DDR_HEAP_MEM-SIZE]" and how to adapt it.

    2.When we directly use 'extern uint8_t g_ddr_local_mem[DDR_HEAP_MEM-SIZE]', the following error will be reported, indicating that it is a related error of tiarmclang

    3.Using the method in 12.6.6 Week Symbols, setting 'extern attribute_ (week)) uint8_t g_ddr_local_mem [DDR_HEAP_MEM-SIZE]' can make the program compile successfully, but after replacing the C7 firmware, the tiovx program cannot perform model inference and the actual memory remains unchanged.

    Memory situation of native TDA4VH:

    Memory situation after replacing C7 firmware and restarting TDA4VH:

     

    Please provide an example of modifying to increase memory, such as how to increase the 64MB of "DDR_C7X_1_LOCAL_HEAP" and "DDR_C7X_1_SCRATCH" to 256MB.

    Thank you very much. Looking forward to your reply.

  • How does this approach solve the problem of "error: implicit declaration of function '_symval' is invalid in C99"?

    To explain or resolve this problem, I need to reproduce it.  For the source file that is being built when this occurs, please follow the directions in the article How to Submit a Compiler Test Case.  

    As for the rest of your questions, I lack needed expertise.  So, I'll notify other experts on TDA4VH about this thread.

    Thanks and regards,

    -George

  • Thank you for your reply. We use the psdk version as follows:

    PSDK : RTOS 08.05.00.11   Linux: 08.05.00.08

    To reproduce the problem, you can directly add the following code (12.6.4 example code) to the appInit() function in vision_apps/platform/j784s4/rtos/common/app_init.c

    This issue was reported during the compilation of vision_apps' error: implicit declaration of function' _symval 'is invalid in C99'.

    In addition, which header file or dependency library defines the _symval function. Can directly referencing header files solve this problem.

    Thanks

  • Hi, 

    I was able to find the root cause of this error 

    g_ddr_local_mem is used by the R5 core too in app_init.c

    so for this region you must put the _symval() under #if defined as shown below

    This is not required for g_ddr_scratch_mem or non_cache_mem as these part of the code are only accessible by C7x core, hence you did not see the error for these variables.

    Please do the above change and this should fix the issue.

    Regards,

    Nikhil

  • Hi,

    Thank you for your reply. The method you provided can solve the function problem, 'error: implicit declaration of function'_ Symval 'is invalid in C99'.


    However, the issue of memory modification has not been resolved, as shown in the red box below. In the testing, we only modified the value of c7x_1_ddr_local_heap_size (in vision_apps/platform/j784s4/rtos/gen_linker_mem_map.py)  to increase from 64MB to 256MB. Do you have any solutions to this problem.

    Please provide an example of modifying to increase memory, such as how to increase the 64MB of "DDR_C7X_1_LOCAL_HEAP" and "DDR_C7X_1_SCRATCH" to 256MB.

    Thank you very much. Looking forward to your reply.

    Jianfei

  • Hi Jianfei,

    As you increased the c7x_1_ddr_local_heap_size, the starting address of scratch memory and all the other memories after this region also moved by 256MB. Because of which it would also be 2GB away from it's respective code region in the lower DDR memory.

    Hence you would have to add symval for scratch_mem and non-cache memory as well

    Regards,

    Nikhil

  • Hi Nikhil,

    Thank you for your reply. The above method can effectively solve the above problem.

    But in the actual testing process using TDA4VH, the actual memory remains unchanged after replacing the C7 firmware, the memory situation is shown in the following figure.

    (1)Memory situation of native TDA4VH:

    (2)Memory situation after replacing C7 firmware and restarting TDA4VH:

    By running the "app_perf.out" program to check the memory modification status, it was found that the memory has been modified, as shown in the following figure. Why does the memory usage display unchanged above?

    (1)Memory situation of native TDA4VH C7X_4:

    (2) after replacing C7 firmware:

    In addition, the above modification method did not achieve our goal. The purpose of increasing memory is to solve the problem of our Tiovx program running stuck. The specific problem analysis is as follows:

    We use the following onnx model to run tests on TDA4 VH, and each time it gets stuck in the 21st layer "TIDL_ConvolutionLayer" and cannot continue running the subsequent layers. By analyzing that the macs value of this layer is one order of magnitude larger than that of other layers, it is speculated that the program is stuck due to the inability to perform such large calculations due to a memory of 64MB. (The same model can run normally on the TDA4 VM. DDR_C7X_1_SCRATH in the VM is 560MB, and DDR_C7X_1_LOCAL_HEAP is 256MB)

    At the same time, we attempted to reduce the channel size of the onnx model to make the MACS values smaller, as shown in the following figure. The program can run all layers normally without getting stuck.

    So we want to solve this problem by increasing memory. Do you have any suggestions and solutions for this problem?

    Best regards,

    Jianfei

     

  • Hi Jianfei,

    (1)Memory situation of native TDA4VH:

    (2)Memory situation after replacing C7 firmware and restarting TDA4VH:

    "free" shows the total DDR memory available for Linux. Modifying the C7x heap and scratch region shouldn't affect this value.

    (1)Memory situation of native TDA4VH C7X_4:

    (2) after replacing C7 firmware:

    Yes, this confirms that your memory has been increased.

    In addition, the above modification method did not achieve our goal. The purpose of increasing memory is to solve the problem of our Tiovx program running stuck. The specific problem analysis is as follows:

    Yes, this looks like the memory provided is not enough. Now since you are able to increase the memory successfully, could you increase the heap and scratch of C7x core that you are using so that there is enough memory for the model?

    Regards,

    Nikhil