debugfs 使用指南

Linux下的Debugfs 调试操作 阅读详情

debugfs 使用指南  https://zhuanlan.zhihu.com/p/651692040

Linux驱动调试中的Debugfs的使用简介 CONFIG_DEBUG_FS 的功能与配置  https://blog.csdn.net/u013165704/article/details/80777799

linux DebugFS介绍  https://zhuanlan.zhihu.com/p/487700961


debugfs使用指南

https://www.cnblogs.com/dennis-wong/p/16391598.html

ebugfs#

概述#

类似sysfs、procfs,debugfs 也是一种内存文件系统。不过不同于sysfs一个kobject对应一个文件,procfs和进程相关的特性,

debugfs的灵活度很大,可以根据需求对指定的变量进行导出并提供读写接口。

debugfs又是一个Linux中 everything is a file 哲学的体现,通过VFS实现了对驱动的控制。可以通过以下命令,来挂载debugfs到指定目录。

mount -t debugfs none /sys/kernel/debug

支持的读写类型#

debugfs支持比较丰富的数据类型,如下所示。

使用方式#

  1. 创建目录和文件
    使用 debugfs_create_dir 创建一个目录,如果parent为NULL,则默认其父目录为debugfs的根目录。函数的返回值为NULL表示目录创建成功。
    debugfs_create_file和debugfs_create_file_size都用来创建文件,不同的是debugfs_create_file_size可以通过file_size字段指定一个初始的大小。

name:文件名
mode:文件权限可以是整型(比如0644)也可以使用内核的宏
parent:父目录,如果为空则该文件的父目录为根目录
data:inode的i_private字段指向这个结构
fops:表示该文件的自定义操作,需要注意的是在我实际测试中open函数可能是必须要实现的,否则在使用echo命令的时候会报以下的错误

struct dentry *debugfs_create_dir(const char *name, struct dentry *parent);
struct dentry *debugfs_create_file(const char *name, umode_t mode,
                                   struct dentry *parent, void *data,
                                   const struct file_operations *fops);
void debugfs_create_file_size(const char *name, umode_t mode,
                              struct dentry *parent, void *data,
                              const struct file_operations *fops,
                              loff_t file_size);
  1. 创建无符号整型文件
//创建十进制的无符号文件
void debugfs_create_u8(const char *name, umode_t mode,
                       struct dentry *parent, u8 *value);
void debugfs_create_u16(const char *name, umode_t mode,
                        struct dentry *parent, u16 *value);
void debugfs_create_u32(const char *name, umode_t mode,
                        struct dentry *parent, u32 *value);
void debugfs_create_u64(const char *name, umode_t mode,
                        struct dentry *parent, u64 *value);
//创建十六进制的无符号文件
void debugfs_create_x8(const char *name, umode_t mode,
                       struct dentry *parent, u8 *value);
void debugfs_create_x16(const char *name, umode_t mode,
                        struct dentry *parent, u16 *value);
void debugfs_create_x32(const char *name, umode_t mode,
                        struct dentry *parent, u32 *value);
void debugfs_create_x64(const char *name, umode_t mode,
                        struct dentry *parent, u64 *value);

//创建一个size_t类型的文件
void debugfs_create_size_t(const char *name, umode_t mode,
                           struct dentry *parent, size_t *value);
//创建一个unsigned long类型的文件
struct dentry *debugfs_create_ulong(const char *name, umode_t mode,
                                    struct dentry *parent,
                                    unsigned long *value);
//创建一个十六进制的unsigned long类型的文件
void debugfs_create_xul(const char *name, umode_t mode,
                        struct dentry *parent, unsigned long *value);
  1. 布尔类型文件
void debugfs_create_bool(const char *name, umode_t mode,
                         struct dentry *parent, bool *value);

读布尔文件会显示Y或者N,写该文件时,只接受(Y, N, y, n, 0, 1)等值,其他值都只会被简单的忽略。

  1. 原子类型
void debugfs_create_atomic_t(const char *name, umode_t mode,
                             struct dentry *parent, atomic_t *value)
  1. blob类型

使用debugfs_create_blob创建一个blob类型的文件,调用该函数前,我们需要在debugfs_blob_wrapper的data字段指定要展示的内容,size表示data长度。

