Tool/software:
Hello,
I have an EtherCAT example that is working fine with the TI Clang compiler. However, with the GCC compiler, the EtherCAT demo stalls with unaligned access to the PRU. I have the compiler flag "-munaligned-access" but it does not help because unaligned memcpy works fine in RAM but it can potentially cause issues when accessing other peripheral memories (as it seems to happen).
It is interesting to notice that uneven length values such as 45 work fine, but with length values such as 47, memcpy stalls. As a workaround, I modified the memcpy wrapper function from the EtherCAT demo and I copy the last bytes bytewise.
void * tiesc_memcpy(uint8_t *dst, const uint8_t *src, uint32_t size_bytes) { #if 0 memcpy(dst, src, size_bytes); return dst; #endif if(size_bytes % 4 != 3) { memcpy(dst, src, size_bytes); } else { memcpy(dst, src, size_bytes - 3); for(int i = size_bytes - 3; i < size_bytes; i++) { dst[i] = src[i]; } } return dst; }
The GCC version I'm using is GCC-10.3-2021.10. Do you have any better idea than using this workaround?
Thanks in advance,
Álvaro