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.

AM62A3: DM Core access to MCU_MCAN register space, clarification on RAT

Part Number: AM62A3

Tool/software:

Hi all,

one of our customers has been adding to the DM core firmware, while retaining existing functionality the firmware builder includes into this firmware.

The TRM shows that MCU_MCAN registers are accessible to the DM core "VIA RAT", we need clarification how the RAT needs to be setup in order to access the MCU_MCAN registers at 0x04E00000 and 0x04E10000.

Current syscfg RAT setup for 0x04E00000 size 128KB

Code summary

//Global struct defined

#define CONFIG_ADDR_TRANSLATE_RAT_BASE_ADDR  (0x02FFE0000u)
#define CONFIG_ADDR_TRANSLATE_REGIONS  (1u)

AddrTranslateP_RegionConfig gAddrTranslateRegionConfig[CONFIG_ADDR_TRANSLATE_REGIONS] = 
{
    {
        .localAddr = 0x4E00000u,
        .systemAddr = 0x4E00000u,
        .size = AddrTranslateP_RegionSize_128K,
    },
};



//Executed Code
AddrTranslateP_Params addrTranslateParams;

AddrTranslateP_Params_init(&addrTranslateParams);
addrTranslateParams.numRegions = CONFIG_ADDR_TRANSLATE_REGIONS;
addrTranslateParams.ratBaseAddr = CONFIG_ADDR_TRANSLATE_RAT_BASE_ADDR;
addrTranslateParams.regionConfig = &gAddrTranslateRegionConfig[0];

AddrTranslateP_init(&addrTranslateParams);
 
 
uint32_t mcu_can0_base_addr = (uint32_t)AddrTranslateP_getLocalAddr( (uint64_t)CSL_MCU_MCAN0_MSGMEM_RAM_BASE);
uint32_t mcu_can1_base_addr = (uint32_t)AddrTranslateP_getLocalAddr( (uint64_t)CSL_MCU_MCAN1_MSGMEM_RAM_BASE);

MCAN_isMemInitDone(mcu_can0_base_addr);          <----DM core hangs here, in this MCAN driver API call, which reads a register based on above base addr
MCAN_isMemInitDone(mcu_can1_base_addr);


But the code does not seem to access the MCU_MCAN registers correctly and the MCAN_isMemInitDone() API hangs as it it not able to access the STAT register

Is there something else required to map the MCU_MCAN register space into the DM core?

Thanks!