需要注意的是blob类型的文件是只读的

struct debugfs_blob_wrapper {
    void *data;
    unsigned long size;
};

struct dentry *debugfs_create_blob(const char *name, umode_t mode,
                                   struct dentry *parent,
                                   struct debugfs_blob_wrapper *blob);    
  1. 寄存器类型

使用 debugfs_reg32 表示一个寄存器内容,name表示文件名,offset表示相对于基地址的偏移。debugfs_regset32 表示一组寄存器文件,nregs:寄存器文件个数 base:io基地址

struct debugfs_reg32 {
    char *name;
    unsigned long offset;
};

struct debugfs_regset32 {
    const struct debugfs_reg32 *regs;
    int nregs;
    void __iomem *base;
    struct device *dev;     /* Optional device for Runtime PM */
};

debugfs_create_regset32(const char *name, umode_t mode,
                        struct dentry *parent,
                        struct debugfs_regset32 *regset);

void debugfs_print_regs32(struct seq_file *s, const struct debugfs_reg32 *regs,
                     int nregs, void __iomem *base, char *prefix);

踩坑#

  1. debugfs的API的都是GPL的,因此在自己的模块必须要指定协议为GPL
  2. 使用echo写文件的话,open函数是必须的。

代码实例#

#include <linux/debugfs.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/uaccess.h>
#include <linux/errno.h>
#include <linux/dcache.h>
#include <linux/types.h>

static char zen_buf[512] = "hello\n";
static struct dentry *zen_dir;


static int zen_open(struct inode *inode, struct file *filp)
{
    printk("zen open\n");
    filp->private_data = inode->i_private;
    return 0;
}

ssize_t zen_read(struct file *filp, char __user *buf, size_t count, loff_t *offp)
{
    int retval = 0;
    if ((*offp + count) > 512)
        count = 512 - *offp;

    printk("read request: count:%u, offset:%u\n", count, *offp);
    if (copy_to_user(buf, zen_buf+*offp, count)) {
        printk("copy to user failed, count:%ld\n", count);
        retval = -EFAULT;
        goto out;
    }
    *offp += count;
    retval = count;
out:
    return retval;
}

ssize_t zen_write(struct file *filp, const char __user *buff, size_t count, loff_t *offp)
{
    int retval;
    printk("write request: count:%u, offset:%u\n", count, *offp);
    if (*offp > 512)
        return 0;

    if (*offp + count > 512)
        count = 512 - *offp;

    if (copy_from_user(zen_buf+*offp, buff, count)) {
        printk("copy from user failed, count:%ld\n", count);
        retval = -EFAULT;
        goto out;
    }
    *offp += count;
    retval = count;
out:
    return retval;
}

struct file_operations my_fops = {
    .owner = THIS_MODULE,
    .read = zen_read,
    .write = zen_write,
    .open = zen_open,
};

static int __init debugfs_init(void)
{
    printk("INIT MODULE\n");
    zen_dir = debugfs_create_dir("zen_dir4", NULL);
    if (!zen_dir) {
        printk("zen_dir4 is null\n");
        goto fail;
    }
    static struct dentry *sub_zen_dir;
    sub_zen_dir = debugfs_create_dir("sub_zen", zen_dir);
    if (!sub_zen_dir) {
        printk("sub zen dir is null\n");
        goto fail;
    }

    struct dentry *filent = debugfs_create_file("zen", 0644, sub_zen_dir, NULL, &my_fops);
    if (!filent) {
        printk("zen file is null\n");
        goto fail;
    }
    printk("INIT SUCCESS\n");
    return 0;
fail:
//return -ENOENT;
    return -1;
}


static void __exit debugfs_exit(void)
{
    printk("exit module\n");
    debugfs_remove_recursive(zen_dir);
    printk("exit success\n");
}


module_init(debugfs_init);
module_exit(debugfs_exit);
MODULE_LICENSE("GPL");

修订记录#

202306123 修改了文章格式

作者:dennis-wong

出处:https://www.cnblogs.com/dennis-wong/p/16391598.html

版权:本作品采用「署名-非商业性使用-相同方式共享 4.0 国际」许可协议进行许可。

