Contributed by bzhou830, curated by Ai-Thinker
1. Origin
Once I happened to hear from Ze Ge that for crash problems, the BL616/618 chips can be configured to generate core dump files. Then we can use gdb to debug the core dump file and find the cause of the crash. This process sounds exactly like kernel debugging. Is the MCU really that powerful? With this question, I asked Ze Ge, and he said that as long as it's configured in the makefile, the core dump can be printed through the serial port, like this: 
2. Trying It
Out of curiosity, I opened aithinker_Ai-M6X_SDK\examples\helloworld and deliberately created a crash. After compiling and flashing, I found no core dump was generated.
Ze Ge also said it only works when FreeRTOS is used. So I simply put the code in a task.
#include "bflb_mtimer.h"
#include "board.h"
#include <FreeRTOS.h>
#include "task.h"
#define DBG_TAG "MAIN"
#include "log.h"
#define STACK_SIZE (1536)
#define TASK_PRIORITY (16)
static TaskHandle_t crash_task_hd;
void crash_task(void *params)
{
char *pBuffer = 0x80000000;
uint32_t i = 0;
while (1) {
pBuffer = i++;
printf("%d\r\n", pBuffer);
bflb_mtimer_delay_ms(500);
}
}
int main(void)
{
board_init();
xTaskCreate(crash_task, "crash_task", STACK_SIZE, NULL, TASK_PRIORITY, &crash_task_hd);
vTaskStartScheduler();
while (1) {
}
}After compiling and flashing again, still no core dump was generated.
3. Tracing the Cause
On the way to work, I thought: these configurations just affect the gcc compilation parameters. If I trace the core_dump configuration parameter, wouldn't I know the reason? When I opened aithinker_Ai-M6X_SDK and searched for the coredump parameter parsing, I couldn't find it at all!
This explains it: they never paid attention to this configuration item at all. No matter how we configure it at the upper level, it won't work. But Ze Ge said it works — is my SDK too old? But I checked the official Ai-Thinker GitHub and the SDK wasn't updated either! So I turned to the Bouffalo SDK. Opening it, I found the relevant content directly:
At this point, the case is closed. To use core_dump, use bl_sdk, or port the core_dump from bl_sdk over.
Have questions?
For other questions, please visit the unified discussion area: Ai-Thinker Discussions

