硬汉嵌入式论坛

 找回密码
 立即注册
查看: 303|回复: 6
收起左侧

[ThreadX全家桶] thread6.0 使用gcc编译过后,进入_tx_thread_schedule函数时hard _fault

[复制链接]

9

主题

54

回帖

81

积分

初级会员

积分
81
发表于 2025-10-5 23:21:25 | 显示全部楼层 |阅读模式
如题
IAR KEIL的IDE使用硬汉的教程移植正常,尝试使用GCC编译器,但是不使用Embedded Studio进行编译,出现hard_fault问题,这种问题我可以从哪里入手检查调试下?
提前感谢下
Snipaste_2025-10-05_23-17-11.png
回复

使用道具 举报

1万

主题

7万

回帖

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
119430
QQ
发表于 2025-10-6 11:54:33 | 显示全部楼层
这个里面的完整信息,我看下


1234.png
回复

使用道具 举报

9

主题

54

回帖

81

积分

初级会员

积分
81
 楼主| 发表于 2025-10-6 16:38:52 | 显示全部楼层
eric2013 发表于 2025-10-6 11:54
这个里面的完整信息,我看下

这样可以吗,
Snipaste_2025-10-06_16-37-24.png
回复

使用道具 举报

1万

主题

7万

回帖

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
119430
QQ
发表于 2025-10-7 12:19:50 | 显示全部楼层

这样,我看着麻烦,类似我们TOOL这样多方便,展开下


1245.png
回复

使用道具 举报

9

主题

54

回帖

81

积分

初级会员

积分
81
 楼主| 发表于 2025-10-7 13:42:16 | 显示全部楼层
eric2013 发表于 2025-10-7 12:19
这样,我看着麻烦,类似我们TOOL这样多方便,展开下

2023-02-23 V1.0   
============================================================   
=========寄存器值读取========================================   
============================================================   
R0 = 00000000   
R1 = 00000000   
R2 = 00000000   
R3 = 00000000   
R4 = 00000000   
R5 = 00000000   
R6 = 00000000   
R7 = 00000000   
R8 = 00000000   
R9 = 00000000   
R10 = 00000000   
R11 = 00000000   
R12 = 00000000   
R13(SP) = 4c05b4f0   
R14(LR) = fffffff9   
R15(PC) = f3af4804   
xPSR = 00000003   

   
------------------------------------------------------------------   
Read System Handler Control and State Register SHCSR = 0x00000000   
------------------------------------------------------------------   
MEMFAULTACT = 0   
BUSFAULTACT = 0   
USGFAULTACT = 0   
SVCALLACT = 0   
MONITORACT = 0   
PENDSVACT = 0   
SYSTICKACT = 0   
USGFAULTPENDED = 0   
MEMFAULTPENDED = 0   
BUSFAULTPENDED = 0   
SVCALLPENDED = 0   
MEMFAULTENA = 0   
BUSFAULTENA = 0   
USGFAULTENA = 0   

   
------------------------------------------------------------------   
Read HardFault Status Register HSFR Register = 0x40000000   
------------------------------------------------------------------   
VECTBL = 0, 中断向量表无Bus Fault   
FORCED = 1, forced Hard Fault   
            Indicates a forced Hard Fault, generated by escalation of a fault with configurable   
            priority that cannot be handled, either because of priority or because it is disabled   
            When this bit is set, the Hard Fault handler must read the other fault status registers   
            to find the cause of the fault   

   
------------------------------------------------------------------   
MemManage Status Register (MMFSR) = 0x01   
------------------------------------------------------------------   
IACCVIOL = 1, 有指令访问冲突错误   
            the processor attempted an instruction fetch from a location that does   
            not permit execution. The PC value stacked for the exception return points to the faulting   
            instruction. The processor has not written a fault address to the MMFAR. This fault condition   
            occurs on any attempt of instruction fetches to an XN (eXecute Never) region, even when the MPU   
            is disabled or not present. Potential reasons   
            a) Branch to regions that are not defined in the MPU or defined as non-executable.   
            b) Invalid return due to corrupted stack content.   
            c) Incorrect entry in the exception vector table.   
