当前位置:网站首页>STM32 how to locate the code segment that causes hard fault
STM32 how to locate the code segment that causes hard fault
2022-07-06 11:59:00 【Weiyuan escort agency】
produce hard fault Method :
Write to inaccessible memory address
uint32_t *addr = (uint32_t *)0x20100000;
*addr = 0x12;STM32 Positioning causes occurrence hard fault Code segment ~ technological process :
1、 Get into interrupt service function HardFault_Handler Before PC value (PC Value indicates where the assembly instruction is located flash Address )
2、 Generate disassembly file ( contains flash Address and corresponding assembly instructions , And compile the corresponding C Program ) perhaps MAP file
3、 In the disassembly file , adopt PC It's worth finding the corresponding C Program statement ; Or in MAP File by PC Value to find the corresponding calling function
Get into interrupt service function HardFault_Handler Before PC value
Method 1:
Use RT-Thread System , If appear hard fault, Will interrupt the service function HardFault_Handler Print the following message in :

from log Can be learned that Threads “ connect t “ The procedure in leads to hard fault, The program runs to PC: 0x08055F22 Jump to the interrupt service function HardFault_Handler
Method 2:
In interrupt service function HardFault_Handler Make a breakpoint at the beginning of

After the program runs here , Check the register first LR Value :
If LR by 0xXXXXXXX9, Before entering the interrupt SP The value of is MSP;
If LR by 0xXXXXXXXD, Before entering the interrupt SP The value of is PSP;
Below LR by 0xXXXXXXXD( The screenshot is not shown ), So look at the register PSP Value , by 0x2000FA30

adopt PSP Value , According to the register stack order , You can get PC value ( Because it is small end coding , So for 0x08055F6A)

Generate disassembly file
Method 1:
ELF File disassembly , Generate assembly file :
.arm-none-eabi-objdump.exe -l -S . tthread.elf > .aaa.c
Method 2:
start-up RT-Thread Studio Or other IDE debugging , open “ Disassembly ” View

Method 3:
see map file , There is some information similar to disassembly file , about RT-Thread function , It is rtthread.map
see rtthread.map It can be seen from the documents 0x08055F22 In function load_data_to_toServerBuf Inside

边栏推荐
猜你喜欢

Machine learning -- decision tree (sklearn)

Basic knowledge of lithium battery

Comparison of solutions of Qualcomm & MTK & Kirin mobile platform USB3.0

ToggleButton实现一个开关灯的效果

Analysis of charging architecture of glory magic 3pro

高通&MTK&麒麟 手機平臺USB3.0方案對比
![[Flink] Flink learning](/img/2e/ff53e0795456e301f61da908c013af.png)
[Flink] Flink learning

Principle and implementation of MySQL master-slave replication

RT-Thread的main线程“卡死”的一种可能原因及解决方案

FTP文件上传文件实现,定时扫描文件夹上传指定格式文件文件到服务器,C语言实现FTP文件上传详解及代码案例实现
随机推荐
4. Install and deploy spark (spark on Yan mode)
使用LinkedHashMap实现一个LRU算法的缓存
STM32型号与Contex m对应关系
JS object and event learning notes
RT-Thread API参考手册
R & D thinking 01 ----- classic of embedded intelligent product development process
Correspondence between STM32 model and contex M
机器学习--决策树(sklearn)
Nodejs connect mysql
Analysis of charging architecture of glory magic 3pro
选择法排序与冒泡法排序【C语言】
PyTorch四种常用优化器测试
mysql实现读写分离
Principle and implementation of MySQL master-slave replication
【presto】presto 参数配置优化
冒泡排序【C语言】
Hutool中那些常用的工具类和方法
arduino UNO R3的寄存器写法(1)-----引脚电平状态变化
SQL time injection
2019腾讯暑期实习生正式笔试