--Gunter

  • As a quick follow up (thank you Gunter for helping me post!)

    the MCAN_isMemInitDone() API simply seems to call below function which just reads a 32bit address. 

    memInit = HW_RD_FIELD32(MCAN_SsAddr(baseAddr) + MCAN_MCANSS_STAT, MCAN_MCANSS_STAT_MEM_INIT_DONE);

    I added a quick log and verified that MCAN_SsAddr(baseAddr) + MCAN_MCANSS_STAT evaluates to 0x4E09008, which should be covered by the VRAT setup above, and is part of the MCU_MCAN0_SS section. 

    It seems like the HW_RD_FIELD32 causes the DM core to crash, so I am wondering if theres some MPU configuration that is not properly set up. I noticed my syscfg out of the box by default as the following REGISTER_REGION area already set up. Is there another MPU instance that should be set up?

    Following is the MPU settings for the REGISTER_REGION:

            .baseAddr = 0x0u,
            .size = MpuP_RegionSize_4G,
            .attrs = {
                .isEnable = 1,
                .isCacheable = 0,
                .isBufferable = 0,
                .isSharable = 0,
                .isExecuteNever = 1,
                .tex = 0,
                .accessPerm = MpuP_AP_ALL_RW,
                .subregionDisableMask = 0x0u
            },

  • Hi, 

    Thanks for posting. I will look into it and back to you soon.

    Regards,
    Aparna

  • Hello Gunter & Yue,

    Setting support expectations

    First to set expectations: our team is not really in a place right now where we can provide deep support on the firmware builder code. So we will offer the assistance that we can, but there are limits to what we can support.

    What is the RAT? When do you need to configure it? 

    Please start by reading the RAT document in the AM62Ax academy, MCU module:
    https://dev.ti.com/tirex/explore/node?node=A__AXBsTEetU2hiTMZSzq4row__AM62A-ACADEMY__WeZ9SsL__LATEST

    I'm the one who wrote that document, so feel free to ask followup questions.

    My initial thoughts - you don't need to configure the RAT module for these accesses 

    Please refer to the above RAT document for details on when you DO need to configure the RAT. I don't think any of those bullet points actually apply to your usecase.

    From the TRM chapter Memory Map > Device Manager R5F Memory View:

    All the R5F transactions can go through RAT for address re-mapping function except the transactions targeted
    to address range 0x2000_0000 to 0x2FFF_FFFF and its own ATCM and BTCM. It is highly recommended only
    remap the R5F’s address range from 0x8000_0000 to 0xFFFF_FFFF to access the target region located at the
    common memory map between 0x8000_0000 and 0xF_FFFF_FFFF.

    So if you are accessing memory at 0x4E0_0000, you COULD remap that system address to a different local address - but there's no reason to do that.

    Regards,

    Nick

  • To further clarify what the TRM means by "VIA RAT":

    Technically, all DM R5F accesses to the data range above 0x2FFF_FFFF will go through the RAT. However, by default, localAddress = systemAddress, so no address translation occurs, even though the electrons are physically passing through the RAT.

    Regards,

    Nick

  • Hi Nick, can you help me confirm that there is then no hard whether or not we use VRAT? In short, it should not affect anything?


    What I am noticing on my end is that the function that the DM core is calling to setup the CAN bus is causing the DM core to crash it looks like. Basically:

    This function in the DM core is being called ( I added the log) and it seems to hang on HW_RD_FIELD32, which is simply reading an address. The address that gets passed in (from log) is of value 0x04e09008, as the log executes and logs this "MCAN_DRIVER using 0x04e09008!"

    uint32_t MCAN_isMemInitDone(uint32_t baseAddr)
    {
        uint32_t memInit;
        uint32_t state;
    
        DebugP_log("MCAN_DRIVER using 0x%08x!\r\n", MCAN_SsAddr(baseAddr) + MCAN_MCANSS_STAT);
    
        memInit = HW_RD_FIELD32(MCAN_SsAddr(baseAddr) + MCAN_MCANSS_STAT,
              MCAN_MCANSS_STAT_MEM_INIT_DONE);

    I have tried other functions in the MCAN driver, which simply write to other addresses in the 0x04e09000 space (or similar, the cfg registers will write to the 0x04exxxxx registers for CAN).

    Off the top of your head, do you have any thoughts on why reading or writing these registers will cause the DM core to hang? 

    I can do the following tests:

    1. Add a few more logs into CAN driver itself, and see what happens
    2. Remove the VRAT config from syscfg, and see if any behavior changes

  • Hi Nick,

    from your comments, are you saying that addresses in the range of the MCU_MCAN0/1, i.e. 0x04E00000 to 0x04E1FFFF specifically, DO NOT require any RAT configuration?

    I am looking at the Table 2-3 in the TRM and is says RAT_region0 for that range.

    Are you saying these address range 0x04E00000 to 0x04E1FFFF automatically goes through the RAT, without configuration needed?

    Thanks!

    --Gunter

  • Hello Gunter,

    That is correct. My understanding is that the RAT is basically conbinational logic (i.e., it does not really add any latency to signals that pass through it because there are no flops or other circuits that take multiple clock cycles for the signal to pass through), and that any accesses to memory that is in a "RAT region" in the table Gunter posted will be physically exiting the DM R5F subsystem through the RAT circuitry.

    Hello Yue,

    I chatted with Gunter a bit just now. My first concern would be to check whether the MCAN is actually getting clocked. If there is not a valid clock signal going to the peripheral, I would expect reads and writes to that register space to fail (although I'm not sure what it looks like from the remote core side, I'm used to seeing that read failure from the Linux side with devmem2).

    I am passing the thread back to a team member who is more familiar with MCU+ SDK programming to provide additional debug thoughts.

    Regards,

    Nick

  • Hi Nick!

    Looks like we are on the same wave length :)

    For the DM core, the syscfg does not allow me to configure CAN busses. But for the "example" code, they are built and done for the MCU core, which does allow you to initialize the MCU can busses via syscfg.

    The delta here that I am missing is what you said, the power clock. In the example code, the syscfg autogenerates this in ti_power_clock_config.c. However, in mine as DM core does not allow me to, I am missing this. 

    I have simply added in this code to my application now prior to using the MCAN driver APIs:

    SOC_moduleClockEnable(TISCI_DEV_MCU_MCAN0, 1);
    SOC_moduleSetClockFrequency(TISCI_DEV_MCU_MCAN0, TISCI_DEV_MCU_MCAN0_MCANSS_CCLK_CLK, 80000000);

    SOC_moduleClockEnable(TISCI_DEV_MCU_MCAN1, 1);
    SOC_moduleSetClockFrequency(TISCI_DEV_MCU_MCAN1, TISCI_DEV_MCU_MCAN1_MCANSS_CCLK_CLK, 80000000);

    Now it no longer hangs! I will continue my testing and let you know if I run into more issues shorlty

  • Hi, I am able to execute loopback tests on both MCU_CAN0 and MCU_CAN1 from DM core. Closing this as resolved. Thanks!

  • Hello Yue,

    Glad to hear that yall are able to move forward now that the peripheral is clocked! I've marked this thread resolved, but feel free to create a new thread if you have future questions.

    Regards,

    Nick