Because of the Thanksgiving holiday in the U.S., TI E2E™ design support forum responses may be delayed the week of November 23.

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.

AM62P: [AM62P] MCU+ SDK UDMA Driver

Part Number: AM62P

Hi TI Team,

We are working on configuring UDMA ring buffers for UART on the AM62P Cortex-R5 core, and we ran into a behavior we hope you could help us clarify. 

Observation & Debug Logs

When we place the ring memory in external DDR (0x93000000 region), Udma_ringAlloc() fails during Sciclient_rmRingCfg():

MCU_R5FSS0_0: [UDMA] ring cfg addr_lo=0x93000000 addr_hi=0xffffffff
MCU_R5FSS0_0: ERROR: Udma_ringAlloc:190: [UDMA] Ring config failed!!!
MCU_R5FSS0_0: ERROR: Udma_chAllocResource:2554: [UDMA] FQ ring alloc failed!!!

However, when the ring memory resides in MSRAM (0x79101200), the configuration succeeds:

MCU_R5FSS0_0: [UDMA] ring cfg addr_lo=0x79101200 addr_hi=0x00000000

My Analysis

Looking into udma_utils.c, Udma_defaultVirtToPhyFxn() performs a direct cast:

uint64_t Udma_defaultVirtToPhyFxn(const void *virtAddr, uint32_t chNum, void *appData)
{
    return ((uint64_t) virtAddr); // Direct cast from 32-bit void* to uint64_t
}

Our understanding is that on a 32-bit architecture, casting a const void * directly to uint64_t when Bit 31 is set (e.g., DDR addresses starting above 0x80000000) might trigger integer sign-extension depending on compiler behavior. This results in physBase becoming 0xFFFFFFFF93000000, causing addr_hi to be set to 0xFFFFFFFF.

When we modified the function locally to cast through uintptr_t first: 

return ((uint64_t)(uintptr_t)virtAddr);

 addr_hi becomes 0x00000000 for DDR addresses, and Udma_ringAlloc() passes cleanly. 

Could you help confirm if our analysis regarding the sign-extension is correct, or if we might be misinterpreting how virtToPhyFxn is intended to be configured for DDR addresses on 32-bit cores?  

We would greatly appreciate your guidance and insights on this.

 

Regards,

Wei Han

  • Hello Wei Han,

    We have not observed this problem when using the TI Clang compiler with either DDR or MSRAM memory.

    We are only seeing this issue with the GCC compiler when type-casting a void * pointer to a 64-bit integer.

    When the MSB is high, GCC automatically performs a signed conversion. However, if the MSB is not set, this signed conversion does not happen.

    Because of this behavior, I believe the root cause is a type-conversion bug within the compiler itself, rather than any other issue.
    We have already discussed this problem with your teammate, Fiallo. I am not sure if you have had a chance to speak with him about it yet?

    Regards,

    Anil.