/proc/mtd 各参数的含义 -- linux内核

经/proc虚拟文件系统读取MTD分区表:cat /proc/mtd

mtd .name = raspi, .size = 0x00400000 (4M) .erasesize = 0x00010000 (64K) .numeraseregions = 0

Creating 6 MTD partitions on "raspi":

0x00000000-0x00400000 : "ALL"

0x00000000-0x00030000 : "Bootloader"

0x00030000-0x00040000 : "Config"

0x00040000-0x00050000 : "Factory"

0x00050000-0x00360000 : "Kernel"

0x00360000-0x003b0000 : "DATA"

通过这个结构体可知size是本mtd分区的最大字节数空间
,erasesize是本分区的最小擦除字节数空间(块大小,linux的flash是以块为擦除单位的) 。

以下是别人的文章:

详细由linux/drivers/mtd下的mtdcore.c文件里的mtd_read_proc函数来实现:

static inline int mtd_proc_info (char *buf, int i)

{

struct mtd_info *this = mtd_table[i];

if (!this)

return 0;

return sprintf(buf, "mtd%d: %8.8x %8.8x \"%s\"\n", i, this->size,

this->erasesize, this->name);

}

static int mtd_read_proc (char *page, char **start, off_t off, int count,

int *eof, void *data_unused)

{

int len, l, i;

off_t begin = 0;

mutex_lock(&mtd_table_mutex);

len = sprintf(page, "dev: size erasesize name\n");

for (i=0; i< MAX_MTD_DEVICES; i++) {

l = mtd_proc_info(page + len, i);

len += l;

if (len+begin > off+count)

goto done;

if (len+begin < off) {

begin += len;

len = 0;

}

}

*eof = 1;

done:

mutex_unlock(&mtd_table_mutex);

if (off >= len+begin)

return 0;

*start = page + (off-begin);

return ((count < begin+len-off) ? count : begin+len-off);

}

读出来的结果例如以下:

dev: size erasesize name

mtd0: 01000000 00020000 "boot"

mtd1: 01000000 00020000 "setting"

mtd2: 02000000 00020000 "rootfs"

mtd3: 0be00000 00020000 "home"

mtd4: 00200000 00020000 "storage"

mtd5: 00040000 00010000 "u-boot"

mtd6: 00040000 00010000 "others"

当中size和erasesize的定义在linux/include/linux/mtd下mtd.h文件里的struct mtd_info结构体定义:

struct mtd_info {

u_char type;

u_int32_t flags;

u_int32_t size; // Total size of the MTD

/* "Major" erase size for the device. users may take this

* to be the only erase size available, or may use the more detailed

* information below if they desire

*/

u_int32_t erasesize;

/* Minimal writable flash unit size. In case of NOR flash it is 1 (even

* though individual bits can be cleared), in case of NAND flash it is

* one NAND page (or half, or one-fourths of it), in case of ECC-ed NOR

* it is of ECC block size, etc. It is illegal to have writesize = 0.

* Any driver registering a struct mtd_info must ensure a writesize of

* 1 or larger.

*/

u_int32_t writesize;

u_int32_t oobsize; // Amount of OOB data per block (e.g. 16)

u_int32_t oobavail; // Available OOB bytes per block

// Kernel-only stuff starts here.

char *name;

int index;

/* ecc layout structure pointer - read only ! */

struct nand_ecclayout *ecclayout;

/* Data for variable erase regions. If numeraseregions is zero,

* it means that the whole device has erasesize as given above.

*/

int numeraseregions;

struct mtd_erase_region_info *eraseregions;

int (*erase) (struct mtd_info *mtd, struct erase_info *instr);

/* This stuff for eXecute-In-Place */

int (*point) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char **mtdbuf);

/* We probably shouldn‘t allow XIP if the unpoint isn‘t a NULL */

void (*unpoint) (struct mtd_info *mtd, u_char * addr, loff_t from, size_t len);

int (*read) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf);

int (*write) (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf);

int (*read_oob) (struct mtd_info *mtd, loff_t from,

struct mtd_oob_ops *ops);

int (*write_oob) (struct mtd_info *mtd, loff_t to,

struct mtd_oob_ops *ops);

/*

* Methods to access the protection register area, present in some

* flash devices. The user data is one time programmable but the

* factory data is read only.

*/

int (*get_fact_prot_info) (struct mtd_info *mtd, struct otp_info *buf, size_t len);

int (*read_fact_prot_reg) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf);

int (*get_user_prot_info) (struct mtd_info *mtd, struct otp_info *buf, size_t len);

int (*read_user_prot_reg) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf);

int (*write_user_prot_reg) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf);

int (*lock_user_prot_reg) (struct mtd_info *mtd, loff_t from, size_t len);

/* kvec-based read/write methods.

NB: The ‘count‘ parameter is the number of _vectors_, each of

which contains an (ofs, len) tuple.

*/

int (*writev) (struct mtd_info *mtd, const struct kvec *vecs, unsigned long count, loff_t to, size_t *retlen);

/* Sync */

void (*sync) (struct mtd_info *mtd);

/* Chip-supported device locking */

int (*lock) (struct mtd_info *mtd, loff_t ofs, size_t len);

int (*unlock) (struct mtd_info *mtd, loff_t ofs, size_t len);

/* Power Management functions */

int (*suspend) (struct mtd_info *mtd);

void (*resume) (struct mtd_info *mtd);

/* Bad block management functions */

