1. 嵌入式存储系统
从冯.诺依曼的存储程序工作原理及计算机的组成来说,计算机由运算器、控制器、存储器和输入/输出设备五大部件组成。其中运算器和控制器统称为中央处理器(CPU),而存储系统分成内部存储器(内存)和外部存储器(外存)。输入/输出设备并非计算机所必需的,如果一个设备具有CPU,内存和外存,我们就可以说它是一台计算机。在很多嵌入式设备上,都没有输入/输出设备,所以从广义来讲,我们的手机,MP3,平板电脑都可以说是一台计算机。
大家可能都听说过单片机,那么什么是单片机呢?其实单片机就是把CPU,内存和外存集成在一个芯片里面,当然他还包括其他的一些功能模块。那么我们听说的ARM9,ARM11是不是单片机呢?从严格意义上来讲,他们并不是单片机,虽说在很多ARM处理器里面都集成得有一个小容量的SRAM,但是由于CPU内部没有能够掉电保存数据的外存,所以它就不是单片机。
中央处理器(英文CentralProcessingUnit,CPU)是一台计算机的运算核心和控制核心,其功能主要是解释计算机指令以及处理计算机软件中的数据。CPU由运算器、控制器和寄存器及实现它们之间联系的数据、控制及状态的总线构成。差不多所有的CPU的运作原理可分为四个阶段:提取/取指(Fetch)、解码(Decode)、执行(Execute)和写回(Writeback)。 由于CPU的速度很快,而外存的速度很慢,所以CPU不从外存中取出数据,而是从内存或高速缓冲存储器(cache)中取出指令,放入指令寄存器,并对指令译码,并执行指令。
存储器是用来存储程序和数据的部件,对于计算机来说,有了存储器,才有记忆功能,才能保证正常工作。存储器的种类很多,按其用途可分为主存储器(简称内存或主存)和辅助存储器(简称外存)。内存是电脑中的主要部件,它是相对于外存而言的,其存储速度快,掉电后数据丢失,是CPU能直接寻址的存储空间。内存一般采用半导体存储单元,包括随机存储器(RAM)以及高速缓存(CACHE),而RAM是其中最重要的存储器。在系统上电前,所有的数据都是存放在外存中的,内存中的数据不可使用。当内存中没有CPU需要的数据时,会使用DMA(相当于一个协处理器)将数据从外存中调入到内存后,再从内存取数据。
l 随机存储器(RAM)
RAM(random access memory)随机存储器。存储单元的内容可按需随意取出或存入,且存取的速度与存储单元的位置无关的存储器。这种存储器在断电时将丢失其存储内容,故主要用于存储短时间使用的程序。 按照存储信息的不同,随机存储器又分为静态随机存储器(Static RAM,SRAM)和动态随机存储器(Dynamic RAM,DRAM)。
SRAM不需要刷新电路即能保存它内部存储的数据,而DRAM(Dynamic Random Access Memory)每隔一段时间,要刷新充电一次,否则内部的数据即会消失,因此SRAM具有较快的速度和较高的性能,但是SRAM也有它的缺点,即它的集成度较低,相同容量的DRAM内存可以设计为较小的体积,但是SRAM却需要很大的体积,且功耗较大。SRAM的速度快但昂贵,一般用小容量的SRAM作为更高速CPU和较低速DRAM 之间的缓存(cache).
在嵌入式领域,我们常见的DRAM有SDRAM和DDR(DOUBLE DATA RATE)RAM。SDRAM将CPU与RAM通过一个相同的时钟锁在一起,使CPU和RAM能够共享一个时钟周期,以相同的速度同步工作,每一个时钟脉冲的上升沿便开始传递数据。DDR RAM 是SDRAM的更新换代产品,他允许在时钟脉冲的上升沿和下降沿传输数据,这样不需要提高时钟的频率就能加倍提高SDRAM的速度,在PC上上很常见,另外,很多高端的ARM处理器也支持DDR RAM。
l 高速缓冲存储器(Cache)
Cache也是我们经常遇到的概念,也就是平常看到的一级缓存(L1 Cache)、二级缓存(L2 Cache)、三级缓存(L3 Cache)这些数据,它位于CPU与内存之间,是一个读写速度比内存更快的存储器。当CPU向内存中写入或读出数据时,这个数据也被存储进高速缓冲存储器中。当CPU再次需要这些数据时,CPU就从高速缓冲存储器读取数据,而不是访问较慢的内存,当然,如需要的数据在Cache中没有,CPU会再去读取内存中的数据。
l 只读存储器(ROM)
只读存储器(Read-Only Memory)是一种只能读取资料的存储器。在制造过程中,将资料以一特制光罩(mask)烧录于线路中,其资料内容在写入后就不能更改,所以有时又称为“光罩式只读内存”(mask ROM)。此内存的制造成本较低,常用于电脑中的开机启动如启动光盘,在系统装好的电脑上时,计算机将C盘目录下的操作系统文件读取至内存,然后通过cpu调用各种配件进行工作这时系统存放存储器为RAM 。这种属于COMPACT DISC激光唱片,光盘就是这种。
l 可编程程序只读内存(PROM)
可编程程序只读内存(Programmable ROM,PROM)之内部有行列式的镕丝,是需要利用电流将其烧断,写入所需的资料,但仅能写录一次。 PROM在出厂时,存储的内容全为1,用户可以根据需要将其中的某些单元写入数据0(部分的PROM在出厂时数据全为0,则用 户可以将其中的部分单元写入1), 以实现对其“编程”的目的。PROM的典型产品是“双极性熔丝结构”,如果我们想改写某些单元,则可以给这些单元通以足够大的电流,并维持一定的时间,原 先的熔丝即可熔断,这样就达到了改写某些位的效果。另外一类经典的PROM为使用“肖特基二极管”的PROM,出厂时,其中的二极管处于反向截止状态,还 是用大电流的方法将反相电压加在“肖特基二极管”,造成其永久性击穿即可。
l EPROM
可擦出可编程只读内存(Erasable Programmable Read Only Memory,EPROM)可利用高电压将资料编程写入,抹除时将线路曝光于紫外线下,则资料可被清空,并且可重复使用。通常在封装外壳上会预留一个石英透明窗以方便曝光。
l EEPROM
电可擦出可编程只读内存(Electrically Erasable Programmable Read Only Memory,EEPROM)之运作原理类似EPROM,但是抹除的方式是使用高电场来完成,因此不需要透明窗。
l FLASH
FLASH表示Flash Memory的意思,即平时所说的“闪存”,全名叫Flash EEPROM Memory。它结合了ROM和RAM的长处,不仅具备电子可擦除可编程(EEPROM)的性能,还可以快速读取数据(NVRAM的优势),使数据不会因为断电而丢失。U盘和MP3里用的就是这种存储器。在过去的20年里,嵌入式系统一直使用ROM(EPROM)作为它们的存储设备,然而近年来Flash全面代替了ROM(EPROM)在嵌入式系统中的地位,用作存储Bootloader以及操作系统或者程序代码,或者直接当硬盘使用(U盘)。
嵌入式硬件系统一般都需要有软件的支持才能够正常工作,嵌入式系统需要为软件提供相应的存储空间。在以往的单片机系统内,一般使用ROM(Read Only Memory)或EPROM(Erasable Programmable Read Only Memory)存储程序。由于现有的嵌入式系统越来越复杂,原有的ROM由于容量、灵活性差等的限制,无法满足日益复杂的应用要求。
闪存(Flash)是电可擦除只读存储器(EEPROM)的变种,但兼有RAM和ROM 的优点,是一种可在系统(In-System)进行电擦写,掉电后信息不丢失的存储器,同时它的高集成度和低成本使它成为市场主流。随着Flash技术的成熟和普及,一些单片机芯片(如Freescale的8位单片机MC68HC908)已经开始采用片内FLASH取代过去常用的片内ROM或EPROM,使单片机具有了在线编程写入或擦除的功能。
FLASH在结构和操作方式上与硬盘、EEROM等其他存储介质有较大区别,他都是只能将1写为0,而不能将0写成1。所以在Flash编程之前,必须以块为单位(块大小一般为256KB到20MB)将对应的块擦除,而擦除的过程就是将所有位都写为1的过程,块内的所有字节变为0xFF。因此可以说,编程是将相应位写0的过程,而擦除是将相应位写1的过程,两者的执行过程完全相反。而EEPROM能在字节水平上进行删除和重写而不是整个芯片擦写,这样闪存就比EEPROM的更新速度快。
Flash 芯片是由内部成千上万个存储单元组成的,每个单元存储一个bit。具有低功耗、大容量、擦写速度快、可整片或分扇区在系统编程(烧写)、擦除等特点,并且可由内部嵌入的算法完成对芯片的操作,因而在各种嵌入式系统中得到了广泛的应用。作为一种非易失性存储器,Flash在系统中通常用于存放程序代码、常量表以及一些在系统掉电后需要保存的用户数据等。常用的Flash为8位或16位的数据宽度,编程电压为单3.3V。主要的生产厂商为INTEL、ATMEL、AMD、HYUNDAI等。Flash 技术根据不同的应用场合也分为不同的发展方向,有擅长存储代码的NOR Flash和擅长存储数据的NAND Flash。
首先表现在向芯片中写数据必须先将芯片中对应的内容清空,然后再写入,即先擦后写。只不过NORFlash芯片只用擦写一个字,而NAND需要擦写整个块.其次,闪存擦写的次数都是有限的.当闪存使用接近使用寿命时,经常会出现写操作失败;到达使用寿命时,闪存内部存放的数据虽然可以读,但不能再进行写操作了.所以为了防止上面问题的发生,不能对某个特定的区域反复进行写操作.通常NANDFlash可擦写次数高于NORFlash芯片,但是由于NANDFlash通常是整块擦写,块内的页面中如果有一位失效整个块就会失效,而且由于擦写过程复杂,失败的概率相对较高,所以从整体上来说NOR的寿命较长.
另一个共性是闪存的读写操作不仅仅是一个物理操作,实际上在闪存上存放数据必须使用算法实现,这个模块一般在驱动程序的MTD'(Memory Technology Drivers)模块中或者在FTLZ (Flash Translation Layer)层内实现,具体算法和芯片的生产厂商以及芯片型号有关系.通过比较可以发现,NAND更适用于复杂的文件应用,但是由于NAND芯片的使用相对复杂,所以对文件系统有较高的要求.
(1)闪存芯片读写的基本单位不同
应用程序对NorFlash芯片操作以“字”为基本单位.为了方便对大容量NorFlash闪存的管理,通常将NOR闪存分成大小为128KB或64KB的逻辑块,有时块内还分扇区.读写时需要同时指定逻辑块号和块内偏移.应用程序对NandFlash芯片操作是以“块”为基本单位.NAND闪存的块比较小,一般是8KB,然后每块又分成页,页大小一般是512字节.要修改NandFlash芯片中一个字节,必须重写整个数据块.
(2)NorFlash闪存是随机存储介质,用于数据量较小的场合;NandFlash闪存是连续存储介质,适合存放大的数据.
(3)由于NorFlash地址线和数据线分开,所以NorFlash芯片可以像SDRAM一样连在数据线上.NOR芯片的使用类似于通常内存芯片,传输效率高,可执行程序可以在芯片内执行(XI P, eXecute In Place),这样应用程序可以直接在flash闪存内运行,不必再把代码读到系统RAM中.由于NorFlash的这个特点,嵌入式系统中经常将NOR芯片做启动芯片使用.NandFlash共用地址和数据总线,需要额外联结一些控制的输入输出,所以直接将NAND芯片做启动芯片比较难.
(4)NandFlash闪存芯片因为共用地址和数据总线的原因,不允许对一个字节甚至一个块进行的数据清空,只能对一个固定大小的区域进行清零操作;NorFlash芯片可以对字进行操作.所以在处理小数据量的I/O操作的时候的速度要快与NorFlash的速度.比如一块NorFlash芯片通常写一个字需要10us,在32位总线上写512字节需要1280us;NandFlash闪存写512字节需要的时间包括:512×每字节50ns+10us的寻页时间+200us的片擦写时间=234us.
(5)NandFlash闪存的容量比较大,最大容量己达到8G字节.为了方便管理,NandFlash的存储空间使用了块和页两级存储体系,也就是说它的存储空间是二维的,比如K9F5608UOA闪存块的大小为16K,每页大小是512字节,每页还16字节空闲区用来存放错误校验码空间(也称为out-of-band,OOB空间).在进行写操作时,NandFlash闪存每次将一个字节的数据放入内部的缓存区,然后再发出“写指令”进行写操作.由于对NandFlash闪存的操作都是以块和页为单位的,所以在向NandFlash闪存进行大量数据的读写时,NAND的速度要快于NOR闪存.
(6)NorFlash闪存的可靠性要高于NandFlash闪存,是因为NorFlash型闪存的接口简单,数据操作少,位交换操作少,因此可靠性高,极少出现坏区块,一般用在对可靠性要求高的地方.NandFlash型闪存接口和操作均相对复杂,位交换操作也很多,关键性数据更是需安错误探测/错误更正(EDC/ECC)算法来确保数据的完整性,因此出现问题的几率要大得多,坏区块也是不可避免的,而且由于坏区块是随机分布的,连纠错也无法做到.
(7)NANDFlash一般地址线和数据线共用,对读写速度有一定影响;NORFlash闪存数据线和地址线分开,相对而言读写速度快一些.
(8)接口对比
NorFlash带有通用的SRAM接口,可以轻松地挂接在CPU的地址、数据总线上,对CPU的接口要求低。NorFlash的特点是芯片内执行(XIP,eXecute In Place),这样应用程序可以直接在flash闪存内运行,不必再把代码读到系统RAM中.如uboot中的ro段可以直接在NorFlash上运行,只需要把rw和zi段拷贝到RAM中运行即可.
NandFlash器件使用复杂的I/O口来串行地存取数据,8个引脚用来传送控制、地址和数据信息。由于时序较为复杂,所以一般CPU最好集成NandFlash控制器.另外由于NandFlash没有挂接在地址总线上,所以如果想用NandFlash作为系统的启动盘,就需要CPU具备特殊的功能,如s3c2440在被选择为NandFlash启动方式时会在上电时自动读取NandFlash的4k数据到地址0的SRAM中.如果CPU不具备这种特殊功能,用户不能直接运行NandFlash上的代码,那可以采取其他方式,比如好多使用NandFlash的开发板除了使用NandFlash以外,还用上了一块小的NorFlash来运行启动代码.
(9)容量和成本对比
相比起NandFlash来说,NorFlash的容量要小,一般在1~16MByte左右,一些新工艺采用了芯片叠加技术可以把NorFlash的容量做得大一些.在价格方面,NorFlash相比NandFlash来说较高,如目前市场上一片4Mbyte的AM29lv320 NorFlash零售价在20元左右,而一片128MByte的k9f1g08 NandFlash零售价在30元左右. NandFlash生产过程更为简单,NAND结构可以在给定的模具尺寸内提供更高的容量,这样也就相应地降低了价格.
(10)可靠性性对比
NandFlash器件中的坏块是随机分布的,以前也曾有过消除坏块的努力,但发现成品率太低,代价太高,根本不划算.Nand器件需要对介质进行初始化扫描以发现坏块,并将坏块标记为不可用.在已制成的器件中,如果通过可靠的方法不能进行这项处理,将导致高故障率。而坏块问题在NorFlash上是不存在的.
在Flash的位翻转(一个bit位发生翻转)现象上,NAND的出现几率要比NorFlash大得多.这个问题在Flash存储关键文件时是致命的,所以在使用NandFlash时建议同时使用EDC/ECC等校验算法.
(11)升级对比
NorFlash的升级较为麻烦,因为不同容量的NorFlash的地址线需求不一样,所以在更换不同容量的NorFlash芯片时不方便.通常我们会通过在电路板的地址线上做一些跳接电阻来解决这样的问题,针对不同容量的NorFlash. 而不同容量的NandFlash的接口是固定的,所以升级简单.
(12)读写性能对比
写操作:任何flash器件的写入操作都只能在空或已擦除的单元内进行.NAND器件执行擦除操作是十分简单的,而NOR则要求在进行擦除前先要将目标块内所有的位都写为1.擦除NOR器件时是以64~128KB的块进行的,执行一个擦除/写入操作的时间约为5s.擦除NAND器件是以8~32KB的块进行的,执行一个擦除/写入操作最多只需要4ms. 读操作:NOR的读速度比NAND稍快一些.
(13)文件系统比较
Linux系统中采用MTD来管理不同类型的Flash芯片,包括NandFlash和NorFlash.支持在Flash上运行的常用文件系统有cramfs、jffs、jffs2、yaffs、yaffs2等.cramfs文件系统是只读文件系统.如果想在Flash上实现读写操作,通常在NorFlash上我们会选取jffs及jffs2文件系统,在NandFlash上选用yaffs或yaffs2文件系统.Yaffs2文件系统支持大页(大于512字节/页)的NandFlash存储器.
*****************************************************************************************************************
装载声明:原文链接
*****************************************************************************************************************
Linux支持多种文件系统,包括ext2、ext3、vfat、ntfs、iso9660、jffs、romfs和nfs等,为了对各类文件系统 进行统一管理,Linux引入了虚拟文件系统VFS(Virtual File System),为各类文件系统提供一个统一的操作界面和应用编程接口。Linux启动时,第一个必须挂载的是根文件系统;若系统不能从指定设备上挂载根文件系统,则系统会出错而退出启动。之后可以自动或手动挂载其他的文件系统。因此,一个系统中可以同时存在不同的文件系统。
不同的文件系统类型有不同的特点,因而根据存储设备的硬件特性、系统需求等有不同的应用场合。在嵌入式Linux应用中,主要的存储设备为 RAM(DRAM, SDRAM)和ROM(常采用FLASH存储器),常用的基于存储设备的文件系统类型包括:jffs2, yaffs, cramfs, romfs, ramdisk, ramfs/tmpfs等。
initramfs在编译内核的同时被编译并与内核生成一个映像文件,可以压缩也可以不压缩,但是目前只支持cpio包格式。它是根文件系统制作和制作的一种非常简单的方法,也可以通过执行这个文件系统中的程序引导真正的文件系统,这样加载根文件系统的工作就不是内核的工作,而是initramfs的工作。由于initramfs使用cpio包格式,所以很容易将一个单一的文件、目录、node编译链接到系统中去,这样很简单的系统中使用起来很方便,不需要另外挂接文件系统。
但是因为cpio包实际是文件、目录、节点的描述语言包,为了描述一个文件、目录、节点,要增加很多额外的描述文字开销,特别是对于目录和节点,本身很小额外添加的描述文字却很多,这样使得cpio包比相应的image文件大很多。
ramdisk是一种基于内存的虚拟文件系统(并非一个实际的文件系统),它将一部分固定大小(这个大小在编译内核的make menuconfig时配置)的内存当作硬盘一个分区来使用。ramdisk是一种将实际的文件系统装入内存的机制,并且可以作为根文件系统,通常我们会使用ext2或ext3文件系统来格式化它。由于ramdisk是在内存中进行操作的,所以我们可以对里面的文件进行添加,修改,删除等等操作,但是一掉电,就什么也没有了。由于这个特性,我们可以将一些经常被访问而又不会更改的文件(如只读的根文件系统)通过Ramdisk放在内存中,这样可以明显地提高系统的性能。
在Linux的启动阶段,内核和ramdisk都是由 bootloader在启动时加载至内存的指定位置(),而initrd提供了一套机制,可以将内核映像和根文件系统一起载入内存。initrd 是boot loader initialized RAM disk,顾名思义是在系统初始化引导时候用的ramdisk,它的作用是完善内核的模块机制,让内核的初始化流程更具弹性。
Ramfs是Linus Torvalds开发的一种基于内存的文件系统,工作于虚拟文件系统(VFS)层,不能格式化,可以创建多个,在创建时可以指定其最大能使用的内存大小。(实际上,VFS本质上可看成一种内存文件系统,它统一了文件在内核中的表示方式,并对磁盘文件系统进行缓冲。)Ramfs/tmpfs文件系统把所有的文件都放在RAM中,所以读/写操作发生在RAM中,可以用ramfs/tmpfs来存储一些临时性或经常要修改的数据,例如/tmp和/var目录,这样既避免了对Flash存储器的读写损耗,也提高了数据读写速度。Ramfs/tmpfs相对于传统的Ramdisk的不同之处主要在于:不能格式化,文件系统大小可随所含文件内容大小变化。但他们都不可以像ramdisk一样作为根文件系统,而只能想procfs,devfs一样作为伪文件系统使用。
NFS网络文件系统(Network File System)是由Sun开发并发展起来的一项在不同机器、不同操作系统之间通过网络共享文件的技术。在嵌入式Linux系统的开发调试阶段,可以利用该技术在主机上建立基于NFS的根文件系统,挂载到嵌入式设备,可以很方便地修改根文件系统的内容。
以上讨论的都是基于存储设备的文件系统(memory-based file system),它们都可用作Linux的根文件系统(除tmpfs和ramfs外)。实际上,Linux还支持逻辑的或伪文件系统(logical or pseudo file system),例如procfs(proc文件系统),用于获取系统信息,以及devfs(设备文件系统)和sysfs,用于维护设备文件。
Flash(闪存)作为嵌入式系统的主要存储媒介,有其自身的特性。Flash的写入操作只能把对应位置的1修改为0,而不能把0修改为1(擦除Flash就是把对应存储块的内容恢复为1),因此,一般情况下,向Flash写入内容时,需要先擦除对应的存储区间,这种擦除是以块(block)为 单位进行的。
闪存主要有NOR和NAND两种技术(简单比较见附录)。Flash存储器的擦写次数是有限的,NAND闪存还有特殊的硬件接口和读写时序。因 此,必须针对Flash的硬件特性设计符合应用要求的文件系统;传统的文件系统如ext2等,用作Flash的文件系统会有诸多弊端。
在嵌入式Linux下,MTD(Memory Technology Device,存储技术设备)为底层硬件(闪存)和上层(文件系统)之间提供一个统一的抽象接口,即Flash的文件系统都是基于MTD驱动层的(参见下面的Linux下的文件系统结构图)。使用MTD驱动程序的主要优点在于,它是专门针对各种非易失性存储器(以闪存为主)而设计的,因而它对Flash有 更好的支持、管理和基于扇区的擦除、读/写操作接口。
顺便一提,一块Flash芯片可以被划分为多个分区,各分区可以采用不同的文件系统;两块Flash芯片也可以合并为一个分区使用,采用一个文件系统。即文件系统是针对于存储器分区而言的,而非存储芯片。
JFFS文件系统最早是由瑞典Axis Communications公司基于Linux2.0的内核为嵌入式系统开发的文件系统。JFFS2(Journalling Flash FileSystem v2,日志闪存文件系统版本2 )是RedHat公司基于JFFS开发的闪存文件系统,最初是针对RedHat公司的嵌入式产品eCos开发的嵌入式文件系统,所JFFS2也可以用在Linux, uCLinux中。它主要用于NOR型闪存,基于MTD驱动层,特点是:可读写的、支持数据压缩的、基于哈希表的日志型文件系统,并提供了崩溃/掉电安全保护,提供“写平衡”支持等。缺点主要是当文件系统已满或接近满时,因为垃圾收集的关系而使jffs2的运行速度大大放慢。
Jffs2不适合用于NAND闪存主要是因为NAND闪存的容量一般较大,这样导致jffs2为维护日志节点所占用的内存空间迅速增大,另外,jffs2文件系统在挂载时需要扫描整个FLASH的内容,以找出所有的日志节点,建立文件结构,对于大容量的NAND闪存会耗费大量时间。
目前jffs3正在开发中,关于jffs2系列文件系统的使用详细文档,可参考MTD补丁包中mtd-jffs-HOWTO.txt。
yaffs/yaffs2(Yet Another Flash File System)是专为嵌入式系统使用NAND型闪存而设计的一种日志型文件系统。与jffs2相比,它减少了一些功能(例如不支持数 据压缩),所以速度更快,挂载时间很短,对内存的占用较小。另外,它还是跨平台的文件系统,除了Linux和eCos,还支持WinCE, pSOS和ThreadX等。
yaffs/yaffs2自带NAND芯片的驱动,并且为嵌入式系统提供了直接访问文件系统的API,用户可以不使用Linux中的MTD与VFS,直接对文件系统操作。当然,yaffs也可与MTD驱动程序配合使用。yaffs与yaffs2的主要区别在于,前者仅支持小页(512 Bytes) NAND闪存,后者则可支持大页(2KB) NAND闪存。同时,yaffs2在内存空间占用、垃圾回收速度、读/写速度等方面均有大幅提升。
无排序区块图像文件系统(Unsorted Block Image File System, UBIFS)是用于固态硬盘存储设备上,并与LogFS相互竞争,作为JFFS2的后继文件系统之一。真正开始开发于2007年,并于2008年10月第一次加入稳定版本于Linux核心2.6.27版。UBIFS最早在2006年由IBM与Nokia的工程师Thomas Gleixner,Artem Bityutskiy所设计,专门为了解决MTD(Memory Technology Device)设备所遇到的瓶颈。由于Nand Flash容量的暴涨,YAFFS等皆无法再去控制Nand Flash的空间。UBIFS通过子系统UBI处理与MTD device之间的动作。与JFFS2一样,UBIFS 建构于MTD device 之上,因而与一般的block device不兼容。
JFFS2运行在MTD设备之上,而UBIFS则只能工作于UBI volume之上。也可以说,UBIFS涉及了三个子系统:
1. MTD 子系统, 提供对flash芯片的访问接口, MTD子系统提供了MTD device的概念,比如/dev/mtdx,MTD可以认为是raw flash
2. UBI subsystem,为flash device提供了wear-leveling和 volume management功能; UBI工作在MTD设备之上,提供了UBI volume;UBI是MTD设备的高层次表示,对上层屏蔽了一些MTD不得不处理的问题,比如wearing以及坏块管理
3. UBIFS文件系统,工作于UBI之上
以下是UBIFS的一些特点:
Ø 可扩展性:UBIFS对flash 尺寸有着很好的扩展性; 也就是说mount时间,内存消耗以及I/O速度都不依赖与flash 尺寸(对于内存消耗并不是完全准确的,但是依赖性非常的低); UBIFS可以很好的适应GB flashes; 当然UBI本身还有扩展性的问题,无论如何 UBI/UBIFS都比JFFS2的可扩展性好,此外如果UBI成为瓶颈,还可以通过升级UBI而不需改变UBIFS
Ø 快速mount:不像JFFS2,UBIFS在mount阶段不需要扫描整个文件系统,UBIFS mount介质的时间只是毫秒级,时间不依赖与flash的尺寸;然而UBI的初始化时间是依赖flash的尺寸的,因此必须把这个时间考虑在内
Ø write-back 支持: 回写或者叫延迟写更准确些吧,同JFFS2的write-through(立即写入内存)相比可以显著的提高文件系统的吞吐量。
Ø 异常unmount适应度:UBIFS是一个日志文件系统可以容忍突然掉电以及unclean重启; UBIFS 通过replay 日志来恢复unclean unmount,在这种情况下replay会消耗一些时间,因此mount时间会稍微增加,但是replay过程并不会扫描整个flash介质,所以UBIFS的mount时间大概在几分之一秒。
Ø 快速I/O - 即使我们disable write-back(可以在unmount时使用-o sync mount选项), UBIFS的性能仍然接近JFFS2; 记住,JFFS2的同步I/O是非常惊人的,因为JFFS2不需要在flash上维护indexing data结构, 所以就没有因此而带来的负担; 而UBIFS恰恰是有index数据的。 UBIFS之所以够快是因为UBIFS提交日志的方式:不是把数据从一个地方移动到另外一个位置,而只是把数据的地址加到文件系统的index,然后选择不同的eraseblock作为新的日志块,此外还有multi-headed日志方式等技巧。
Ø on-the_flight compression - 存储在flash介质上的数据是压缩的;同时也可以灵活的针对单个文件来打开关闭压缩; 例如,可能需要针对某个特定的文件打开压缩,或者可能缺省方式下支持压缩,但是对多媒体文件则关闭压缩。
Ø 可恢复性 - UBIFS可以从index破坏后恢复; UBIFS中的每一片信息都有一个header来描述,因此可以通过扫描这个flash介质来重构文件系统,这点和JFFS2非常类似;想像一下,如果你擦出了FAT文件系统的FAT表,那么对于FAT FS是致命的错误,但是如果擦除UBIFS的index,你人然可以重构文件系统,当然这需要一个特定的用户空间程序来做这个恢复
Ø 完整性 - UBIFS通过写checksum到flash 介质上来保证数据的完整性,UBIFS不会无视损坏文件数据或meta-data; 缺省的情况,UBIFS仅仅检查meta-data的CRC,但是你可以通过mount选项,强制进行data CRC的检查
Cramfs(Compressed ROM File System)是Linux的创始人 Linus Torvalds参与开发的一种只读的压缩文件系统,它也基于MTD驱动程序。在cramfs文件系统中,每一页(4KB)被单独压缩,可以随机页访问,其压缩比高达2:1,为嵌入式系统节省大量的Flash存储空间,使系统可通过更低容量的FLASH存储相同的文件,从而降低系统成本。
Cramfs文件系统以压缩方式存储,在运行时解压缩,所以不支持应用程序以XIP方式运行,所有的应用程序要求被拷到RAM里去运行,但这并不代表比Ramfs需求的RAM空间要大一点,因为Cramfs是采用分页压缩的方式存放档案,在读取档案时,不会一下子就耗用过多的内存空间,只针对目前实际读取的部分分配内存,尚没有读取的部分不分配内存空间,当我们读取的档案不在内存时,Cramfs文件系统自动计算压缩后的资料所存的位置,再即时 解压缩到RAM中。
另外,它的速度快,效率高,其只读的特点有利于保护文件系统免受破坏,提高了系统的可靠性。Cramfs映像通常是放在Flash中,但是也能放在别的文件系统里,使用loopback设备可以把它安装别的文件系统里。
由于以上特性,Cramfs在嵌入式系统中应用广泛。但是它的只读属性同时又是它的一大缺陷,使得用户无法对其内容对进扩充。
传统型的Romfs文件系统是一种简单的、紧凑的、只读的文件系统,不支持动态擦写保存,按顺序存放数据,因而支持应用程序以 XIP(eXecute In Place,片内运行)方式运行,在系统运行时,节省RAM空间。uClinux系统通常采用Romfs文件系统。
fat/fat32也可用于实际嵌入式系统的扩展存储器(例如PDA, Smartphone, 数码相机等的SD卡),这主要是为了更好的与最流行的Windows桌面操作系统相兼容。ext2也可以作为嵌入式Linux的文件系统,不过将它用于FLASH闪存会有诸多弊端。
首先要明白的是“什么是文件系统”,文件系统是对一个存储设备上的数据和元数据进行组织的机制。这种机制有利于用户和操作系统的交互。在一篇oracle的技术文章中看到这样一句话“尽管内核是 Linux 的核心,但文件却是用户与操作系统交互所采用的主要工具。这对 Linux 来说尤其如此,这是因为在 UNIX 传统中,它使用文件 I/O 机制管理硬件设备和数据文件”,这句话我是这样理解的,在Linux没有文件系统的话,用户和操作系统的交互也就断开了,例如我们使用最多的交互shell,包括其它的一些用户程序,都没有办法运行。在这里可以看到文件系统相对于Linux操作系统的重要性。下面是Linux文件系统组件的体系结构。
用户空间包含一些应用程序(例如,文件系统的使用者)和 GNU C 库(glibc),它们为文件系统调用(打开、读取、写和关闭)提供用户接口。系统调用接口的作用就像是交换器,它将系统调用从用户空间发送到内核空间中的适当端点。
VFS 是底层文件系统的主要接口。这个组件导出一组接口,然后将它们抽象到各个文件系统,各个文件系统的行为可能差异很大。有两个针对文件系统对象的缓存(inode 和dentry)。它们缓存最近使用过的文件系统对象。
每个文件系统实现(比如 ext2、JFS 等等)导出一组通用接口,供 VFS 使用。缓冲区缓存会缓存文件系统和相关块设备之间的请求。例如,对底层设备驱动程序的读写请求会通过缓冲区缓存来传递。这就允许在其中缓存请求,减少访问物理设备的次数,加快访问速度。以最近使用(LRU)列表的形式管理缓冲区缓存。注意,可以使用 sync 命令将缓冲区缓存中的请求发送到存储媒体(迫使所有未写的数据发送到设备驱动程序,进而发送到存储设备)。
当我们在Windows下,提到文件系统时,你的第一反应是想到的是什么?是不是Windows下的一些Fat32、NTFS等的文件系统的类型。而在Linux中,你可能会想到Ext2、Ext3,但你还必须要有一个根文件系统的概念。根文件系统首先是一种文件系统,该文件系统不仅具有普通文件系统的存储数据文件的功能,但是相对于普通的文件系统,它的特殊之处在于,它是内核启动时所挂载(mount)的第一个文件系统,内核代码的映像文件保存在根文件系统中,系统引导启动程序会在根文件系统挂载之后从中把一些初始化脚本(如rcS,inittab)和服务加载到内存中去运行。我们要明白文件系统和内核是完全独立的两个部分。在嵌入式中移植的内核下载到开发板上,是没有办法真正的启动Linux操作系统的,会出现无法加载文件系统的错误。
那么根文件系统在系统启动中到底是什么时候挂载的呢?先将/dev/ram0挂载,而后执行/linuxrc.等其执行完后。切换根目录,再挂载具体的根文件系统.根文件系统执行完之后,也就是到了Start_kernel()函数的最后,执行init的进程,也就第一个用户进程。对系统进行各种初始化的操作。如果要能明白这里的过程的话,可要好好的看看Linux内核源码了。下图展示了VFS,内核,文件系统的层次结构:
根文件系统之所以在前面加一个”根“,说明它是加载其它文件系统的”根“,既然是根的话,那么如果没有这个根,其它的文件系统也就没有办法进行加载的。它包含系统引导和使其他文件系统得以挂载(mount)所必要的文件。根文件系统包括Linux启动时所必须的目录和关键性的文件,例如Linux启动时都需要有init目录下的相关文件,在 Linux挂载分区时Linux一定会找/etc/fstab这个挂载文件等,根文件系统中还包括了许多的应用程序bin目录等,任何包括这些Linux 系统启动所必须的文件都可以成为根文件系统。
Linux启动时,第一个必须挂载的是根文件系统;若系统不能从指定设备上挂载根文件系统,则系统会出错而退出启动。成功之后可以自动或手动挂载其他的文件系统。因此,一个系统中可以同时存在不同的文件系统。
在 Linux 中将一个文件系统与一个存储设备关联起来的过程称为挂载(mount)。使用 mount 命令将一个文件系统附着到当前文件系统层次结构中(根)。在执行挂装时,要提供文件系统类型、文件系统和一个挂装点。根文件系统被挂载到根目录下“/”上后,在根目录下就有根文件系统的各个目录,文件:/bin /sbin /mnt等,再将其他分区挂接到/mnt目录上,/mnt目录下就有这个分区的各个目录,文件。
该目录下的命令可以被root与一般账号所使用,由于这些命令在挂接其它文件系统之前就可以使用,所以/bin目录必须和根文件系统在同一个分区中。
/bin目录下常用的命令有:cat、chgrp、chmod、cp、ls、sh、kill、mount、umount、mkdir、[、test等。其中“[”命令就是test命令,我们在利用Busybox制作根文件系统时,在生成的bin目录下,可以看到一些可执行的文件,也就是可用的一些命令。
该目录下存放系统命令,即只有系统管理员(俗称最高权限的root)能够使用的命令,系统命令还可以存放在/usr/sbin,/usr/local/sbin目录下,/sbin目录中存放的是基本的系统命令,它们用于启动系统和修复系统等,与/bin目录相似,在挂接其他文件系统之前就可以使用/sbin,所以/sbin目录必须和根文件系统在同一个分区中。
/sbin目录下常用的命令有:shutdown、reboot、fdisk、fsck、init等,本地用户自己安装的系统命令放在/usr/local/sbin目录下。
该目录下存放的是设备与设备接口的文件,设备文件是Linux中特有的文件类型,在Linux系统下,以文件的方式访问各种设备,即通过读写某个设备文件操作某个具体硬件。比如通过"dev/ttySAC0"文件可以操作串口0,通过"/dev/mtdblock1"可以访问MTD设备的第2个分区。比较重要的文件有/dev/null, /dev/zero, /dev/tty, /dev/lp*等。
该目录下存放着系统主要的配置文件,例如人员的账号密码文件、各种服务的其实文件等。一般来说,此目录的各文件属性是可以让一般用户查阅的,但是只有root有权限修改。对于PC上的Linux系统,/etc目录下的文件和目录非常多,这些目录文件是可选的,它们依赖于系统中所拥有的应用程序,依赖于这些程序是否需要配置文件。在嵌入式系统中,这些内容可以大为精减。
该目录下存放共享库和可加载(驱动程序),共享库用于启动系统。运行根文件系统中的可执行程序,比如:/bin /sbin 目录下的程序。
系统默认的用户文件夹,它是可选的,对于每个普通用户,在/home目录下都有一个以用户名命名的子目录,里面存放用户相关的配置文件。
系统管理员(root)的主文件夹,即是根用户的目录,与此对应,普通用户的目录是/home下的某个子目录。
/usr目录的内容可以存在另一个分区中,在系统启动后再挂接到根文件系统中的/usr目录下。里面存放的是共享、只读的程序和数据,这表明/usr目录下的内容可以在多个主机间共享,这些主要也符合FHS标准的。/usr中的文件应该是只读的,其他主机相关的,可变的文件应该保存在其他目录下,比如/var。/usr目录在嵌入式中可以精减。
与/usr目录相反,/var目录中存放可变的数据,比如spool目录(mail,news),log文件,临时文件。
这是一个空目录,常作为proc文件系统的挂接点,proc文件系统是个虚拟的文件系统,它没有实际的存储设备,里面的目录,文件都是由内核
临时生成的,用来表示系统的运行状态,也可以操作其中的文件控制系统。
用于临时挂载某个文件系统的挂接点,通常是空目录,也可以在里面创建一引起空的子目录,比如/mnt/cdram /mnt/hda1 。用来临时挂载光盘、移动存储设备等。
用于存放临时文件,通常是空目录,一些需要生成临时文件的程序用到的/tmp目录下,所以/tmp目录必须存在并可以访问。
那我们利用Busybox制作根文件系统就是创建这上面的这些目录,和这些目录下面的各种文件。
对于嵌入式Linux系统的根文件系统来说,一般可能没有上面所列出的那么复杂,比如嵌入式系统通常都不是针对多用户的,所以/home这个目录在一般嵌入式Linux中可能就很少用到,而/boot这个目录则取决于你所使用的BootLoader是否能够重新获得内核映象从你的根文件系统在内核启动之前。一般说来,只有/bin,/dev,/etc,/lib,/proc,/var,/usr这些需要的,而其他都是可选的。
根文件系统一直以来都是所有类Unix操作系统的一个重要组成部分,也可以认为是嵌入式Linux系统区别于其他一些传统嵌入式操作系统的重要特征,它给 Linux带来了许多强大和灵活的功能,同时也带来了一些复杂性。我们需要清楚的了解根文件系统的基本结构,以及细心的选择所需要的系统库、内核模块和应用程序等,并配置好各种初始化脚本文件,以及选择合适的文件系统类型并把它放到实际的存储设备的合适位置。
对于嵌入式文件系统的制作和移植而言,它的根文件系统结构基本一样。因此,对同一个根文件系统,通过相应的工具和方法就能容易生成对应文件系统。下面介绍如何制作一个简洁的根文件系统。
制作根文件系统经常会用到根用户权限,所以需要倍加小心。
[lingyun@localhost opt]$ pwd
/opt
[lingyun@localhost opt]$ mkdir rootfs
[lingyun@localhost opt]$ cd rootfs
[lingyun@localhost rootfs]$ ls
[lingyun@localhost rootfs]$ mkdir-p
{apps,bin,data,dev,info,proc,root,sbin,sys,tmp,var,etc/{,init.d,dropbear},mnt/{,usb,sdc,nfs,dev},usr/{,bin,sbin,lib,share},lib/{,modules/{,3.0.0}}}
[lingyun@localhost rootfs]$ tree -L 3
.
|-- apps # 挂载Application所在分区用的目录
|-- bin
|-- data # 挂载data分区所在的目录
|-- dev
|-- etc
| |-- dropbear # dropbear ssh server依赖的文件
| `-- init.d # 系统启动初始化脚本
|-- info # 挂载info分区所在的目录
|-- lib # 动态库所存放的目录
| `-- modules # insmod时,依赖/lib/modules/内核版本目录
| `-- 3.0.0 # 我们将Linux驱动放到该目录下,目录名对应内核版本号
|-- mnt # 设备在运行时的一些挂载点
| |-- dev # 保留备用
| |-- nfs # NFS挂载点
| |-- sdc # SD卡挂载点
| `-- usb # U盘挂载点
|-- proc # proc文件挂载点
|-- root # root用户目录
|-- sbin
|-- sys # sys文件系统挂载点
|-- tmp # tmpfs文件系统挂载点
|-- usr
| |-- bin
| |-- lib # 用户程序动态库放到这里
| |-- sbin
| `-- share
`-- var
27 directories, 0 files
上面的一些目录,可以先不用关系它的用途,今后对文件系统进行扩展时在介绍。
因为内核挂载完文件系统后,init进程需要用到/dev/console和/dev/null这两个设备文件来调用mdev构建dev,所以必须在制作文件系统时静态创建这两个设备文件,否则在系统启动时将提示
Waring:unable to open an initial console:
[lingyun@localhost rootfs]$ sudo mknod -m666 dev/null c 1 3
[lingyun@localhost rootfs]$ sudo mknod -m666 dev/console c 5 1
[lingyun@localhost rootfs]$ sudo mknod -m666 dev/ttyS0 c 4 64
[lingyun@localhost rootfs]$ sudo mknod -m666 dev/ttySAC0 c 4 64
[lingyun@localhost rootfs]$ sudo mknod dev/mtdblock0 b 31 0
[lingyun@localhost rootfs]$ sudo mknod dev/mtdblock1 b 31 1
[lingyun@localhost rootfs]$ sudo mknod dev/mtdblock2 b 31 2
[lingyun@localhost rootfs]$ sudo mknod dev/mtdblock3 b 31 3
[lingyun@localhost rootfs]$ sudo mknod dev/mtdblock4 b 31 4
[lingyun@localhost rootfs]$ sudo mknod dev/mtdblock5 b 31 5
[lingyun@localhost rootfs]$ sudo mknod dev/mtdblock6 b 31 6
[lingyun@localhost rootfs]$ sudo mknod dev/mtdblock7 b 31 7
[lingyun@localhost rootfs]$ sudo mknod dev/mtdblock8 b 31 8
[lingyun@localhost rootfs]$ sudo mknod dev/mtdblock9 b 31 9
[lingyun@localhost rootfs]$ ls -l dev/
total 0
crw-rw-rw- 1 root root 5, 1 Apr 25 20:43 console
brw-r--r-- 1 root root 31, 0 Apr 25 20:49 mtdblock0
brw-r--r-- 1 root root 31, 1 Apr 25 20:49 mtdblock1
brw-r--r-- 1 root root 31, 2 Apr 25 20:49 mtdblock2
brw-r--r-- 1 root root 31, 3 Apr 25 20:49 mtdblock3
brw-r--r-- 1 root root 31, 4 Apr 25 20:49 mtdblock4
brw-r--r-- 1 root root 31, 5 Apr 25 20:49 mtdblock5
brw-r--r-- 1 root root 31, 6 Apr 25 20:50 mtdblock6
brw-r--r-- 1 root root 31, 7 Apr 25 20:50 mtdblock7
brw-r--r-- 1 root root 31, 8 Apr 25 20:51 mtdblock8
brw-r--r-- 1 root root 31, 9 Apr 25 20:51 mtdblock9
crw-rw-rw- 1 root root 1, 3 Apr 25 20:43 null
crw-rw-rw- 1 root root 4, 64 Apr 25 20:44 ttyS0
crw-rw-rw- 1 root root 4, 64 Apr 25 20:44 ttySAC0
[lingyun@localhost rootfs]$
[lingyun@localhost rootfs]$ ln -s /tmp var/lock
[lingyun@localhost rootfs]$ ln -s /tmp var/log
[lingyun@localhost rootfs]$ ln -s /tmp var/run
[lingyun@localhost rootfs]$ ln -s /tmp var/tmp
[lingyun@localhost rootfs]$ ls -l var/
total 0
lrwxrwxrwx 1 lingyun trainning 4 Apr 25 20:57 lock -> /tmp
lrwxrwxrwx 1 lingyun trainning 4 Apr 25 20:57 log -> /tmp
lrwxrwxrwx 1 lingyun trainning 4 Apr 25 20:57 run -> /tmp
lrwxrwxrwx 1 lingyun trainning 4 Apr 25 20:57 tmp -> /tmp
[lingyun@localhost rootfs]$
[lingyun@localhost rootfs]$cp -af /opt/buildroot-2011.02/arm920t/usr/arm-linux/sysroot/lib/*so* lib/
[lingyun@localhost rootfs]$ cp -af /opt/buildroot-2011.02/arm920t/usr/arm-linux/lib/*so*
lib/
同时也可以用下面的一个安全的脚本来执行这个工作
[lingyun@localhost tools]$ vim install_shared_library.sh
#!/bin/bash
if [ $# != 1 ] ; then
echo "Usage: $0 [rootfs_path]"
exit;
fi
INST_PATH=$1
if [ ! -d $INST_PATH -o $INST_PATH == "/" ] ; then
echo "$INST_PATH is not exist or it's root path,exit now"
exit;
fi
if [ ! -d $INST_PATH/data ] ; then
echo "It's not an embedded root file system tree"
exit;
fi
CROSSTOOL_PATH=/opt/buildroot-2012.08/arm920t/usr/
CMD_PREFIX=sudo
set -ev
LIB_PATH=$INST_PATH/lib
USR_LIB_PATH=$INST_PATH/usr/lib
$CMD_PREFIX rm -rf $LIB_PATH/*.so*
$CMD_PREFIX rm -rf $USR_LIB_PATH/*
$CMD_PREFIX cp -af $CROSSTOOL_PATH/arm-unknown-linux-uclibcgnueabi/sysroot/lib/*.so* $LIB_PATH
$CMD_PREFIX cp -af $CROSSTOOL_PATH/arm-unknown-linux-uclibcgnueabi/lib/*.so* $LIB_PATH
$CMD_PREFIX cp -af $CROSSTOOL_PATH/lib/*.so* $LIB_PATH
#$CMD_PREFIX sudo rm -rf $LIB_PATH/libmudflap*
$CMD_PREFIX sudo rm -rf $LIB_PATH/libstdc++.so.6.0.14-gdb.py
mkdir -p lib
$CMD_PREFIX cp -af $CROSSTOOL_PATH/arm-unknown-linux-uclibcgnueabi/sysroot/usr/lib/*.so* lib
#$CMD_PREFIX cp -af $CROSSTOOL_PATH/arm-unknown-linux-uclibcgnueabi/sysroot/usr/lib/engines lib
$CMD_PREFIX sudo rm -rf lib/libstdc++.so*
$CMD_PREFIX mv lib/* $USR_LIB_PATH
rm -rf lib
#执行shell脚本
[lingyun@localhost tools]$ sh install_shared_library.sh /opt/rootfs
LIB_PATH=$INST_PATH/lib
USR_LIB_PATH=$INST_PATH/usr/lib
$CMD_PREFIX rm -rf $LIB_PATH/*.so*
$CMD_PREFIX rm -rf $USR_LIB_PATH/*
$CMD_PREFIX cp -af $CROSSTOOL_PATH/arm-unknown-linux-uclibcgnueabi/sysroot/lib/*.so* $LIB_PATH
$CMD_PREFIX cp -af $CROSSTOOL_PATH/arm-unknown-linux-uclibcgnueabi/lib/*.so* $LIB_PATH
$CMD_PREFIX cp -af $CROSSTOOL_PATH/lib/*.so* $LIB_PATH
#$CMD_PREFIX sudo rm -rf $LIB_PATH/libmudflap*
$CMD_PREFIX sudo rm -rf $LIB_PATH/libstdc++.so.6.0.14-gdb.py
mkdir -p lib
$CMD_PREFIX cp -af $CROSSTOOL_PATH/arm-unknown-linux-uclibcgnueabi/sysroot/usr/lib/*.so* lib
#$CMD_PREFIX cp -af $CROSSTOOL_PATH/arm-unknown-linux-uclibcgnueabi/sysroot/usr/lib/engines lib
$CMD_PREFIX sudo rm -rf lib/libstdc++.so*
$CMD_PREFIX mv lib/* $USR_LIB_PATH
rm -rf lib
[lingyun@localhost rootfs]$ ls lib/
ld-uClibc-0.9.33.2.so libgcc_s.so.1 libmpc.so libmudflap.so.0 libpthread.so.0 libuClibc-0.9.33.2.so
ld-uClibc.so.0 libgmp.so libmpc.so.2 libmudflap.so.0.0.0 libresolv-0.9.33.2.so libutil-0.9.33.2.so
libcrypt-0.9.33.2.so libgmp.so.10 libmpc.so.2.0.0 libmudflapth.so libresolv.so.0 libutil.so.0
libcrypt.so.0 libgmp.so.10.0.5 libmpfr.so libmudflapth.so.0 librt-0.9.33.2.so modules
libc.so.0 libltdl.so libmpfr.so.4 libmudflapth.so.0.0.0 librt.so.0
libdl-0.9.33.2.so libltdl.so.7 libmpfr.so.4.1.1 libnsl-0.9.33.2.so libstdc++.so
libdl.so.0 libltdl.so.7.2.2 libm.so.0 libnsl.so.0 libstdc++.so.6
libgcc_s.so libm-0.9.33.2.so libmudflap.so libpthread-0.9.33.2.so libstdc++.so.6.0.14
[lingyun@localhost rootfs]$ cd etc/
[lingyun@localhost etc]$ ls
dropbear init.d
[lingyun@localhost etc]$ vim inittab
# /etc/inittab
#
# Copyright (C) 2011 fulinux
#
# Note: BusyBox init doesn't support runlevels. The runlevels field is
# completely ignored by BusyBox init. If you want runlevels, use sysvinit.
#
# Format for each entry:
#
# id == tty to run on, or empty for /dev/console.
# If specified, then /dev/$id device must exist
# runlevels == ignored, busybox doesn't support it
# action == one of sysinit, respawn, askfirst, wait, and once
# process == program to run
# Startup the system
# mount all the file systems specified in /etc/fstab
::sysinit:/bin/mount -a
#Use mdev as hotplug to auto mount USB storage or SD card
::sysinit:/bin/echo /sbin/mdev > /proc/sys/kernel/hotplug
#Use mdev to auto generate the device node in /dev path
::sysinit:/sbin/mdev -s
#make shm, pts support
::sysinit:/bin/mkdir -p /dev/pts
::sysinit:/bin/mkdir -p /dev/shm
::sysinit:/bin/mount -t devpts devpts /dev/pts
#Mount our apps/info partition
null::wait:/bin/mount -o sync,noatime,ro -t jffs2 /dev/mtdblock6 /apps
null::wait:/bin/mount -o sync,noatime,ro -t jffs2 /dev/mtdblock7 /info
#Set hostname
null::sysinit:/bin/hostname -F /etc/hostname
#Enable console logon
null::respawn:/sbin/getty -L ttyS0 115200 vt100
# now run any rc scripts
null::wait:/etc/init.d/rcS
# system daemon
null::respawn:/sbin/syslogd -n
null::respawn:/sbin/klogd -n
# Stuff to do before rebooting
null::shutdown:/bin/umount /apps
null::shutdown:/bin/umount /info
null::shutdown:/bin/killall klogd
null::shutdown:/bin/killall syslogd
null::shutdown:/bin/umount -a -r
#null::shutdown:/sbin/swapoff -a
[lingyun@localhost etc]$
[lingyun@localhost etc]$ vim init.d/rcS
#!/bin/sh
# Copyright (C) 2011 fulinux
# Start all init scripts in /etc/init.d
# executing them in numerical order.
#
for i in /etc/init.d/S??* ; do
$i
done
[lingyun@localhost etc]$ vim init.d/S01_network
#!/bin/sh
ifconfig eth0 192.168.1.111 netmask 255.255.255.0 up
[lingyun@localhost etc]$ vim init.d/S99_rcsApp
#!/bin/sh
# Copyright (C) 2011 fulinux
#
# Start all init scripts in /apps/etc/init.d
# executing them in numerical order.
#
if (test -d /apps/etc/init.d)
then
for i in /apps/etc/init.d/S??* ; do
$i
done
fi
[lingyun@localhost etc]$ chmod 777 init.d/*
[lingyun@localhost etc]$ ll init.d/
total 12
-rwxrwxrwx 1 lingyun trainning 222 Apr 26 13:27 rcS
-rwxrwxrwx 1 lingyun trainning 64 Apr 26 13:33 S01_network
-rwxrwxrwx 1 lingyun trainning 248 Apr 26 13:37 S99_rcsApp
[lingyun@localhost etc]$
[lingyun@localhost etc]$ vim fstab
# /etc/fstab: static file system information.
# Copyright (C) 2011 fulinux
#
#
#devpts /dev/pts devpts defaults 0 0
#/dev/root / ext2 rw,noauto 0 1
proc /proc proc defaults 0 0
tmpfs /tmp tmpfs defaults 0 0
tmpfs /dev tmpfs defaults 0 0
sysfs /sys sysfs defaults 0 0
[lingyun@localhost etc]$ echo "root" > hostname
[lingyun@localhost etc]$ echo "127.0.0.1 localhost" >> hosts
[lingyun@localhost etc]$ echo "MST7MDT" >> TZ
[lingyun@localhost etc]$ echo "Copyright (C) 2011 fulinux
[lingyun@localhost etc]$ vim profile
# /etc/profile: system-wide .profile file for the Bourne shells.
export PATH=\
/bin:\
/sbin:\
/usr/bin:\
/usr/sbin:\
/usr/local/bin:\
/apps/bin:\
/apps/tools:\
/apps/tslib/bin\
# If running interactively, then:
if [ "$PS1" ]; then
if [ "$BASH" ]; then
export PS1="[\u@\h \W]\\$ "
alias ll='/bin/ls --color=tty -laFh'
alias ls='/bin/ls --color=tty -F'
export LS_COLORS='no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;
32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=0
1;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.png=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35
:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.d
l=01;35:*.xcf=01;35:*.xwd=01;35:';
else
if [ "`id -u`" -eq 0 ]; then
export PS1='>: '
else
export PS1='>: '
fi
fi
# System Setting
set -o vi
alias ll='ls -l'
export USER=`id -un`
export LOGNAME=$USER
export HOSTNAME=`/bin/hostname`
export HISTSIZE=1000
export HISTFILESIZE=1000
export PAGER='/bin/more '
export EDITOR='/bin/vi'
export INPUTRC=/etc/inputrc
export DMALLOC_OPTIONS=debug=0x34f47d83,inter=100,log=logfile
export VAR1=
export VAR2=
export VAR3=
export VAR4=
export VAR5=
export LD_LIBRARY_PATH=/lib:/usr/lib/
# QT Extendded 4.4.3 Setting
export QTDIR=/apps/qt-extended-4.4.3
export QWS_MOUSE_PROTO='TSLIB:/dev/event0'
export QWS_DISPLAY='LinuxFB:/dev/fb0'
export QWS_DISPLAY='LinuxFB:mmWidth240:mmHeight320:0'
export QWS_SIZE='240x320'
export QT_PLUGIN_PATH=$QTDIR/plugins/
export QT_QWS_FONTDIR=$QTDIR/lib/fonts
export PATH=$QTDIR/bin:$PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$QTDIR/lib
# Touch Scree tslib Setting
export TSLIB_ROOT=/apps/tslib
export TSLIB_CONFFILE=$TSLIB_ROOT/etc/ts.conf
export TSLIB_CALIBFILE=$TSLIB_ROOT/etc/pointercal
export TSLIB_TSDEVICE=/dev/event0
export TSLIB_CONSOLEDEVICE=none
export TSLIB_FBDEVICE=/dev/fb0
fi;
[lingyun@localhost etc]$ vim protocols
# /etc/protocols:
# $Id: protocols,v 1.1.1.1 2001/09/12 19:03:24 andersee Exp $
#
# Internet (IP) protocols
#
# from: @(#)protocols 5.1 (Berkeley) 4/17/89
#
# Updated for NetBSD based on RFC 1340, Assigned Numbers (July 1992).
ip 0 IP # internet protocol, pseudo protocol number
icmp 1 ICMP # internet control message protocol
igmp 2 IGMP # Internet Group Management
ggp 3 GGP # gateway-gateway protocol
ipencap 4 IP-ENCAP # IP encapsulated in IP (officially ``IP'')
st 5 ST # ST datagram mode
tcp 6 TCP # transmission control protocol
egp 8 EGP # exterior gateway protocol
pup 12 PUP # PARC universal packet protocol
udp 17 UDP # user datagram protocol
hmp 20 HMP # host monitoring protocol
xns-idp 22 XNS-IDP # Xerox NS IDP
rdp 27 RDP # "reliable datagram" protocol
iso-tp4 29 ISO-TP4 # ISO Transport Protocol class 4
xtp 36 XTP # Xpress Tranfer Protocol
ddp 37 DDP # Datagram Delivery Protocol
idpr-cmtp 39 IDPR-CMTP # IDPR Control Message Transport
rspf 73 RSPF #Radio Shortest Path First.
vmtp 81 VMTP # Versatile Message Transport
ospf 89 OSPFIGP # Open Shortest Path First IGP
ipip 94 IPIP # Yet Another IP encapsulation
encap 98 ENCAP # Yet Another IP encapsulation
mdev会在/etc目录下找mdev的配置文件: mdev.conf. 如果该文件不存在,那么在执行mdev –s这个命令时,
会提示找不到mdev.conf,这时我们可以建一个空的mdev.conf文件解决这个问题。下面创建使用mdev自动挂载u盘和SD卡的配置/etc/mdev.conf
[lingyun@localhost etc]$ vim mdev.conf
sd[a-z][0-9] 0:0 0777 @(mount /dev/$MDEV /mnt/usb)
sd[a-z] 0:0 0777 $(umount /mnt/usb)
ub[a-z][0-9] 0:0 0777 @(mount /dev/$MDEV /mnt/usb)
ub[a-z] 0:0 0777 $(umount /mnt/usb)
mmcblk[0-9]p[0-9] 0:0 0777 @(mount /dev/$MDEV /mnt/sdc)
mmcblk[0-9] 0:0 0777 $(umount /mnt/sdc)
[lingyun@localhost etc]$ vim group
root:x:0:root
它的格式如下:
groupname:password:gid:members
第一个字段为用户组名称
第二个字段为用户组密码,当为x时密码是映射到/etc/gshadow中的,是非逆的
第三个字段为GID,及组号,为正整数或0,0被付于了root用户组;系统通常会预留一些较靠前的GID给系统虚拟用户之用,每个系统预留的GID都不同,Fedora预留了500个,所以我们添加新用户组时是从500开始的。GID的范围由/etc/login.defs中的GID_MIN和GID_MAX决定
第四个字段为用户列表,每个用户间用逗号分隔
这里的password代表组口令,很少用到。它可使原先不在这个群组中的用户可以通过newgrp命令暂时继承该组的权限,使用 newgrp命令时会新开一个shell。口令的加密方式和passwd文件中的口令一样,所以如果需设置组口令,要用passwd程序虚设一个用户,再把该用户password节中的加密口令拷贝到/etc/group文件中。members列代表组成员,我们可把需加入该组的用户以逗号分隔添加到这里即可。同一组的成员可继承该组所拥有的权限。
[lingyun@localhost etc]$ vim passwd
root:x:0:0:root:/:/bin/sh
它的格式如下:
username:password:uid:gid:gecos:homedir:shell
第一个字段为登录名
第二个字段为口令,一般被映射到shadow文件中
第三个字段为UID
第四个字段为GID
第五个字段为用户名全称,gecos是通用电子计算机操作系统的缩写,是Bell实验室中的一台大型主机。
第六个字段为用户根目录
第七个字段为用户所用SHELL的类型
Unix系统最初是用明文保存密码的,后来由于安全的考虑,采用crypt()算法加密密码并存放在/etc/passwd文件。现在,由于计算机处理能力的提高,使密码破解变得越来越容易。/etc/passwd文件是所有合法用户都可访问的,大家都可互相看到密码的加密字符串,这给系统带来很大的安全威胁。现代的Unix系统使用影子密码系统,它把密码从/etc/pa sswd文件中分离出来,真正的密码保存在/etc/shadow文件中,shadow文件只能由超级用户访问。这样入侵者就不能获得加密密码串,用于破解。使用shadow密码文件后,/etc/passwd文件中所有帐户的password域的内容为"x",如果password域的内容为"*",则该帐号被停用。使用passwd这个程序可修改用户的密。
[lingyun@localhost etc]$ vim shadow
root:($jGZIHmtT$y8ZXoPllK12/wl51kMw4e/:0:0:99999:7:::)# 显示的是加密后的字符串
该文件我们可以在Linux系统上使用passwd命令修改root口令来获取:
[lingyun@localhost ~]$ passwd root
Changing password for user root.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[lingyun@localhost ~]$ cat /etc/shadow | grep root
root:$1$jGZIHmtT$y8ZXoPllK12/wl51kMw4e/:0:0:99999:7:::
当然,在设置为嵌入式平台上的root口令后,最好把系统上的root命令恢复到原始密码。
他的格式如下:
username:password:last_change:min_change:max_change:warm:failed_expire:expiration:reserved
第一字段:用户名(也被称为登录名),在/etc/shadow中,用户名和/etc/passwd 是相同的,这样就把passwd 和shadow中用的用户记录联系在一起;这个字段是非空的;
第二字段:密码(已被加密),这个字段是非空的;
第三字段:上次修改口令的时间;这个时间是从1970年01月01日算起到最近一次修改口令的时间间隔(天数),您可以通过passwd 来修改用户的密码,然后查看/etc/shadow中此字段的变化;
第四字段:两次修改口令间隔最少的天数;如果这个字段的值为空,帐号永久可用;
第五字段:两次修改口令间隔最多的天数;如果这个字段的值为空,帐号永久可用;
第六字段:提前多少天警告用户口令将过期;如果这个字段的值为空,帐号永久可用;
第七字段:在口令过期之后多少天禁用此用户;如果这个字段的值为空,帐号永久可用;
第八字段:用户过期日期;此字段指定了用户作废的天数(从1970年的1月1日开始的天数),如果这个字段的值为空,帐号永久可用;
第九字段:保留字段,目前为空,以备将来发展之用;
这里我们设置为不用密码登陆,将password格式的内容清空:
[lingyun@localhost rootfs]$ vim etc/shadow
root::0:0:99999:7:::
[lingyun@localhost opt]$ sudo tar xjf ~/fulinux/systools/busybox-1.20.2.tar.bz2
[lingyun@localhost opt]$ cd busybox-1.20.2/
[lingyun@localhost busybox-1.20.2]$ vim Makefile
#修改CROSS_COMPILER为:
CROSS_COMPILE ?= /opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-
[lingyun@localhost busybox-1.20.2]$ ls ../rootfs
apps bin data dev etc info lib mnt proc root sbin sys tmp usr var
[lingyun@localhost busybox-1.20.2]$ vt100
[lingyun@localhost busybox-1.20.2]$ sudo make menuconfig
#选择:
Busybox Settings --->
General Configuration --->
[*] Don't use /usr
Installation Options ("make install" behavior) --->
What kind of applet links to install (as soft-links) --->
(../rootfs) BusyBox installation prefix
#其他选项结合和自己的需求定制
[lingyun@localhost busybox-1.20.2]$ sudo make
#编译过程略
[lingyun@localhost busybox-1.20.2]$ file busybox
busybox: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, stripped
[lingyun@localhost busybox-1.20.2]$ sudo make install
....
../rootfs/sbin/udhcpc -> ../bin/busybox
../rootfs/sbin/udhcpd -> ../bin/busybox
../rootfs/sbin/vconfig -> ../bin/busybox
../rootfs/sbin/zcip -> ../bin/busybox
--------------------------------------------------
You will probably need to make your busybox binary
setuid root to ensure all configured applets will
work properly.
--------------------------------------------------
[lingyun@localhost busybox-1.20.2]$
[lingyun@localhost busybox-1.20.2]$ ls ../rootfs
apps bin data dev etc info lib linuxrc mnt proc root sbin sys tmp usr var
[lingyun@localhost ~]$ wget http://matt.ucc.asn.au/dropbear/releases/dropbear-0.53.1.tar.bz2
[lingyun@localhost ~]$ tar -xjf dropbear-0.53.1.tar.bz2
[lingyun@localhost ~]$ cd dropbear-0.53.1
[lingyun@localhost dropbear-0.53.1]$ ./configure && make
生成的文件:
dropbear: ssh2 server
dropbearkey: 密钥生成器
dropbearconvert: 可以转换openssh的密钥
dbclient: ssh2 client
[lingyun@localhost dropbear-0.53.1]$ ./dropbearkey -t rsa -f /opt/rootfs/etc/dropbear/dropbear_rsa_host_key
Will output 1024 bit rsa secret key to '/opt/rootfs/etc/dropbear/dropbear_rsa_host_key'
Generating key, this may take a while...
Public key portion is:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgwChXpm6ogojmWy7GTZloJDdSIFq7pd49P3dh2I8Ap/7Cr9KRWlfQb0rchkFv1h62736FyX28S1jo7HpES9Rjp7MinG66pyzFjOfrsruzkeheo7YBrk8GPeSdEm65O3gPlJzReyMY3r020fwVIGaMf7+bPBuMsYY1g+8OcgeEygYCExz [email protected]
Fingerprint: md5 ed:a6:c9:6d:6e:85:f6:10:b2:3c:49:90:52:be:9b:19
[lingyun@localhost dropbear-0.53.1]$ ./dropbearkey -t dss -f /opt/rootfs/etc/dropbear/dropbear_dss_host_key
Will output 1024 bit dss secret key to '/opt/rootfs/etc/dropbear/dropbear_dss_host_key'
Generating key, this may take a while...
Public key portion is:
ssh-dss AAAAB3NzaC1kc3MAAACBAOa5XsTcByi4cdnhJ44Uro/athrTzv68+yeizFejzQM+K1e4ung/2SfAIZW/ms41HSSMhO6Siv/oOGz3cPnw8NKkWHWTP6pQmyZlvl2zNdrbDwiPGQ17rb5THoVDbXwn54c/aMR27mj+DBJ4+SDpL08wfs6k2JaelQIpBYWbFJ+rAAAAFQCgrFTR2dqbRdrk+lhaxnU7L8ADiQAAAIEAwUThj2irqMRCuItsKN+hYKmydUAtAL47ys+GBYMxKH36cLBovm19+2gaBTKsdBJbBs7j/7/xrFLPypAQmN3MukeSQvIUGQ0qzqPEcwtOdDtqOzi2//f4Cb3JUQd+JVXYj0lYGjRMZGuGzUlk6zoVoY8SEdGpQgRtI5Zi/M1H5YEAAACAMYxm7p6mBeA/SD5uESAgfPgF87h0ZIdC2cONVG0Ay/TJvOJC2ioNyQEL+UinNEV5+cA4tv5huA8zryp/jBgHVtxUQu168KlzSzo8397Rsy5Lhg7zgRGZYhLNEBzypHQjX8bpEve76GgHSbZ+9aj+zznpvAmKwonqZNLic2/HTMc= [email protected]
Fingerprint: md5 96:f3:31:04:8b:a6:1b:a5:cc:37:e5:08:9c:18:98:cd
[lingyun@localhost dropbear-0.53.1]$
[lingyun@localhost dropbear-0.53.1]$ chmod 666 /opt/rootfs/etc/dropbear/dropbear_*
[lingyun@localhost dropbear-0.53.1]$
[lingyun@localhost dropbear-0.53.1]$ make distclean
[lingyun@localhost dropbear-0.53.1]$ ./configure CC=/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-gcc --build=i686 --host=arm-linux --disable-zlib
[lingyun@localhost dropbear-0.53.1]$ make
[lingyun@localhost dropbear-0.53.1]$ file dropbear
dropbear: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), not stripped
[lingyun@localhost dropbear-0.53.1]$ file dbclient
dbclient: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), not stripped
[lingyun@localhost dropbear-0.53.1]$ mv dbclient ssh
[lingyun@localhost dropbear-0.53.1]$ arm-linux-strip dropbear
[lingyun@localhost dropbear-0.53.1]$ arm-linux-strip ssh
[lingyun@localhost dropbear-0.53.1]$ cp dropbear ssh /opt/rootfs/usr/sbin/
[lingyun@localhost rootfs]$ vim etc/init.d/S04_dropbear
#!/bin/sh
/usr/sbin/dropbear
[lingyun@localhost rootfs]$ chmod 777 etc/init.d/S04_dropbear
[lingyun@localhost rootfs]$ ls
apps bin data dev etc info lib linuxrc mnt proc root sbin sys tmp usr var
[lingyun@localhost rootfs]$ OK
* 在开发板中移植上面制作的根文件系统后的截图如下所示:
以上我们已经成功的创建了一个根文件系统。下面我们开始对在嵌入式应用领域的多种文件系统的优缺点进行比较。
下面我们开始制作和移植多种嵌入式领域所广泛应用的文件系统initramfs、nfs、ramdisk、cramfs、jffs2、yaff2和ubifs这些文件系统。
由于制作initramfs文件系统启动时会在根文件系统中执行第一个init程序,它对uboot传过来的参数init=/linuxrc不予理睬,所以需要在上面制作的根文件系统里的根目录加入init程序,否则无法启动。init程序和linuxrc程序一样都是符号链接文件,它们都是指向/bin/busybox程序。
[lingyun@localhost rootfs]$ ll
total 60
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 apps
drwxr-xr-x 2 lingyun trainning 4096 Apr 26 15:16 bin
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 data
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:51 dev
drwxr-xr-x 4 lingyun trainning 4096 Apr 26 14:16 etc
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 info
drwxr-xr-x 3 lingyun trainning 4096 Apr 25 21:17 lib
lrwxrwxrwx 1 root root 11 Apr 26 15:16 linuxrc -> bin/busybox
drwxr-xr-x 6 lingyun trainning 4096 Apr 25 20:15 mnt
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 proc
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 root
drwxr-xr-x 2 lingyun trainning 4096 Apr 26 15:16 sbin
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 sys
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 tmp
drwxr-xr-x 6 lingyun trainning 4096 Apr 25 20:15 usr
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:57 var
[lingyun@localhost rootfs]$ ln -s bin/busybox init
[lingyun@localhost rootfs]$ ll
total 60
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 apps
drwxr-xr-x 2 lingyun trainning 4096 Apr 26 15:16 bin
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 data
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:51 dev
drwxr-xr-x 4 lingyun trainning 4096 Apr 26 14:16 etc
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 info
lrwxrwxrwx 1 lingyun trainning 11 Apr 27 21:19 init -> bin/busybox
drwxr-xr-x 3 lingyun trainning 4096 Apr 25 21:17 lib
lrwxrwxrwx 1 root root 11 Apr 26 15:16 linuxrc -> bin/busybox
drwxr-xr-x 6 lingyun trainning 4096 Apr 25 20:15 mnt
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 proc
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 root
drwxr-xr-x 2 lingyun trainning 4096 Apr 26 15:16 sbin
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 sys
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 tmp
drwxr-xr-x 6 lingyun trainning 4096 Apr 25 20:15 usr
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:57 var
[lingyun@localhost rootfs]$
[lingyun@localhost kernel]$ ls
build.sh linux-3.0 linux-3.0.tar.bz2 patch
[lingyun@localhost kernel]$ cd linux-3.0
[lingyun@localhost linux-3.0]$ vt100
[lingyun@localhost linux-3.0]$ make menuconfig
。 。 。 。 。 。
General setup --->
[*] Initial RAM filesystem and RAM disk (initramfs/initrd) support
(/opt/rootfs) Initramfs source file(s) #输入根文件系统的所在目录
。 。 。 。 。 。
[lingyun@localhost linux-3.0]$ ls
arch crypto fs Kbuild linuxrom-s3c2440.bin modules.builtin README security usr
block Documentation include Kconfig MAINTAINERS modules.order REPORTING-BUGS sound virt
COPYING drivers init kernel Makefile Module.symvers samples System.map vmlinux
CREDITS firmware ipc lib mm net scripts tools vmlinux.o
[lingyun@localhost linux-3.0]$ du -h linuxrom-s3c2440.bin
6.9M /tftp/linuxrom-s3c2440.bin
[lingyun@localhost linux-3.0]$ mv linuxrom-s3c2440.bin /tftp/
因为文件系统和内核是集成在一起的,所以不需要制作文件系统映像
Uboot源码基本上不做修改。
下面对uboot进行修改。
[ s3c2440@fulinux ]# pri
bbl=nand erase 0 100000;tftp 30008000 u-boot-$cpu.bin;nand write 30008000 0 $filesize
norbbl=erase bank 1;tftp 30008000 u-boot-$cpu.bin;cp.b 30008000 0 $filesize
bkr=tftp 30008000 uImage-$cpu.gz;nand erase 100000 400000;nand write 30008000 100000 $filesize
bootcmd_rootfs=nand read 30008000 100000 400000;bootm 30008000
tpb=tftp 30008000 uImage-$cpu.gz;tftp 30800000 ramdisk-$cpu.gz;bootm 30008000
mtdids=nand0=nand0
mtdparts=mtdparts=nand0:1M@0x0(u-boot),5M@0x100000(kernel),10M@0x600000(ramdisk),10M@0x1000000(cramfs),20M@0x1a00000(yaffs2),20M@0x2e00000(ubifs),-(users)
bootdelay=1
baudrate=115200
ethaddr=08:00:3e:26:0a:6b
ethact=dm9000
bcramfs=tftp 30800000 rootfs.cramfs;nand erase f00000 600000;nand write 30800000 f00000 600000
bjffs2=tftp 30008000 rootfs.jffs2;nand erase 1e00000 1400000;nand write.jffs2 30008000 1e00000 1400000
bootargs_jffs2=noinitrd root=/dev/mtdblock4 rootfstype=jffs2 init=/linuxrc console=ttyS0,115200
bootargs_cramfs=noinitrd root=/dev/mtdblock3 rootfstype=cramfs init=/linuxrc console=ttyS0,115200
bootargs_ubifs=console=ttyS0,115200 mem=64M ubi.mtd=6 root=ubi0:rootfs rootwait rootfstype=ubifs rw
bubifs=tftp 30008000 ubifs-$cpu.img;nand erase 6e00000 900000;nand write 30008000 6e00000 900000
cpu=arm920t
brdfs=tftp 30008000 ramdisk.gz;nand erase 500000 a00000;nand write 30008000 500000 500000
bootcmd_ramdisk=nand read 30008000 100000 400000;nand read 30800000 500000 500000;bootm 30008000
bootargs_ramdisk=console=ttyS0,115200 mem=64M initrd=0x30800000,16M root=/dev/ram0 rw loglevel=7
ip=192.168.1.111:192.168.1.3:192.168.1.1:255.255.255.0:localhost.com:eth0:off
bootargs_nfs=noinitrd console=ttyS0,115200 init=/linuxrc mem=64M loglevel=7 root=/dev/nfs rw nfsroot=192.168.1.3:/opt/rootfs ip=192.168.1.111:192.168.1.3:192.168.1.1:255.255.255.0:localhost.com:eth0:off
bootargs=noinitrd root=/dev/mtdblock3 rootfstype=cramfs init=/linuxrc console=ttyS0,115200
filesize=4DF000
fileaddr=30800000
netmask=255.255.255.0
ipaddr=192.168.1.111
serverip=192.168.1.3
bootcmd=run bootcmd_rootfs
stdin=serial
stdout=serial
stderr=serial
Environment size: 2064/131068 bytes
[ s3c2440@fulinux ]#
[ s3c2440@fulinux ]# set bkr 'tftp 30008000 linuxrom-s3c2440.bin;nand erase 100000 800000;nand write 30008000 100000 800000'
[ s3c2440@fulinux ]# set bootargs 'console=ttyS0,115200 mem=64M init=/linuxrc rw loglevel=7'
[ s3c2440@fulinux ]# set bootcmd 'run bootcmd_initramdisk'
[ s3c2440@fulinux ]# save
Saving Environment to NAND...
Erasing Nand...
Erasing at 0x60000 -- 100% complete.
Writing to Nand... Done
[ s3c2440@fulinux ]# run bkr
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:00:3e:26:0a:6b
could not establish link
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 192.168.1.3; our IP address is 192.168.1.111
Filename 'linuxrom-s3c2440.bin'.
Load address: 0x30008000
Loading: T T #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
###################################
done
Bytes transferred = 7187832 (6dad78 hex)
NAND erase: device 0 offset 0x100000, size 0x800000
Erasing at 0x8e0000 -- 100% complete.
OK
NAND write: device 0 offset 0x100000, size 0x800000
8388608 bytes written: OK
[ s3c2440@fulinux ]# boot
NAND read: device 0 offset 0x100000, size 0x800000
8388608 bytes read: OK
## Booting kernel from Legacy Image at 30008000 ...
Image Name: Linux Kernel
Created: 2013-04-27 9:26:23 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 7187540 Bytes = 6.9 MiB
Load Address: 30008000
Entry Point: 30008040
Verifying Checksum ... OK
XIP Kernel Image ... OK
OK
OS entry point: 30008040
Image entry point=30008040
Starting kernel ...
Uncompressing Linux... done, booting the kernel.
Linux version 3.0.0 ([email protected]) (gcc version 4.5.4 (Buildroot 2012.08) ) #3 Fri Apr 26 22:06:01 CST 2013
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT data cache, VIVT instruction cache
Machine: SMDK2440
Memory policy: ECC disabled, Data cache writeback
CPU S3C2440A (id 0x32440001)
S3C24XX Clocks, Copyright 2004 Simtec Electronics
S3C244X: core 405.000 MHz, memory 101.250 MHz, peripheral 50.625 MHz
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16256
Kernel command line: noinitrd console=ttyS0,115200 mem=64M init=/linuxrc rw loglevel=7
PID hash table entries: 256 (order: -2, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 48940k/48940k available, 16596k reserved, 0K highmem
Virtual kernel memory layout:
vector : 0xffff0000 - 0xffff1000 ( 4 kB)
fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB)
DMA : 0xffc00000 - 0xffe00000 ( 2 MB)
vmalloc : 0xc4800000 - 0xf6000000 ( 792 MB)
lowmem : 0xc0000000 - 0xc4000000 ( 64 MB)
modules : 0xbf000000 - 0xc0000000 ( 16 MB)
.init : 0xc0008000 - 0xc0a77000 (10684 kB)
.text : 0xc0a77000 - 0xc0f3b000 (4880 kB)
.data : 0xc0f3c000 - 0xc0f6bc40 ( 192 kB)
.bss : 0xc0f6bc64 - 0xc0f980c4 ( 178 kB)
NR_IRQS:85
irq: clearing pending ext status 00080000
irq: clearing subpending status 00000003
irq: clearing subpending status 00000002
Console: colour dummy device 80x30
console [ttyS0] enabled
Calibrating delay loop... 201.52 BogoMIPS (lpj=503808)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
gpiochip_add: gpios 288..303 (GPIOK) failed to register
gpiochip_add: gpios 320..334 (GPIOL) failed to register
gpiochip_add: gpios 352..353 (GPIOM) failed to register
NET: Registered protocol family 16
S3C Power Management, Copyright 2004 Simtec Electronics
S3C2440: Initialising architecture
S3C2440: IRQ Support
S3C24XX DMA Driver, Copyright 2003-2006 Simtec Electronics
DMA channel 0 at c4804000, irq 33
DMA channel 1 at c4804040, irq 34
DMA channel 2 at c4804080, irq 35
DMA channel 3 at c48040c0, irq 36
S3C244X: Clock Support, DVS off
s3c-adc s3c24xx-adc: attached adc driver
bio: create slab
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
s3c-i2c s3c2440-i2c: slave address 0x10
s3c-i2c s3c2440-i2c: bus frequency set to 98 KHz
s3c-i2c s3c2440-i2c: i2c-0: S3C I2C adapter
Advanced Linux Sound Architecture Driver Version 1.0.24.
cfg80211: Calling CRDA to update world regulatory domain
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
NetWinder Floating Point Emulator V0.97 (extended precision)
NTFS driver 2.1.30 [Flags: R/W].
JFFS2 version 2.2. (NAND) (SUMMARY) © 2001-2006 Red Hat, Inc.
msgmni has been set to 95
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
Console: switching to colour frame buffer device 60x34
fb0: s3c2410fb frame buffer device
s3c2440-uart.0: ttyS0 at MMIO 0x50000000 (irq = 70) is a S3C2440
s3c2440-uart.1: ttyS1 at MMIO 0x50004000 (irq = 73) is a S3C2440
s3c2440-uart.2: ttyS2 at MMIO 0x50008000 (irq = 76) is a S3C2440
brd: module loaded
loop: module loaded
at24 0-0050: 65536 byte 24c512 EEPROM, writable, 128 bytes/write
physmap platform flash device: 00400000 at 08000000
physmap-flash physmap-flash.0: map_probe failed
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c24xx-nand s3c2440-nand: Tacls=3, 29ns Twrph0=7 69ns, Twrph1=3 29ns
s3c24xx-nand s3c2440-nand: NAND soft ECC
NAND device: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V 8-bit)
Scanning device for bad blocks
Bad eraseblock 221 at 0x000001ba0000
Bad eraseblock 1592 at 0x00000c700000
Creating 11 MTD partitions on "NAND":
0x000000000000-0x000000100000 : "mtdblock0 u-boot 1MB"
0x000000100000-0x000000500000 : "mtdblock1 kernel 4MB"
0x000000500000-0x000000f00000 : "mtdblock2 ramdisk 10MB"
0x000000f00000-0x000001e00000 : "mtdblock3 cramfs 15MB"
0x000001e00000-0x000004600000 : "mtdblock3 jffs2 40MB"
0x000004600000-0x000006e00000 : "mtdblock4 yaffs2 40MB"
0x000006e00000-0x000009600000 : "mtdblock5 ubifs 40MB"
0x000009600000-0x000009700000 : "mtdblock6 info 1MB"
0x000009700000-0x00000bf00000 : "mtdblock7 apps 40MB"
0x00000bf00000-0x00000e700000 : "mtdblock8 data 40MB"
0x00000e700000-0x000010000000 : "mtdblock9 backup 25MB"
PPP generic driver version 2.4.2
PPP Deflate Compression module registered
PPP BSD Compression module registered
PPP MPPE Compression module registered
NET: Registered protocol family 24
dm9000 Ethernet Driver, V1.31
dm9000 dm9000.0: eth%d: Invalid ethernet MAC address. Please set using ifconfig
eth0: dm9000a at c4864300,c4866304 IRQ 51 MAC: fe:82:53:01:3c:fa (random)
usbcore: registered new interface driver rt2800usb
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
usb usb1: New USB device found, idVendor=1d6b, idProduct=0001
usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
usb usb1: Product: S3C24XX OHCI
usb usb1: Manufacturer: Linux 3.0.0 ohci_hcd
usb usb1: SerialNumber: s3c24xx
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
usbcore: registered new interface driver usbserial
usbserial: USB Serial Driver core
USB Serial support registered for ch341-uart
usbcore: registered new interface driver ch341
USB Serial support registered for FTDI USB Serial Device
usbcore: registered new interface driver ftdi_sio
ftdi_sio: v1.6.0:USB FTDI Serial Converters Driver
USB Serial support registered for GSM modem (1-port)
usbcore: registered new interface driver option
option: v0.7.2:USB Driver for GSM modems
USB Serial support registered for pl2303
usbcore: registered new interface driver pl2303
pl2303: Prolific PL2303 USB to serial adaptor driver
mousedev: PS/2 mouse device common for all mice
samsung-ts s3c2440-ts: driver attached, registering input device
input: S3C24XX TouchScreen as /devices/virtual/input/input0
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
s3c-rtc s3c2410-rtc: rtc disabled, re-enabling
s3c-rtc s3c2410-rtc: rtc core: registered s3c as rtc0
i2c /dev entries driver
s3c-sdi s3c2440-sdi: mmc0 - using pio, sw SDIO IRQ
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
S3C24XX_UDA134X SoC Audio driver
UDA134X SoC Audio Codec
asoc: uda134x-hifi <-> s3c24xx-iis mapping ok
ALSA device list:
#0: S3C24XX_UDA134X
Netfilter messages via NETLINK v0.30.
nf_conntrack version 0.5.0 (764 buckets, 3056 max)
ctnetlink v0.93: registering with nfnetlink.
xt_time: kernel timezone is -0000
ip_set: protocol 6
IPVS: Registered protocols (TCP, UDP, AH, ESP)
IPVS: Connection hash table configured (size=4096, memory=32Kbytes)
IPVS: Creating netns size=1008 id=0
IPVS: ipvs loaded.
IPVS: [rr] scheduler registered.
IPVS: [wrr] scheduler registered.
IPVS: [lc] scheduler registered.
IPVS: [wlc] scheduler registered.
IPVS: [lblc] scheduler registered.
IPVS: [lblcr] scheduler registered.
IPVS: [dh] scheduler registered.
IPVS: [sh] scheduler registered.
IPVS: [sed] scheduler registered.
IPVS: [nq] scheduler registered.
ip_tables: (C) 2000-2006 Netfilter Core Team
ipt_CLUSTERIP: ClusterIP Version 0.8 loaded successfully
arp_tables: (C) 2002 David S. Miller
TCP cubic registered
NET: Registered protocol family 17
lib80211: common routines for IEEE802.11 drivers
Registering the dns_resolver key type
s3c-rtc s3c2410-rtc: setting system clock to 2023-01-09 16:43:58 UTC (1673282638)
Freeing init memory: 10684K
usb 1-1: new full speed USB device number 2 using s3c2410-ohci
usb 1-1: New USB device found, idVendor=05e3, idProduct=0606
usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 1-1: Product: USB Hub 2.0
hub 1-1:1.0: USB hub found
hub 1-1:1.0: 4 ports detected
dm9000 dm9000.0: eth0: link down
Copyright (C) 2013 fulinux
root login: dm9000 dm9000.0: eth0: link up, 100Mbps, full-duplex, lpa 0xCDE1
Copyright (C) 2013 fulinux
root login: root
>:
>: ls
apps data etc init linuxrc proc sbin tmp var
bin dev info lib mnt root sys usr
>:
这样initramfs文件系统就自作成功
我们在上面移植了initramfs文件系统,并且已经成功运行了。下面我们开始移植nfs,之前开启PC上的nfs服务功能
确认并安装NFS服务依赖软件包
一般NFS服务器要提供服务,必须启动inet,nfs, mount,portmap或rpcbind这些守护进程并保持在后台状态运行. 这里需要提示的是从RHEL6开始, 系统使用rpcbind替换了以前早期版本中NFS依赖的portmap服务。
在使用NFS共享文件之前,我们首先使用rpm命令确认我们安装了这些应用程序。如果没有安装,则从安装光盘中找到他们并安装,或者使用yum安装。下面显示我们在安装系统时,已经选择安装了NFS服务相关软件
[lingyun@localhost opt]$ rpm -qa | grep nfs
nfs4-acl-tools-0.3.3-6.el6.x86_64
nfs-utils-lib-1.1.5-4.el6.x86_64
nfs-utils-1.2.3-36.el6.x86_64
[lingyun@localhost opt]$ rpm -qa | grep rpcbind
rpcbind-0.2.0-11.el6.x86_64
[lingyun@localhost opt]$
修改主机上的NFS配置文件,导出/opt目录使用NFS共享:
[lingyun@localhost opt]$ sudo vim /etc/exports
/opt/ *(rw,sync,no_root_squash)
下面是一些NFS共享的常用参数:
ro 只读访问
rw 读写访问
sync 所有数据在请求时写入共享
async NFS在写入数据前可以相应请求
secure NFS通过1024以下的安全TCP/IP端口发送
insecure NFS通过1024以上的端口发送
wdelay如果多个用户要写入NFS目录,则归组写入(默认)
no_wdelay 如果多个用户要写入NFS目录,则立即写入,当使用async时,无需此设置。
hide 在NFS共享目录中不共享其子目录
no_hide 共享NFS目录的子目录
subtree_check 如果共享/usr/bin之类的子目录时,强制NFS检查父目录的权限(默认)
no_subtree_check 和上面相对,不检查父目录权限
all_squash 共享文件的UID和GID映射匿名用户anonymous,适合公用目录。
no_all_squash 保留共享文件的UID和GID(默认)
root_squash root用户的所有请求映射成如anonymous用户一样的权限(默认)
no_root_squas root用户具有根目录的完全管理访问权限
anonuid=xxx 指定NFS服务器/etc/passwd文件中匿名用户的UID
anongid=xxx 指定NFS服务器/etc/passwd文件中匿名用户的GID
关于/etc/exports文件的更加详细的配置说明,我们可以使用man exports命令来查看帮助手册。
重新启动rpcbind或portmap和nfs服务
使用root权限运行“service rpcbind restart”(RHEL高于6.0版本)或“service portmap restart”(RHEL5及以下版本)命令重启NFS依赖的服务:
[lingyun@localhost opt]$ sudo service rpcbind restart
Stopping rpcbind: [ OK ]
Starting rpcbind: [ OK ]
使用root权限运行“service nfs restart”命令重启NFS服务,让其生效:
[lingyun@localhost opt]$ sudo service nfs restart
Shutting down NFS daemon: [ OK ]
Shutting down NFS mountd: [ OK ]
Shutting down NFS quotas: [ OK ]
Shutting down NFS services: [ OK ]
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS mountd: [ OK ]
Starting NFS daemon: [ OK ]
[lingyun@localhost opt]$
使用service rpcbind status命令和“service nfs status”命令查看相关服务的运行状态,同时可以使用“showmount –e”命令可以查看我们通过NFS服务共享的文件:
[lingyun@localhost opt]$ service rpcbind status
rpcbind (pid 3719) is running...
[lingyun@localhost opt]$ service nfs status
rpc.svcgssd is stopped
rpc.mountd (pid 7935) is running...
nfsd (pid 7962 7961 7960 7959 7958 7957 7956 7955) is running...
rpc.rquotad (pid 7931) is running...
[lingyun@localhost opt]$ showmount -e
Export list for localhost.localdomain:
/opt *
/usr/local/src *
[lingyun@localhost opt]$
测试NFS访问
在另外一个Linux机器上,或者在本机上通过mount命令挂载并测试如下:
[lingyun@localhost opt]$ sudo mkdir -p /mnt/nfs
[lingyun@localhost opt]$ sudo mount -t nfs 192.168.1.3:/opt /mnt/nfs
[lingyun@localhost opt]$ mount
/dev/sda2 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
nfsd on /proc/fs/nfsd type nfsd (rw)
192.168.1.2:/var/ftp/pub on /opt/pub type nfs (rw,nolock,vers=4,addr=192.168.1.2,clientaddr=192.168.1.3)
192.168.1.3:/opt on /mnt/nfs1 type nfs (rw,vers=4,addr=192.168.1.3,clientaddr=192.168.1.3)
[lingyun@localhost opt]$ ls /mnt/nfs/
buildroot-2012.08 mtd pub rootfs
[lingyun@localhost opt]$ ls /mnt/nfs1/rootfs/
apps bin dev home init linuxrc media opt root stat tmp var
backup data etc info lib logs mnt proc sbin sys usr xxx
[lingyun@localhost opt]$ ls /opt/rootfs/
apps bin dev home init linuxrc media opt root stat tmp var
backup data etc info lib logs mnt proc sbin sys usr xxx
[lingyun@localhost opt]$ rm /mnt/nfs1/rootfs/xxx
rm: remove write-protected regular empty file `/mnt/nfs1/rootfs/xxx'? y
[lingyun@localhost opt]$ ls /mnt/nfs/rootfs/
apps bin dev home init linuxrc media opt root stat tmp var
backup data etc info lib logs mnt proc sbin sys usr
[lingyun@localhost opt]$ ls /opt/rootfs/
apps bin dev home init linuxrc media opt root stat tmp var
backup data etc info lib logs mnt proc sbin sys usr
这里我们先假定PC上的功能已经开启,同时在上面移植initramfs文件系统时也完成了下面添加内核对nfs的支持的前提下,我们先在上面已经运行起来的环境中试着先看看开发板上的nfs客户端功能是否支持:
PC上/opt目录下的内容:
[lingyun@localhost rootfs]$ ls /opt/
buildroot-2011.11 busybox-1.20.2 dropbear-0.53.1.tar.bz2 pub rootfs.cramfs
buildroot-2012.08 dropbear-0.53.1 mtd rootfs rootfs_tree
[lingyun@localhost rootfs]$
下面是开发中挂载PC上的/opt目录情况:
Copyright (C) 2013 fulinux
root login: root
>: ls
apps data etc init linuxrc proc sbin tmp var
bin dev info lib mnt root sys usr
>: mount -o nolock 192.168.1.3:/opt /mnt/nfs/
>: ls mnt/nfs/
buildroot-2011.11 dropbear-0.53.1.tar.bz2 rootfs.cramfs
buildroot-2012.08 mtd rootfs_tree
busybox-1.20.2 pub
dropbear-0.53.1 rootfs
>: OK
我们看到开发板是可以挂载PC上的/opt目录,如果能实现会对你下面的工作可能少一些困难,也不是必然的,仅供参考。
无修改
[lingyun@localhost linux-3.0]$ pwd
/home/lingyun/fulinux/kernel/linux-3.0
[lingyun@localhost linux-3.0]$ vt100
[lingyun@localhost linux-3.0]$ make menuconfig
关掉上面的initramfs功能 General setup --->
[ ] Initial RAM filesystem and RAM disk (initramfs/initrd) support
开启nfs功能
Networking --->
Networking options --->
[*] IP: kernel level autoconfiguration
[ ] IP: DHCP support
[ ] IP: BOOTP support
[ ] IP: RARP support
File systems --->
Network File Systems --->
<*> NFS file system support
[ ] Provide NFSv3 client support
[ ] Provide NFSv4 client support (EXPERIMENTAL)
[ ] Allow direct I/O on NFS files
< > NFS server support
[*] Root file system on NFS
注:对于nfs文件系统,上面红色标注的要选上,其余选项根据自身的情况而言。
[lingyun@localhost linux-3.0]$ make
[lingyun@localhost linux-3.0]$ du -h linuxrom-s3c2440.bin
2.5M linuxrom-s3c2440.bin # 比起initramfs小了很多
[lingyun@localhost linux-3.0]$ mv linuxrom-s3c2440.bin /tftp/
mv: try to overwrite `/tftp/linuxrom-s3c2440.bin', overriding mode 0644 (rw-r--r--)? y
[lingyun@localhost linux-3.0]$
无需制作映像文件
设置启动参数
[ s3c2440@fulinux ]# set bootcmd_rootfs 'nand read 30008000 100000 400000;bootm 30008000'
[ s3c2440@fulinux ]# set bootcmd 'run bootcmd_rootfs'
注:下面这个设置只为保存nfs的启动bootargs参数
[ s3c2440@fulinux ]# set bootargs_nfs 'noinitrd console=ttyS0,115200 init=/linuxrc mem=64M loglevel=7 root=/dev/nfs rw nfsroot=192.168.1.3:/opt/rootfs ip=192.168.1.111:192.168.1.3:192.168.1.1:255.255.255.0:localhost.com:eth0:off' '
[ s3c2440@fulinux ]# set bootargs 'noinitrd console=ttyS0,115200 init=/linuxrc mem=64M loglevel=7 root=/dev/nfs rw nfsroot=192.168.1.3:/opt/rootfs ip=192.168.1.111:192.168.1.3:192.168.1.1:255.255.255.0:localhost.com:eth0:off ‘
注:上面的设置中ip=
[ s3c2440@fulinux ]# set bkr 'tftp 30008000 linuxrom-s3c2440.bin;nand erase 100000 400000;nand write 30008000 100000 400000'
上面的bootargs参数解析:
initrd, noinitrd:
当你没有使用ramdisk启动系统的时候,你需要使用noinitrd这个参数,但是如果使用了的话,就需要指定initrd=r_addr,size, r_addr表示initrd在内存中的位置,size表示initrd的大小。
console=ttyS?[,options] 使用特定的串口,options可以是这样的形式bbbbpnx,这里bbbb是指串口的波特率,p是奇偶位,n是指的bits。不过我们一般默认会使用console=ttyS0,115200作为参数;有时,在s3c24x0的u-boot环境变量中,我们会看到
console=ttySAC0,115200,这时因为在Linux-2.6以后的某个版本开始(如我们移植的linux-2.6.24),将drivers/serial/s3c2410.c中设置:
#define S3C24XX_SERIAL_NAME "ttySAC"
另外,在struct uart_driver s3c24xx_uart_drv中定义
.dev_name = "s3c2410_serial",
这时,我们将上面的两处定义分别修改为下面值就OK了:
#define S3C24XX_SERIAL_NAME "ttyS"
static struct uart_driver s3c24xx_uart_drv = {
{
****
.dev_name = "ttyS",
****
}
init指定的是内核启起来后,进入系统中运行的第一个脚本,一般init=/linuxrc, 或者init=/etc/preinit,preinit的内容
一般是创建console,null设备节点,运行init程序,挂载一些文件系统等等操作。请注意,很多初学者以为init=/linuxrc
是固定写法,其实不然,/linuxrc指的是/目录下面的linuxrc脚本,一般是一个连接罢了。如果内核找不到linurc文件,
将会依次搜索/sbin/init,/etc/init,bin/init,/bin/sh
mem: 指定内存大小,非必须的
loglevel: 设置内核的调试打印级别,非必须的;
lpj: 该选项为启动时间优化选项,非必须。LPJ值在硬件条件不变的情况下不会变化,这里我们强制设置LPJ的值,
可以节约启动时间。如果没有预设该值的话,内核启动后,使用dmesg可以看到启动过程打印:
>: dmesg | grep BogoMIPS
Calibrating delay loop... 201.93 BogoMIPS (lpj=504832)
如果设置该值后,dmesg则会显示:
>: dmesg | grep BogoMIPS
Calibrating delay loop (skipped)... 201.93 BogoMIPS preset
root:
用来指定rootfs的位置, 常见的情况有:
ramdisk文件系统使用:root=/dev/ram0 rw
cramfs文件系统使用: root=/dev/mtdblock3 rootfstype=cramfs
jffs2文件系统使用: root=/dev/mtdblock5 rootfstype=jffs2
yaffs2文件系统使用: root=/dev/mtdblock4 rootfstype=yaffs2
NFS文件系统使用: root=/dev/nfs
在文件系统为基于NFS的文件系统时。指定root=/dev/nfs之后,还需要指定nfsroot。
这里的/dev/nfs并非真的设备,而是一个告诉内核经由网络取得根文件系统的旗标。
nfsroot这个参数告诉内核以哪一台机器,哪个目录以及哪个网络文件系统选项作为根文件系统使用。参数的格式如下:
nfsroot=[
如果指令列上没有给定 nfsroot 参数,则将使用‘/tftpboot/%s’预设值。其它选项如下:
(见下面)所决定的值。此参数的用途之一是允许使用不同机器作为反向地址解析协议(RARP)及网络文件系统服务端。
通常你可以不管它(设为空白)。
地址之ASCII 表示法。
port = as given by server portmap daemon
rsize = 1024
wsize = 1024
timeo = 7
retrans = 3
acregmin = 3
acregmax = 60
acdirmin = 30
acdirmax = 60
flags = hard, nointr, noposix, cto, ac
参数nfsaddrs设定网络通讯所需的各种网络接口地址。如果没有给定这个参数,则内核核会试著使用反向地址解析协议
以及/或是启动协议(BOOTP)以找出这些参数。其格式如下:
ip:
下面是U-boot官方文档提供的IP参数解析:
setenv bootargs ${bootargs}
ip=${ipaddr}:${serverip}:\
${gatewayip}:${netmask}:\
${hostname:${netdev}:off
注意,上面换行的地方均有空格。其中 192.168.1.244是开发板的IP,192.168.1.155是PC端(或虚拟机)的 IP,上面的IP根据自己的实际情况修改,不要弄错了。
nfsaddrs=
视配置核心时打开的选项以及 参数而定。如果设定此参数,就不会使用反向地址解析协议或启动协议。
接受从指定之服务端传来的回应。要使用不同的机器作为反向地址解析与网络文件系统服务端的话,在此指定你的反向
地址解析协议服务端(保持空白)并在 nfsroot 参数(见上述)中指定你的网络文件系统服务端。如果此项目空白则
使用回答反向地址解析协议或启动协议之服务端的地址。
服务端在本地的(local)网络上,除非由启动协议接收到值。
设备发出。网络文件系统使用接收到反向地址解析协议或启动协议回应的设备。如果你只有一个设备那你可以不管它。
若配置核心时有打开这两种协议则都使用。 `none' 表示不使用自动配置。这种情况下你必须指定前述栏位中所有必要的值。
此参数可以作为 nfsaddrs 的参数单独使用(前面没有任何 `:` 字符),这种情况下会使用自动配置。然而,此种情况
不能使用 `none'作为值。
查看uboot中的环境变量:
[ s3c2440@guowenxue ]# pri
bbl=nand erase 0 100000;tftp 30008000 u-boot-$cpu.bin;nand write 30008000 0 $filesize
norbbl=erase bank 1;tftp 30008000 u-boot-$cpu.bin;cp.b 30008000 0 $filesize
tpb=tftp 30008000 uImage-$cpu.gz;tftp 30800000 ramdisk-$cpu.gz;bootm 30008000
mtdids=nand0=nand0
mtdparts=mtdparts=nand0:1M@0x0(u-boot),5M@0x100000(kernel),10M@0x600000(ramdisk),10M@0x1000000(cramfs),20M@0x1a00000(yaffs2),20M@0x2e00000(ubifs),-(users)
bootdelay=1
baudrate=115200
ethaddr=08:00:3e:26:0a:6b
ethact=dm9000
bcramfs=tftp 30800000 rootfs.cramfs;nand erase f00000 600000;nand write 30800000 f00000 600000
bjffs2=tftp 30008000 rootfs.jffs2;nand erase 1e00000 1400000;nand write.jffs2 30008000 1e00000 1400000
bootargs_jffs2=noinitrd root=/dev/mtdblock4 rootfstype=jffs2 init=/linuxrc console=ttyS0,115200
bootargs_cramfs=noinitrd root=/dev/mtdblock3 rootfstype=cramfs init=/linuxrc console=ttyS0,115200
bootargs_ubifs=console=ttyS0,115200 mem=64M ubi.mtd=6 root=ubi0:rootfs rootwait rootfstype=ubifs rw
bubifs=tftp 30008000 ubifs-$cpu.img;nand erase 6e00000 900000;nand write 30008000 6e00000 900000
cpu=arm920t
brdfs=tftp 30008000 ramdisk.gz;nand erase 500000 a00000;nand write 30008000 500000 500000
bootcmd_ramdisk=nand read 30008000 100000 400000;nand read 30800000 500000 500000;bootm 30008000
bootargs_ramdisk=console=ttyS0,115200 mem=64M initrd=0x30800000,16M root=/dev/ram0 rw loglevel=7
ip=192.168.1.111:192.168.1.3:192.168.1.1:255.255.255.0:localhost.com:eth0:off
filesize=4DF000
fileaddr=30800000
netmask=255.255.255.0
ipaddr=192.168.1.111
serverip=192.168.1.3
bootcmd_initramdisk=nand read 30008000 100000 800000;bootm 30008000
stdin=serial
stdout=serial
stderr=serial
bootcmd_rootfs=nand read 30008000 100000 400000;bootm 30008000
bootcmd=run bootcmd_rootfs
bootargs_nfs=noinitrd console=ttyS0,115200 init=/linuxrc mem=64M loglevel=7 root=/dev/nfs rw nfsroot=192.168.1.3:/opt/rootfs ip=192.168.1.111:192.168.1.3:192.168.1.1:255.255.255.0:localhost.com:eth0:off
bootargs=noinitrd console=ttyS0,115200 init=/linuxrc mem=64M loglevel=7 root=/dev/nfs rw nfsroot=192.168.1.3:/opt/rootfs ip=192.168.1.111:192.168.1.3:192.168.1.1:255.255.255.0:localhost.com:eth0:off
bkr=tftp 30008000 linuxrom-s3c2440.bin;nand erase 100000 800000;nand write 30008000 100000 800000
Environment size: 2243/131068 bytes
[ s3c2440@guowenxue ]#
下载内核:
[ s3c2440@guowenxue ]# run bkr
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:00:3e:26:0a:6b
could not establish link
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 192.168.1.3; our IP address is 192.168.1.111
Filename 'linuxrom-s3c2440.bin'.
Load address: 0x30008000
Loading: T #################################################################
#################################################################
################################################
done
Bytes transferred = 2608020 (27cb94 hex)
NAND erase: device 0 offset 0x100000, size 0x800000
Erasing at 0x8e0000 -- 100% complete.
OK
NAND write: device 0 offset 0x100000, size 0x800000
8388608 bytes written: OK
[ s3c2440@guowenxue ]# boot
NAND read: device 0 offset 0x100000, size 0x400000
4194304 bytes read: OK
## Booting kernel from Legacy Image at 30008000 ...
Image Name: Linux Kernel
Created: 2013-04-27 14:26:28 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2607956 Bytes = 2.5 MiB
Load Address: 30008000
Entry Point: 30008040
Verifying Checksum ... OK
XIP Kernel Image ... OK
OK
OS entry point: 30008040
Image entry point=30008040
Starting kernel ...
Uncompressing Linux... done, booting the kernel.
Linux version 3.0.0 ([email protected]) (gcc version 4.5.4 (Buildroot 2012.08) ) #5 Sat Apr 27 22:26:24 CST 2013
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT data cache, VIVT instruction cache
Machine: SMDK2440
Memory policy: ECC disabled, Data cache writeback
CPU S3C2440A (id 0x32440001)
S3C24XX Clocks, Copyright 2004 Simtec Electronics
S3C244X: core 405.000 MHz, memory 101.250 MHz, peripheral 50.625 MHz
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16256
Kernel command line: noinitrd console=ttyS0,115200 init=/linuxrc mem=64M loglevel=7 root=/dev/nfs rw nfsroot=192.168.1.3:/opt/rootfs ip=192.168.1.111:192.168.1.3:192.168.1.1:255.255.255.0:localhost.com:eth0:off
PID hash table entries: 256 (order: -2, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 59484k/59484k available, 6052k reserved, 0K highmem
Virtual kernel memory layout:
vector : 0xffff0000 - 0xffff1000 ( 4 kB)
fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB)
DMA : 0xffc00000 - 0xffe00000 ( 2 MB)
vmalloc : 0xc4800000 - 0xf6000000 ( 792 MB)
lowmem : 0xc0000000 - 0xc4000000 ( 64 MB)
modules : 0xbf000000 - 0xc0000000 ( 16 MB)
.init : 0xc0008000 - 0xc002d000 ( 148 kB)
.text : 0xc002d000 - 0xc04f0000 (4876 kB)
.data : 0xc04f0000 - 0xc051fc20 ( 192 kB)
.bss : 0xc051fc44 - 0xc054c0a4 ( 178 kB)
NR_IRQS:85
irq: clearing pending ext status 00080000
irq: clearing subpending status 00000003
irq: clearing subpending status 00000002
Console: colour dummy device 80x30
console [ttyS0] enabled
Calibrating delay loop... 201.52 BogoMIPS (lpj=503808)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
gpiochip_add: gpios 288..303 (GPIOK) failed to register
gpiochip_add: gpios 320..334 (GPIOL) failed to register
gpiochip_add: gpios 352..353 (GPIOM) failed to register
NET: Registered protocol family 16
S3C Power Management, Copyright 2004 Simtec Electronics
S3C2440: Initialising architecture
S3C2440: IRQ Support
S3C24XX DMA Driver, Copyright 2003-2006 Simtec Electronics
DMA channel 0 at c4804000, irq 33
DMA channel 1 at c4804040, irq 34
DMA channel 2 at c4804080, irq 35
DMA channel 3 at c48040c0, irq 36
S3C244X: Clock Support, DVS off
s3c-adc s3c24xx-adc: attached adc driver
bio: create slab
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
s3c-i2c s3c2440-i2c: slave address 0x10
s3c-i2c s3c2440-i2c: bus frequency set to 98 KHz
s3c-i2c s3c2440-i2c: i2c-0: S3C I2C adapter
Advanced Linux Sound Architecture Driver Version 1.0.24.
cfg80211: Calling CRDA to update world regulatory domain
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
NetWinder Floating Point Emulator V0.97 (extended precision)
NTFS driver 2.1.30 [Flags: R/W].
JFFS2 version 2.2. (NAND) (SUMMARY) © 2001-2006 Red Hat, Inc.
msgmni has been set to 116
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
Console: switching to colour frame buffer device 60x34
fb0: s3c2410fb frame buffer device
s3c2440-uart.0: ttyS0 at MMIO 0x50000000 (irq = 70) is a S3C2440
s3c2440-uart.1: ttyS1 at MMIO 0x50004000 (irq = 73) is a S3C2440
s3c2440-uart.2: ttyS2 at MMIO 0x50008000 (irq = 76) is a S3C2440
brd: module loaded
loop: module loaded
at24 0-0050: 65536 byte 24c512 EEPROM, writable, 128 bytes/write
physmap platform flash device: 00400000 at 08000000
physmap-flash physmap-flash.0: map_probe failed
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c24xx-nand s3c2440-nand: Tacls=3, 29ns Twrph0=7 69ns, Twrph1=3 29ns
s3c24xx-nand s3c2440-nand: NAND soft ECC
NAND device: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V 8-bit)
Scanning device for bad blocks
Bad eraseblock 221 at 0x000001ba0000
Bad eraseblock 1592 at 0x00000c700000
Creating 11 MTD partitions on "NAND":
0x000000000000-0x000000100000 : "mtdblock0 u-boot 1MB"
0x000000100000-0x000000500000 : "mtdblock1 kernel 4MB"
0x000000500000-0x000000f00000 : "mtdblock2 ramdisk 10MB"
0x000000f00000-0x000001e00000 : "mtdblock3 cramfs 15MB"
0x000001e00000-0x000004600000 : "mtdblock3 jffs2 40MB"
0x000004600000-0x000006e00000 : "mtdblock4 yaffs2 40MB"
0x000006e00000-0x000009600000 : "mtdblock5 ubifs 40MB"
0x000009600000-0x000009700000 : "mtdblock6 info 1MB"
0x000009700000-0x00000bf00000 : "mtdblock7 apps 40MB"
0x00000bf00000-0x00000e700000 : "mtdblock8 data 40MB"
0x00000e700000-0x000010000000 : "mtdblock9 backup 25MB"
PPP generic driver version 2.4.2
PPP Deflate Compression module registered
PPP BSD Compression module registered
PPP MPPE Compression module registered
NET: Registered protocol family 24
dm9000 Ethernet Driver, V1.31
eth0: dm9000a at c4864300,c4866304 IRQ 51 MAC: 08:00:3e:26:0a:6b (chip)
usbcore: registered new interface driver rt2800usb
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
usb usb1: New USB device found, idVendor=1d6b, idProduct=0001
usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
usb usb1: Product: S3C24XX OHCI
usb usb1: Manufacturer: Linux 3.0.0 ohci_hcd
usb usb1: SerialNumber: s3c24xx
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
usbcore: registered new interface driver usbserial
usbserial: USB Serial Driver core
USB Serial support registered for ch341-uart
usbcore: registered new interface driver ch341
USB Serial support registered for FTDI USB Serial Device
usbcore: registered new interface driver ftdi_sio
ftdi_sio: v1.6.0:USB FTDI Serial Converters Driver
USB Serial support registered for GSM modem (1-port)
usbcore: registered new interface driver option
option: v0.7.2:USB Driver for GSM modems
USB Serial support registered for pl2303
usbcore: registered new interface driver pl2303
pl2303: Prolific PL2303 USB to serial adaptor driver
mousedev: PS/2 mouse device common for all mice
samsung-ts s3c2440-ts: driver attached, registering input device
input: S3C24XX TouchScreen as /devices/virtual/input/input0
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
s3c-rtc s3c2410-rtc: rtc disabled, re-enabling
s3c-rtc s3c2410-rtc: rtc core: registered s3c as rtc0
i2c /dev entries driver
s3c-sdi s3c2440-sdi: mmc0 - using pio, sw SDIO IRQ
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
S3C24XX_UDA134X SoC Audio driver
UDA134X SoC Audio Codec
asoc: uda134x-hifi <-> s3c24xx-iis mapping ok
ALSA device list:
#0: S3C24XX_UDA134X
Netfilter messages via NETLINK v0.30.
nf_conntrack version 0.5.0 (929 buckets, 3716 max)
ctnetlink v0.93: registering with nfnetlink.
xt_time: kernel timezone is -0000
ip_set: protocol 6
IPVS: Registered protocols (TCP, UDP, AH, ESP)
IPVS: Connection hash table configured (size=4096, memory=32Kbytes)
IPVS: Creating netns size=1008 id=0
IPVS: ipvs loaded.
IPVS: [rr] scheduler registered.
IPVS: [wrr] scheduler registered.
IPVS: [lc] scheduler registered.
IPVS: [wlc] scheduler registered.
IPVS: [lblc] scheduler registered.
IPVS: [lblcr] scheduler registered.
IPVS: [dh] scheduler registered.
IPVS: [sh] scheduler registered.
IPVS: [sed] scheduler registered.
IPVS: [nq] scheduler registered.
ip_tables: (C) 2000-2006 Netfilter Core Team
ipt_CLUSTERIP: ClusterIP Version 0.8 loaded successfully
arp_tables: (C) 2002 David S. Miller
TCP cubic registered
NET: Registered protocol family 17
lib80211: common routines for IEEE802.11 drivers
Registering the dns_resolver key type
s3c-rtc s3c2410-rtc: setting system clock to 2023-01-10 05:41:40 UTC (1673329300)
dm9000 dm9000.0: eth0: link down
usb 1-1: new full speed USB device number 2 using s3c2410-ohci
usb 1-1: New USB device found, idVendor=05e3, idProduct=0606
usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 1-1: Product: USB Hub 2.0
dm9000 dm9000.0: eth0: link up, 100Mbps, full-duplex, lpa 0xCDE1
IP-Config: Complete:
device=eth0, addr=192.168.1.111, mask=255.255.255.0, gw=192.168.1.1,
host=localhost, domain=, nis-domain=com,
bootserver=192.168.1.3, rootserver=192.168.1.3, rootpath=
hub 1-1:1.0: USB hub found
hub 1-1:1.0: 4 ports detected
VFS: Mounted root (nfs filesystem) on device 0:12.
Freeing init memory: 148K
Copyright (C) 2013 fulinux
root login: root
>: ls
apps data etc init linuxrc proc sbin tmp var
bin dev info lib mnt root sys usr
>:
测试:
*****************************************************************************************************************
装载声明:希望大家能转载此文谢谢:点击打开链接
*****************************************************************************************************************
无修改
在内核中为256M的nandflash进行分区,修改文件arch/arm/plat-s3c24xx/common-smdk.c 中第109行开始处的代码如下:
/* NAND parititon from 2.4.18-swl5, modify by guowenxue 2011.08.30, K9F2G08,256MiB */
static struct mtd_partition smdk_default_nand_part[] = {
[0] = {
.name = "mtdblock0 u-boot 1MB",
.size = SZ_1M*1,
.offset = 0,
},
[1] = {
.name = "mtdblock1 kernel 4MB",
.offset = MTDPART_OFS_NXTBLK,
.size = SZ_1M*4,
},
[2] = {
.name = "mtdblock2 ramdisk 10MB",
.offset = MTDPART_OFS_NXTBLK,
.size = SZ_1M*10,
},
[3] = {
.name = "mtdblock3 cramfs 15MB",
.offset = MTDPART_OFS_NXTBLK,
.size = SZ_1M*15,
},
[4] = {
.name = "mtdblock3 jffs2 40MB",
.offset = MTDPART_OFS_NXTBLK,
.size = SZ_1M*40,
},
[5] = {
.name = "mtdblock4 yaffs2 40MB",
.offset = MTDPART_OFS_NXTBLK,
.size = SZ_1M*40,
},
[6] = {
.name = "mtdblock5 ubifs 40MB",
.offset = MTDPART_OFS_NXTBLK,
.size = SZ_1M*40,
},
[7] = {
.name = "mtdblock6 info 1MB",
.offset = MTDPART_OFS_NXTBLK,
.size = SZ_1M*1,
},
[8] = {
.name = "mtdblock7 apps 40MB",
.offset = MTDPART_OFS_NXTBLK,
.size = SZ_1M*40,
},
[9] = {
.name = "mtdblock8 data 40MB",
.offset = MTDPART_OFS_NXTBLK,
.size = SZ_1M*40,
},
[10] = {
.name = "mtdblock9 backup 25MB",
.offset = MTDPART_OFS_NXTBLK,
.size = MTDPART_SIZ_FULL,
}
};
下面是修改后的内核在开发板启动时打印的信息:
Creating 11 MTD partitions on "NAND":
0x000000000000-0x000000100000 : "mtdblock0 u-boot 1MB"
0x000000100000-0x000000500000 : "mtdblock1 kernel 4MB"
0x000000500000-0x000000f00000 : "mtdblock2 ramdisk 10MB"
0x000000f00000-0x000001e00000 : "mtdblock3 cramfs 15MB"
0x000001e00000-0x000004600000 : "mtdblock3 jffs2 40MB"
0x000004600000-0x000006e00000 : "mtdblock4 yaffs2 40MB"
0x000006e00000-0x000009600000 : "mtdblock5 ubifs 40MB"
0x000009600000-0x000009700000 : "mtdblock6 info 1MB"
0x000009700000-0x00000bf00000 : "mtdblock7 apps 40MB"
0x00000bf00000-0x00000e700000 : "mtdblock8 data 40MB"
0x00000e700000-0x000010000000 : "mtdblock9 backup 25MB"
我们现在重点关心mtdblock2这个分区,它将是我们存放ramdisk映像的地方。
[lingyun@localhost linux-3.0]$ vt100
[lingyun@localhost linux-3.0]$ make menuconfig
General setup --->
[*] Initial RAM filesystem and RAM disk (initramfs/initrd) support
() Initramfs source file(s)
Device Drivers --->
Block devices --->
<*> RAM disk support
(1) Default number of RAM disks
(16384) Default RAM disk size (kbytes)
(1024) Default RAM disk block size (bytes)
[lingyun@localhost linux-3.0]$ make
[lingyun@localhost linux-3.0]$ du -h linuxrom-s3c2440.bin
2.5M linuxrom-s3c2440.bin
[lingyun@localhost linux-3.0]$ cp linuxrom-s3c2440.bin /tftp/
[lingyun@localhost linux-3.0]$
使用dd命令建立一个16MB的文件系统映像ramdisk. 以/dev/zero对其初始化.对于dd命令可以参考
http://www.cnblogs.com/dkblog/archive/2009/09/18/1980715.html
[lingyun@localhost opt]$ ls
buildroot-2011.11 busybox-1.20.2 dropbear-0.53.1.tar.bz2 pub rootfs.cramfs
buildroot-2012.08 dropbear-0.53.1 mtd rootfs rootfs_tree
[lingyun@localhost opt]$ dd if=/dev/zero of=ramdisk bs=1M count=16
16+0 records in
16+0 records out
16777216 bytes (17 MB) copied, 0.0123997 s, 1.4 GB/s
16777216 bytes (17 MB) copied, 0.0117027 s, 1.4 GB/s
[lingyun@localhost opt]$ ls
buildroot-2011.11 busybox-1.20.2 dropbear-0.53.1.tar.bz2 pub rootfs rootfs_tree
buildroot-2012.08 dropbear-0.53.1 mtd ramdisk rootfs.cramfs
注:因为ramdisk只是一个块设备,只有将其格式化为特定的文件系统后才能使用,我们将其格式化ext2格式:
[lingyun@localhost opt]$ mke2fs -F -v -m0 ramdisk
mke2fs 1.42.7 (21-Jan-2013)
fs_types for mke2fs.conf resolution: 'ext2', 'small'
Discarding device blocks: done
Discard succeeded and will return 0s - skipping inode table wipe
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
4096 inodes, 16384 blocks
0 blocks (0.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=16777216
2 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
8193
Allocating group tables: done
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
其中:
-F : 迫使mke2fs在ramdisk.image上运行, 否则, mke2fs会抱怨ramdisk.image不是块设备.
-v : 以verbose模式运行
-m0 : 指定不必在文件系统上为"超级用户"保留任何block.(一般嵌入式Linux都是单用户系统).
[lingyun@localhost opt]$ file ramdisk
ramdisk: Linux rev 1.0 ext2 filesystem data
挂载ramdisk,并拷贝制作好的根文件系统到mnt目录下:
[lingyun@localhost opt]$ mkdir mnt
[lingyun@localhost opt]$ ls mnt/
[lingyun@localhost opt]$ sudo mount -o loop ramdisk mnt/
[lingyun@localhost opt]$ mount | grep ramdisk
/opt/ramdisk on /opt/mnt type ext2 (rw,loop=/dev/loop0)
[lingyun@localhost opt]$ ls mnt/
lost+found
[lingyun@localhost opt]$ rm -rf mnt/*
[lingyun@localhost opt]$ ls rootfs
apps bin data dev etc info init lib lingyun linuxrc mnt proc root sbin sys tmp usr var
[lingyun@localhost opt]$ sudo cp -af rootfs/* mnt/
[lingyun@localhost opt]$ ls mnt/
apps bin data dev etc info init lib lingyun linuxrc mnt proc root sbin sys tmp usr var
卸载并压缩ramdisk根文件系统Image:
[lingyun@localhost opt]$ sudo umount ramdisk
[lingyun@localhost opt]$ du -h ramdisk
16M ramdisk
[lingyun@localhost opt]$ gzip ramdisk
[lingyun@localhost opt]$ du -h ramdisk.gz
4.5M ramdisk.gz
将其拷贝到tftp目录下:
[lingyun@localhost opt]$ cp ramdisk.gz /tftp/
[ s3c2440@guowenxue ]# set bkr 'tftp 30008000 linuxrom-s3c2440.bin;nand erase 100000 800000;nand write 30008000 100000 800000'
[ s3c2440@guowenxue ]# set brdfs 'tftp 30008000 ramdisk.gz;nand erase 500000 a00000;nand write 30008000 500000 500000'
[ s3c2440@guowenxue ]# set bootcmd_ramdisk 'nand read 30008000 100000 400000;nand read 30800000 500000 500000;bootm 30008000'
[ s3c2440@guowenxue ]# set bootcmd 'run bootcmd_ramdisk'
[ s3c2440@guowenxue ]# set bootargs 'console=ttyS0,115200 mem=64M initrd=0x30800000,16M root=/dev/ram0 rw loglevel=7'
[ s3c2440@guowenxue ]# save
Saving Environment to NAND...
Erasing Nand...
Erasing at 0x60000 -- 100% complete.
Writing to Nand... done
[ s3c2440@guowenxue ]# pri
bbl=nand erase 0 100000;tftp 30008000 u-boot-$cpu.bin;nand write 30008000 0 $filesize
norbbl=erase bank 1;tftp 30008000 u-boot-$cpu.bin;cp.b 30008000 0 $filesize
tpb=tftp 30008000 uImage-$cpu.gz;tftp 30800000 ramdisk-$cpu.gz;bootm 30008000
mtdids=nand0=nand0
mtdparts=mtdparts=nand0:1M@0x0(u-boot),5M@0x100000(kernel),10M@0x600000(ramdisk),10M@0x1000000(cramfs),20M@0x1a00000(yaffs2),20M@0x2e00000(ubifs),-(users)
bootdelay=1
baudrate=115200
ethaddr=08:00:3e:26:0a:6b
ethact=dm9000
bcramfs=tftp 30800000 rootfs.cramfs;nand erase f00000 600000;nand write 30800000 f00000 600000
bjffs2=tftp 30008000 rootfs.jffs2;nand erase 1e00000 1400000;nand write.jffs2 30008000 1e00000 1400000
bootargs_jffs2=noinitrd root=/dev/mtdblock4 rootfstype=jffs2 init=/linuxrc console=ttyS0,115200
bootargs_cramfs=noinitrd root=/dev/mtdblock3 rootfstype=cramfs init=/linuxrc console=ttyS0,115200
bootargs_ubifs=console=ttyS0,115200 mem=64M ubi.mtd=6 root=ubi0:rootfs rootwait rootfstype=ubifs rw
bubifs=tftp 30008000 ubifs-$cpu.img;nand erase 6e00000 900000;nand write 30008000 6e00000 900000
cpu=arm920t
bootargs_ramdisk=console=ttyS0,115200 mem=64M initrd=0x30800000,16M root=/dev/ram0 rw loglevel=7
ip=192.168.1.111:192.168.1.3:192.168.1.1:255.255.255.0:localhost.com:eth0:off
filesize=4DF000
fileaddr=30800000
netmask=255.255.255.0
ipaddr=192.168.1.111
serverip=192.168.1.3
bootcmd_initramdisk=nand read 30008000 100000 800000;bootm 30008000
bootcmd_rootfs=nand read 30008000 100000 400000;bootm 30008000
bootargs_nfs=noinitrd console=ttyS0,115200 init=/linuxrc mem=64M loglevel=7 root=/dev/nfs rw nfsroot=192.168.1.3:/opt/rootfs ip=192.168.1.111:192.168.1.3:192.168.1.1:255.255.255.0:localhost.com:eth0:off
stdin=serial
stdout=serial
stderr=serial
bkr=tftp 30008000 linuxrom-s3c2440.bin;nand erase 100000 800000;nand write 30008000 100000 800000
brdfs=tftp 30008000 ramdisk.gz;nand erase 500000 a00000;nand write 30008000 500000 500000
bootcmd_ramdisk=nand read 30008000 100000 400000;nand read 30800000 500000 500000;bootm 30008000
bootcmd=run bootcmd_ramdisk
bootargs=console=ttyS0,115200 mem=64M initrd=0x30800000,16M root=/dev/ram0 rw loglevel=7
Environment size: 2134/131068 bytes
[ s3c2440@guowenxue ]#
下载内核和文件系统映像
[ s3c2440@guowenxue ]# run bkr
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:00:3e:26:0a:6b
could not establish link
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 192.168.1.3; our IP address is 192.168.1.111
Filename 'linuxrom-s3c2440.bin'.
Load address: 0x30008000
Loading: T #################################################################
#################################################################
################################################
done
Bytes transferred = 2612580 (27dd64 hex)
NAND erase: device 0 offset 0x100000, size 0x800000
Erasing at 0x8e0000 -- 100% complete.
OK
NAND write: device 0 offset 0x100000, size 0x800000
8388608 bytes written: OK
[ s3c2440@guowenxue ]# run brdfs
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:00:3e:26:0a:6b
could not establish link
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 192.168.1.3; our IP address is 192.168.1.111
Filename 'ramdisk.gz'.
Load address: 0x30008000
Loading: T #################################################################
#################################################################
#################################################################
#################################################################
#######################################################
done
Bytes transferred = 4619771 (467dfb hex)
NAND erase: device 0 offset 0x500000, size 0xa00000
Erasing at 0xee0000 -- 100% complete.
OK
NAND write: device 0 offset 0x500000, size 0x500000
5242880 bytes written: OK
[ s3c2440@guowenxue ]#
[ s3c2440@guowenxue ]# boot
NAND read: device 0 offset 0x100000, size 0x400000
4194304 bytes read: OK
NAND read: device 0 offset 0x500000, size 0x500000
5242880 bytes read: OK
## Booting kernel from Legacy Image at 30008000 ...
Image Name: Linux Kernel
Created: 2013-04-28 2:33:43 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2612516 Bytes = 2.5 MiB
Load Address: 30008000
Entry Point: 30008040
Verifying Checksum ... OK
XIP Kernel Image ... OK
OK
OS entry point: 30008040
Image entry point=30008040
Starting kernel ...
Uncompressing Linux... done, booting the kernel.
Linux version 3.0.0 ([email protected]) (gcc version 4.5.4 (Buildroot 2012.08) ) #6 Sun Apr 28 10:33:40 CST 2013
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT data cache, VIVT instruction cache
Machine: SMDK2440
Memory policy: ECC disabled, Data cache writeback
CPU S3C2440A (id 0x32440001)
S3C24XX Clocks, Copyright 2004 Simtec Electronics
S3C244X: core 405.000 MHz, memory 101.250 MHz, peripheral 50.625 MHz
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16256
Kernel command line: console=ttyS0,115200 mem=64M initrd=0x30800000,16M root=/dev/ram0 rw loglevel=7
PID hash table entries: 256 (order: -2, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 43084k/43084k available, 22452k reserved, 0K highmem
Virtual kernel memory layout:
vector : 0xffff0000 - 0xffff1000 ( 4 kB)
fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB)
DMA : 0xffc00000 - 0xffe00000 ( 2 MB)
vmalloc : 0xc4800000 - 0xf6000000 ( 792 MB)
lowmem : 0xc0000000 - 0xc4000000 ( 64 MB)
modules : 0xbf000000 - 0xc0000000 ( 16 MB)
.init : 0xc0008000 - 0xc002f000 ( 156 kB)
.text : 0xc002f000 - 0xc04f3000 (4880 kB)
.data : 0xc04f4000 - 0xc0523c40 ( 192 kB)
.bss : 0xc0523c64 - 0xc05500c4 ( 178 kB)
NR_IRQS:85
irq: clearing pending ext status 00080000
irq: clearing subpending status 00000003
irq: clearing subpending status 00000002
Console: colour dummy device 80x30
console [ttyS0] enabled
Calibrating delay loop... 201.52 BogoMIPS (lpj=503808)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
gpiochip_add: gpios 288..303 (GPIOK) failed to register
gpiochip_add: gpios 320..334 (GPIOL) failed to register
gpiochip_add: gpios 352..353 (GPIOM) failed to register
NET: Registered protocol family 16
S3C Power Management, Copyright 2004 Simtec Electronics
S3C2440: Initialising architecture
S3C2440: IRQ Support
S3C24XX DMA Driver, Copyright 2003-2006 Simtec Electronics
DMA channel 0 at c4804000, irq 33
DMA channel 1 at c4804040, irq 34
DMA channel 2 at c4804080, irq 35
DMA channel 3 at c48040c0, irq 36
S3C244X: Clock Support, DVS off
s3c-adc s3c24xx-adc: attached adc driver
bio: create slab
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
s3c-i2c s3c2440-i2c: slave address 0x10
s3c-i2c s3c2440-i2c: bus frequency set to 98 KHz
s3c-i2c s3c2440-i2c: i2c-0: S3C I2C adapter
Advanced Linux Sound Architecture Driver Version 1.0.24.
cfg80211: Calling CRDA to update world regulatory domain
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
Trying to unpack rootfs image as initramfs...
rootfs image is not initramfs (no cpio magic); looks like an initrd
Freeing initrd memory: 16384K
NetWinder Floating Point Emulator V0.97 (extended precision)
NTFS driver 2.1.30 [Flags: R/W].
JFFS2 version 2.2. (NAND) (SUMMARY) © 2001-2006 Red Hat, Inc.
msgmni has been set to 116
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
Console: switching to colour frame buffer device 60x34
fb0: s3c2410fb frame buffer device
s3c2440-uart.0: ttyS0 at MMIO 0x50000000 (irq = 70) is a S3C2440
s3c2440-uart.1: ttyS1 at MMIO 0x50004000 (irq = 73) is a S3C2440
s3c2440-uart.2: ttyS2 at MMIO 0x50008000 (irq = 76) is a S3C2440
brd: module loaded
loop: module loaded
at24 0-0050: 65536 byte 24c512 EEPROM, writable, 128 bytes/write
physmap platform flash device: 00400000 at 08000000
physmap-flash physmap-flash.0: map_probe failed
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c24xx-nand s3c2440-nand: Tacls=3, 29ns Twrph0=7 69ns, Twrph1=3 29ns
s3c24xx-nand s3c2440-nand: NAND soft ECC
NAND device: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V 8-bit)
Scanning device for bad blocks
Bad eraseblock 221 at 0x000001ba0000
Bad eraseblock 1592 at 0x00000c700000
Creating 11 MTD partitions on "NAND":
0x000000000000-0x000000100000 : "mtdblock0 u-boot 1MB"
0x000000100000-0x000000500000 : "mtdblock1 kernel 4MB"
0x000000500000-0x000000f00000 : "mtdblock2 ramdisk 10MB"
0x000000f00000-0x000001e00000 : "mtdblock3 cramfs 15MB"
0x000001e00000-0x000004600000 : "mtdblock3 jffs2 40MB"
0x000004600000-0x000006e00000 : "mtdblock4 yaffs2 40MB"
0x000006e00000-0x000009600000 : "mtdblock5 ubifs 40MB"
0x000009600000-0x000009700000 : "mtdblock6 info 1MB"
0x000009700000-0x00000bf00000 : "mtdblock7 apps 40MB"
0x00000bf00000-0x00000e700000 : "mtdblock8 data 40MB"
0x00000e700000-0x000010000000 : "mtdblock9 backup 25MB"
PPP generic driver version 2.4.2
PPP Deflate Compression module registered
PPP BSD Compression module registered
PPP MPPE Compression module registered
NET: Registered protocol family 24
dm9000 Ethernet Driver, V1.31
dm9000 dm9000.0: eth%d: Invalid ethernet MAC address. Please set using ifconfig
eth0: dm9000a at c4864300,c4866304 IRQ 51 MAC: 1a:25:c7:c6:83:ad (random)
usbcore: registered new interface driver rt2800usb
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
usb usb1: New USB device found, idVendor=1d6b, idProduct=0001
usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
usb usb1: Product: S3C24XX OHCI
usb usb1: Manufacturer: Linux 3.0.0 ohci_hcd
usb usb1: SerialNumber: s3c24xx
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
usbcore: registered new interface driver usbserial
usbserial: USB Serial Driver core
USB Serial support registered for ch341-uart
usbcore: registered new interface driver ch341
USB Serial support registered for FTDI USB Serial Device
usbcore: registered new interface driver ftdi_sio
ftdi_sio: v1.6.0:USB FTDI Serial Converters Driver
USB Serial support registered for GSM modem (1-port)
usbcore: registered new interface driver option
option: v0.7.2:USB Driver for GSM modems
USB Serial support registered for pl2303
usbcore: registered new interface driver pl2303
pl2303: Prolific PL2303 USB to serial adaptor driver
mousedev: PS/2 mouse device common for all mice
samsung-ts s3c2440-ts: driver attached, registering input device
input: S3C24XX TouchScreen as /devices/virtual/input/input0
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
s3c-rtc s3c2410-rtc: rtc disabled, re-enabling
s3c-rtc s3c2410-rtc: rtc core: registered s3c as rtc0
i2c /dev entries driver
s3c-sdi s3c2440-sdi: mmc0 - using pio, sw SDIO IRQ
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
S3C24XX_UDA134X SoC Audio driver
UDA134X SoC Audio Codec
asoc: uda134x-hifi <-> s3c24xx-iis mapping ok
ALSA device list:
#0: S3C24XX_UDA134X
Netfilter messages via NETLINK v0.30.
nf_conntrack version 0.5.0 (929 buckets, 3716 max)
ctnetlink v0.93: registering with nfnetlink.
xt_time: kernel timezone is -0000
ip_set: protocol 6
IPVS: Registered protocols (TCP, UDP, AH, ESP)
IPVS: Connection hash table configured (size=4096, memory=32Kbytes)
IPVS: Creating netns size=1008 id=0
IPVS: ipvs loaded.
IPVS: [rr] scheduler registered.
IPVS: [wrr] scheduler registered.
IPVS: [lc] scheduler registered.
IPVS: [wlc] scheduler registered.
IPVS: [lblc] scheduler registered.
IPVS: [lblcr] scheduler registered.
IPVS: [dh] scheduler registered.
IPVS: [sh] scheduler registered.
IPVS: [sed] scheduler registered.
IPVS: [nq] scheduler registered.
ip_tables: (C) 2000-2006 Netfilter Core Team
ipt_CLUSTERIP: ClusterIP Version 0.8 loaded successfully
arp_tables: (C) 2002 David S. Miller
TCP cubic registered
NET: Registered protocol family 17
lib80211: common routines for IEEE802.11 drivers
Registering the dns_resolver key type
s3c-rtc s3c2410-rtc: setting system clock to 2023-01-10 06:30:03 UTC (1673332203)
RAMDISK: gzip image found at block 0
usb 1-1: new full speed USB device number 2 using s3c2410-ohci
usb 1-1: New USB device found, idVendor=05e3, idProduct=0606
usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 1-1: Product: USB Hub 2.0
hub 1-1:1.0: USB hub found
hub 1-1:1.0: 4 ports detected
VFS: Mounted root (ext2 filesystem) on device 1:0.
Freeing init memory: 156K
dm9000 dm9000.0: eth0: link down
Copyright (C) 2013 fulinux
root login: dm9000 dm9000.0: eth0: link up, 100Mbps, full-duplex, lpa 0xCDE1
Copyright (C) 2013 fulinux
root login: root
>: ls
apps data etc init lingyun mnt root sys usr
bin dev info lib linuxrc proc sbin tmp var
>:
>: rm -rf *
。 。 。 。 。 。
>: ls
-sh: ls: not found # ls等命令失效
>: cd root/ # cd 命令可以执行
>: cd /dev/
>:
重启开发板后一切恢复原样
[lingyun@localhost linux-3.0]$ vt100
[lingyun@localhost linux-3.0]$ make menuconfig
File systems --->
Miscellaneous filesystems --->
<*> Compressed ROM file system support (cramfs)
[lingyun@localhost linux-3.0]$ du -h linuxrom-s3c2440.bin
2.5M linuxrom-s3c2440.bin
[lingyun@localhost linux-3.0]$ cp linuxrom-s3c2440.bin /tftp/
[lingyun@localhost linux-3.0]$
[lingyun@localhost opt]$ ls
buildroot-2011.11 busybox-1.20.2 dropbear-0.53.1.tar.bz2 mtd ramdisk.gz
buildroot-2012.08 dropbear-0.53.1 mnt pub rootfs
[lingyun@localhost opt]$ mkcramfs rootfs rootfs.cramfs
Directory data: 9692 bytes
Everything: 4988 kilobytes
Super block: 76 bytes
CRC: eb7dba44
warning: files were skipped due to errors
warning: gids truncated to 8 bits (this may be a security concern)
[lingyun@localhost opt]$ du -h rootfs.cramfs
4.9M rootfs.cramfs
[lingyun@localhost opt]$ cp rootfs.cramfs /tftp/
[lingyun@localhost opt]$
[ s3c2440@guowenxue ]# set bcramfs 'tftp 30800000 rootfs.cramfs;nand erase f00000 600000;nand write 30800000 f00000 600000'
[ s3c2440@guowenxue ]# set bootargs 'noinitrd root=/dev/mtdblock3 rootfstype=cramfs init=/linuxrc console=ttyS0,115200'
[ s3c2440@guowenxue ]# set bootcmd_cramfs 'nand read 30008000 100000 400000;bootm 30008000'
[ s3c2440@guowenxue ]# set bootcmd 'run bootcmd_cramfs'
[ s3c2440@guowenxue ]# save
Saving Environment to NAND...
Erasing Nand...
Erasing at 0x60000 -- 100% complete.
Writing to Nand... done
[ s3c2440@guowenxue ]# pri
bbl=nand erase 0 100000;tftp 30008000 u-boot-$cpu.bin;nand write 30008000 0 $filesize
norbbl=erase bank 1;tftp 30008000 u-boot-$cpu.bin;cp.b 30008000 0 $filesize
tpb=tftp 30008000 uImage-$cpu.gz;tftp 30800000 ramdisk-$cpu.gz;bootm 30008000
mtdids=nand0=nand0
mtdparts=mtdparts=nand0:1M@0x0(u-boot),5M@0x100000(kernel),10M@0x600000(ramdisk),10M@0x1000000(cramfs),20M@0x1a00000(yaffs2),20M@0x2e00000(ubifs),-(users)
bootdelay=1
baudrate=115200
ethaddr=08:00:3e:26:0a:6b
ethact=dm9000
bjffs2=tftp 30008000 rootfs.jffs2;nand erase 1e00000 1400000;nand write.jffs2 30008000 1e00000 1400000
bootargs_jffs2=noinitrd root=/dev/mtdblock4 rootfstype=jffs2 init=/linuxrc console=ttyS0,115200
bootargs_cramfs=noinitrd root=/dev/mtdblock3 rootfstype=cramfs init=/linuxrc console=ttyS0,115200
bootargs_ubifs=console=ttyS0,115200 mem=64M ubi.mtd=6 root=ubi0:rootfs rootwait rootfstype=ubifs rw
bubifs=tftp 30008000 ubifs-$cpu.img;nand erase 6e00000 900000;nand write 30008000 6e00000 900000
cpu=arm920t
bootargs_ramdisk=console=ttyS0,115200 mem=64M initrd=0x30800000,16M root=/dev/ram0 rw loglevel=7
ip=192.168.1.111:192.168.1.3:192.168.1.1:255.255.255.0:localhost.com:eth0:off
filesize=4DF000
fileaddr=30800000
netmask=255.255.255.0
ipaddr=192.168.1.111
serverip=192.168.1.3
bootcmd_initramdisk=nand read 30008000 100000 800000;bootm 30008000
bootcmd_rootfs=nand read 30008000 100000 400000;bootm 30008000
bootargs_nfs=noinitrd console=ttyS0,115200 init=/linuxrc mem=64M loglevel=7 root=/dev/nfs rw nfsroot=192.168.1.3:/opt/rootfs ip=192.168.1.111:192.168.1.3:192.168.1.1:255.255.255.0:localhost.com:eth0:off
bkr=tftp 30008000 linuxrom-s3c2440.bin;nand erase 100000 800000;nand write 30008000 100000 800000
brdfs=tftp 30008000 ramdisk.gz;nand erase 500000 a00000;nand write 30008000 500000 500000
bootcmd_ramdisk=nand read 30008000 100000 400000;nand read 30800000 500000 500000;bootm 30008000
stdin=serial
stdout=serial
stderr=serial
bcramfs=tftp 30800000 rootfs.cramfs;nand erase f00000 600000;nand write 30800000 f00000 600000
bootargs=noinitrd root=/dev/mtdblock3 rootfstype=cramfs init=/linuxrc console=ttyS0,115200
bootcmd_cramfs=nand read 30008000 100000 400000;bootm 30008000
bootcmd=run bootcmd_cramfs
Environment size: 2288/131068 bytes
[ s3c2440@guowenxue ]#
下载内核和文件系统映像
[ s3c2440@guowenxue ]# run bkr
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:00:3e:26:0a:6b
could not establish link
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 192.168.1.3; our IP address is 192.168.1.111
Filename 'linuxrom-s3c2440.bin'.
Load address: 0x30008000
Loading: T #################################################################
#################################################################
################################################
done
Bytes transferred = 2612580 (27dd64 hex)
NAND erase: device 0 offset 0x100000, size 0x800000
Erasing at 0x8e0000 -- 100% complete.
OK
NAND write: device 0 offset 0x100000, size 0x800000
8388608 bytes written: OK
[ s3c2440@guowenxue ]# run bcramfs
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:00:3e:26:0a:6b
could not establish link
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 192.168.1.3; our IP address is 192.168.1.111
Filename 'rootfs.cramfs'.
Load address: 0x30800000
Loading: T #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#######################
done
Bytes transferred = 5107712 (4df000 hex)
NAND erase: device 0 offset 0xf00000, size 0x600000
Erasing at 0x14e0000 -- 100% complete.
OK
NAND write: device 0 offset 0xf00000, size 0x600000
6291456 bytes written: OK
[ s3c2440@guowenxue ]#
[ s3c2440@guowenxue ]# boot
NAND read: device 0 offset 0x100000, size 0x400000
4194304 bytes read: OK
## Booting kernel from Legacy Image at 30008000 ...
Image Name: Linux Kernel
Created: 2013-04-28 2:33:43 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2612516 Bytes = 2.5 MiB
Load Address: 30008000
Entry Point: 30008040
Verifying Checksum ... OK
XIP Kernel Image ... OK
OK
OS entry point: 30008040
Image entry point=30008040
Starting kernel ...
Uncompressing Linux... done, booting the kernel.
Linux version 3.0.0 ([email protected]) (gcc version 4.5.4 (Buildroot 2012.08) ) #6 Sun Apr 28 10:33:40 CST 2013
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT data cache, VIVT instruction cache
Machine: SMDK2440
Memory policy: ECC disabled, Data cache writeback
CPU S3C2440A (id 0x32440001)
S3C24XX Clocks, Copyright 2004 Simtec Electronics
S3C244X: core 405.000 MHz, memory 101.250 MHz, peripheral 50.625 MHz
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16256
Kernel command line: noinitrd root=/dev/mtdblock3 rootfstype=cramfs init=/linuxrc console=ttyS0,115200
PID hash table entries: 256 (order: -2, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 59468k/59468k available, 6068k reserved, 0K highmem
Virtual kernel memory layout:
vector : 0xffff0000 - 0xffff1000 ( 4 kB)
fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB)
DMA : 0xffc00000 - 0xffe00000 ( 2 MB)
vmalloc : 0xc4800000 - 0xf6000000 ( 792 MB)
lowmem : 0xc0000000 - 0xc4000000 ( 64 MB)
modules : 0xbf000000 - 0xc0000000 ( 16 MB)
.init : 0xc0008000 - 0xc002f000 ( 156 kB)
.text : 0xc002f000 - 0xc04f3000 (4880 kB)
.data : 0xc04f4000 - 0xc0523c40 ( 192 kB)
.bss : 0xc0523c64 - 0xc05500c4 ( 178 kB)
NR_IRQS:85
irq: clearing pending ext status 00080000
irq: clearing subpending status 00000003
irq: clearing subpending status 00000002
Console: colour dummy device 80x30
console [ttyS0] enabled
Calibrating delay loop... 201.52 BogoMIPS (lpj=503808)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
gpiochip_add: gpios 288..303 (GPIOK) failed to register
gpiochip_add: gpios 320..334 (GPIOL) failed to register
gpiochip_add: gpios 352..353 (GPIOM) failed to register
NET: Registered protocol family 16
S3C Power Management, Copyright 2004 Simtec Electronics
S3C2440: Initialising architecture
S3C2440: IRQ Support
S3C24XX DMA Driver, Copyright 2003-2006 Simtec Electronics
DMA channel 0 at c4804000, irq 33
DMA channel 1 at c4804040, irq 34
DMA channel 2 at c4804080, irq 35
DMA channel 3 at c48040c0, irq 36
S3C244X: Clock Support, DVS off
s3c-adc s3c24xx-adc: attached adc driver
bio: create slab
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
s3c-i2c s3c2440-i2c: slave address 0x10
s3c-i2c s3c2440-i2c: bus frequency set to 98 KHz
s3c-i2c s3c2440-i2c: i2c-0: S3C I2C adapter
Advanced Linux Sound Architecture Driver Version 1.0.24.
cfg80211: Calling CRDA to update world regulatory domain
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
NetWinder Floating Point Emulator V0.97 (extended precision)
NTFS driver 2.1.30 [Flags: R/W].
JFFS2 version 2.2. (NAND) (SUMMARY) © 2001-2006 Red Hat, Inc.
msgmni has been set to 116
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
Console: switching to colour frame buffer device 60x34
fb0: s3c2410fb frame buffer device
s3c2440-uart.0: ttyS0 at MMIO 0x50000000 (irq = 70) is a S3C2440
s3c2440-uart.1: ttyS1 at MMIO 0x50004000 (irq = 73) is a S3C2440
s3c2440-uart.2: ttyS2 at MMIO 0x50008000 (irq = 76) is a S3C2440
brd: module loaded
loop: module loaded
at24 0-0050: 65536 byte 24c512 EEPROM, writable, 128 bytes/write
physmap platform flash device: 00400000 at 08000000
physmap-flash physmap-flash.0: map_probe failed
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c24xx-nand s3c2440-nand: Tacls=3, 29ns Twrph0=7 69ns, Twrph1=3 29ns
s3c24xx-nand s3c2440-nand: NAND soft ECC
NAND device: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V 8-bit)
Scanning device for bad blocks
Bad eraseblock 221 at 0x000001ba0000
Bad eraseblock 1592 at 0x00000c700000
Creating 11 MTD partitions on "NAND":
0x000000000000-0x000000100000 : "mtdblock0 u-boot 1MB"
0x000000100000-0x000000500000 : "mtdblock1 kernel 4MB"
0x000000500000-0x000000f00000 : "mtdblock2 ramdisk 10MB"
0x000000f00000-0x000001e00000 : "mtdblock3 cramfs 15MB"
0x000001e00000-0x000004600000 : "mtdblock3 jffs2 40MB"
0x000004600000-0x000006e00000 : "mtdblock4 yaffs2 40MB"
0x000006e00000-0x000009600000 : "mtdblock5 ubifs 40MB"
0x000009600000-0x000009700000 : "mtdblock6 info 1MB"
0x000009700000-0x00000bf00000 : "mtdblock7 apps 40MB"
0x00000bf00000-0x00000e700000 : "mtdblock8 data 40MB"
0x00000e700000-0x000010000000 : "mtdblock9 backup 25MB"
PPP generic driver version 2.4.2
PPP Deflate Compression module registered
PPP BSD Compression module registered
PPP MPPE Compression module registered
NET: Registered protocol family 24
dm9000 Ethernet Driver, V1.31
eth0: dm9000a at c4864300,c4866304 IRQ 51 MAC: 08:00:3e:26:0a:6b (chip)
usbcore: registered new interface driver rt2800usb
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
usb usb1: New USB device found, idVendor=1d6b, idProduct=0001
usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
usb usb1: Product: S3C24XX OHCI
usb usb1: Manufacturer: Linux 3.0.0 ohci_hcd
usb usb1: SerialNumber: s3c24xx
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
usbcore: registered new interface driver usbserial
usbserial: USB Serial Driver core
USB Serial support registered for ch341-uart
usbcore: registered new interface driver ch341
USB Serial support registered for FTDI USB Serial Device
usbcore: registered new interface driver ftdi_sio
ftdi_sio: v1.6.0:USB FTDI Serial Converters Driver
USB Serial support registered for GSM modem (1-port)
usbcore: registered new interface driver option
option: v0.7.2:USB Driver for GSM modems
USB Serial support registered for pl2303
usbcore: registered new interface driver pl2303
pl2303: Prolific PL2303 USB to serial adaptor driver
mousedev: PS/2 mouse device common for all mice
samsung-ts s3c2440-ts: driver attached, registering input device
input: S3C24XX TouchScreen as /devices/virtual/input/input0
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
s3c-rtc s3c2410-rtc: rtc disabled, re-enabling
s3c-rtc s3c2410-rtc: rtc core: registered s3c as rtc0
i2c /dev entries driver
s3c-sdi s3c2440-sdi: mmc0 - using pio, sw SDIO IRQ
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
S3C24XX_UDA134X SoC Audio driver
UDA134X SoC Audio Codec
asoc: uda134x-hifi <-> s3c24xx-iis mapping ok
ALSA device list:
#0: S3C24XX_UDA134X
Netfilter messages via NETLINK v0.30.
nf_conntrack version 0.5.0 (929 buckets, 3716 max)
ctnetlink v0.93: registering with nfnetlink.
xt_time: kernel timezone is -0000
ip_set: protocol 6
IPVS: Registered protocols (TCP, UDP, AH, ESP)
IPVS: Connection hash table configured (size=4096, memory=32Kbytes)
IPVS: Creating netns size=1008 id=0
IPVS: ipvs loaded.
IPVS: [rr] scheduler registered.
IPVS: [wrr] scheduler registered.
IPVS: [lc] scheduler registered.
IPVS: [wlc] scheduler registered.
IPVS: [lblc] scheduler registered.
IPVS: [lblcr] scheduler registered.
IPVS: [dh] scheduler registered.
IPVS: [sh] scheduler registered.
IPVS: [sed] scheduler registered.
IPVS: [nq] scheduler registered.
ip_tables: (C) 2000-2006 Netfilter Core Team
ipt_CLUSTERIP: ClusterIP Version 0.8 loaded successfully
arp_tables: (C) 2002 David S. Miller
TCP cubic registered
NET: Registered protocol family 17
lib80211: common routines for IEEE802.11 drivers
Registering the dns_resolver key type
s3c-rtc s3c2410-rtc: setting system clock to 2023-01-10 06:48:58 UTC (1673333338)
VFS: Mounted root (cramfs filesystem) readonly on device 31:3.
Freeing init memory: 156K
usb 1-1: new full speed USB device number 2 using s3c2410-ohci
usb 1-1: New USB device found, idVendor=05e3, idProduct=0606
usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 1-1: Product: USB Hub 2.0
hub 1-1:1.0: USB hub found
hub 1-1:1.0: 4 ports detected
dm9000 dm9000.0: eth0: link down
dm9000 dm9000.0: eth0: link up, 100Mbps, full-duplex, lpa 0xCDE1
Copyright (C) 2013 fulinux
root login: root
>: ls
apps data etc init lingyun mnt root sys usr
bin dev info lib linuxrc proc sbin tmp var
>:
因为cramfs文件系统时只读的文件系统,所以会有上面的信息
无修改
[lingyun@localhost linux-3.0]$ vt100
[lingyun@localhost linux-3.0]$ make menuconfig
File systems --->
Miscellaneous filesystems --->
<*> Journalling Flash File System v2 (JFFS2) support
(0) JFFS2 debugging verbosity (0 = quiet, 2 = noisy)
[*] JFFS2 write-buffering support
[ ] JFFS2 summary support (EXPERIMENTAL)
[ ] JFFS2 XATTR support (EXPERIMENTAL)
[ ] Advanced compression options for JFFS2
[lingyun@localhost linux-3.0]$ make
[lingyun@localhost linux-3.0]$ cp linuxrom-s3c2440.bin /tftp/
[lingyun@localhost opt]$ mkdir mtd-utiles
[lingyun@localhost opt]$ cd mtd-utiles/
[lingyun@localhost mtd-utiles]$ vim build.sh
#!/bin/sh
#+--------------------------------------------------------------------------------------------
#|Description: This shell script used to download lzo,zlib,mtd-utils source code
#| and cross compile it for ARM Linux, all is static cross compile.
#| Author: GuoWenxue
#| ChangeLog:
#| 1, Initialize 1.0.0 on 2011.04.12
#+--------------------------------------------------------------------------------------------
PRJ_PATH=`pwd`
LZO="lzo-2.04"
ZLIB="zlib-1.2.5"
e2fsprogs_ver=1.42
mtd="mtd-utils-1.4.9"
function decompress_packet()
(
echo "+---------------------------------------------+"
echo "| Decompress $1 now"
echo "+---------------------------------------------+"
ftype=`file "$1"`
case "$ftype" in
"$1: Zip archive"*)
unzip "$1" ;;
"$1: gzip compressed"*)
if [ `expr "$1" : ".*.tar.*" ` ] ; then
tar -xzf $1
else
gzip -d "$1"
fi ;;
"$1: bzip2 compressed"*)
if [ `expr "$1" : ".*.tar.*" ` ] ; then
tar -xjf $1
else
bunzip2 "$1"
fi ;;
"$1: POSIX tar archive"*)
tar -xf "$1" ;;
*)
echo "$1 is unknow compress format";;
esac
)
# Download lzo source code packet
if [ ! -s $LZO.tar.gz ] ; then
wget http://www.oberhumer.com/opensource/lzo/download/$LZO.tar.gz
fi
# Decompress lzo source code packet
if [ ! -d $LZO ] ; then
decompress_packet $LZO.tar.*
fi
# Cross compile lzo
cd $LZO
if [ ! -s src/.libs/liblzo*.a ] ; then
unset LDFLAGS
./configure --enable-static --disable-shared
make
fi
cd -
echo "+----------------------------------------+"
echo "| Cross compile $ZLIB now "
echo "| Crosstool: $CROSS"
echo "+----------------------------------------+"
# Download zlib source code packet
if [ ! -s $ZLIB.tar* ] ; then
#wget http://www.zlib.net/$ZLIB.tar.gz
#wget http://www.imagemagick.org/download/delegates/$ZLIB.tar.bz2
#wget http://down1.chinaunix.net/distfiles/$ZLIB.tar.bz2
wget http://pkgs.fedoraproject.org/repo/pkgs/zlib/zlib-1.2.5.tar.bz2/be1e89810e66150f5b0327984d8625a0/$ZLIB.tar.bz2
fi
# Decompress zlib source code packet
if [ ! -d $ZLIB ] ; then
decompress_packet $ZLIB.tar.*
fi
#Cross compile zlib
cd $ZLIB
if [ ! -s libz.a ] ; then
unset LDFLAGS
./configure --static
make
fi
cd -
echo "+----------------------------------------+"
echo "| Cross compile e2fsprogsV$e2fsprogs_ver now "
echo "| Crosstool: $CROSS"
echo "+----------------------------------------+"
#e2fsprogs is for UBIFS, download e2fsprogs source code packet
if [ ! -s e2fsprogs-$e2fsprogs_ver.tar.gz ] ; then
wget http://nchc.dl.sourceforge.net/project/e2fsprogs/e2fsprogs/$e2fsprogs_ver/e2fsprogs-$e2fsprogs_ver.tar.gz
fi
# Decompress e2fsprogs source code packet
if [ ! -d e2fsprogs-$e2fsprogs_ver ] ; then
decompress_packet e2fsprogs-$e2fsprogs_ver.tar.*
fi
cd e2fsprogs-$e2fsprogs_ver
if [ ! -s lib/libuuid.a ] ; then
./configure --enable-elf-shlibs
make
fi
cd -
echo "+----------------------------------------+"
echo "| Cross compile mtd-utils now "
echo "| Crosstool: $CROSS"
echo "+----------------------------------------+"
if [ ! -s ${mtd}.tar.bz2 ] ; then
wget ftp://ftp.infradead.org/pub/mtd-utils/${mtd}.tar.bz2
fi
decompress_packet ${mtd}.tar.bz2
# download mtd-utils source code
#if [ ! -d mtd-utils* ] ; then
#git clone git://git.infradead.org/mtd-utils.git
#fi
cd ${mtd}
#Add the CROSS tool in file common.mk
line=`sed -n '/CFLAGS ?= -O2 -g/=' common.mk `
if [ ! -z $line ] ; then
sed -i -e ${line}s"|.*|CFLAGS ?= -O2 -g --static|" common.mk
fi
unset LDFLAGS
unset CFLAGS
set -x
export CFLAGS="-DWITHOUT_XATTR -I$PRJ_PATH/$ZLIB -I$PRJ_PATH/$LZO/include -I$PRJ_PATH/e2fsprogs-$e2fsprogs_ver/lib"
export ZLIBLDFLAGS=-L$PRJ_PATH/$ZLIB
export LZOLDFLAGS=-L$PRJ_PATH/$LZO/src/.libs/
export LDFLAGS="-static -L $PRJ_PATH/e2fsprogs-$e2fsprogs_ver/lib $ZLIBLDFLAGS $LZOLDFLAGS"
make
set -x
#strip nandwrite flash_erase nanddump
#sudo cp nandwrite $INST_PATH/.nandwrite
#sudo cp flash_erase $INST_PATH/.flash_erase
#sudo cp nanddump $INST_PATH/.nanddump
[lingyun@localhost mtd-utiles]$ ls
build.sh
[lingyun@localhost mtd-utiles]$ sh build.sh
[lingyun@localhost mtd-utils-1.4.9]$ ls
common.mk feature-removal-schedule.txt flash_otp_lock.c jffs-dump.c nanddump.o recv_image.o
compr.c fectest.c flash_otp_write.c lib nandtest rfddump
compr.h flashcp flash_unlock load_nandsim.sh nandtest.c rfddump.c
compr_lzo.c flashcp.c flash_unlock.c make_a_release.sh nandtest.o rfddump.o
compr_lzo.o flashcp.o flash_unlock.o MAKEDEV nandwrite rfdformat
compr.o flash_erase ftl_check Makefile nandwrite.c rfdformat.c
compr_rtime.c flash_eraseall ftl_check.c mcast_image.h nandwrite.o rfdformat.o
compr_rtime.o flash_erase.c ftl_check.o mkfs.jffs2 nftldump serve_image
compr_zlib.c flash_erase.o ftl_format mkfs.jffs2.1 nftldump.c serve_image.c
compr_zlib.o flash_lock ftl_format.c mkfs.jffs2.c nftldump.o serve_image.o
COPYING flash_lock.c ftl_format.o mkfs.jffs2.o nftl_format summary.h
device_table.txt flash_lock.o include mkfs.ubifs nftl_format.c sumtool
docfdisk flash_otp_dump jffs2dump mtd_debug nftl_format.o sumtool.c
docfdisk.c flash_otp_dump.c jffs2dump.c mtd_debug.c rbtree.c sumtool.o
docfdisk.o flash_otp_dump.o jffs2dump.o mtd_debug.o rbtree.h tests
doc_loadbios flash_otp_info jffs2reader mtd-utils.spec rbtree.o ubi-utils
doc_loadbios.c flash_otp_info.c jffs2reader.c nanddump recv_image
doc_loadbios.o flash_otp_info.o jffs2reader.o nanddump.c recv_image.c
[lingyun@localhost mtd-utils-1.4.9]$ file mkfs.jffs2
mkfs.jffs2: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, not stripped
[lingyun@localhost mtd-utils-1.4.9]$ sudo cp mkfs.jffs2 /usr/local/bin/
[lingyun@localhost mtd-utils-1.4.9]$ mkfs
mkfs mkfs.ext2 mkfs.ext4 mkfs.jffs mkfs.msdos mkfs.vfat
mkfs.cramfs mkfs.ext3 mkfs.ext4dev mkfs.jffs2 mkfs.ubifs/
[lingyun@localhost mtd-utils-1.4.9]$ mkfs.jffs2 -V
mkfs.jffs2: error!: revision 1.60
[lingyun@localhost mtd-utils-1.4.9]$ mkfs.jffs2
mkfs.jffs2: error!: Usage: mkfs.jffs2 [OPTIONS]
Make a JFFS2 file system image from an existing directory tree
Options:
-p, --pad[=SIZE] Pad output to SIZE bytes with 0xFF. If SIZE is
not specified, the output is padded to the end of
the final erase block
-r, -d, --root=DIR Build file system from directory DIR (default: cwd)
-s, --pagesize=SIZE Use page size (max data node size) SIZE (default: 4KiB)
-e, --eraseblock=SIZE Use erase block size SIZE (default: 64KiB)
-c, --cleanmarker=SIZE Size of cleanmarker (default 12)
-m, --compr-mode=MODE Select compression mode (default: priortiry)
-x, --disable-compressor=COMPRESSOR_NAME
Disable a compressor
-X, --enable-compressor=COMPRESSOR_NAME
Enable a compressor
-y, --compressor-priority=PRIORITY:COMPRESSOR_NAME
Set the priority of a compressor
-L, --list-compressors Show the list of the avaiable compressors
-t, --test-compression Call decompress and compare with the original (for test)
-n, --no-cleanmarkers Don't add a cleanmarker to every eraseblock
-o, --output=FILE Output to FILE (default: stdout)
-l, --little-endian Create a little-endian filesystem
-b, --big-endian Create a big-endian filesystem
-D, --devtable=FILE Use the named FILE as a device table file
-f, --faketime Change all file times to '0' for regression testing
-q, --squash Squash permissions and owners making all files be owned by root
-U, --squash-uids Squash owners making all files be owned by root
-P, --squash-perms Squash permissions on all files
-h, --help Display this help text
-v, --verbose Verbose operation
-V, --version Display version information
-i, --incremental=FILE Parse FILE and generate appendage output for it
[lingyun@localhost mtd-utils-1.4.9]$
[lingyun@localhost opt]$ ls
buildroot-2011.11 busybox-1.20.2 dropbear-0.53.1.tar.bz2 mtd pub rootfs rootfs.jffs2
buildroot-2012.08 dropbear-0.53.1 mnt mtd-utiles ramdisk.gz rootfs.cramfs rootfs_tree
[lingyun@localhost opt]$ sudo mkfs.jffs2 -n -s 2048 -e 128KiB -d rootfs -o rootfs.jffs2 --pad=0x1400000
[lingyun@localhost opt]$ du -h rootfs.jffs2
20M rootfs.jffs2
[lingyun@localhost opt]$
各参数的意义:
(1)-r :指定根文件系统目录.
(2)-o : 指定输出的根文件系统名.
(3)-s : 指定flash每一页的大小;
(3)-e : 指定flash的檫除块的大小,預設是64KB.
要注意,不同的flash, 其page size和block size會不一樣.,如果是K9F2G08U0M,在它的datasheet上有说明:
1 Page = (2K+64)Bytes
1 Block = (2K+64)Bytes = (128K+4K) Bytes
1 Device = (2K+64)B * 64Pages * 2048 Blocks = 2112 Mbits
所以上面指定: "s 2048 -e 128KiB"。
如果是K9F1208U0C,在它的datasheet上有说明:
则上面指定: "s 512 -e 16KiB"
(5)如果挂载后会出现类似:CLEANMARKER node found at 0x0042c000 has totlen 0xc != normal 0x0 的警告,则加上 -n 就会消失。
(5) -n 指明不添加清除标记(nand flash 有自己的校检块,存放相关的信息。)
如果挂载后会出现类似下面的警告,则加上-n就会消失:
CLEANMARKER node found at 0x0042c000 has totlen 0xc != normal 0x0
通过下面的方式可以对rootfs.jffs2映像文件中的内容进行修改,如果没有必要可以不用
[lingyun@localhost opt]$ uname -a
Linux localhost.localdomain 2.6.32-279.el6.x86_64 #1 SMP Fri Jun 22 12:19:21 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
[lingyun@localhost opt]$ modprobe mtdblock
FATAL: Error inserting mtdblock (/lib/modules/2.6.32-279.el6.x86_64/kernel/drivers/mtd/mtdblock.ko): Operation not permitted
[lingyun@localhost opt]$ sudo modprobe mtdblock
[lingyun@localhost opt]$ sudo modprobe mtdram total_size=20480 erase_size=128
[lingyun@localhost opt]$ ls /dev/mtdblock0 -l
brw-rw---- 1 root disk 31, 0 Apr 28 13:25 /dev/mtdblock0
[lingyun@localhost opt]$ sudo dd if=rootfs.jffs2 of=/dev/mtdblock0
40960+0 records in
40960+0 records out
20971520 bytes (21 MB) copied, 0.120246 s, 174 MB/s
[lingyun@localhost opt]$ ls
buildroot-2011.11 busybox-1.20.2 dropbear-0.53.1.tar.bz2 mtd pub rootfs rootfs.jffs2
buildroot-2012.08 dropbear-0.53.1 mnt mtd-utiles ramdisk.gz rootfs.cramfs rootfs_tree
[lingyun@localhost opt]$ mkdir mtd
[lingyun@localhost opt]$ ls mnt/
[lingyun@localhost opt]$ sudo mount -t jffs2 /dev/mtdblock0 mtd/
[lingyun@localhost opt]$ ls mtd/
apps bin data dev etc info init lib lingyun linuxrc mnt proc root sbin sys tmp usr var
[lingyun@localhost opt]$ cd mtd
[lingyun@localhost mtd]$ sudo touch lingyun=emb
[lingyun@localhost mtd]$ ls
apps bin data dev etc info init lib lingyun lingyun=emb linuxrc mnt proc root sbin sys tmp usr var
[lingyun@localhost mtd]$ cd ../
[lingyun@localhost opt]$ sudo umount /dev/mtdblock0
[lingyun@localhost opt]$ ls mtd/
[lingyun@localhost opt]$ cp rootfs.jffs2 /tftp/
使用该方法更新后得到的文件系统在启动时会出现以下WARNING:
CLEANMARKER node found at 0x01380000 has totlen 0xc != normal 0x0
CLEANMARKER node found at 0x013a0000 has totlen 0xc != normal 0x0
根据上面内核对nandlfash的分区,对uboot的环境参数做相应的设置:
[ s3c2440@guowenxue ]# set bjffs2 'tftp 30008000 rootfs.jffs2;nand erase 1e00000 1400000;nand write.jffs2 30008000 1e00000 1400000'
[ s3c2440@guowenxue ]# set bootargs_jffs2 'noinitrd root=/dev/mtdblock4 rootfstype=jffs2 init=/linuxrc console=ttyS0,115200'
[ s3c2440@guowenxue ]# set bootargs 'noinitrd root=/dev/mtdblock4 rootfstype=jffs2 init=/linuxrc console=ttyS0,115200'
[ s3c2440@guowenxue ]# set bootcmd_jffs2 'nand read 30008000 100000 400000;bootm 30008000'
[ s3c2440@guowenxue ]# set bootcmd 'run bootcmd_jffs2'
[ s3c2440@guowenxue ]# save
Saving Environment to NAND...
Erasing Nand...
Erasing at 0x60000 -- 100% complete.
Writing to Nand... done
[ s3c2440@guowenxue ]# pri
bbl=nand erase 0 100000;tftp 30008000 u-boot-$cpu.bin;nand write 30008000 0 $filesize
norbbl=erase bank 1;tftp 30008000 u-boot-$cpu.bin;cp.b 30008000 0 $filesize
tpb=tftp 30008000 uImage-$cpu.gz;tftp 30800000 ramdisk-$cpu.gz;bootm 30008000
mtdids=nand0=nand0
mtdparts=mtdparts=nand0:1M@0x0(u-boot),5M@0x100000(kernel),10M@0x600000(ramdisk),10M@0x1000000(cramfs),20M@0x1a00000(yaffs2),20M@0x2e00000(ubifs),-(users)
bootdelay=1
baudrate=115200
ethaddr=08:00:3e:26:0a:6b
ethact=dm9000
bootargs_cramfs=noinitrd root=/dev/mtdblock3 rootfstype=cramfs init=/linuxrc console=ttyS0,115200
bootargs_ubifs=console=ttyS0,115200 mem=64M ubi.mtd=6 root=ubi0:rootfs rootwait rootfstype=ubifs rw
bubifs=tftp 30008000 ubifs-$cpu.img;nand erase 6e00000 900000;nand write 30008000 6e00000 900000
cpu=arm920t
bootargs_ramdisk=console=ttyS0,115200 mem=64M initrd=0x30800000,16M root=/dev/ram0 rw loglevel=7
ip=192.168.1.111:192.168.1.3:192.168.1.1:255.255.255.0:localhost.com:eth0:off
bootcmd_initramdisk=nand read 30008000 100000 800000;bootm 30008000
bootcmd_rootfs=nand read 30008000 100000 400000;bootm 30008000
bootargs_nfs=noinitrd console=ttyS0,115200 init=/linuxrc mem=64M loglevel=7 root=/dev/nfs rw nfsroot=192.168.1.3:/opt/rootfs ip=192.168.1.111:192.168.1.3:192.168.1.1:255.255.255.0:localhost.com:eth0:off
bkr=tftp 30008000 linuxrom-s3c2440.bin;nand erase 100000 800000;nand write 30008000 100000 800000
brdfs=tftp 30008000 ramdisk.gz;nand erase 500000 a00000;nand write 30008000 500000 500000
bootcmd_ramdisk=nand read 30008000 100000 400000;nand read 30800000 500000 500000;bootm 30008000
bcramfs=tftp 30800000 rootfs.cramfs;nand erase f00000 600000;nand write 30800000 f00000 600000
filesize=4DF000
fileaddr=30800000
netmask=255.255.255.0
ipaddr=192.168.1.111
serverip=192.168.1.3
bootcmd_cramfs=nand read 30008000 100000 400000;bootm 30008000
stdin=serial
stdout=serial
stderr=serial
bjffs2=tftp 30008000 rootfs.jffs2;nand erase 1e00000 1400000;nand write.jffs2 30008000 1e00000 1400000
bootargs_jffs2=noinitrd root=/dev/mtdblock4 rootfstype=jffs2 init=/linuxrc console=ttyS0,115200
bootargs=noinitrd root=/dev/mtdblock4 rootfstype=jffs2 init=/linuxrc console=ttyS0,115200
bootcmd_jffs2=nand read 30008000 100000 400000;bootm 30008000
bootcmd=run bootcmd_jffs2
Environment size: 2258/131068 bytes
[ s3c2440@guowenxue ]#
下载内核和rootfs.jffs2映像文件
[ s3c2440@guowenxue ]# run bkr
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:00:3e:26:0a:6b
could not establish link
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 192.168.1.3; our IP address is 192.168.1.111
Filename 'linuxrom-s3c2440.bin'.
Load address: 0x30008000
Loading: T #################################################################
#################################################################
################################################
done
Bytes transferred = 2612580 (27dd64 hex)
NAND erase: device 0 offset 0x100000, size 0x800000
Erasing at 0x8e0000 -- 100% complete.
OK
NAND write: device 0 offset 0x100000, size 0x800000
8388608 bytes written: OK
[ s3c2440@guowenxue ]# run bjffs2
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:00:3e:26:0a:6b
could not establish link
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 192.168.1.3; our IP address is 192.168.1.111
Filename 'rootfs.jffs2'.
Load address: 0x30008000
Loading: T #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
################################################################
done
Bytes transferred = 20971520 (1400000 hex)
NAND erase: device 0 offset 0x1e00000, size 0x1400000
Erasing at 0x31e0000 -- 100% complete.
OK
NAND write: device 0 offset 0x1e00000, size 0x1400000
20971520 bytes written: OK
[ s3c2440@guowenxue ]#
[ s3c2440@guowenxue ]# boot
NAND read: device 0 offset 0x100000, size 0x400000
4194304 bytes read: OK
## Booting kernel from Legacy Image at 30008000 ...
Image Name: Linux Kernel
Created: 2013-04-28 2:33:43 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2612516 Bytes = 2.5 MiB
Load Address: 30008000
Entry Point: 30008040
Verifying Checksum ... OK
XIP Kernel Image ... OK
OK
OS entry point: 30008040
Image entry point=30008040
Starting kernel ...
Uncompressing Linux... done, booting the kernel.
Linux version 3.0.0 ([email protected]) (gcc version 4.5.4 (Buildroot 2012.08) ) #6 Sun Apr 28 10:33:40 CST 2013
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT data cache, VIVT instruction cache
Machine: SMDK2440
Memory policy: ECC disabled, Data cache writeback
CPU S3C2440A (id 0x32440001)
S3C24XX Clocks, Copyright 2004 Simtec Electronics
S3C244X: core 405.000 MHz, memory 101.250 MHz, peripheral 50.625 MHz
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16256
Kernel command line: noinitrd root=/dev/mtdblock4 rootfstype=jffs2 init=/linuxrc console=ttyS0,115200
PID hash table entries: 256 (order: -2, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 59468k/59468k available, 6068k reserved, 0K highmem
Virtual kernel memory layout:
vector : 0xffff0000 - 0xffff1000 ( 4 kB)
fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB)
DMA : 0xffc00000 - 0xffe00000 ( 2 MB)
vmalloc : 0xc4800000 - 0xf6000000 ( 792 MB)
lowmem : 0xc0000000 - 0xc4000000 ( 64 MB)
modules : 0xbf000000 - 0xc0000000 ( 16 MB)
.init : 0xc0008000 - 0xc002f000 ( 156 kB)
.text : 0xc002f000 - 0xc04f3000 (4880 kB)
.data : 0xc04f4000 - 0xc0523c40 ( 192 kB)
.bss : 0xc0523c64 - 0xc05500c4 ( 178 kB)
NR_IRQS:85
irq: clearing pending ext status 00080000
irq: clearing subpending status 00000003
irq: clearing subpending status 00000002
Console: colour dummy device 80x30
console [ttyS0] enabled
Calibrating delay loop... 201.52 BogoMIPS (lpj=503808)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
gpiochip_add: gpios 288..303 (GPIOK) failed to register
gpiochip_add: gpios 320..334 (GPIOL) failed to register
gpiochip_add: gpios 352..353 (GPIOM) failed to register
NET: Registered protocol family 16
S3C Power Management, Copyright 2004 Simtec Electronics
S3C2440: Initialising architecture
S3C2440: IRQ Support
S3C24XX DMA Driver, Copyright 2003-2006 Simtec Electronics
DMA channel 0 at c4804000, irq 33
DMA channel 1 at c4804040, irq 34
DMA channel 2 at c4804080, irq 35
DMA channel 3 at c48040c0, irq 36
S3C244X: Clock Support, DVS off
s3c-adc s3c24xx-adc: attached adc driver
bio: create slab
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
s3c-i2c s3c2440-i2c: slave address 0x10
s3c-i2c s3c2440-i2c: bus frequency set to 98 KHz
s3c-i2c s3c2440-i2c: i2c-0: S3C I2C adapter
Advanced Linux Sound Architecture Driver Version 1.0.24.
cfg80211: Calling CRDA to update world regulatory domain
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
NetWinder Floating Point Emulator V0.97 (extended precision)
NTFS driver 2.1.30 [Flags: R/W].
JFFS2 version 2.2. (NAND) (SUMMARY) © 2001-2006 Red Hat, Inc.
msgmni has been set to 116
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
Console: switching to colour frame buffer device 60x34
fb0: s3c2410fb frame buffer device
s3c2440-uart.0: ttyS0 at MMIO 0x50000000 (irq = 70) is a S3C2440
s3c2440-uart.1: ttyS1 at MMIO 0x50004000 (irq = 73) is a S3C2440
s3c2440-uart.2: ttyS2 at MMIO 0x50008000 (irq = 76) is a S3C2440
brd: module loaded
loop: module loaded
at24 0-0050: 65536 byte 24c512 EEPROM, writable, 128 bytes/write
physmap platform flash device: 00400000 at 08000000
physmap-flash physmap-flash.0: map_probe failed
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c24xx-nand s3c2440-nand: Tacls=3, 29ns Twrph0=7 69ns, Twrph1=3 29ns
s3c24xx-nand s3c2440-nand: NAND soft ECC
NAND device: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V 8-bit)
Scanning device for bad blocks
Bad eraseblock 221 at 0x000001ba0000
Bad eraseblock 1592 at 0x00000c700000
Creating 11 MTD partitions on "NAND":
0x000000000000-0x000000100000 : "mtdblock0 u-boot 1MB"
0x000000100000-0x000000500000 : "mtdblock1 kernel 4MB"
0x000000500000-0x000000f00000 : "mtdblock2 ramdisk 10MB"
0x000000f00000-0x000001e00000 : "mtdblock3 cramfs 15MB"
0x000001e00000-0x000004600000 : "mtdblock3 jffs2 40MB"
0x000004600000-0x000006e00000 : "mtdblock4 yaffs2 40MB"
0x000006e00000-0x000009600000 : "mtdblock5 ubifs 40MB"
0x000009600000-0x000009700000 : "mtdblock6 info 1MB"
0x000009700000-0x00000bf00000 : "mtdblock7 apps 40MB"
0x00000bf00000-0x00000e700000 : "mtdblock8 data 40MB"
0x00000e700000-0x000010000000 : "mtdblock9 backup 25MB"
PPP generic driver version 2.4.2
PPP Deflate Compression module registered
PPP BSD Compression module registered
PPP MPPE Compression module registered
NET: Registered protocol family 24
dm9000 Ethernet Driver, V1.31
eth0: dm9000a at c4864300,c4866304 IRQ 51 MAC: 08:00:3e:26:0a:6b (chip)
usbcore: registered new interface driver rt2800usb
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
usb usb1: New USB device found, idVendor=1d6b, idProduct=0001
usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
usb usb1: Product: S3C24XX OHCI
usb usb1: Manufacturer: Linux 3.0.0 ohci_hcd
usb usb1: SerialNumber: s3c24xx
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
usbcore: registered new interface driver usbserial
usbserial: USB Serial Driver core
USB Serial support registered for ch341-uart
usbcore: registered new interface driver ch341
USB Serial support registered for FTDI USB Serial Device
usbcore: registered new interface driver ftdi_sio
ftdi_sio: v1.6.0:USB FTDI Serial Converters Driver
USB Serial support registered for GSM modem (1-port)
usbcore: registered new interface driver option
option: v0.7.2:USB Driver for GSM modems
USB Serial support registered for pl2303
usbcore: registered new interface driver pl2303
pl2303: Prolific PL2303 USB to serial adaptor driver
mousedev: PS/2 mouse device common for all mice
samsung-ts s3c2440-ts: driver attached, registering input device
input: S3C24XX TouchScreen as /devices/virtual/input/input0
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
s3c-rtc s3c2410-rtc: rtc disabled, re-enabling
s3c-rtc s3c2410-rtc: rtc core: registered s3c as rtc0
i2c /dev entries driver
s3c-sdi s3c2440-sdi: mmc0 - using pio, sw SDIO IRQ
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
S3C24XX_UDA134X SoC Audio driver
UDA134X SoC Audio Codec
asoc: uda134x-hifi <-> s3c24xx-iis mapping ok
ALSA device list:
#0: S3C24XX_UDA134X
Netfilter messages via NETLINK v0.30.
nf_conntrack version 0.5.0 (929 buckets, 3716 max)
ctnetlink v0.93: registering with nfnetlink.
xt_time: kernel timezone is -0000
ip_set: protocol 6
IPVS: Registered protocols (TCP, UDP, AH, ESP)
IPVS: Connection hash table configured (size=4096, memory=32Kbytes)
IPVS: Creating netns size=1008 id=0
IPVS: ipvs loaded.
IPVS: [rr] scheduler registered.
IPVS: [wrr] scheduler registered.
IPVS: [lc] scheduler registered.
IPVS: [wlc] scheduler registered.
IPVS: [lblc] scheduler registered.
IPVS: [lblcr] scheduler registered.
IPVS: [dh] scheduler registered.
IPVS: [sh] scheduler registered.
IPVS: [sed] scheduler registered.
IPVS: [nq] scheduler registered.
ip_tables: (C) 2000-2006 Netfilter Core Team
ipt_CLUSTERIP: ClusterIP Version 0.8 loaded successfully
arp_tables: (C) 2002 David S. Miller
TCP cubic registered
NET: Registered protocol family 17
lib80211: common routines for IEEE802.11 drivers
Registering the dns_resolver key type
s3c-rtc s3c2410-rtc: setting system clock to 2023-01-10 09:24:14 UTC (1673342654)
usb 1-1: new full speed USB device number 2 using s3c2410-ohci
usb 1-1: New USB device found, idVendor=05e3, idProduct=0606
usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 1-1: Product: USB Hub 2.0
hub 1-1:1.0: USB hub found
hub 1-1:1.0: 4 ports detected
VFS: Mounted root (jffs2 filesystem) on device 31:4.
Freeing init memory: 156K
dm9000 dm9000.0: eth0: link down
dm9000 dm9000.0: eth0: link up, 100Mbps, full-duplex, lpa 0xCDE1
Copyright (C) 2013 fulinux
root login: root
>: ls
apps data etc init lingyun mnt root sys usr
bin dev info lib linuxrc proc sbin tmp var
>:
将etc/mdev.conf文件中的下面两行注释掉。
[lingyun@localhost etc]$ vim mdev.conf
sd[a-z][0-9] 0:0 0777 @(mount /dev/$MDEV /mnt/usb)
sd[a-z] 0:0 0777 $(umount /mnt/usb)
#ub[a-z][0-9] 0:0 0777 @(mount /dev/$MDEV /mnt/usb)#第一处需要注释的地方
#ub[a-z] 0:0 0777 $(umount /mnt/usb)#第二处需要注释的地方
mmcblk[0-9]p[0-9] 0:0 0777 @(mount /dev/$MDEV /mnt/sdc)
mmcblk[0-9] 0:0 0777 $(umount /mnt/sdc)
将etc/inittab文件中的下面两行注释掉。
[lingyun@localhost rootfs]$ cd etc/
[lingyun@localhost etc]$ ls
dropbear init.d
[lingyun@localhost etc]$ vim inittab
# /etc/inittab
#
# Copyright (C) 2011 fulinux
#
# Note: BusyBox init doesn't support runlevels. The runlevels field is
# completely ignored by BusyBox init. If you want runlevels, use sysvinit.
#
# Format for each entry:
#
# id == tty to run on, or empty for /dev/console.
# If specified, then /dev/$id device must exist
# runlevels == ignored, busybox doesn't support it
# action == one of sysinit, respawn, askfirst, wait, and once
# process == program to run
# Startup the system
# mount all the file systems specified in /etc/fstab
::sysinit:/bin/mount -a
#Use mdev as hotplug to auto mount USB storage or SD card
::sysinit:/bin/echo /sbin/mdev > /proc/sys/kernel/hotplug
#Use mdev to auto generate the device node in /dev path
::sysinit:/sbin/mdev -s
#make shm, pts support
::sysinit:/bin/mkdir -p /dev/pts
::sysinit:/bin/mkdir -p /dev/shm
::sysinit:/bin/mount -t devpts devpts /dev/pts
#Mount our apps/info partition
#null::wait:/bin/mount -o sync,noatime,ro -t jffs2 /dev/mtdblock6 /apps#第一处需要注释的地方
#null::wait:/bin/mount -o sync,noatime,ro -t jffs2 /dev/mtdblock7 /info#第二处需要注释的地方
#Set hostname
null::sysinit:/bin/hostname -F /etc/hostname
#Enable console logon
null::respawn:/sbin/getty -L ttyS0 115200 vt100
# now run any rc scripts
null::wait:/etc/init.d/rcS
# system daemon
null::respawn:/sbin/syslogd -n
null::respawn:/sbin/klogd -n
# Stuff to do before rebooting
null::shutdown:/bin/umount /apps
null::shutdown:/bin/umount /info
null::shutdown:/bin/killall klogd
null::shutdown:/bin/killall syslogd
null::shutdown:/bin/umount -a -r
#null::shutdown:/sbin/swapoff -a
[lingyun@localhost etc]$
[lingyun@localhost linux-3.0]$ vt100
[lingyun@localhost linux-3.0]$ make menuconfig
Device Drivers --->
<*> Memory Technology Device (MTD) support --->
<*> Enable UBI - Unsorted block images --->
--- Enable UBI - Unsorted block images
(4096) UBI wear-leveling threshold (NEW)
(1) Percentage of reserved eraseblocks for bad eraseblocks handling (NEW)
< > MTD devices emulation driver (gluebi) (NEW)
[ ] UBI debugging (NEW)
File systems --->
[*] Miscellaneous filesystems --->
<*> UBIFS file system support
[*] Extended attributes support
[*] Advanced compression options
[*] LZO compression support (NEW)
[*] ZLIB compression support (NEW)
[ ] Enable debugging support (NEW)
[lingyun@localhost linux-3.0]$ make
前面在制作mkfs.jffs2工具的同时制作了一个mkfs.ubifs工具,这个工具就是用来制作ubifs映像的一个工具
[lingyun@localhost opt]$ cd mtd-utiles/
[lingyun@localhost mtd-utiles]$ cd mtd-utils-1.4.9
[lingyun@localhost mtd-utils-1.4.9]$ ls
common.mk feature-removal-schedule.txt flash_otp_lock.c jffs-dump.c nanddump.o recv_image.o
compr.c fectest.c flash_otp_write.c lib nandtest rfddump
compr.h flashcp flash_unlock load_nandsim.sh nandtest.c rfddump.c
compr_lzo.c flashcp.c flash_unlock.c make_a_release.sh nandtest.o rfddump.o
compr_lzo.o flashcp.o flash_unlock.o MAKEDEV nandwrite rfdformat
compr.o flash_erase ftl_check Makefile nandwrite.c rfdformat.c
compr_rtime.c flash_eraseall ftl_check.c mcast_image.h nandwrite.o rfdformat.o
compr_rtime.o flash_erase.c ftl_check.o mkfs.jffs2 nftldump serve_image
compr_zlib.c flash_erase.o ftl_format mkfs.jffs2.1 nftldump.c serve_image.c
compr_zlib.o flash_lock ftl_format.c mkfs.jffs2.c nftldump.o serve_image.o
COPYING flash_lock.c ftl_format.o mkfs.jffs2.o nftl_format summary.h
device_table.txt flash_lock.o include mkfs.ubifs nftl_format.c sumtool
docfdisk flash_otp_dump jffs2dump mtd_debug nftl_format.o sumtool.c
docfdisk.c flash_otp_dump.c jffs2dump.c mtd_debug.c rbtree.c sumtool.o
docfdisk.o flash_otp_dump.o jffs2dump.o mtd_debug.o rbtree.h tests
doc_loadbios flash_otp_info jffs2reader mtd-utils.spec rbtree.o ubi-utils
doc_loadbios.c flash_otp_info.c jffs2reader.c nanddump recv_image
doc_loadbios.o flash_otp_info.o jffs2reader.o nanddump.c recv_image.c
[lingyun@localhost mtd-utils-1.4.9]$ cd mkfs.ubifs/
[lingyun@localhost mkfs.ubifs]$ ls
compr.c compr.o crc16.c crc16.o devtable.c hashtable lpt.c lpt.o mkfs.ubifs.c mkfs.ubifs.o ubifs.h
compr.h COPYING crc16.h defs.h devtable.o key.h lpt.h mkfs.ubifs mkfs.ubifs.h README ubifs-media.h
[lingyun@localhost mkfs.ubifs]$ sudo cp mkfs.ubifs /usr/bin/
因为mkfs.ubifs工具制作的文件系统映像,在uboot中烧录这种映像文件的方式过于复杂,既要使uboot支持nandflash分区,又要在uboot中激活这个分区,再通过ubi write命令烧录这个映像。所以我们换一种比较容易的方式来移植这个文件系统
在制作mkfs.jffs2和mkfs.ubifs工具时,其实还有一个ubinize工具是同时生成的,它的作用是将mkfs.ubifs制作的映像转换为可以直接用nand write命令烧录的映像文件。
[lingyun@localhost mkfs.ubifs]$ cd ..
[lingyun@localhost mtd-utils-1.4.9]$ cd ubi-utils/
[lingyun@localhost ubi-utils]$ ls
dictionary.c libscan.c libubi_int.h ubiattach.c ubidetach.o ubinfo ubirename.c ubirsvol.o
dictionary.o libscan.o libubi.o ubiattach.o ubiformat ubinfo.c ubirename.o ubiupdatevol
include libubi.a LICENSE.libiniparser ubicrc32 ubiformat.c ubinfo.o ubirmvol ubiupdatevol.c
libiniparser.a libubi.c mtdinfo ubicrc32.c ubiformat.o ubinize ubirmvol.c ubiupdatevol.o
libiniparser.c libubigen.a mtdinfo.c ubicrc32.o ubimkvol ubinize.c ubirmvol.o ubiutils-common.c
libiniparser.o libubigen.c mtdinfo.o ubidetach ubimkvol.c ubinize.o ubirsvol ubiutils-common.o
libscan.a libubigen.o ubiattach ubidetach.c ubimkvol.o ubirename ubirsvol.c
[lingyun@localhost ubi-utils]$ sudo cp ubinize /usr/bin/
[lingyun@localhost ubi-utils]$ cd /opt
[lingyun@localhost opt]$
rootfs.ubifs的制作过程是通过下面的shell脚本完成的:
[lingyun@localhost opt]$ vim build_ubifs.sh
#!/bin/sh
#+--------------------------------------------------------------------------------------------
#|Description: This shell script is used to generate a UBIFS rootfs for K9F2G08 nandflash
#| Author: GuoWenxue
#| ChangeLog:
#| 1, Initialize 1.2.0 on 2013.05.4
#| Reference:
#| http://www.linux-mtd.infradead.org/faq/ubifs.html
#| http://blog.sina.com.cn/s/blog_5b9ea9840100apqc.html
#+--------------------------------------------------------------------------------------------
#===================================================================
# U-BOOT print the Rootfs partition UBI information for reference +
#===================================================================
#U-Boot> mtdparts default
#U-Boot> mtdparts
#device nand0
# #: name size offset mask_flags
# 0: uboot 0x00100000 0x00000000 0
# 1: kernel 0x00400000 0x00100000 0
# 2: ramdisk 0x00a00000 0x00500000 0
# 3: cramfs 0x00f00000 0x00f00000 0
# 4: jffs2 0x02800000 0x01e00000 0
# 5: yaffs2 0x02800000 0x04600000 0
# 6: ubifs 0x02800000 0x06e00000 0
# 7: info 0x00100000 0x09600000 0
# 8: apps 0x02800000 0x09700000 0
# 9: data 0x02800000 0x0bf00000 0
# 10:backup 0x01900000 0x0e700000 0
# active partition: nand0,0 - (bootloader) 0x00100000 @ 0x00000000
#
# defaults:
# mtdids : nand0=nand0
#===================================================================
# Linux kenrel print nandflash partition information for reference +
#===================================================================
#Creating 9 MTD partitions on "NAND":
#0x000000000000-0x000000100000 : "mtdblock0 u-boot 1MB"
#0x000000100000-0x000001000000 : "mtdblock1 kernel 15MB"
#0x000001000000-0x000002400000 : "mtdblock2 ramdisk 20MB"
#0x000002400000-0x000003800000 : "mtdblock3 cramfs 20MB"
#0x000003800000-0x000006000000 : "mtdblock4 jffs2 40MB"
#0x000006000000-0x000008800000 : "mtdblock5 yaffs2 40MB"
#0x000008800000-0x00000b000000 : "mtdblock6 ubifs 40MB"
#0x00000b000000-0x00000d800000 : "mtdblock7 apps 40MB"
#0x00000d800000-0x000010000000 : "mtdblock8 data 40MB"
#UBI: attaching mtd6 to ubi0
#UBI: physical eraseblock size: 131072 bytes (128 KiB)
#UBI: logical eraseblock size: 129024 bytes
#UBI: smallest flash I/O unit: 2048
#UBI: sub-page size: 512
#UBI: VID header offset: 512 (aligned 512)
#UBI: data offset: 2048
#UBI: max. sequence number: 0
#UBI: volume 0 ("rootfs") re-sized from 300 to 312 LEBs
#UBI: attached mtd6 to ubi0
#UBI: MTD device name: "mtdblock6 ubifs 40MB"
#UBI: MTD device size: 40 MiB
#UBI: number of good PEBs: 319
#UBI: number of bad PEBs: 1
#UBI: number of corrupted PEBs: 0
#UBI: max. allowed volumes: 128
#UBI: wear-leveling threshold: 4096
#UBI: number of internal volumes: 1
#UBI: number of user volumes: 1
#UBI: available PEBs: 0
#UBI: total number of reserved PEBs: 319
#UBI: number of PEBs reserved for bad PEB handling: 3
#UBI: max/mean erase counter: 1/0
#UBI: image sequence number: 124781291
#UBI: background thread "ubi_bgt0d" started, PID 439
#===================================================================
# Shell script body start here +
#===================================================================
#-r, -d, --root=DIR root filesystem source code tree
rootfs_dir=rootfs
partition_sizeM=40
image_name=rootfs.ubifs
exit;
fi
#Default setting by UBIFS
sub_page_size=512
vid_head_offset=512
#-m, minimum I/O unit size, it's 2K(the Page size) on K9F2G08, refer to "UBI: smallest flash I/O unit: 2048"
page_size_in_bytes=2048
#It's 64 pages per block on K9F2G08
pages_per_block=64
block_size_in_bytes=`expr $page_size_in_bytes \* $pages_per_block`
#echo "[$pages_per_block] pages per block and [$block_size_in_bytes] bytes"
#It's 2048 blocks on K9F2G08
blocks_per_device=2048
#echo "Blocks per device [$blocks_per_device]"
#-e, logical erase block size, fixed on K9F2G08, refer to u-boot information "UBI: logical eraseblock size: 129024 bytes"
# logical erase block size is physical erase block size minus 1 page for UBI
logical_pages_per_block=`expr $pages_per_block - 1`
logical_erase_block_size=`expr $page_size_in_bytes \* $logical_pages_per_block`
#echo "Logical erase block size: [$logical_erase_block_size] bytes."
# wear_level_reserved_blocks is 1% of total blcoks per device
wear_level_reserved_blocks=`expr $blocks_per_device / 100`
#echo "Reserved blocks for wear level [$wear_level_reserved_blocks]"
#The rootfs partition size in bytes
partition_size_in_bytes=`expr $partition_sizeM \* 1024 \* 1024`
partition_physical_blocks=`expr $partition_size_in_bytes / $block_size_in_bytes`
#echo "Partition size [$partition_size_in_bytes] bytes and [$partition_physical_blocks] blocks."
#Logical blocks on a partition = physical blocks on a partitiion - reserved for wear level
patition_logical_blocks=`expr $partition_physical_blocks - $wear_level_reserved_blocks`
echo $patition_logical_blocks
#echo "Logical blocks in a partition [$patition_logical_blocks]"
#File-system volume = Logical blocks in a partition * Logical erase block size
fs_vol_size=`expr $patition_logical_blocks \* $logical_erase_block_size`
#echo "File-system volume [$fs_vol_size] bytes."
config_file=rootfs_ubinize.cfg
image_tmp=rootfs.img
echo ""
echo "Generating $image_tmp file by mkfs.ubifs..."
set -x
sudo /usr/bin/mkfs.ubifs -x lzo -m $page_size_in_bytes -e $logical_erase_block_size -c $patition_logical_blocks -r
$rootfs_dir -o $image_tmp
set +x
echo
echo "Generating configuration file..."
echo "[ubifs-volume]" > $config_file
echo "mode=ubi" >> $config_file
echo "image=$image_tmp" >> $config_file
echo "vol_id=0" >> $config_file
echo "vol_size=$fs_vol_size" >> $config_file
echo "vol_type=dynamic" >> $config_file
echo "vol_name=rootfs" >> $config_file
echo "vol_flags=autoresize" >> $config_file
echo "vol_alignment=1" >> $config_file
echo
set -x
sudo ubinize -o /tftp/$image_name -m $page_size_in_bytes -p $block_size_in_bytes -s $sub_page_size -O $vid_head_offset
$config_file
set +x
sudo rm -f $image_tmp $config_file
注1:mkfs.ubifs中的选项说明
-r, -d, --root=DIR build file system from directory DIR
-m, --min-io-size=SIZE minimum I/O unit size, 参考上面手动挂载一个分区时的信息
-e, --leb-size=SIZE logical erase block size 参考上面手动挂载一个分区时的信息
-c, --max-leb-cnt=COUNT maximum logical erase block count 依赖分区大小,调整测试出来
-o, --output=FILE output to FILE
-x, --compr=TYPE compression type - "lzo", "favor_lzo", "zlib" or
"none" (default: "lzo")
注2: ubinize选项说明:
-o, --output=
-p, --peb-size=
this UBI image is created for in bytes,
kilobytes (KiB), or megabytes (MiB)
(mandatory parameter),这里是物理擦除快大小
-m, --min-io-size=
in bytes
-s, --sub-page-size=
headers, e.g. sub-page size in case of NAND
flash (equivalent to the minimum input/output
unit size by default) 查看上面手动挂载时的信息
-O, --vid-hdr-offset=
physical eraseblock (default is the next
minimum I/O unit or sub-page after the EC
header) 查看上面手动挂载时的VID信息
(该脚本凌云实验室内部人士可以直接使用目录下的l2440/trunk/src/rootfs/tools/build_ubifs.sh文件)
[lingyun@localhost opt]$ sh build_ubifs.sh
Generating rootfs_ubifs.img file by mkfs.ubifs...
+ sudo mkfs.ubifs -x lzo -m 2048 -e 129024 -c 140 -r rootfs -o rootfs_ubifs.img
+ set +x
Generating configuration file...
+ sudo ubinize -o rootfs.ubifs -m 2048 -p 131072 -s 512 -O 512 rootfs_ubinize.cfg
+ set +x
[lingyun@localhost opt]$ ls
buildroot-2011.11 busybox-1.20.2 lingyun-emb mtd-utiles rootfs rootfs_tree
buildroot-2012.08 dropbear-0.53.1 mnt pub rootfs.cramfs rootfs.ubifs
build_ubifs.sh dropbear-0.53.1.tar.bz2 mtd ramdisk.gz rootfs.jffs2
[lingyun@localhost opt]$ du -h rootfs.ubifs
7.8M rootfs.ubifs
[lingyun@localhost opt]$ cp rootfs.ubifs /tftp/
[ s3c2440@guowenxue ]# set bubifs 'tftp 30008000 rootfs.ubifs;nand erase 6e00000 9000000;nand write 30008000 6e00000 900000'
[ s3c2440@guowenxue ]# set bootargs_ubifs 'console=ttyS0,115200 mem=64M ubi.mtd=6 root=ubi0:rootfs rootwait rootfstype=ubifs rw'
[ s3c2440@guowenxue ]# set bootargs 'console=ttyS0,115200 mem=64M ubi.mtd=6 root=ubi0:rootfs rootwait rootfstype=ubifs rw'
[ s3c2440@guowenxue ]# set bootcmd_rootfs 'nand read 30008000 100000 400000;bootm 30008000'
[ s3c2440@guowenxue ]# set bootcmd 'run bootcmd_rootfs'
[ s3c2440@guowenxue ]# save
Saving Environment to NAND...
Erasing Nand...
Erasing at 0x60000 -- 100% complete.
Writing to Nand... done
[ s3c2440@guowenxue ]#
下载内核和rootfs.ubifs
[ s3c2440@guowenxue ]# run bkr
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:00:3e:26:0a:6b
could not establish link
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 192.168.1.3; our IP address is 192.168.1.111
Filename 'linuxrom-s3c2440.bin'.
Load address: 0x30008000
Loading: T #################################################################
#################################################################
################################################
done
Bytes transferred = 2612580 (27dd64 hex)
NAND erase: device 0 offset 0x100000, size 0x800000
Erasing at 0x8e0000 -- 100% complete.
OK
NAND write: device 0 offset 0x100000, size 0x800000
8388608 bytes written: OK
[ s3c2440@guowenxue ]# run bubifs
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:00:3e:26:0a:6b
could not establish link
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 192.168.1.3; our IP address is 192.168.1.111
Filename 'rootfs.ubifs'.
Load address: 0x30008000
Loading: T #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
##################################
done
Bytes transferred = 8126464 (7c0000 hex)
NAND erase: device 0 offset 0x6e00000, size 0x9000000
Skipping bad block at 0x0c700000
Erasing at 0xfde0000 -- 100% complete.
OK
NAND write: device 0 offset 0x6e00000, size 0x900000
9437184 bytes written: OK
[ s3c2440@guowenxue ]# boot
NAND read: device 0 offset 0x100000, size 0x400000
4194304 bytes read: OK
## Booting kernel from Legacy Image at 30008000 ...
Image Name: Linux Kernel
Created: 2013-05-01 10:16:48 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2610884 Bytes = 2.5 MiB
Load Address: 30008000
Entry Point: 30008040
Verifying Checksum ... OK
XIP Kernel Image ... OK
OK
OS entry point: 30008040
Image entry point=30008040
Starting kernel ...
Uncompressing Linux... done, booting the kernel.
Linux version 3.0.0 ([email protected]) (gcc version 4.5.4 (Buildroot 2012.08) ) #8 Wed May 1 18:16:45 CST 2013
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT data cache, VIVT instruction cache
Machine: SMDK2440
Memory policy: ECC disabled, Data cache writeback
CPU S3C2440A (id 0x32440001)
S3C24XX Clocks, Copyright 2004 Simtec Electronics
S3C244X: core 405.000 MHz, memory 101.250 MHz, peripheral 50.625 MHz
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16256
Kernel command line: console=ttyS0,115200 mem=64M ubi.mtd=6 root=ubi0:rootfs rootwait rootfstype=ubifs rw
PID hash table entries: 256 (order: -2, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 59476k/59476k available, 6060k reserved, 0K highmem
Virtual kernel memory layout:
vector : 0xffff0000 - 0xffff1000 ( 4 kB)
fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB)
DMA : 0xffc00000 - 0xffe00000 ( 2 MB)
vmalloc : 0xc4800000 - 0xf6000000 ( 792 MB)
lowmem : 0xc0000000 - 0xc4000000 ( 64 MB)
modules : 0xbf000000 - 0xc0000000 ( 16 MB)
.init : 0xc0008000 - 0xc002f000 ( 156 kB)
.text : 0xc002f000 - 0xc04f1000 (4872 kB)
.data : 0xc04f2000 - 0xc0521c00 ( 191 kB)
.bss : 0xc0521c24 - 0xc054e07c ( 178 kB)
NR_IRQS:85
irq: clearing pending ext status 00080000
irq: clearing subpending status 00000003
irq: clearing subpending status 00000002
Console: colour dummy device 80x30
console [ttyS0] enabled
Calibrating delay loop... 201.52 BogoMIPS (lpj=503808)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
gpiochip_add: gpios 288..303 (GPIOK) failed to register
gpiochip_add: gpios 320..334 (GPIOL) failed to register
gpiochip_add: gpios 352..353 (GPIOM) failed to register
NET: Registered protocol family 16
S3C Power Management, Copyright 2004 Simtec Electronics
S3C2440: Initialising architecture
S3C2440: IRQ Support
S3C24XX DMA Driver, Copyright 2003-2006 Simtec Electronics
DMA channel 0 at c4804000, irq 33
DMA channel 1 at c4804040, irq 34
DMA channel 2 at c4804080, irq 35
DMA channel 3 at c48040c0, irq 36
S3C244X: Clock Support, DVS off
s3c-adc s3c24xx-adc: attached adc driver
bio: create slab
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
s3c-i2c s3c2440-i2c: slave address 0x10
s3c-i2c s3c2440-i2c: bus frequency set to 98 KHz
s3c-i2c s3c2440-i2c: i2c-0: S3C I2C adapter
Advanced Linux Sound Architecture Driver Version 1.0.24.
cfg80211: Calling CRDA to update world regulatory domain
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
NetWinder Floating Point Emulator V0.97 (extended precision)
NTFS driver 2.1.30 [Flags: R/W].
JFFS2 version 2.2. (NAND) (SUMMARY) © 2001-2006 Red Hat, Inc.
msgmni has been set to 116
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
Console: switching to colour frame buffer device 60x34
fb0: s3c2410fb frame buffer device
s3c2440-uart.0: ttyS0 at MMIO 0x50000000 (irq = 70) is a S3C2440
s3c2440-uart.1: ttyS1 at MMIO 0x50004000 (irq = 73) is a S3C2440
s3c2440-uart.2: ttyS2 at MMIO 0x50008000 (irq = 76) is a S3C2440
brd: module loaded
loop: module loaded
at24 0-0050: 65536 byte 24c512 EEPROM, writable, 128 bytes/write
physmap platform flash device: 00400000 at 08000000
physmap-flash physmap-flash.0: map_probe failed
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c24xx-nand s3c2440-nand: Tacls=3, 29ns Twrph0=7 69ns, Twrph1=3 29ns
s3c24xx-nand s3c2440-nand: NAND soft ECC
NAND device: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V 8-bit)
Scanning device for bad blocks
Bad eraseblock 221 at 0x000001ba0000
Bad eraseblock 1592 at 0x00000c700000
Creating 11 MTD partitions on "NAND":
0x000000000000-0x000000100000 : "mtdblock0 u-boot 1MB"
0x000000100000-0x000000500000 : "mtdblock1 kernel 4MB"
0x000000500000-0x000000f00000 : "mtdblock2 ramdisk 10MB"
0x000000f00000-0x000001e00000 : "mtdblock3 cramfs 15MB"
0x000001e00000-0x000004600000 : "mtdblock4 jffs2 40MB"
0x000004600000-0x000006e00000 : "mtdblock5 yaffs2 40MB"
0x000006e00000-0x000009600000 : "mtdblock6 ubifs 40MB"
0x000009600000-0x000009700000 : "mtdblock7 info 1MB"
0x000009700000-0x00000bf00000 : "mtdblock8 apps 40MB"
0x00000bf00000-0x00000e700000 : "mtdblock9 data 40MB"
0x00000e700000-0x000010000000 : "mtdblock10 backup 25MB"
UBI: attaching mtd6 to ubi0
UBI: physical eraseblock size: 131072 bytes (128 KiB)
UBI: logical eraseblock size: 129024 bytes
UBI: smallest flash I/O unit: 2048
UBI: sub-page size: 512
UBI: VID header offset: 512 (aligned 512)
UBI: data offset: 2048
UBI: max. sequence number: 3
UBI: attached mtd6 to ubi0
UBI: MTD device name: "mtdblock6 ubifs 40MB"
UBI: MTD device size: 40 MiB
UBI: number of good PEBs: 320
UBI: number of bad PEBs: 0
UBI: number of corrupted PEBs: 0
UBI: max. allowed volumes: 128
UBI: wear-leveling threshold: 4096
UBI: number of internal volumes: 1
UBI: number of user volumes: 1
UBI: available PEBs: 0
UBI: total number of reserved PEBs: 320
UBI: number of PEBs reserved for bad PEB handling: 3
UBI: max/mean erase counter: 1/0
UBI: image sequence number: 507274365
UBI: background thread "ubi_bgt0d" started, PID 451
PPP generic driver version 2.4.2
PPP Deflate Compression module registered
PPP BSD Compression module registered
PPP MPPE Compression module registered
NET: Registered protocol family 24
dm9000 Ethernet Driver, V1.31
dm9000 dm9000.0: eth%d: Invalid ethernet MAC address. Please set using ifconfig
eth0: dm9000a at c48b4300,c48b6304 IRQ 51 MAC: 66:6f:cf:af:bb:f8 (random)
usbcore: registered new interface driver rt2800usb
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
usb usb1: New USB device found, idVendor=1d6b, idProduct=0001
usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
usb usb1: Product: S3C24XX OHCI
usb usb1: Manufacturer: Linux 3.0.0 ohci_hcd
usb usb1: SerialNumber: s3c24xx
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
usbcore: registered new interface driver usbserial
usbserial: USB Serial Driver core
USB Serial support registered for ch341-uart
usbcore: registered new interface driver ch341
USB Serial support registered for FTDI USB Serial Device
usbcore: registered new interface driver ftdi_sio
ftdi_sio: v1.6.0:USB FTDI Serial Converters Driver
USB Serial support registered for GSM modem (1-port)
usbcore: registered new interface driver option
option: v0.7.2:USB Driver for GSM modems
USB Serial support registered for pl2303
usbcore: registered new interface driver pl2303
pl2303: Prolific PL2303 USB to serial adaptor driver
mousedev: PS/2 mouse device common for all mice
samsung-ts s3c2440-ts: driver attached, registering input device
input: S3C24XX TouchScreen as /devices/virtual/input/input0
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
s3c-rtc s3c2410-rtc: rtc disabled, re-enabling
s3c-rtc s3c2410-rtc: rtc core: registered s3c as rtc0
i2c /dev entries driver
s3c-sdi s3c2440-sdi: mmc0 - using pio, sw SDIO IRQ
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
S3C24XX_UDA134X SoC Audio driver
UDA134X SoC Audio Codec
asoc: uda134x-hifi <-> s3c24xx-iis mapping ok
ALSA device list:
#0: S3C24XX_UDA134X
Netfilter messages via NETLINK v0.30.
nf_conntrack version 0.5.0 (929 buckets, 3716 max)
ctnetlink v0.93: registering with nfnetlink.
xt_time: kernel timezone is -0000
ip_set: protocol 6
IPVS: Registered protocols (TCP, UDP, AH, ESP)
IPVS: Connection hash table configured (size=4096, memory=32Kbytes)
IPVS: Creating netns size=1008 id=0
IPVS: ipvs loaded.
IPVS: [rr] scheduler registered.
IPVS: [wrr] scheduler registered.
IPVS: [lc] scheduler registered.
IPVS: [wlc] scheduler registered.
IPVS: [lblc] scheduler registered.
IPVS: [lblcr] scheduler registered.
IPVS: [dh] scheduler registered.
IPVS: [sh] scheduler registered.
IPVS: [sed] scheduler registered.
IPVS: [nq] scheduler registered.
ip_tables: (C) 2000-2006 Netfilter Core Team
ipt_CLUSTERIP: ClusterIP Version 0.8 loaded successfully
arp_tables: (C) 2002 David S. Miller
TCP cubic registered
NET: Registered protocol family 17
lib80211: common routines for IEEE802.11 drivers
Registering the dns_resolver key type
s3c-rtc s3c2410-rtc: setting system clock to 2023-01-16 17:03:34 UTC (1673888614)
UBIFS: recovery needed
UBIFS: recovery completed
UBIFS: mounted UBI device 0, volume 0, name "rootfs"
UBIFS: file system size: 37416960 bytes (36540 KiB, 35 MiB, 290 LEBs)
UBIFS: journal size: 5160960 bytes (5040 KiB, 4 MiB, 40 LEBs)
UBIFS: media format: w4/r0 (latest is w4/r0)
UBIFS: default compressor: lzo
UBIFS: reserved for root: 0 bytes (0 KiB)
VFS: Mounted root (ubifs filesystem) on device 0:11.
Freeing init memory: 156K
usb 1-1: new full speed USB device number 2 using s3c2410-ohci
usb 1-1: New USB device found, idVendor=05e3, idProduct=0606
usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 1-1: Product: USB Hub 2.0
hub 1-1:1.0: USB hub found
hub 1-1:1.0: 4 ports detected
dm9000 dm9000.0: eth0: link down
dm9000 dm9000.0: eth0: link up, 100Mbps, full-duplex, lpa 0xCDE1
Copyright (C) 2013 fulinux
root login: root
>: ls
apps data etc init lingyun mnt root sys usr
bin dev info lib linuxrc proc sbin tmp var
>: touch this_is_ubifs
>: ls
apps etc lingyun root tmp
bin info linuxrc sbin usr
data init mnt sys var
dev lib proc this_is_ubifs
>:
1. 嵌入式存储系统
从冯.诺依曼的存储程序工作原理及计算机的组成来说,计算机由运算器、控制器、存储器和输入/输出设备五大部件组成。其中运算器和控制器统称为中央处理器(CPU),而存储系统分成内部存储器(内存)和外部存储器(外存)。输入/输出设备并非计算机所必需的,如果一个设备具有CPU,内存和外存,我们就可以说它是一台计算机。在很多嵌入式设备上,都没有输入/输出设备,所以从广义来讲,我们的手机,MP3,平板电脑都可以说是一台计算机。
大家可能都听说过单片机,那么什么是单片机呢?其实单片机就是把CPU,内存和外存集成在一个芯片里面,当然他还包括其他的一些功能模块。那么我们听说的ARM9,ARM11是不是单片机呢?从严格意义上来讲,他们并不是单片机,虽说在很多ARM处理器里面都集成得有一个小容量的SRAM,但是由于CPU内部没有能够掉电保存数据的外存,所以它就不是单片机。
中央处理器(英文CentralProcessingUnit,CPU)是一台计算机的运算核心和控制核心,其功能主要是解释计算机指令以及处理计算机软件中的数据。CPU由运算器、控制器和寄存器及实现它们之间联系的数据、控制及状态的总线构成。差不多所有的CPU的运作原理可分为四个阶段:提取/取指(Fetch)、解码(Decode)、执行(Execute)和写回(Writeback)。 由于CPU的速度很快,而外存的速度很慢,所以CPU不从外存中取出数据,而是从内存或高速缓冲存储器(cache)中取出指令,放入指令寄存器,并对指令译码,并执行指令。
存储器是用来存储程序和数据的部件,对于计算机来说,有了存储器,才有记忆功能,才能保证正常工作。存储器的种类很多,按其用途可分为主存储器(简称内存或主存)和辅助存储器(简称外存)。内存是电脑中的主要部件,它是相对于外存而言的,其存储速度快,掉电后数据丢失,是CPU能直接寻址的存储空间。内存一般采用半导体存储单元,包括随机存储器(RAM)以及高速缓存(CACHE),而RAM是其中最重要的存储器。在系统上电前,所有的数据都是存放在外存中的,内存中的数据不可使用。当内存中没有CPU需要的数据时,会使用DMA(相当于一个协处理器)将数据从外存中调入到内存后,再从内存取数据。
l 随机存储器(RAM)
RAM(random access memory)随机存储器。存储单元的内容可按需随意取出或存入,且存取的速度与存储单元的位置无关的存储器。这种存储器在断电时将丢失其存储内容,故主要用于存储短时间使用的程序。 按照存储信息的不同,随机存储器又分为静态随机存储器(Static RAM,SRAM)和动态随机存储器(Dynamic RAM,DRAM)。
SRAM不需要刷新电路即能保存它内部存储的数据,而DRAM(Dynamic Random Access Memory)每隔一段时间,要刷新充电一次,否则内部的数据即会消失,因此SRAM具有较快的速度和较高的性能,但是SRAM也有它的缺点,即它的集成度较低,相同容量的DRAM内存可以设计为较小的体积,但是SRAM却需要很大的体积,且功耗较大。SRAM的速度快但昂贵,一般用小容量的SRAM作为更高速CPU和较低速DRAM 之间的缓存(cache).
在嵌入式领域,我们常见的DRAM有SDRAM和DDR(DOUBLE DATA RATE)RAM。SDRAM将CPU与RAM通过一个相同的时钟锁在一起,使CPU和RAM能够共享一个时钟周期,以相同的速度同步工作,每一个时钟脉冲的上升沿便开始传递数据。DDR RAM 是SDRAM的更新换代产品,他允许在时钟脉冲的上升沿和下降沿传输数据,这样不需要提高时钟的频率就能加倍提高SDRAM的速度,在PC上上很常见,另外,很多高端的ARM处理器也支持DDR RAM。
l 高速缓冲存储器(Cache)
Cache也是我们经常遇到的概念,也就是平常看到的一级缓存(L1 Cache)、二级缓存(L2 Cache)、三级缓存(L3 Cache)这些数据,它位于CPU与内存之间,是一个读写速度比内存更快的存储器。当CPU向内存中写入或读出数据时,这个数据也被存储进高速缓冲存储器中。当CPU再次需要这些数据时,CPU就从高速缓冲存储器读取数据,而不是访问较慢的内存,当然,如需要的数据在Cache中没有,CPU会再去读取内存中的数据。
l 只读存储器(ROM)
只读存储器(Read-Only Memory)是一种只能读取资料的存储器。在制造过程中,将资料以一特制光罩(mask)烧录于线路中,其资料内容在写入后就不能更改,所以有时又称为“光罩式只读内存”(mask ROM)。此内存的制造成本较低,常用于电脑中的开机启动如启动光盘,在系统装好的电脑上时,计算机将C盘目录下的操作系统文件读取至内存,然后通过cpu调用各种配件进行工作这时系统存放存储器为RAM 。这种属于COMPACT DISC激光唱片,光盘就是这种。
l 可编程程序只读内存(PROM)
可编程程序只读内存(Programmable ROM,PROM)之内部有行列式的镕丝,是需要利用电流将其烧断,写入所需的资料,但仅能写录一次。 PROM在出厂时,存储的内容全为1,用户可以根据需要将其中的某些单元写入数据0(部分的PROM在出厂时数据全为0,则用 户可以将其中的部分单元写入1), 以实现对其“编程”的目的。PROM的典型产品是“双极性熔丝结构”,如果我们想改写某些单元,则可以给这些单元通以足够大的电流,并维持一定的时间,原 先的熔丝即可熔断,这样就达到了改写某些位的效果。另外一类经典的PROM为使用“肖特基二极管”的PROM,出厂时,其中的二极管处于反向截止状态,还 是用大电流的方法将反相电压加在“肖特基二极管”,造成其永久性击穿即可。
l EPROM
可擦出可编程只读内存(Erasable Programmable Read Only Memory,EPROM)可利用高电压将资料编程写入,抹除时将线路曝光于紫外线下,则资料可被清空,并且可重复使用。通常在封装外壳上会预留一个石英透明窗以方便曝光。
l EEPROM
电可擦出可编程只读内存(Electrically Erasable Programmable Read Only Memory,EEPROM)之运作原理类似EPROM,但是抹除的方式是使用高电场来完成,因此不需要透明窗。
l FLASH
FLASH表示Flash Memory的意思,即平时所说的“闪存”,全名叫Flash EEPROM Memory。它结合了ROM和RAM的长处,不仅具备电子可擦除可编程(EEPROM)的性能,还可以快速读取数据(NVRAM的优势),使数据不会因为断电而丢失。U盘和MP3里用的就是这种存储器。在过去的20年里,嵌入式系统一直使用ROM(EPROM)作为它们的存储设备,然而近年来Flash全面代替了ROM(EPROM)在嵌入式系统中的地位,用作存储Bootloader以及操作系统或者程序代码,或者直接当硬盘使用(U盘)。
嵌入式硬件系统一般都需要有软件的支持才能够正常工作,嵌入式系统需要为软件提供相应的存储空间。在以往的单片机系统内,一般使用ROM(Read Only Memory)或EPROM(Erasable Programmable Read Only Memory)存储程序。由于现有的嵌入式系统越来越复杂,原有的ROM由于容量、灵活性差等的限制,无法满足日益复杂的应用要求。
闪存(Flash)是电可擦除只读存储器(EEPROM)的变种,但兼有RAM和ROM 的优点,是一种可在系统(In-System)进行电擦写,掉电后信息不丢失的存储器,同时它的高集成度和低成本使它成为市场主流。随着Flash技术的成熟和普及,一些单片机芯片(如Freescale的8位单片机MC68HC908)已经开始采用片内FLASH取代过去常用的片内ROM或EPROM,使单片机具有了在线编程写入或擦除的功能。
FLASH在结构和操作方式上与硬盘、EEROM等其他存储介质有较大区别,他都是只能将1写为0,而不能将0写成1。所以在Flash编程之前,必须以块为单位(块大小一般为256KB到20MB)将对应的块擦除,而擦除的过程就是将所有位都写为1的过程,块内的所有字节变为0xFF。因此可以说,编程是将相应位写0的过程,而擦除是将相应位写1的过程,两者的执行过程完全相反。而EEPROM能在字节水平上进行删除和重写而不是整个芯片擦写,这样闪存就比EEPROM的更新速度快。
Flash 芯片是由内部成千上万个存储单元组成的,每个单元存储一个bit。具有低功耗、大容量、擦写速度快、可整片或分扇区在系统编程(烧写)、擦除等特点,并且可由内部嵌入的算法完成对芯片的操作,因而在各种嵌入式系统中得到了广泛的应用。作为一种非易失性存储器,Flash在系统中通常用于存放程序代码、常量表以及一些在系统掉电后需要保存的用户数据等。常用的Flash为8位或16位的数据宽度,编程电压为单3.3V。主要的生产厂商为INTEL、ATMEL、AMD、HYUNDAI等。Flash 技术根据不同的应用场合也分为不同的发展方向,有擅长存储代码的NOR Flash和擅长存储数据的NAND Flash。
首先表现在向芯片中写数据必须先将芯片中对应的内容清空,然后再写入,即先擦后写。只不过NORFlash芯片只用擦写一个字,而NAND需要擦写整个块.其次,闪存擦写的次数都是有限的.当闪存使用接近使用寿命时,经常会出现写操作失败;到达使用寿命时,闪存内部存放的数据虽然可以读,但不能再进行写操作了.所以为了防止上面问题的发生,不能对某个特定的区域反复进行写操作.通常NANDFlash可擦写次数高于NORFlash芯片,但是由于NANDFlash通常是整块擦写,块内的页面中如果有一位失效整个块就会失效,而且由于擦写过程复杂,失败的概率相对较高,所以从整体上来说NOR的寿命较长.
另一个共性是闪存的读写操作不仅仅是一个物理操作,实