一、背景
1.硬件:GD32F10x
2.软件:KEIL5
3.RTOS:RT_Thread Nano
二、操作后出现的问题
1.GD32裸机使用时,不会报错并且能正常运行,但是添加RT-Thread后,报错SCB_CFSR_UFSR:0x100 UNALIGNED
三、错误log
\ | /
- RT - Thread Operating System
/ | \ 3.1.3 build Jan 18 2022
2006 - 2019 Copyright by rt-thread team
psr: 0x25002200
r00: 0x200049ee
r01: 0x00000204
r02: 0x00000000
r03: 0x00000000
r04: 0x00000000
r05: 0x00000003
r06: 0xdeadbeef
r07: 0xdeadbeef
r08: 0xdeadbeef
r09: 0xdeadbeef
r10: 0xdeadbeef
r11: 0xdeadbeef
r12: 0x00000000
lr: 0x00000000
pc: 0x08000924
hard fault on thread: main
thread pri status sp stack size max used left tick error
---------------- --- ------- ---------- ---------- ------ ---------- ---
tshell 21 ready 0x00000040 0x00000400 06% 0x0000000a 000
tidle 31 ready 0x00000040 0x00000080 50% 0x00000020 000
main 10 ready 0x00000040 0x00000800 12% 0x00000010 000
usage fault:
SCB_CFSR_UFSR:0x100 UNALIGNED
四、错误原因
1.跟踪发现错误点是在运行memset函数后,出现了“非对齐访问出错”错误;
2. memset函数导致的硬件错误;
3.查看帖子对应的解释:RT-Thread-elmfat写数据长度大于512字节,系统hard faultRT-Thread问答社区 - RT-Thread
五、解决办法
1.将memset修改为rt_memset;