int (*block_isbad) (struct mtd_info *mtd, loff_t ofs);

int (*block_markbad) (struct mtd_info *mtd, loff_t ofs);

struct notifier_block reboot_notifier; /* default mode before reboot */

/* ECC status information */

struct mtd_ecc_stats ecc_stats;

/* Subpage shift (NAND) */

int subpage_sft;

void *priv;

struct module *owner;

int usecount;

/* If the driver is something smart, like UBI, it may need to maintain

* its own reference counting. The below functions are only for driver.

* The driver may register its callbacks. These callbacks are not

* supposed to be called by MTD users */

int (*get_device) (struct mtd_info *mtd);

void (*put_device) (struct mtd_info *mtd);

}

版权声明:本文博主原创文章,博客,未经同意不得转载。

时间: 2024-10-12 20:26:37

/proc/mtd 各参数的含义 -- linux内核的相关文章

/proc/mtd 各个参数含义 -- linux内核

通过/proc虚拟文件系统读取MTD分区表:cat /proc/mtd mtd .name = raspi, .size = 0x00400000 (4M) .erasesize = 0x00010000 (64K) .numeraseregions = 0 Creating 6 MTD partitions on "raspi": 0x00000000-0x00400000 : "ALL" 0x00000000-0x00030000 : "Bootloa

nginx 高并发参数配置及linux内核参数优化

一.一般来说nginx 配置文件中对优化比较有作用的为以下几项: 1.  worker_processes 8; nginx 进程数,建议按照cpu 数目来指定,一般为它的倍数 (如,2个四核的cpu计为8). 2.  worker_cpu_affinity 00000001 0000001000000100 00001000 00010000 00100000 01000000 10000000; 为每个进程分配cpu,上例中将8 个进程分配到8 个cpu,当然可以写多个,或者将一个进程分配到

linux 内核参数优化

linux 内核参数优化 Sysctl命令及linux内核参数调整 一.Sysctl命令用来配置与显示在/proc/sys目录中的内核参数.如果想使参数长期保存,可以通过编辑/etc/sysctl.conf文件来实现. 命令格式: sysctl [-n] [-e] -w variable=value sysctl [-n] [-e] -p (default /etc/sysctl.conf) sysctl [-n] [-e] –a 常用参数的意义: -w  临时改变某个指定参数的值,如 # sy

Sysctl命令及linux内核参数调整

一.Sysctl命令用来配置与显示在/proc/sys目录中的内核参数.如果想使参数长期保存,可以通过编辑/etc/sysctl.conf文件来实现. 命令格式: sysctl [-n] [-e] -w variable=value sysctl [-n] [-e] -p (default /etc/sysctl.conf) sysctl [-n] [-e] –a 常用参数的意义: -w  临时改变某个指定参数的值,如 # sysctl -w net.ipv4.ip_forward=1 -a  

Linux 内核引导参数简介

概述 内核引导参数大体上可以分为两类:一类与设备无关.另一类与设备有关.与设备有关的引导参数多如牛毛,需要你自己阅读内核中的相应驱动程序源码以获取其能够接受的引导参数.比如,如果你想知道可以向 AHA1542 SCSI 驱动程序传递哪些引导参数,那么就查看 drivers/scsi/aha1542.c 文件,一般在前面 100 行注释里就可以找到所接受的引导参数说明.大多数参数是通过"__setup(... , ...)"函数设置的,少部分是通过"early_param(..

Linux 内核参数 arp_ignore &amp; arp_announce 详解

arp_ignore定义了对目标地址为本机IP的ARP询问的不同应答模式. arp_announce对网络接口(网卡)上发出的ARP请求包中的源IP地址作出相应的限制:主机会根据这个参数值的不同选择使用IP数据包的源IP或当前网络接口卡的IP地址作为ARP请求包的源IP地址. arp_ignore 在内核参数中除了每个网卡都有自己的arp_ignore配置外,还有两个(一个是默认default,一个是全局all)需要用到arp_ignore配置.所有配置项如下面的代码段: net.ipv4.co

技巧-Linux内核参数调整办法

技巧 -Linux内核参数调整办法 ulimit设置 ulimit -n 要调整为100000甚至更大. 命令行下执行 ulimit -n 100000即可修改.如果不能修改,需要设置 /etc/security/limits.conf,加入 * soft nofile 262140 * hard nofile 262140 root soft nofile 262140 root hard nofile 262140 * soft core unlimited * hard core unli

linux内核参数注释与优化

转自:http://yangrong.blog.51cto.com/6945369/1321594 目录 1.linux内核参数注释 2.两种修改内核参数方法 3.内核优化参数生产配置 参数解释由网络上收集整理,常用优化参数对比了网上多个实际应用进行表格化整理,使查看更直观. 学习linux也有不少时间了,每次优化linux内核参数时,都是在网上拷贝而使用,甚至别人没有列出来的参数就不管了,难道我就不需要了吗? 参考文章: linux内核TCP相关参数解释 http://os.chinaunix

uboot环境变量(设置bootargs向linux内核传递正确的参数)

这是我uboot的环境变量设置,在该设置下可以运行initram内核(从内存下载到nandflash再运行),但是运行nfs根文件系统的时候一直出错,各种错误.查看了很多资料后猜想应该是uboot传递给linux内核的参数有问题,也就是bootargs的设置有问题. #printenv bootargs=noinitrd root=/dev/mtdblock3 init=/linuxrc console=ttySAC0,115200 rootfstype=yaffs2 rw mem=64M bo