当前位置: 代码迷 >> 综合 >> GD32 RT_Thread Nano ---hard fault on thread
  详细解决方案

GD32 RT_Thread Nano ---hard fault on thread

热度:111   发布时间:2023-09-23 00:00:06.0

一、背景

1.硬件:GD32F10x

2.软件:KEIL5

3.RTOS:RT_Thread Nano

二、操作后出现的问题

1.添加FlashDB数据库后,系统出现了hard fault on thread的错误

三、错误log

 \ | /

- RT -     Thread Operating System

 / | \     3.1.3 build Dec 17 2021

 2006 - 2019 Copyright by rt-thread team

[SFUD]Find a Winbond W25Q32JV flash chip. Size is 4194304 bytes.

[SFUD](FlashDB\sfud\src\sfud.c:840) Flash device reset success.

[SFUD]norflash0 flash device is initialize success.

[D/FAL] (fal_flash_init:63) Flash device |                norflash0 | addr: 0x00000000 | len: 0x00400000 | blk_size: 0x00001000 |initialized finish.

[32;22m[I/FAL] ==================== FAL partition table ====================[0m

[32;22m[I/FAL] | name      | flash_dev |   offset   |    length  |[0m

[32;22m[I/FAL] -------------------------------------------------------------[0m

[32;22m[I/FAL] | fdb_tsdb1 | norflash0 | 0x00000000 | 0x00100000 |[0m

[32;22m[I/FAL] | fdb_kvdb1 | norflash0 | 0x00100000 | 0x00100000 |[0m

[32;22m[I/FAL] =============================================================[0m

[32;22m[I/FAL] Flash Abstraction Layer (V0.5.0) initialize success.[0m

[FlashDB][kv][env] (FlashDB\flashdb\src\fdb_kvdb.c:1638) KVDB size is 1048576 bytes.

[FlashDB] FlashDB V1.1.0 is initialize success.

[FlashDB] You can get the latest version on https://github.com/armink/FlashDB .

psr: 0x00000000

r00: 0x00000010

r01: 0x00f01f03

r02: 0x20000714

r03: 0x001ff000

r04: 0x20000714

r05: 0x20000178

r06: 0x20000198

r07: 0x00000010

r08: 0x001ff000

r09: 0x20000714

r10: 0x00000000

r11: 0x08009a75

r12: 0x20000714

 lr: 0x00000010

 pc: 0x00000010

hard fault on thread: led1

thread   pri  status      sp     stack size max used left tick  error

-------- ---  ------- ---------- ----------  ------  ---------- ---

led1      20  ready   0x00000044 0x00000400    18%   0x00000014 000

tshell    21  ready   0x00000040 0x00000200    12%   0x0000000a 000

tidle     31  ready   0x00000040 0x00000080    50%   0x00000020 000

main      10  suspend 0x00000098 0x00000200    100%   0x00000004 000

usage fault:

SCB_CFSR_UFSR:0x02 INVSTATE

四、错误原因

1.查看线程使用情况,发现main线程使用情况为100%;---猜测是线程的栈空间设置比较小;

五、解决办法

1.将main线程修改为2048(2K),系统正常运行;

  相关解决方案