Linux驱动开发调试 -- 打开dev_dbg()

如何打开linux内核函数dev_dbg()调试开关 我们先看一下定义在<linux/device.h>里面关于打印级别基本的定义在来看下kernel/printk.c 中定义的打印级别,如下:DEFAULT_CONSOLE_LOGLEVEL, /* console_loglevel 控制台日志级别,优先级高于该值的消息将在控制台显示*/MINIMUM_CONSOLE_LOGLEVEL, /* minimum_console_loglevel 最低的控制台日志级别 */ 阅读详情

转载地址:http://blog.chinaunix.net/uid-22841689-id-3924244.html

一、打印调试       
        linux设备驱动调试,我们在内核中看到内核使用dev_dbg来控制输出信息,这个函数的实质是调用
printk(KERN_DEBUG )来输出打印信息。要打开这个开关需要下面两步。

1.1、打开调试开关
        你调试的文件中必然包含了<linux/device.h>,或者<linux /paltforam_device.h>,后者包含了前者,
在包含此头文件之前,使用#define DEBUG 1 来打开调试开关:例如

点击(此处)折叠或打开

  1. #include <linux/kernel.h>
  2. #include <linux/init.h>
  3. #include <linux/clk.h>
  4. #include <linux/module.h>
  5. #define DEBUG 1
  6. #include <linux/platform_device.h>
     在linux/device.h文件中:

