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.

AM6548: How to create a baremetal application to run on the R5F MCU for MCAN communication?

Part Number: AM6548

Hello,

I want to create a baremetal application to run on the R5F MCU for MCAN communication. 

In the am65xx PDK, there is an example: packages/ti/csl/example/mcan/mcanEvmLoopback.

How can I setup a CCS project to test this example?

My environment is as follows:

Code Composer Studio 9.3.0.00012

PDK: pdk_am65xx_08_00_00_36

Phytec AM65x development board

XDS200 USB JTAG Emulator

Here is what I have done so far:

1. Create a new CSS Hello World project in CSS, change the Linker commander file to PDK/packages/ti/build/am65xx/linker_r5.lds

 

2. Change the ARM Compiler, Processor Options as follows:

3. In ARM Compiler -> Include Options, add PDK\packges

4. In ARM Compiler -> Predefined Symbols, add SOC_AM65XX

5. In ARM Linker -> File Search Path, add the following libraries and paths:

6. Remove the default hello.c file from the project and add the following file:  PDK\packages\ti\csl\example\mcan\mcanEvmLoopback\mcan_evm_loopback_app_main_k3.c

7. I can build the project successfully, and I setup a breakpoint in the code.

8. Then I go to the top menu Run -> Debug, select the CPU MCU_PULSAR_Cortex_R5_0

9. It looks like it's running, but the breakpoint I configured is not working, and there is no output on the Debugger Console.

Could you please let me know what I have missed? Why the configured breakpoint is not working? How could I debug and test the application?

And where can I change the code to make it working with the Phytec board?

