KSDK 1.0.0: Bug report in fsl_edma_driver.c - TCD's index

cancel
Showing results for 
Search instead for 
Did you mean: 

KSDK 1.0.0: Bug report in fsl_edma_driver.c - TCD's index

516 Views
mauricelauze
Contributor III

Description:

 

In function : edma_status_t EDMA_DRV_ConfigLoopTransfer(

                              edma_chn_state_t *chn, edma_software_tcd_t *stcd,

                              edma_transfer_type_t,

                              uint32_t srcAddr, uint32_t destAddr, uint32_t size, uint32_t bytesOnEachRequest, uint32_t totalLength, uint8_t number)

 

there is a bug reading the address of the TCD passed in function parameter  *stcd.

 

This is caused by the macro:

 

#define STCD_ADDR(address)          (edma_software_tcd_t *)(((uint32_t)address + 32) & ~0x1FU)

 

this macro should be:

 

#define STCD_ADDR(address)          (edma_software_tcd_t *)(((uint32_t)address) & ~0x1FU)

 

This leads to an offset of one TCD in the TCD's list defined by the user.

 

I fixed this issue by not using that macro, provided the address is well aligned (modulo 32 bytes)

 

//edma_software_tcd_t *stcdAddr = (edma_software_tcd_t)STCD_ADDR(stcd);

edma_software_tcd_t *stcdAddr = (edma_software_tcd_t *)(stcd);

 

Hope this helps,

Maurice

Labels (1)
Tags (3)
0 Kudos
2 Replies

219 Views
jeremyzhou
NXP TechSupport
NXP TechSupport

Hi Maurice,

Thanks for sharing this bug issue,

In my opinion, I don't agree with you about this issue.

However I'll contact with the SDK tech supporter to check issue and update you ASAP after we have conclusion.

Have a great day,

Ping

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

219 Views
mauricelauze
Contributor III

Hi Jeremyzhou,

In "fsl_edma_driver.c", there is :

/*!

* @brief Macro for size of memory need for software TCD.

*

* Software TCD is aligned to 32 bytes. To make sure the software TCD can meet the

* eDMA module's requirement, allocate memory with extra 32 bytes.

*/

#define STCD_SIZE(number)           ((number + 1) * 32)

#define STCD_ADDR(address)          (edma_software_tcd_t *)(((uint32_t)address + 32) & ~0x1FU)

With the following code :

tcd = malloc(STCD_SIZE(number_of_TCDs))

memory allocation is not garanteed to be 32 bytes aligned, and the use of  STCD_ADDR(address) is necessary and is working as it is.

But, using for instance :

tcd[number_of_TCDs] __attribute__ ((aligned (32)));

makes address aligned on 32 bytes boundary, and call to STCD_ADDR(address) drops to address TCD+1 as I have experienced.

It seems that I am not the only one experiencing such a problem :

Re: KSDK eDMA edma_software_tcd_t allocation needs to be 'number plus 1'

I might say that using " __attribute__ ((aligned (32)))" in the TCDs memory allocation should be sufficient and keep off the trouble of allocating "+1 " TCD...

Hope this helps,

Maurice

0 Kudos