CN102662844A - 一种linux内核启动时数据跟踪的方法 - Google Patents

一种linux内核启动时数据跟踪的方法 Download PDF

Info

Publication number
CN102662844A
CN102662844A CN201210106362XA CN201210106362A CN102662844A CN 102662844 A CN102662844 A CN 102662844A CN 201210106362X A CN201210106362X A CN 201210106362XA CN 201210106362 A CN201210106362 A CN 201210106362A CN 102662844 A CN102662844 A CN 102662844A
Authority
CN
China
Prior art keywords
data
inner core
serial port
kernel
linux
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201210106362XA
Other languages
English (en)
Other versions
CN102662844B (zh
Inventor
郑明明
贺福华
黄双榜
罗小建
黄洪波
张永杰
朱余浩
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Gongjin Electronics Co Ltd
Original Assignee
Shenzhen Gongjin Electronics Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Gongjin Electronics Co Ltd filed Critical Shenzhen Gongjin Electronics Co Ltd
Priority to CN201210106362.XA priority Critical patent/CN102662844B/zh
Publication of CN102662844A publication Critical patent/CN102662844A/zh
Application granted granted Critical
Publication of CN102662844B publication Critical patent/CN102662844B/zh
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

本发明提供了一种linux内核启动时数据跟踪的方法,在linux内核启动时,将启动数据直接写入到串口输出寄存器。本发明能够调试内核的前提是引导区的引导程序(bootloader)已经正常工作,串口在bootloader下能正常打印信息。在内核执行平台初始化函数之前,串口设置寄存器使用的还是bootloader阶段设置的功能,我们可以直接往串口输出寄存器中写数据,使串口输出我们需要的信息。

Description

一种linux内核启动时数据跟踪的方法
技术领域
本发明涉及通信终端领域,具体的说是通信终端中嵌入式软件的调试方法,该方法中可以跟踪linux内核启动时printk盲区的数据。
背景技术
近年来,随着计算技术、通信技术的飞速发展,特别是互联网的迅速普及和3C(计算机、通信、消费电子)合一的加速,微型化和专业化成为发展的新趋势,嵌入式产品成为信息产业的主流,而嵌入式linux操作系统依据依据其先天的开源优势、强大的网络支持、完整的工具链和广泛的硬件支持等特点,是嵌入式产品的首先操作系统。
嵌入式linux操作系统是靠bootloader引导启动的。Bootloader的作用之一就是把操作系统映像文件拷贝到RAM中去,然后跳转到它的入口处去执行。
为保证linux系统能够正常运行,在开发阶段对内核的调试是避免不了的操作步骤。
目前,常规调试方法如下:
在我们日常的嵌入式开发调试中,最常用也是最有效的方法是跟踪查看串口输出数据,如果一个系统没有串口输出功能,对开发人员来说是最可怕的,特别是在Linux操作系统中。Linux内核中最常用的调试方法是使用printk函数把相应的数据输出到串口,其实现方法是在printk()-> vprintk()函数中使用了一个printk_buf[1024]的临时缓冲区,用来处理一次传给printk的数据的格式化操作,最后将格式化过的临时数据存储到printk_buf数组中的数据通过emit_log_char函数一个一个的输送到log_buf[]--真正的所有待打印数据的缓冲区,在硬件平台初始化完成后输出到串口。但是在硬件平台初始化完成之前,如果系统不能正常运行,那么printk缓冲区的数据是没有办法输出到串口的。而此时,如果能够在显示屏或者其它地方看到启动过程中的数据将对不能正常运行的系统故障定位将是非常直观的,定位故障点对解决故障是非常重要的。
发明内容
为解决目前linux内核启动时,串口控制寄存器初始化完成之前不能及时对启动数据进行跟踪所带来的不便,本发明提供一种在linux内核启动时及时显示启动数据的内核数据跟踪方法。
本发明为了完成其技术目的所采用的技术方案是:一种linux内核启动时数据跟踪的方法,在linux内核启动时,将启动数据直接写入到串口输出寄存器。
进一步的,上述的linux内核启动时数据跟踪的方法中:linux内核启动过程中包括以下步骤:
步骤A、启动linux内核的步骤;
步骤B、将启动数据写入到串口寄存器的步骤。
本发明能够调试内核的前提是引导区的引导程序(bootloader)已经正常工作,串口在bootloader下能正常打印信息。在内核执行平台初始化(console_ini)函数之前,串口设置寄存器使用的还是bootloader阶段设置的功能,我们可以直接往串口输出寄存器中写数据,使串口输出我们需要的信息。
具体实施方式
实施例1,本实施例中能够在内核阶段调试时有效弥补printk功能的先天性缺陷,做到对嵌入式linux内核的全方位跟踪,保证嵌入式产品的稳定运行。
首先查看bootloader阶段串口发送的方法,其次直接把实现方法拷贝到linux内核初始化代码中。下面以boardcom的硬件平台bcm5358u为例,说明解决方法。
1、查看bootloader阶段串口发送数据的操作方法。bootloader阶段串口的初始化是在bcm5358u/bcm_serial.c文件中实现的,最终调用函数NS16550_putc
void NS16550_putc (char c)
{
    unsigned int status;
    do {
      status = R_UART_LSR & LSR_TXRDY;
    } while( !status );
   R_UART_DATA = c;
}
找到其使用的寄存器的地址,如下:
#define CFG_NS16550_COM1 (( (0x18000000 & 0x1fffffff) | 0xa0000000) + 0x300) 
#define R_UART_DATA    (*(volatile unsigned char*)((void*)CFG_NS16550_COM1+0x0))
#define R_UART_LSR      (*(volatile unsigned char*)((void*)CFG_NS16550_COM1+0x5))
#define    LSR_TXRDY 0x20
2、把串口发送操作的实现方法直接拷贝到内核。Linux内核的C语言部分初始化是从init/main.c中的start_kernel()函数开始启动,为了简单起见,把上述函数及宏定义拷贝到main.c中,并封装成debug_prints函数:
void debug_prints(char *s)
{
    while (*s) {
         NS16550_putc (*s++);
    }
}
3、执行效果
在start_kernel函数开始处按顺序添加如下操作:
printk("\nprintk:start_kernel is starting\n");
debug_prints("\ndebug_prints:start_kernel is starting\n");
如果debug_prints函数能够在printk函数之前输出信息,说明验证成功。编译内核后查看相应的串口输出信息如下:
Starting kernel……
debug_prints:start_kernel is starting
printk:start_kernel is starting。 

Claims (2)

1.一种linux内核启动时数据跟踪的方法,其特征在于:在linux内核启动时,将启动数据直接写入到串口输出寄存器。
2.根据权利要求1所述的linux内核启动时数据跟踪的方法,其特征在于:linux内核启动过程中包括以下步骤:
步骤A、启动linux内核的步骤;
步骤B、将启动数据写入到串口寄存器的步骤。
CN201210106362.XA 2012-04-12 2012-04-12 一种linux内核启动时数据跟踪的方法 Expired - Fee Related CN102662844B (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201210106362.XA CN102662844B (zh) 2012-04-12 2012-04-12 一种linux内核启动时数据跟踪的方法

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201210106362.XA CN102662844B (zh) 2012-04-12 2012-04-12 一种linux内核启动时数据跟踪的方法

Publications (2)

Publication Number Publication Date
CN102662844A true CN102662844A (zh) 2012-09-12
CN102662844B CN102662844B (zh) 2015-11-18

Family

ID=46772341

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201210106362.XA Expired - Fee Related CN102662844B (zh) 2012-04-12 2012-04-12 一种linux内核启动时数据跟踪的方法

Country Status (1)

Country Link
CN (1) CN102662844B (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104461872A (zh) * 2014-11-19 2015-03-25 浪潮(北京)电子信息产业有限公司 一种调试信息处理方法及系统
CN116361195A (zh) * 2023-05-24 2023-06-30 麒麟软件有限公司 一种调试Linux内核的方法

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101281488A (zh) * 2007-04-06 2008-10-08 上海宇梦通信科技有限公司 Linux操作系统的内核调试方法
CN101770386A (zh) * 2010-03-08 2010-07-07 北京飞天诚信科技有限公司 一种Linux嵌入式系统的安全启动方法
CN101894069A (zh) * 2010-06-10 2010-11-24 中兴通讯股份有限公司 Linux中的早期串口打印调试方法及装置

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101281488A (zh) * 2007-04-06 2008-10-08 上海宇梦通信科技有限公司 Linux操作系统的内核调试方法
CN101770386A (zh) * 2010-03-08 2010-07-07 北京飞天诚信科技有限公司 一种Linux嵌入式系统的安全启动方法
CN101894069A (zh) * 2010-06-10 2010-11-24 中兴通讯股份有限公司 Linux中的早期串口打印调试方法及装置

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104461872A (zh) * 2014-11-19 2015-03-25 浪潮(北京)电子信息产业有限公司 一种调试信息处理方法及系统
CN104461872B (zh) * 2014-11-19 2017-08-25 浪潮(北京)电子信息产业有限公司 一种调试信息处理方法及系统
CN116361195A (zh) * 2023-05-24 2023-06-30 麒麟软件有限公司 一种调试Linux内核的方法
CN116361195B (zh) * 2023-05-24 2023-08-22 麒麟软件有限公司 一种调试Linux内核的方法

Also Published As

Publication number Publication date
CN102662844B (zh) 2015-11-18

Similar Documents

Publication Publication Date Title
EP2915047B1 (en) System and method for debugging domain specific languages
US7484127B2 (en) Method and system for preserving crash dump in a diskless system
CN102929747B (zh) 基于龙芯服务器的Linux操作系统崩溃转储的处理方法
DE10297273B4 (de) Verfahren zur Bereitstellung von Systemintegrität und Legacy-Umgebungsemulation
JP6124994B2 (ja) レガシーos環境から統合拡張可能ファームウェア・インターフェース(uefi)ブート前環境への復元を行うための方法およびシステム、ならびにコンピュータ・プログラム
US9311177B2 (en) Mechanism to support reliability, availability, and serviceability (RAS) flows in a peer monitor
US20160054945A1 (en) Method, system, and device for modifying a secure enclave configuration without changing the enclave measurement
US8797338B2 (en) Platform agnostic screen capture tool
US20130031568A1 (en) Virtualizable and Forward-Compatible Hardware-Software Interface
KR20200125159A (ko) 전자 장치 및 이의 제어 방법
JP2015531187A (ja) ポータブル通信デバイス上でオペレーティングシステムをリカバーする方法、装置、及びシステム
CN106990985A (zh) 基于bmc更新及备份系统uefi固件的设备和方法
US20090307680A1 (en) Side-by-side driver installation
US20190332461A1 (en) Embedding forensic and triage data in memory dumps
CN103092654A (zh) 一种基于WebKit的WebOS实现方法和系统
US20100088689A1 (en) Branding binary modules using resource patching
CN101673210A (zh) 基于可扩展固件接口的跨平台和跨处理器的方法和装置
CN102662844A (zh) 一种linux内核启动时数据跟踪的方法
CN105373414B (zh) 支持MIPS平台的Java虚拟机实现方法及装置
WO2013008326A1 (ja) ソフトウェア検証方法、およびソフトウェア検証システム
CN104142843A (zh) 一种系统开机故障诊断方法
JP2016001418A (ja) 電子機器、及び、電子機器の制御方法
US20130326511A1 (en) Hypervisor printer emulation for virtual machines
US10942810B2 (en) Start-up processing for information processing apparatus and method, and storage medium
CN108845889A (zh) 一种查看BIOS选项是否符合Intel需求的测试方法与系统

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20151118