DACCVIOL = 0,  无数据访问异常   
MUNSTKERR = 0,  出栈正常   
MSTKERR = 0,  入栈正常   
MLSPERR = 0,  浮点lazy stacking特性保存期间未发生故障   
MMARVALID = 0,  SCB->MMFAR寄存器没有记录异常地址   

   
------------------------------------------------------------------   
MemManage Address Register (MMFAR) = 0xe000edf8   
------------------------------------------------------------------   
Data address for a MemManage fault. This register is updated with the address of a location   
that produced a MemManage fault. The MMFSR shows the cause of the fault. This field is valid   
only when MMFSR.MMARVALID is set. In implementations without unique BFAR and MMFAR   
registers, the value of this register is UNKNOWN if BFSR.BFARVALID is set   

   
------------------------------------------------------------------   
BusFault Status Register (BFSR) = 0x10   
------------------------------------------------------------------   
IBUSERR = 0, 指令总线正常   
PRECISERR = 0, 数据总线正常   
IMPRECISERR = 0, 数据总线正常   
UNSTKERR = 0, 中断出栈时正常   
STKERR = 1, 中断入栈时异常   
            stacking for an exception entry has caused one or more BusFaults   
            When the processor sets this bit, the SP is still adjusted but the values in the context area on the   
            stack might be incorrect. The processor does not write a fault address to the BFAR. Potential   
            reasons:   
            a) Stack pointer is corrupted or not initialized   
            b) Stack is reaching an undefined memory region.   
LSPERR = 0, 浮点lazy stacking特性保存期间未生故障   
BFARVALID = 0, BFAR寄存器未记录有效的异常地址   

   
------------------------------------------------------------------   
BusFault Address Register (BFAR) = 0xe000edf8   
------------------------------------------------------------------   
Data address for a precise BusFault. This register is updated with the address of a location that   
produced a BusFault. The BFSR shows the reason for the fault. This field is valid only when   
BFSR.BFARVALID is set. In implementations without unique BFAR and MMFAR registers, the   
value of this register is UNKNOWN if MMFSR.MMARVALID is set   

   
------------------------------------------------------------------   
UsageFault Status Register (UFSR) = 0x0000   
------------------------------------------------------------------   
UNDEFINSTR = 0, 处理器访问指令正常   
INVSTATE = 0, 没有无效状态   
INVPC = 0, PC加载正常   
NOCP = 0, 访问协处理正常   
UNALIGNED = 0, 内存对齐访问正常   
DIVBYZERO = 0,  无除数为0的异常, 或者没有使能除数为0的异常   

   
============================================================   
=========异常进一步分析======================================   
============================================================   
进入和退出中断使用MSP, 返回线程模式, 进入中断前没有使用硬件浮点单元   
进入硬件异常前, 寄存器数值, 如果出现非精确异常, 这些值是不准确的:   
读内存失败 0x4C05B4F0
R0 = 0040bc12   
读内存失败 0x4C05B4F4
R1 = 0040bc12   
读内存失败 0x4C05B4F8
R2 = 0040bc12   
读内存失败 0x4C05B4FC
R3 = 0040bc12   
读内存失败 0x4C05B500
R12 = 0040bc12   
读内存失败 0x4C05B504
LR = 0040bc12   
读内存失败 0x4C05B508
PC = 0040bc12   
读内存失败 0x4C05B50C
PSR = 0040bc12   
回复

使用道具 举报

9

主题

54

回帖

81

积分

初级会员

积分
81
 楼主| 发表于 2025-10-7 13:42:37 | 显示全部楼层
看起来有很多提示,我也再看看
回复

使用道具 举报

1万

主题

7万

回帖

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
119430
QQ
发表于 2025-10-8 11:41:00 | 显示全部楼层
TRX 发表于 2025-10-7 13:42
看起来有很多提示,我也再看看

你这个时候的截图还没有触发异常,因为这些都是0

------------------------------------------------------------------   
Read System Handler Control and State Register SHCSR = 0x00000000   
------------------------------------------------------------------   
MEMFAULTACT = 0   
BUSFAULTACT = 0   
USGFAULTACT = 0   
SVCALLACT = 0   
MONITORACT = 0   
PENDSVACT = 0   
SYSTICKACT = 0   
USGFAULTPENDED = 0   
MEMFAULTPENDED = 0   
BUSFAULTPENDED = 0   
SVCALLPENDED = 0   
MEMFAULTENA = 0   
BUSFAULTENA = 0   
USGFAULTENA = 0
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|Archiver|手机版|硬汉嵌入式论坛

GMT+8, 2025-11-22 00:26 , Processed in 0.042660 second(s), 28 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表