ESP32-S2系统加固实践(二) ESP32 Core Dump to FLASH

5 篇文章 1 订阅

LoRa网关功能调试完成了,需要加固,测试。

Upon the crash system enters panic state, prints some information and halts or reboots depending configuration.

Core dump contains snapshots of all tasks in the system at the moment of failure. Snapshots include tasks control blocks (TCB) and stacks. So it is possible to find out what task, at what instruction (line of code) and what callstack of that task lead to the crash. 

ESP-IDF provides special script espcoredump.py to help users to retrieve and analyse core dumps. This tool provides two commands for core dumps analysis:

  • info_corefile - prints crashed task’s registers, callstack, list of available tasks in the system, memory regions and contents of memory stored in core dump (TCBs and stacks)

  • dbg_corefile - creates core dump ELF file and runs GDB debug session with this file. User can examine memory, variables and tasks states manually.

配置到flash

 分配flash空间,官方如下

 There are no special requirements for partition name. It can be chosen according to the user application needs, but partition type should be ‘data’ and sub-type should be ‘coredump’. Also when choosing partition size note that core dump data structure introduces constant overhead of 20 bytes and per-task overhead of 12 bytes. This overhead does not include size of TCB and stack for every task. So partition size should be at least 20 + max tasks number x (12 + TCB size + max task stack size) bytes.

--如何知道系统中有多少个task?

如何使用保存在FLASH中的core dump?

ROM Functions in Backtraces--Rom里面的函数也可以分析

To overcome this issue you can use ROM ELF provided by Espressif (https://dl.espressif.com/dl/esp32_rom.elf) and pass it to ‘espcoredump.py’.

Dumping variables on demand--变量也可以倒出,正常只有tasks control blocks (TCB) and stacks

  • COREDUMP_DRAM_ATTR places variable into DRAM area which will be included into dump.

  • COREDUMP_RTC_ATTR places variable into RTC area which will be included into dump.

  • COREDUMP_RTC_FAST_ATTR places variable into RTC_FAST area which will be included into dump.

测试例子--模仿官方

 python coredump.py -p COM47 dbg_corefile  E:\AIOT\Lora\esp\IOT1LG1C_MCU01\build\IOT1LG1C_MCU01.elf

python import 同一目录下内容总是报错呀,还得研究。。。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值