L2 memory in SC571

Dear all,

    Recently I tested the l2 memory in my project, I found that the memory browser in CCES2.8.2 can't display the right data defined in l2, unless I add a printf() function after anywhere I change the data values.  It's inconvenient to debug the project.

    Now, here is my problem. I want to use l2 memory to store some datas, which will be shared both by core1 and core2. I realized that MCAPI can do this job, but I think MCAPI is suitable for few datas transmission, however in my project, a lot of datas need to be shared between core1 and core2, is there any other way to do this job?

    In core2 project, I have tried to define some params in l2 memory. Then In core1, I read the address of params defined in l2, but I can't get the right values, how can I directly read from l2 memory to get the values defined in core2?

    Thanks for help! 

Parents
  • 0
    •  Analog Employees 
    on Feb 2, 2021 8:06 AM 2 months ago

    Hi,

    We recommend you to refer the below thread which will be helpful to you. In that you can focus on Mr.Kenny's reply.
    ez.analog.com/.../structure-in-memory-accessible-by-all-three-cores


    Regards,
    Nishanthi.V

  • Hi,

    I have tested the RESOLVE command to share datas, it's much helpful.

    However, I don't know how to share a structure between sharc cores. in command RESOLVE(x., "../../Test_Core1/Release/Test_Core1.dxe"), if I change param x from int to a structure type, CCES will compile error.

    Could you please refer an example of structure sharing using RESOLVE command?

    Thank you very much! 

  • +1
    •  Analog Employees 
    on Feb 23, 2021 4:39 PM 1 month ago in reply to Foster

    You need to ensure you use the 'mangled' assembly name of the symbol and that symbol, also the symbol must be globally defined. The elfsyms utility might be useful for getting the symbol names and addresses that you want to resolve. See the CCES help for elfsyms details.

    A small example source to demonstrate RESOLVE is:

    #include <stdio.h>
    #include <sys/adi_core.h>

    typedef struct s {
      int i;
      char c;
      float f;
    } a_shared_struct_ty;

    #ifdef CORE1
    /* Define an instance of a_shared_struct_ty when building for CORE1 */
    a_shared_struct_ty a_shared_struct = {1, 'x', 3.14f};
    #else
    /* Other cores use a reference. */
    extern a_shared_struct_ty a_shared_struct;
    #endif

    int main(void) {
      printf("Hello from core %d\n"
              "&a_shared_struct = 0x%08x\n", adi_core_id(), &a_shared_struct);
      return 0;
    }

    The core 1 build simply has to ensure to define CORE1 macro as used above. This happens automatically in CCES projects.
    The core 2 build will need to instead define CORE2 and link using a modified LDF to include your RESOLVE:

    $ diff -u ...snip... SHARC/ldf/ADSP-SC573.ldf modified-SC573.ldf
    --- SHARC/ldf/ADSP-SC573.ldf 2020-08-19 09:15:34.000000000 +0100
    +++ modified-SC573.ldf 2021-02-23 16:33:09.478285000 +0000
    @@ -536,6 +536,10 @@
    #endif
    ENTRY(___lib_start)

    +#if !defined(CORE1)
    + RESOLVE(a_shared_struct., core1.dxe)
    +#endif
    +
    SECTIONS
    {

    To check this works I built and run the example for each core as shown below:

    ssmith2@SSMITH2-L02 ~/tmp/resolve_example
    $ /cygdrive/c/analog/cces2.9.4/cc21k.exe -proc ADSP-SC573 core.c -DCORE1 -o core1.dxe

    ssmith2@SSMITH2-L02 ~/tmp/resolve_example
    $ /cygdrive/c/analog/cces2.9.4/System/chipfactory.exe -quiet -proc ADSP-SC573 1:core1.dxe
    Hello from core 1
    &a_shared_struct = 0x002411e8

    ssmith2@SSMITH2-L02 ~/tmp/resolve_example
    $ /cygdrive/c/analog/cces2.9.4/cc21k.exe -proc ADSP-SC573 core.c -DCORE2 -flags-link -MDCORE2 -T modified-SC573.ldf -o core2.dxe

    ssmith2@SSMITH2-L02 ~/tmp/resolve_example
    $ /cygdrive/c/analog/cces2.9.4/System/chipfactory.exe -quiet -proc ADSP-SC573 2:core2.dxe
    Hello from core 2
    &a_shared_struct = 0x002411e8

    Regards,
    Stuart.




Reply
  • +1
    •  Analog Employees 
    on Feb 23, 2021 4:39 PM 1 month ago in reply to Foster

    You need to ensure you use the 'mangled' assembly name of the symbol and that symbol, also the symbol must be globally defined. The elfsyms utility might be useful for getting the symbol names and addresses that you want to resolve. See the CCES help for elfsyms details.

    A small example source to demonstrate RESOLVE is:

    #include <stdio.h>
    #include <sys/adi_core.h>

    typedef struct s {
      int i;
      char c;
      float f;
    } a_shared_struct_ty;

    #ifdef CORE1
    /* Define an instance of a_shared_struct_ty when building for CORE1 */
    a_shared_struct_ty a_shared_struct = {1, 'x', 3.14f};
    #else
    /* Other cores use a reference. */
    extern a_shared_struct_ty a_shared_struct;
    #endif

    int main(void) {
      printf("Hello from core %d\n"
              "&a_shared_struct = 0x%08x\n", adi_core_id(), &a_shared_struct);
      return 0;
    }

    The core 1 build simply has to ensure to define CORE1 macro as used above. This happens automatically in CCES projects.
    The core 2 build will need to instead define CORE2 and link using a modified LDF to include your RESOLVE:

    $ diff -u ...snip... SHARC/ldf/ADSP-SC573.ldf modified-SC573.ldf
    --- SHARC/ldf/ADSP-SC573.ldf 2020-08-19 09:15:34.000000000 +0100
    +++ modified-SC573.ldf 2021-02-23 16:33:09.478285000 +0000
    @@ -536,6 +536,10 @@
    #endif
    ENTRY(___lib_start)

    +#if !defined(CORE1)
    + RESOLVE(a_shared_struct., core1.dxe)
    +#endif
    +
    SECTIONS
    {

    To check this works I built and run the example for each core as shown below:

    ssmith2@SSMITH2-L02 ~/tmp/resolve_example
    $ /cygdrive/c/analog/cces2.9.4/cc21k.exe -proc ADSP-SC573 core.c -DCORE1 -o core1.dxe

    ssmith2@SSMITH2-L02 ~/tmp/resolve_example
    $ /cygdrive/c/analog/cces2.9.4/System/chipfactory.exe -quiet -proc ADSP-SC573 1:core1.dxe
    Hello from core 1
    &a_shared_struct = 0x002411e8

    ssmith2@SSMITH2-L02 ~/tmp/resolve_example
    $ /cygdrive/c/analog/cces2.9.4/cc21k.exe -proc ADSP-SC573 core.c -DCORE2 -flags-link -MDCORE2 -T modified-SC573.ldf -o core2.dxe

    ssmith2@SSMITH2-L02 ~/tmp/resolve_example
    $ /cygdrive/c/analog/cces2.9.4/System/chipfactory.exe -quiet -proc ADSP-SC573 2:core2.dxe
    Hello from core 2
    &a_shared_struct = 0x002411e8

    Regards,
    Stuart.




Children
No Data