Thanks.

  • Hi Kevin,

    Can you pause the core and share the screenshot of Debug window. I want to check trace of APIs called.
    Also, CCS projects are not supported in AM65xx PDK.

    You can use the makefile based build to build your binaries.
    Please follow the procedure below:
    1) Open command window at <PDK_Install_Path>/package
    2) Setup build environment by running pdksetupenv.bat
    3) cd ti/build
    4) gmake BOARD=am65xx_idk CORE=mcu1_0 csl_mcan_evm_loopback_app // This will build the test in release mode
    or
    gmake BOARD=am65xx_idk CORE=mcu1_0 BUILD_PROFILE=debug csl_mcan_evm_loopback_app // This will build the test in debug mode

    Regards,
    Parth

  • Hi Parth,

    Thanks for your reply.

    AM65xx PDK and CCS:

    If CSS projects are not supported in AM65xx PDK, how to debug and test the R5F application? Is there any other way? Are there any documents available?

    I have followed the below documents to setup the CSS project:

    https://e2e.ti.com/support/processors-group/processors/f/processors-forum/875604/am6548-r5f-hello-world

    http://software-dl.ti.com/processor-sdk-rtos/esd/docs/latest/rtos/index_examples_demos.html#id50

    Debug and Breakpoint:

    For the breakpoint issue, below is the screenshot of the debug window:

    After I clicked the suspend button, the screenshot is as follows. It looks like the running is outside of the program code.


    After some tests, I figured out that If I remove the --entry_point definition and the SECTIONS code from the linker_r5.lds file, the breakpoints work.

    That's, for the file PDK\packages\ti\build\am65xx\linker_r5.lds, the original code is as follows:

    /* This is standard linker options used by examples applications and tests    */
    /* Please refer user guide that came with this release for more details       */
    /* on which sections could be used at load time and runtime                   */
    
    
    /* Linker Settings */
    /* Standard linker options */
    --retain="*(.intvecs)"
    --retain="*(.intc_text)"
    --retain="*(.rstvectors)"
    --retain="*(.irqStack)"
    --retain="*(.fiqStack)"
    --retain="*(.abortStack)"
    --retain="*(.undStack)"
    --retain="*(.svcStack)"
    --fill_value=0
    --stack_size=0x2000
    --heap_size=0x1000
    --entry_point=_resetvectors /* Default C RTS boot.asm */
    
    -stack  0x2000              /* SOFTWARE STACK SIZE */
    -heap   0x2000              /* HEAP AREA SIZE */
    
    /* Stack Sizes for various modes */
    __IRQ_STACK_SIZE = 0x1000;
    __FIQ_STACK_SIZE = 0x1000;
    __ABORT_STACK_SIZE = 0x1000;
    __UND_STACK_SIZE = 0x1000;
    __SVC_STACK_SIZE = 0x1000;
    
    
    
    /*----------------------------------------------------------------------------*/
    /* Memory Sections                                                            */
    MEMORY
    {
        /* Refer the user guide for details on persistence of these sections */
        /* Also, when these memories can be used by apps */
        MCU0_ATCM_NOT_USED          (R)     : origin=0x0        length=0x7FFF
        MCU0_BTCM_NOT_USED          (R)     : origin=0x41010000 length=0x7FFF
        /* Used by SBL, can be used after APPs is started */
        MCU_MSRAM_RSVD_UNUSED       (R)     : origin=0x41C00000 length=0x200
        MCU_MSRAM_RSVD_SBL          (RWIX)  : origin=0x41C00200 length=0x3DE00
    
        VECTORS                     (RWIX)  : origin=0x41C3E000 length=0x100
        RESET_VECTORS               (RWIX)  : origin=0x41C3E100 length=0x1000
        OCMRAM                      (RWIX)  : origin=0x41C3F100 length=0x40F00
    
        /* COMPUTE_CLUSTER0_MSMC_SRAM */
        MSMC3                       (RWIX)  : origin=0x70000000 length=0x1EFC00
        /* The origin and length is determined by board cfg, */
        /* refer user guide for details */
        MSMC3_RSVD_DMSC             (RWIX)  : origin=0x701F0000 length=0x1000
    
        DDR0                        (RWIX)  : origin=0x80000000 length=0x7FFFFFE4
    
    }  /* end of MEMORY */
    
    /*----------------------------------------------------------------------------*/
    /* Section Configuration                                                      */
    
    SECTIONS
    {
        .intvecs        : {} palign(8) > VECTORS
        .intc_text      : {} palign(8) > VECTORS
        .rstvectors     : {} palign(8) > RESET_VECTORS
        .bootCode       : {} palign(8) > MSMC3
        .startupCode    : {} palign(8) > MSMC3
        .startupData    : {} palign(8) > MSMC3, type = NOINIT
    
    
        .text    : {} palign(8) > MSMC3
        .const   : {} palign(8) > MSMC3
        .cinit   : {} palign(8) > MSMC3
        .pinit   : {} palign(8) > MSMC3
    
        /* For NDK packet memory, we need to map this sections before .bss*/
        .bss:NDK_MMBUFFER  (NOLOAD) {} ALIGN (128) > DDR0
        .bss:NDK_PACKETMEM (NOLOAD) {} ALIGN (128) > DDR0
    
        .bss    : {} align(8)   > MSMC3
        .far    : {} align(8)   > DDR0
        .data   : {} palign(128)> MSMC3
        .boardcfg_data : {} palign(128) > MSMC3
        .sysmem : {} align(8)   > MSMC3
    
        /* USB ram disk dev-msc example */
        .bss:extMemCache:ramdisk : {} align (32)    > DDR0
    
        /* SA sections */
        .scBufs         : {} align(8)   > DDR0
        .saSrcBuffers   : {} align(8)   > DDR0
        .saDstBuffers   : {} align(8)   > DDR0
    
        /* LLD buffer for benchmarking */
        .benchmark_buffer (NOLOAD) {} ALIGN (8) > DDR0
    
        .stack      : {} align(8)                           > MSMC3  (HIGH)
        .irqStack   : {. = . + __IRQ_STACK_SIZE;} align(8)  > MSMC3  (HIGH)
        RUN_START(__IRQ_STACK_START)
        RUN_END(__IRQ_STACK_END)
    
        .fiqStack  	: {. = . + __FIQ_STACK_SIZE;} align(8)  > MSMC3  (HIGH)
        RUN_START(__FIQ_STACK_START)
        RUN_END(__FIQ_STACK_END)
    
        .abortStack  	: {. = . + __ABORT_STACK_SIZE;} align(8) > MSMC3  (HIGH)
        RUN_START(__ABORT_STACK_START)
        RUN_END(__ABORT_STACK_END)
    
        .undStack  	: {. = . + __UND_STACK_SIZE;} align(8)      > MSMC3  (HIGH)
        RUN_START(__UND_STACK_START)
        RUN_END(__UND_STACK_END)
    
        .svcStack  	: {. = . + __SVC_STACK_SIZE;} align(8)      > MSMC3  (HIGH)
        RUN_START(__SVC_STACK_START)
        RUN_END(__SVC_STACK_END)
    
    
        /* Additional sections settings */
    
    }  /* end of SECTIONS */
    
    /*----------------------------------------------------------------------------*/
    /* Misc linker settings                                                       */
    
    
    /*-------------------------------- END ---------------------------------------*/
    

    I only kept the MEMORY section and removed all other code. The final file is as follows:

    /* Memory Sections                                                            */
    MEMORY
    {
        /* Refer the user guide for details on persistence of these sections */
        /* Also, when these memories can be used by apps */
        MCU0_ATCM_NOT_USED          (R)     : origin=0x0        length=0x7FFF
        MCU0_BTCM_NOT_USED          (R)     : origin=0x41010000 length=0x7FFF
        /* Used by SBL, can be used after APPs is started */
        MCU_MSRAM_RSVD_UNUSED       (R)     : origin=0x41C00000 length=0x200
        MCU_MSRAM_RSVD_SBL          (RWIX)  : origin=0x41C00200 length=0x3DE00
    
        VECTORS                     (RWIX)  : origin=0x41C3E000 length=0x100
        RESET_VECTORS               (RWIX)  : origin=0x41C3E100 length=0x1000
        OCMRAM                      (RWIX)  : origin=0x41C3F100 length=0x40F00
    
        /* COMPUTE_CLUSTER0_MSMC_SRAM */
        MSMC3                       (RWIX)  : origin=0x70000000 length=0x1EFC00
        /* The origin and length is determined by board cfg, */
        /* refer user guide for details */
        MSMC3_RSVD_DMSC             (RWIX)  : origin=0x701F0000 length=0x1000
    
        DDR0                        (RWIX)  : origin=0x80000000 length=0x7FFFFFE4
    
    }  /* end of MEMORY */

    After I made the change, the debugger stops at the main function, the breakpoint works, I can also step into or step over to execute the code. The debug screenshot is as follows. 

    I wonder if you know why the linker commands will cause the problem?  Will changing the linker_r5.lds file cause any other problem?

    It also looks like the linker commands are related to the ti.csl.init.aer5f library. What is the ti.csl.init library for?

    The Board and the Application:

    The application still doesn't work though. The debug was lost (I think the code was crashed) when it executed the following code:

    boardStatus = Board_init(boardCfg);

    But I think it's because the function Board_init is relevant to the board. I am using the Phytec AM65x development board. The PDK only supports the TI AM65x EVM and IDK boards.

  • Hi Kevin,

    If CSS projects are not supported in AM65xx PDK, how to debug and test the R5F application?

    You can build the test in debug mode with the procedure mentioned in the previous post and load the *.xer5f file generated to the R5 core.

    For some reason your code is not reaching to the "main" .

    You can debug this by following the procedure:
    1) Run -> Debug Configurations
    2) Select the target configuration file from list of ccxml files available.
    3) Click Target
    4) Select "Auto Run and Launch options" and clear Run to symbol
    5) Now launch the target config file and load your test.
    6) Now the debugger will be halted at the code entry point

    You can single step from here and see why debugger is not reaching main.

    The debug was lost (I think the code was crashed) when it executed the following code:

    Yes, you have to modify Board_init to adapt to your board.

    Regards,
    Parth