Debugging

Linux Debugging

Kernel Logging Kernel log buffer (default: 64KB) is used to store all kernel log messages. It can be configured from Uboot bootargs (log_buf_len=n) or kernel config option (CONFIG_LOG_BUF_SHIFT=n) where size = 2^n. Logging API’s (printk) are provided to save the data in kernel log buffer from kernel (pr_*()) and device drivers (dev_*()). User can add messages…… Continue reading Linux Debugging

Debugging

printk

printk function is used to print messages to the console from the kernel source code, same as printf from application. LogLevels in printk are used to classify messages as per the severity. printk(KERN_DEBUG “Print me at Debug Level”); LogLevels KERN_EMERG (0) – Emergency , ususally before crash messages KERN_ALERT (1) – Immediate action required KERN_CRIT (2) – Critical condition / failure KERN_ERR…… Continue reading printk

Device Drivers · Fundamentals

ISR – Linux Device Driver

Kernel keeps registry of interrupt lines, drivers should request for interrupt line and release it when done. Interrupt line can be requested either during init function or during open call of the device driver. Since embedded systems have limited interrupt lines and few are shared between resources it is recommended to hold/request the interrupt during open call…… Continue reading ISR – Linux Device Driver

Device Drivers

Device Driver – Modules

Kernel modules (device drivers) are event driven. Device drivers register themselves in the kernel during initialization process using  module_init()  function (Entry point). Initialization function exists only till module is loaded, after that memory of init function is freed. module_exit() function is called during unloading the module, after which device operations cannot be done. Kernel modules run in kernel…… Continue reading Device Driver – Modules