Dec 14, 2017
02:22 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dec 14, 2017
02:22 AM
I think there is an error in the XMC Peripheral Libray for the FCE (Flexible CRC Engine). In the function XMC_FCE_CalculateCRC32() the data should be checked if it is word aligned, but in the code the length is check:
XMC_FCE_STATUS_t XMC_FCE_CalculateCRC32(const XMC_FCE_t *const engine,
const uint32_t *data,
uint32_t length,
uint32_t *result)
{
XMC_FCE_STATUS_t status = XMC_FCE_STATUS_OK;
XMC_ASSERT("XMC_FCE_CalculateCRC32: Wrong FCE kernel used", ((engine->kernel_ptr == XMC_FCE_CRC32_0) ||
(engine->kernel_ptr == XMC_FCE_CRC32_1)));
XMC_ASSERT("XMC_FCE_CalculateCRC32: Length field is empty", (length != 0));
XMC_ASSERT("XMC_FCE_CalculateCRC32: Length is not aligned", ((length & 0x03) == 0));
XMC_ASSERT("XMC_FCE_CalculateCRC32: Buffer is not aligned", (((uint32_t)data % 4U) == 0));
/* Check if data and length are word aligned */
if (((length & 0x03U) != 0U) || (((uint32_t)length % 4U) != 0U))
{
status = XMC_FCE_STATUS_ERROR;
}
else
{
while (0UL != length)
{
engine->kernel_ptr->IR = *data;
data++;
length -= 4U;
}
*result = engine->kernel_ptr->CRC;
}
return status;
}
const uint32_t *data,
uint32_t length,
uint32_t *result)
{
XMC_FCE_STATUS_t status = XMC_FCE_STATUS_OK;
XMC_ASSERT("XMC_FCE_CalculateCRC32: Wrong FCE kernel used", ((engine->kernel_ptr == XMC_FCE_CRC32_0) ||
(engine->kernel_ptr == XMC_FCE_CRC32_1)));
XMC_ASSERT("XMC_FCE_CalculateCRC32: Length field is empty", (length != 0));
XMC_ASSERT("XMC_FCE_CalculateCRC32: Length is not aligned", ((length & 0x03) == 0));
XMC_ASSERT("XMC_FCE_CalculateCRC32: Buffer is not aligned", (((uint32_t)data % 4U) == 0));
/* Check if data and length are word aligned */
if (((length & 0x03U) != 0U) || (((uint32_t)length % 4U) != 0U))
{
status = XMC_FCE_STATUS_ERROR;
}
else
{
while (0UL != length)
{
engine->kernel_ptr->IR = *data;
data++;
length -= 4U;
}
*result = engine->kernel_ptr->CRC;
}
return status;
}
- Tags:
- IFX
2 Replies
Dec 14, 2017
09:58 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dec 14, 2017
09:58 AM
Hi,
Thanks for reporting.We will address it in the next release.
I think that there is no need for the data to be aligned.
The check only makes sense if the user has enabled the unalign access exception.
Otherwise the unalign access is allowed in CortexM4 with the associated performance penalties.
Regards,
Jesus
Thanks for reporting.We will address it in the next release.
I think that there is no need for the data to be aligned.
The check only makes sense if the user has enabled the unalign access exception.
Otherwise the unalign access is allowed in CortexM4 with the associated performance penalties.
Regards,
Jesus
Dec 15, 2017
12:15 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dec 15, 2017
12:15 AM
I am not sure if it is necessary, but the comment and the code do not seem to match.