点击(此处)折叠或打开

  1. #define dev_printk(level, dev, format, arg...)\
  2.     printk(level "%s %s: " format , dev_driver_string(dev), (dev)->bus_id, ## arg)

  3. #ifdef DEBUG
  4. #define dev_dbg(dev, format, arg...)\
  5.     dev_printk(KERN_DEBUG , dev , format , ## arg)
  6. #else
  7. static inline int __attribute__ ((format (printf, 2, 3)))
  8. dev_dbg(struct device * dev, const char* fmt, ...)
  9. {
  10.     return 0;
  11. }
  12. #endif
        但是这个打开了之后,也不能顺利的输出信息,原因是printk有默认的信息级别。
        linux/kernel文件中

点击(此处)折叠或打开

  1. #define KERN_EMERG "<0>"
  2. #define KERN_ALERT "<1>"
  3. #define KERN_CRIT "<2>"
  4. #define KERN_ERR "<3>"
  5. #define KERN_WARNING "<4>"
  6. #define KERN_NOTICE "<5>"
  7. #define KERN_INFO "<6>"
  8. #define KERN_DEBUG "<7>"
        可以看到KERN_DEBUG是级别最低的。
1.2、修改文件kernel/printk文件

点击(此处)折叠或打开

  1. #define DEFAULT_MESSAGE_LOGLEVEL 4
  2. #define MINIMUM_CONSOLE_LOGLEVEL 1
  3. #define DEFAULT_CONSOLE_LOGLEVEL 8
        其中DEFAULT_CONSOLE_LOGLEVEL 为终端console输出的最低级别,比这严重的都将输出。
原来该值为7,则调试信息无法输出,修改为8则全部有输出。
1.3、修改Makefile
        通过配置内核选项,修改Makefile实现显示打印调试信息。Kconfig内容如下:

点击(此处)折叠或打开

  1. config ADC_DEV_DEBUG
  2.     bool "adc dev debugging messages"
  3.     depends on ADC_INTF_DEV
  4.     help
  5.      Say Y here if you want the adc dev to produce a bunch of debug
  6.      messages to the system log. Select thisif you are having a
  7.      problem with adc core and want to see more of what is going on.
        Makefile内容如下:

点击(此处)折叠或打开

  1. #
  2. # Makefile for the i2c bus drivers.
  3. #

  4. obj-$(CONFIG_GSC_SPI0_ADC_CORE)        += adc-core.o
  5. obj-$(CONFIG_ADC_INTF_DEV)            += adc-dev.o
  6. obj-$(CONFIG_ADC_INTF_PROC)            += adc-proc.o
  7. obj-$(CONFIG_ADC_INTF_SYSFS)            += adc-sysfs.o

  8. obj-$(CONFIG_GSC3280_ADC)            += gsc3280_adc.o

  9. ccflags-$(CONFIG_GSC_ADC_DEV_DEBUG)+= -DGSC3280_ADC_DEV_DEBUG
        红色部分即是。当内核配置选中后,CONFIG_GSC_ADC_DEV_DEBUG即被定义,编译后,源码中使用
GSC3280_ADC_DEV_DEBUG宏定义的调试语句将被打印。
开启dev_dbg方法 本篇文章将详细介绍如何通过动态调试机制启用 dev_dbg,以及在特定情况下通过其他方式实现调试信息输出。 阅读详情

相关推荐

dev_dbg() 调试信息

dev_dbg() 如何打印 调试信息 里面说明了如何打开一个开关 让内核里面的调试信息打印出来

第四章--调试技术

本位作为第四章--调试技术,主要讲述: 1、打印调试。

辉辉308 1223

【PADS-开发指南】

馒头破戒大师

sinat_23896491的博客 3298

Linux驱动开发调试 -- 打开dev_dbg()【转】

本文转载自:https://blog.csdn.net/kunkliu/article/details/78048618 转载地址:http://blog.chinaunix.net/uid-22841689-id-3924244.html 一、打印调试 linux设备驱动调试,我们在内核中看到内核使用dev_dbg来控制输出信息,这个函数的实质是...

782

从接线到组态:手把手教你搞定PROFIBUS-DP与PA的混合网络搭建(基于西门子TIA Portal)

本文详细介绍了PROFIBUS-DP与PA混合网络的搭建方法,基于西门子TIA Portal平台,从硬件选型、网络架构设计到组态配置和现场调试,提供了一套完整的实战指南。重点解析了DP/PA耦合器的使用、地址映射策略及网络诊断技巧,帮助工程师高效构建高可靠性的工业自动化网络。

weixin_32103009的博客 313

Auracast广播音频开发实战:基于BT2106C从协议到实测

蓝牙音频技术正从传统的点对点连接向一对多广播演进。经典A2DP协议因单一连接限制,难以满足公共场景下的多用户同步收听需求。LE Audio引入的Auracast广播音频,通过等时通道与LC3编解码器,实现无限接收端同时接收、天然同步且支持多语言频道独立切换,为博物馆导览、会议室同传、电视辅听等场景提供了全新的技术路径。文章以BT2106C低功耗蓝牙模块为例,系统梳理了Auracast广播发送端与接收端的开发流程,包括SDK结构、BIG/BIS配置、关键参数调优方法,并给出户外、室内及干扰环境下的实测距离、丢

weixin_33461476的博客 336

打开dev_dbg()调试开关

打开dev_dbg开关,使其日志输出到控制台 内核驱动中(大多数是子系统中)有大量使用dev_dbg打印日志信息,但是这些信息默认是不会输出到控制台的。调试过程中,我们如何打开DEBUG,获取这些dev_dbg日志呢? 打开dev_dbg需要满足两个条件: 开启DEBUG 调整printk日志级别 下面介绍为什么需要这两个条件以及如何修改。 开启DEBUG 首先看下dev_...

HelloBirthday的博客 2万+

ADS笔记,新旧两组仿真数据进行绘图和列表对比

原理图器件参数的不同,怎么进行对比观看,操作如下。

彭辉荣的博客 3884

dev_info()/dev_dbg()/dev_err()

目前在kernel驱动代码中,都不再建议直接使用printk直接添加打印信息,而是使用dev_info,dev_dbg,dev_err之类的函数代替,虽然这些dev_xxx函数的本质还是使用printk打印的,但是相比起printk: 支持打印模块信息、dev信息 支持动态调试(dynamic debug)方式 下面简述下这几个dev_xxx函数的基本使用规则,以及动态调试使用方式。 dev...

boyemachao的专栏 1万+

手把手教你用Deep Single-Image Portrait Relighting实现人像光影重塑(附GitHub代码)

本文提供了一份详细的实战指南,手把手教你利用Deep Single-Image Portrait Relighting技术实现人像光影重塑。文章从环境搭建、核心原理拆解出发,逐步指导构建简易重光照流程,并探讨了使用预训练模型进行效果优化的进阶方法,最后附上避坑指南与常见问题排查,帮助开发者快速上手这一AI图像处理技术。

weixin_29065015的博客 332

别再乱设阻尼了!Abaqus动力分析中瑞利阻尼的α和β到底怎么算?

本文深入解析Abaqus动力分析中瑞利阻尼参数α和β的科学计算方法,帮助工程师准确设置阻尼参数以提升仿真精度。详细介绍了基于模态阻尼比的经典计算方法和多模态优化法,并结合工程案例演示参数设置流程,避免常见的阻尼设置误区。

weixin_42634811的博客 772

Linux 内核动态打印调试(dev_info、 dev_dbg )

在 kernel 驱动代码中,使用动态输出是系统内核调试的重要手段之一,printk打印是全局的,只能设置输出等级。而动态输出可以动态选择打开某个内核子系统的输出,可以有选择性地打开某些模块的输出,printk被dev_info,dev_dbg,dev_err之类的函数代替,dev_xxx函数的本质还是使用printk打印的,只是对printk进行了一层包装。下面简述下这几个dev_xxx函数的基本使用规则,以及动态调试使用方式。

嵌入式大师之路 9252

DataGridView 右键菜单复制(公共)

dataGridView1.CellMouseClick += new DataGridViewCellMouseEventHandler( (sender1, e1) => { if (e1.Button == MouseButtons.Right) {

沁心渃水 2848

Linux内核中dev_info、dev_dbg、dev_err及动态调试

目前在kernel驱动代码中,都不再建议直接使用printk直接添加打印信息,而是使用dev_info,dev_dbg,dev_err之类的函数代替,虽然这些dev_xxx函数的本质还是使...

Peter的专栏 3565

【推荐100个unity插件之24】实现2d交互式草树叶和随风飘动的效果——pixelgraphics插件

【推荐100个unity插件之23】实现2d交互式草树叶和随风飘动的效果——pixelgraphics插件

向宇的博客,专注php/web全栈 unity游戏开发,欢迎大家评论纠错 1697

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

开启dev_dbg调试日志

内核中的大部分驱动都使用了dev_dbg接口打印调试信息,默认是不会输出到控制台的。 先看一下dev_dbg的定义: 文件路径:/kernel/include/linux/device.h #if defined(CONFIG_DYNAMIC_DEBUG) #define dev_dbg(dev, format, ...) \ do { \ dynamic_...

sunnywalden 2573

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

打开Linux的dev_dbg

[转自:http://hi.baidu.com/dreammerge/item/1fe7e04db5cd8fea1e19bca0]     Linux设备驱动调试,我们在内核中看到内核使用dev_dbg来控制输出信息,这个函数的实质是调用 printk(KERN_DEBUG)来输出打印信息。要打开这个开关需要下面两步:     1、打开调试开关。     你调试的文件中必然包含了

skywalker_leo的专栏 2965

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

使能linux驱动中的dev_dbg

linux设备驱动调试,我们在内核中看到内核使用dev_dbg来控制输出信息,这个函数的实质是调用 printk(KERN_DEBUG )来输出打印信息。要打开这个开关需要下面两步。      1、打开调试开关:你调试的文件中必然包含了,或者《linux /paltfora

WishMaster 2万+

Linux驱动开发 -- 打开dev_dbg()

转载:http://blog.chinaunix.net/u1/38038/showart_1359825.html          linux设备驱动调试,我们在内核中看到内核使用dev_dbg来控制输出信息,这个函数的实质是调用printk(KERN_DEBUG )来

1568

linux 驱动打开dev_dbg/pr_debug 调试信息

linux设备驱动调试,我们在内核中看到内核使用dev_dbg/pr_debug来控制输出信息,这个函数的实质是调用printk(KERN_DEBUG )来输出打印信息。要打开这个开关需要下面两步。 1、打开调试开关:你调试的文件中必然包含了<linux/device.h>,或者<linux /paltforam_device.h>,后者包含了前者, 必须在包含此头文件之前,使用#define DEBUG 1 来打开调试开关:例如 #include &l.

gaosiniquanjia的博客 1712

linux 驱动打开dev_dbg调试信息

原文地址:http://www.mamicode.com/info-detail-603325.htmllinux设备驱动调试,我们在内核中看到内核使用dev_dbg来控制输出信息,这个函数的实质是调用printk(KERN_DEBUG )来输出打印信息。要打开这个开关需要下面两步。 1、打开调试开关:你调试的文件中必然包含了&lt;linux/device.h&gt;,或者&lt;l...

dragon_cdut的博客 2163

linux dev err,Linux内核中dev_info、dev_dbg、dev_err及动态调试

目前在kernel驱动代码中,都不再建议直接使用printk直接添加打印信息,而是使用dev_info,dev_dbg,dev_err之类的函数代替,虽然这些dev_xxx函数的本质还是使用printk打印的,但是相比起printk:支持打印模块信息、dev信息支持动态调试(dynamic debug)方式下面简述下这几个dev_xxx函数的基本使用规则,以及动态调试使用方式。dev_info()...

weixin_36429440的博客 3591
上一篇: uboot2013-10移植(二)--mkconfig注释
下一篇: Linux内核动态调试信息的打开,如pr_debug
kunkliu
博客等级 码龄15年 2866粉丝 19原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值