原因是代码中设置 #pragma pack(1)导致结构体不是4字节对齐的,采用#pragma pack()恢复到编译器默认对齐设置后,问题解决!
调试发现 memcpy() 实际上依次调用下面的函数
__rt_memcpy_w
__aeabi_memcpy4 (may assume the pointers are 4-byte aligned)
感谢下面的文章:
STM32F407因为结构体字节对齐导致的HardFault_Handler异常_f407 hardfault-CSDN博客