centos误删除恢复 如果在centos系统下,你不小心删除了文件或目录(例如:rm -rf test.txt ),那么不要慌,先静下心来,下面我告诉你恢复方法(删除文件和目录都是一样的) 下边唯一要注意的是,要换成你自己被删除文件的目录 1.执行命令“cd /gitea”进入服务器根目录gitea; 2.执行命令“ mkdir asd”创建一个文件夹; 3.执行命令“ rm -rf asd ”删除该文件;ll查看此时文件以及不存在了 4.执行命令“ debugfs ”运用系统自带恢复工具debugfs来修复; 5.额外 阅读详情

相关推荐

使用debugfs

Linux Kernel debugfs使用及编程

阿xin*的嵌入式AI 973

Linux 内核debugfs总结

Debugfs 是内核开发人员向用户空间提供信息的一种简单方法。/proc 仅用于提供有关进程的信息,或者 sysfs 具有严格的每个文件一个值的规则,而 debugfs 则完全没有规则。开发人员可以将他们想要的任何信息放在那里。debugfs 文件系统也不能作为用户空间的稳定 ABI;理论上,在那里导出的文件没有稳定性限制。现实世界并不总是那么简单,即使是 debugfs 接口,最好的设计也是考虑到它们需要永远维护。(或等效的 /etc/fstab 行)。

uunubt的专栏 4799

DebugFS on Rust

