本帖最后由 keer_zu 于 2020-3-19 14:33 编辑
通过串口看到内核的打印对于调试内核是十分必要的,否则只能dmesg看到过期的累积信息。
通过串口显示printk打印信息,需要修改内核以下部分,重新编译内核生成镜像文件,下载到硬件系统,就可以了。
需要修改的文件linux-kernel/kernel/printk/printk.c
- 1415 static void call_console_drivers(int level, const char *text, size_t len)
- 1416 {
- 1417 struct console *con;
- 1418
- 1419 trace_console(text, len);
- 1420
- 1421 if (level >= console_loglevel && !ignore_loglevel)
- 1422 return;
- 1423 if (!console_drivers)
- 1424 return;
- 1425 #if 0 // #ifndef CONFIG_DYNAMIC_DEBUG
- 1426 if (!perf_mode_console)
- 1427 return;
- 1428 #endif
- 1429
- 1430 for_each_console(con) {
- 1431 if (exclusive_console && con != exclusive_console)
- 1432 continue;
- 1433 if (!(con->flags & CON_ENABLED))
- 1434 continue; ………
- 1441 }
- 1442 }
只需要将上面代码中的宏开关关闭即可,使用 #if 0 代替 #ifndef CONFIG_DYNAMIC_DEBUG
|