摘要:内核开发者Matthew Maurer在Kangrejos 2025会议上介绍了Rust版DebugFS绑定的实现。DebugFS作为内核的无规则调试接口,允许开发者暴露内部数据用于调试,其特殊性(如文件生命周期长于私有数据、目录需手动清理等)给Rust建模带来挑战。Maurer提出两种API:简单的File API(文件拥有数据)和复杂的Scope API(支持多文件共享数据),并通过"指针走私"技巧(利用Rust函数类型的零大小特性在编译时生成file_operations结构

mounter625的专栏 1006

Linux内核编程(08):debugfs文件系统

一、什么是debugfs 简介:天生为调试内核而生,一个基于内存的文件系统,基于libfs开发的,提供的调试功能强大;相对于procfs、sysfs的优势: ​ procfs:使用procfs调试内核、修改寄存器,对于他的底层read、write接口添加了大量的调试代码。 ​ sysfs:设备模型,导出到用户空间。 ​ debugfs:简化了导处的接口,一行代码就可以将内核变量、数组、链表、内存中的数据、寄存器等信息进行导出。挂载在/sys/kernel/debug上。 二、debugfs配置编译和注

qq_29023095的博客 2315

Linux内核调试工具——Debugfs

Debugfs其存在的主要意义是为了内核开发者向用户空间传递更多有用的信息,与proc不同,proc只提供进程相关的信息;同时也与sysfs不同,sysfs对每个文件都要求一定的规则,而Debugfs没有任何的规则。简而言之,Debugfs是一种用于内核调试的虚拟文件系统。name:文件夹名称parent:父目录,如果为NULL,则在root根目录下name:文件名mode:文件访问权限parent:父目录,用于保存该文件data:保存一些数据等fops:文件操作接口一些类似的接口。...

Donge's Blog 1713

RK3568平台开发系列讲解(调试篇)debugfs 分析手段

debugfs

内核笔记 2329

内核Debugfs文件系统使用指南

什么是Debugfs文件系统? linux文件系统fs的一种,在kernel space和user space之间传递数据,主要是kernel向user输出debug信息。 与sysfs和procfs的区别 procfs:主要输出系统内核参数和进程信息,目录位于/proc/*,参考http://blog.chinaunix.net/uid-20543672-id-3220151.html ...

您的编程如已上线 2406

别再让COGI拖慢你的SAP接口!手把手教你配置BAPI_PRODORDCONF_CREATE_TT的同步货物移动

本文深入解析SAP生产订单报工接口中的COGI问题,通过BAPI_PRODORDCONF_CREATE_TT的同步配置实战,解决异步更新导致的性能瓶颈。文章详细介绍了增强点配置和性能验证,帮助用户彻底消除COGI堆积,提升接口效率。

weixin_29214691的博客 494

gh_mirrors/li/linux内核虚拟文件系统:debugfs与tracefs使用指南

你是否还在为内核调试时缺乏实时状态观测手段而困扰?是否因传统调试方法侵入性过强而影响系统稳定性?本文将系统介绍Linux内核中两种强大的虚拟文件系统——debugfs(调试文件系统)和tracefs(跟踪文件系统),通过12个核心API解析、8个实战案例和5组性能对比数据,帮助开发者构建高效、低侵入的内核调试与跟踪体系。 读完本文你将掌握: - debugfs与tracefs的架构差异及适用场景...

gitblog_00133的博客 2104

MATLAB插值与拟合实战:从数据点到函数模型的完整指南

在数据处理与科学计算中,插值和拟合是两种基础且核心的技术方法。插值旨在构建一个精确穿过所有已知数据点的函数,适用于数据精确、需要重构中间值的场景,如信号重采样和图像缩放;其数学原理基于在数据点间构造分段多项式或样条函数。拟合则侧重于从含有噪声的数据中提取整体趋势,通过最小化残差平方和等准则确定模型参数,广泛应用于物理定律验证和预测分析。从技术价值看,正确选择插值或拟合能避免模型失真,确保结论可靠性。在工程实践中,MATLAB提供了interp1、polyfit等强大工具,结合样条插值、多项式拟合等方法,可有

weixin_34301132的博客 477

涨姿势|小众建模软件Make human,MakeClothes插件使用详解教程(2)

衣服可以从头开始建模,或者通过改变人体网格或由MakeClothes工具提供的“服装助手”(见下文)来建模。在设计和建模一件衣物时,应该记住两个限制。首先,将服装网格映射到人体网格的算法要求服装网格完全由四面体组成。其次,知道MakeClothes每件衣服只支持一种材料是很重要的。 完成MakeClothes工作流程后,您的HOME / makehuman / v1 / data / clothes中的工具将创建一个新文件夹。该文件夹将采用用户为服装项目提供的唯一名称。该文件夹将填充必要的资源,以使该项目在

Crazy_in_3Dmax的博客 1880

内核调度器终极调试:sched_debugfs_write实现全解析

你是否曾在调试Linux内核调度问题时陷入困境?面对系统卡顿、进程优先级异常等问题,却找不到有效的调试入口?本文将深入解析内核调度器调试机制的核心实现,通过对相关模块的分析,帮助你掌握内核调度行为的调试技巧。 ## 内核调度器调试框架概述 Linux内核提供了丰富的调试接口,其中debugfs文件系统是内核开发者常用的调试工具之一。调度器作为内核的核心组件,其调试接口主要通过debugfs实现...

gitblog_00712的博客 1076

SAP-PM设备模块-PM主数据之功能位置

SAP-PM模块学习

TRUIXIANG的博客 5151

攻克内核调试痛点:debugfs_create_symlink创建符号链接完全指南

你是否还在为内核调试中复杂的文件系统层级而困扰?是否经常需要在不同目录间切换查看相关调试信息?本文将为你详细介绍`debugfs_create_symlink`函数,它能帮助你在调试文件系统(DebugFS)中创建符号链接,简化调试路径,提升内核调试效率。读完本文后,你将能够熟练使用该函数创建符号链接,优化调试环境,解决实际调试中的路径跳转问题。 ## 一、DebugFS简介 DebugFS(...

gitblog_00406的博客 477

基于单片机负载控制的无人机电气设备监测系统设计

为深入分析无人机电气设备的电子负载性能,实现对传输电子量的合理性监管与控制,设计基于单片机负载控制的无人机电气设备监测系统;利用电气信号发生电路,构建负载网络控制器与以太网模块运行所需的电气设备负载环境,借助PCB监控板建立PLC扩展负载模块与核心监控主机之间的物理连接关系,实现无人机电气设备监测系统的硬件执行环境搭建;在此基础上,通过STM32型单片机移植协议,确定无人机电气设备通信主机的现有组态形式,联合已设定的监控任务有线级条件,实现监测系统的软件执行环境搭建,完成基于单片机负载控制的无人机电气设备监

weixin_45905610的博客 1312

PLECS中DLL模块的使用

PLECS中DLL模块的使用 之前发布了一篇文章,介绍如何使用PSIM中的DLL模块。而本篇文章的内容与之类似,不过主角换成了PLECS。 PLECS和PSIM类似,也属于电力电子仿真软件,使用方便,仿真速度快,和Matlab也有一定的联系,有兴趣的可以去试试。PLECS可以利用外部动态链接库(DLL)来调用外部的代码参与仿真,方便复杂控制算法的实现,也有利于后期直接将代码移植到硬件控制器上。

OptimisticPoplar的博客 2735

linux gpiolib

gpiolib的建立 smdkc110_map_io s5pv210_gpiolib_init // gpiolib的初始化过程 struct s3c_gpio_chip 结构体 里面变量,分析 调用关系 samsung_gpiolib_add_4bit_chips samsung_gpiolib_add_4bit s3c_gpiolib_add 注册方法: s3c_gpiol...

longjingcha110的博客 159

Verilog流水线CPU设计(超详细)

快把这一篇给更了

Ace Cheney的博客 7万+

debugfs案例实战分析

选择原则调试需求 → debugfs系统信息展示 → proc持久化配置 → sysfs三、实战案例分析。

m0_74186706的博客 1256

Versal - 从零构建Petalinux 2024.2 AI边缘计算平台(VD100+SDT+JupyterLab实战)

本文详细介绍了如何从零开始,基于AMD Versal VD100开发板和Petalinux 2024.2构建AI边缘计算平台。内容涵盖开发环境搭建、Petalinux工程创建与配置、SDT新流程实战、启动SD卡制作,并最终集成JupyterLab与Conda,打造出开箱即用的交互式AI开发环境,帮助开发者快速进行算法验证与部署。

5f4d3s2a1q的博客 495

深度学习工具包 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")

[Linux]使用debugfs文件系统

内核开发者经常需要向用户空间应用输出一些调试信息,在稳定的系统中可能根本不需要这些调试信息,但是在开发过程中,为了搞清楚内核的行为,调试信息非常必要,printk可能是用的最多的,但它并不是最好的,调试信息只是在开发中用于调试,而printk将一直输出,因此开发完毕后需要清除不必要的printk语句,另外如果开发者希望用户空间应用能够改变内核行为时,printk就无法实现。因此,需要一种新的机制,...

wangyijieonline的博客 8561

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

debugfs

在调试linux驱动的时候,可以用debugfs来调试,debugfs类似字符设备驱动一样,甚至更简单,不需要主设备号次设备号等等,只需要实现一个file_operations,然后通过debugfs_create_file就可以在debugfs中建立一个文件结点,就像字符设备驱动那样,只需要对这个文件结点进行open就可以进行read、write、ioctl,等等操作,这些操作对应到我们在驱动里为debugfs准备的file_operations。 让内核支持DEBUGFS,使能宏CONFIG_DEBU

ddddfang的专栏 1583

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

linux debugfs

执行完成挂载命令以后,进入。

帅的没拼音 1027

第1章: DebugFS 概述

DebugFS 是 Linux 内核中的轻量级虚拟文件系统,专门用于内核调试和开发。它通过文件形式暴露内核内部状态,具有动态生成、零开销等特点。DebugFS 主要用于驱动调试、性能分析、内核子系统诊断等功能,相比 SysFS 和 ProcFS 提供了更灵活的调试接口。默认挂载在 /sys/kernel/debug,通常仅 root 可访问。用户可通过命令行工具或编程接口读取/写入 DebugFS 文件,实现内核状态的实时监控和调试功能。由于不保证 ABI 稳定性,建议仅用于开发环境。

图形/计算GPU的驱动与虚拟化技术分享园地 1419

08 - debugfs

debugfs

嵌入式wu 1200

Linux内核开启DebugFS以及查看debug信息(/sys/kernel/debug及debugfs)

一、Linux内核开启DebugFS 进入内核配置界面,查找DebugFS: 开启配置: 二、Linux内核挂载DebugFS mount -t debugfs none /sys/kernel/debug/ 三、查看debug信息 所有debug信息都在/sys/kernel/debug/路径中。 比如查看当前gpio使用情况: ...

Mculover666的博客(嵌入式) 1万+
上一篇: QT提示warning: overriding recipe for target【解决方法】
下一篇: 在Linux中查找和删除重复文件的4种方法
ken2232
博客等级 码龄10年 1万+粉丝 409原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址