diff --git a/Zim/.zim/index.db b/Zim/.zim/index.db index 15db4b0..648c97b 100644 Binary files a/Zim/.zim/index.db and b/Zim/.zim/index.db differ diff --git a/Zim/.zim/state.conf b/Zim/.zim/state.conf index 077842e..3696f44 100644 --- a/Zim/.zim/state.conf +++ b/Zim/.zim/state.conf @@ -1,7 +1,7 @@ [History] -list=[["Research:Error Notes:\u7f16\u8bd1\u9519\u8bef:libnl",4177,null],["Research:Error Notes:\u7f16\u8bd1\u9519\u8bef:ltib",0,null],["Research:Error Notes:\u7f16\u8bd1\u9519\u8bef:iw",133,null],["Research:Error Notes:\u7f16\u8bd1\u9519\u8bef:libnl",4177,null],["Research:Error Notes:\u7f16\u8bd1\u9519\u8bef:ltib",256,null],["Research:Error Notes:\u7f16\u8bd1\u9519\u8bef:merge",0,null],["Research:Error Notes:\u7f16\u8bd1\u9519\u8bef:sparse",0,null],["Research:Error Notes:\u7f16\u8bd1\u9519\u8bef:merge",0,null],["Research:Error Notes:\u7f16\u8bd1\u9519\u8bef:libnl",4177,null],["Research:Error Notes:\u7f16\u8bd1\u9519\u8bef:ltib",269,null],["Research:Error Notes:\u7f16\u8bd1\u9519\u8bef:libnl",4692,null],["Research:Error Notes:b43",0,null],["Research:Error Notes:\u7f16\u8bd1\u9519\u8bef:busybox",0,null],["Research:Error Notes:\u7f16\u8bd1\u9519\u8bef:crdb",0,null],["Research:Error Notes:\u7f16\u8bd1\u9519\u8bef:crdb:db",0,null],["Research:Error Notes:\u7f16\u8bd1\u9519\u8bef:iw",133,null],["Research:Error Notes:\u7f16\u8bd1\u9519\u8bef:libnl",4692,null],["Research:Error Notes:\u7f16\u8bd1\u9519\u8bef:ltib",269,null],["Research:Error Notes:\u7f16\u8bd1\u9519\u8bef:sparse",0,null],["Research:Error Notes:\u7f16\u8bd1\u9519\u8bef:uboot",0,null],["Research:Error Notes:\u7f16\u8bd1\u9519\u8bef:udev",0,null],["Research:Error Notes:\u7f16\u8bd1\u9519\u8bef:uboot",0,null],["Research:Error Notes:\u7f16\u8bd1\u9519\u8bef:ltib",269,null],["Research:Error Notes:\u7f16\u8bd1\u9519\u8bef:libnl",4692,null],["Research:Error Notes",null,null]] +list=[["Research:\u6241\u5e73\u8bbe\u5907\u6811:Device Tree Introduction",0,null],["Research:\u6241\u5e73\u8bbe\u5907\u6811",0,null],["Research:\u6241\u5e73\u8bbe\u5907\u6811:Device Tree Introduction",0,null],["Research:\u6241\u5e73\u8bbe\u5907\u6811:Device Tree Introduction:Device Tree Usage",32107,null],["Research:\u6241\u5e73\u8bbe\u5907\u6811:Device Tree Introduction:mpc8315erdb.dts",7935,null],["Research:Error Notes:\u4e0b\u8f7d\u9519\u8bef:chosen node create failed",426,null],["Research:\u6241\u5e73\u8bbe\u5907\u6811:Device Tree Introduction:mpc8315erdb.dts",7935,null],["Research:\u6241\u5e73\u8bbe\u5907\u6811",0,null],["Interview:AWK\u4e4b\u7236\u8bbf\u8c08\u5f55",0,null],["Interview",0,null],["Interview:The History of the Floppy Disk",0,null],["Programme:C++:size t vs size type:size type",3680,null],["Programme:C++:size t vs size type",53,null],["Programme:C++:size t vs size type:size type",0,null],["Programme:C++:size t vs size type",52,null],["Programme:C++:Refer VS Pointer",0,null],["Programme:C++:size t vs size type",52,null],["Programme:C++:Refer VS Pointer",0,null],["Programme:C++:size t vs size type",52,null],["Utils:cscope",0,null],["Research:Error Notes:\u4e0b\u8f7d\u9519\u8bef:chosen node create failed",426,null],["Research:\u6241\u5e73\u8bbe\u5907\u6811:Device Tree Introduction",0,null],["Research:\u6241\u5e73\u8bbe\u5907\u6811:Device Tree Introduction:Device Tree Usage",32107,null],["Research:\u6241\u5e73\u8bbe\u5907\u6811:Device Tree Introduction:mpc8315erdb.dts",7935,null],["Research:Error Notes:\u4e0b\u8f7d\u9519\u8bef:chosen node create failed",null,null]] current=24 -recent=[["Research:Error Notes:\u7f16\u8bd1\u9519\u8bef:busybox",0,null],["Research:Error Notes:\u7f16\u8bd1\u9519\u8bef:crdb",0,null],["Research:Error Notes:\u7f16\u8bd1\u9519\u8bef:crdb:db",0,null],["Research:Error Notes:\u7f16\u8bd1\u9519\u8bef:iw",133,null],["Research:Error Notes:\u7f16\u8bd1\u9519\u8bef:sparse",0,null],["Research:Error Notes:\u7f16\u8bd1\u9519\u8bef:udev",0,null],["Research:Error Notes:\u7f16\u8bd1\u9519\u8bef:uboot",0,null],["Research:Error Notes:\u7f16\u8bd1\u9519\u8bef:ltib",269,null],["Research:Error Notes:\u7f16\u8bd1\u9519\u8bef:libnl",4692,null],["Research:Error Notes",null,null]] +recent=[["Interview",0,null],["Interview:The History of the Floppy Disk",null,null],["Programme:C++:size t vs size type:size type",0,null],["Programme:C++:Refer VS Pointer",0,null],["Programme:C++:size t vs size type",null,null],["Utils:cscope",null,null],["Research:\u6241\u5e73\u8bbe\u5907\u6811:Device Tree Introduction",0,null],["Research:\u6241\u5e73\u8bbe\u5907\u6811:Device Tree Introduction:Device Tree Usage",32107,null],["Research:\u6241\u5e73\u8bbe\u5907\u6811:Device Tree Introduction:mpc8315erdb.dts",7935,null],["Research:Error Notes:\u4e0b\u8f7d\u9519\u8bef:chosen node create failed",null,null]] [MainWindow] windowsize=[1600,836] diff --git a/Zim/Interview/AWK之父访谈录.txt b/Zim/Interview/AWK之父访谈录.txt new file mode 100644 index 0000000..5f08b47 --- /dev/null +++ b/Zim/Interview/AWK之父访谈录.txt @@ -0,0 +1,112 @@ +Content-Type: text/x-zim-wiki +Wiki-Format: zim 0.4 +Creation-Date: 2012-08-28T18:09:54+08:00 + +====== AWK之父访谈录 ====== +Created Tuesday 28 August 2012 +{{./1}} + Alfred Aho + +计算机科学家、编译器专家 Alfred V. Aho 一直紧盯计算机科学研究前沿。Aho 教授一直致力于**编程语言开发**,曾任贝尔实验室计算机科学研究中心副主任,现为哥伦比亚大学 Lawrence Gussman 计算机科学系教授。 + +  Aho 教授不仅是“龙书”系列的作者之一,而且在上世纪70年代同 Brain Kernighan 和 Peter Weinberger 一起开发了模式匹配语言 AWK。 + +  近日,《计算机世界》有幸邀请到 Aho 教授谈一谈 AWK 的开发。 + +**问:您为什么要开发 AWK 语言?** + +  和大部分语言一样,AWK 是**应实际需要而生**的。上世纪80年代初,我还是贝尔实验室的研究员。那时我需要追踪经费预算。同时因为我在临近的一所大学兼职,追踪学生的成绩也成了一件棘手的事情。 + +  我想要一种小巧的语言,能让我只写一两行代码就完成这些工作。碰巧 Brian Kernighan 也有这种需求,于是我俩一起开发了**一个专门针对简易数据处理的模式匹配语言**。 + +  GREP 对我们的影响很大,它是 UNIX 下一个很流行的字串匹配工具。GREP 也是我们研究中心开发的。GREP 可以根据某个正则表达式查找文本文件中特定的行,然后输出它们。 + +  我们想进一步扩展它,使得数字也能向字串那样处理。我们还想在打印之外提供一些计算功能。 + +  开发 AWK 仅仅是用来满足我们,或是那些对计算机不是很懂的人,处理常规数据的需要。它采取“**匹配模式——执行动作**”的方式工作。 + +**问:在你们开发 AWK 时有没有哪种程序或是语言已经具备了这些功能?** + +  我们最初是以 GREP 为原型(开发 AWK 的)。但是 GREP 在“//模式——动作//”处理上有一些局限,所以我们想扩展它。当时,我还在研究字串匹配算法和编译器里的上下文无关文法,自觉不自觉地借鉴了一些 LEX 和 YACC(构造编译器的工具)里的东西。 + +  LEX 用于**词法分析**,而 YACC 用于**语法分析**。它俩都是构造编译器的重要工具,当时在贝尔实验室很流行。后来流传开来,用来开发了很多小语言。Brian Kernighan 当时用它们来开发数学排版和图形处理语言。 + +  LEX 用来分拣输入文本中的词法单元(词元)。词元是一串可以构成逻辑含义的字符,比如,编程语言中的关键字“then”就是一个词元。我们对字母‘t’不感兴趣,对‘h’也不感兴趣,我们感兴趣的是‘then’这个组合。编译器的第一个部分就是__词法处理单元__,它读入源程序,分析出其中的词元。 + +  AWK 受这种词法分析方式的影响(很大),但 __AWK 的定位是数据处理__,而且对用户的计算机背景要求很少。 + +**问:您能简短地向《计算机世界》的读者们介绍一下 AWK 语言吗?** + +  AWK 是一门处理文本文件的语言。它把文件看作一串记录(record),缺省情况下一行即为一个记录。每一行又被拆成若干域(field)。我们可以把一行中的第一个词看作第一域,第二个词看作第二域,以此类推。一个 AWK 程序就是一连串“模式——动作”语句。AWK 一次读入一行,然后对照程序中的各个模式进行扫描。一旦匹配成功就执行相应的操作(action)。 + +  举个例可能更清楚一些。假设我们有一个文件,它的每一行都是一个名字后跟一个电话号码。我们假设其中一行为“Pope 15193741273”。AWK 语言把第一域记作$1,第二域记作$2。现在我们想查 Pope 的电话号码,只需一行 AWK 语句:$1 == "Pope" { print $2 } + +  这条语句的意思是:若我们找到一行,其第一域为 Pope,则输出其第二域(即电话号码)。现在你已经算是 AWK 程序员了^_^ + +  AWK 程序一般由一组“模式——动作”语句构成。模式可以是字串或数字的真假判断;动作是一组类似C语言的语句。 + +  AWK 随着成为 UNIX 的标配而流行起来。 + +**问:在 AWK 的开发过程中,您最得意的是什么?** + +  AWK 是由 Brian Kernighan、Peter Weinberger 和我三个人开发的。那时,Peter Weinberger 很好奇 Brian 和我整天在忙什么。我们写好了 AWK 的语法规范,但缺少一个完整的运行环境。Weinberger 跑来对我们说“这看起来很像我写过的一个语言”,然后就在一个星期内写好了 AWK 的运行环境。我们用这个原始版本来处理我们感兴趣的数据,很称手。更重要的是,它为 AWK 提供了一个可以不断扩展的平台。 + +  对我来说,最重要的是__这个项目让我了解了 Kernighan 和 Weinberger 是怎么考虑语言设计的__——这真是一次很受益的合作!有了这个灵巧的**编译器构造工具**,我们就可以完全掌控我们的开发了。我们很快加入了一些新的语法来改进 AWK。整整一年,我们都在激烈地讨论哪些特性应该加进 AWK,哪些应该丢弃。 + +  语言设计是一项非常随性的活动,每个设计者都会把他们需要的特性加入到语言之中,这些特性或者来自他们**需要解决的问题**,或者来自他们**解决问题的方式**。在开发 AWK 的过程中,我得到了许多乐趣,而和 Kernighan、Weinberger 他们共事是我的职业生涯中最刺激的事情。我可不想和他们那样的设计者竞争。__他们的编程能力无与伦比。__ + +  说来也有意思,最开始我们并没有想到,除我们三个以外还会有人用它。但很快我们发现,很多人有数据处理的需求,而这正是 AWK 所擅长的。人们不愿写几百行的C程序来做数据处理,而同样的工作只需几行 AWK 代码。于是越来越多的人开始使用 AWK。 + +  很多年后,AWK 仍然是 UNIX 下很常用的一个命令。时至今日,即使已经出现了一大批类似的语言,但 AWK 仍然常年保持在编程语言流行排行榜上25至30名的样子。而这一切都起于我们仨为了满足自己的需要开发的一个小工具。 + +**问:AWK 如此流行,您有何感触?** + +  我很高兴有人喜欢 AWK。AWK 不仅吸引了很多人使用它,后来很多语言的设计者也借鉴了它的工作方式。 + +  在 AWK 开发出来10年后,Larry Wall 开发了一门叫 Perl 的语言,借鉴了 AWK 和其他一些 UNIX 工具的特性。Perl 现在是世界上最流行的语言之一。所以不光是它刚出现的时候受欢迎,它也影响了很多新生语言。 + +**问:您刚才提到 AWK 影响了很多语言,您认为这是为什么?** + +  最初让 AWK 得以流行是__因为它的简洁和它的定位__。它有一个__很简单的编程模型__。它这种“识别模式——执行动作”的编程方式很容易理解。我们还在 AWK 中添加了对管道的支持。AWK 里的动作其实就是一些简单的C程序。你既可以写下像{ print $2 } 这样简单的动作,也可以为某个模式写一个复杂得多的类C程序。甚至华尔街的一些金融机构都用 AWK 来做账,因为它处理起数据来真的很简单。 + +  AWK 的学习曲线很平缓,很多人都是从 AWK 开始接触编程这行的。即使是今天,仍有很多人还在使用 AWK,他们说像 Perl 这样的语言变得太复杂了。 + +  AWK 的另一个优势在于__它很稳定__。自上世纪80年代中期以后,我们就没有改动过它了。所以也有很多人将 AWK 移植到不同的平台(比如 Windows)上。 + +**问:A、W、K这个顺序最初是怎么定的?** + +  这其实不是由我们定的。研究中心的同事看到我们仨挤在一个屋里,就推门喊到“AWK! AWK!”。我们觉得不错,就叫它 AWK 了。我们出版那本《AWK 编程语言》时还专门在封面里加了一只海雀(译注:AUK,音同 AWK)。 + +**问:您开发 AWK 时收获哪些受益至今的经验?** + +  我的研究方向包括算法和程序语言。很多人知道我是因为 AWK。很多人在学术论文里引用我们的算法(已经在很多工具里实现了),但很少有人因为这个知道我。在我们开发 AWK 时借鉴了很多高效的字串匹配算法。UNIX 的很多工具,包括 EGREP 和 FGREP 这两个我研究字串匹配时写的小程序,也用到了这些算法。 + +  __AWK 是理论与实践结合的典范。__最好的工程实践往往是建立在科学的基础上。我们在 AWK 中引入了富于表达的记法和高效的算法。实际中,它们的效率也很高。 + +  __和聪明人共事你会获得智慧。__Brian Kernighan 就是这样的聪明人,一个程序语言设计大师。__他的心得就是保持简洁__,简洁的语言易于理解,也易于使用。我想,这就是对所有语言设计者最好的忠告。 + +**问:AWK 开发出来这么多年,您有没有遇到过什么惊喜?** + +  有次星期一一上班,我发现有个人在我办公室。他是贝尔实验室微电子产品部门的,他说他用几千行 AWK 写了一个计算机辅助设计系统。我当时就惊呆了。我原以为没人会写超过一千行的 AWK。但他用 AWK 写了一个很强大的 CAD 开发系统。他说用 AWK 来开发很快,很灵巧。最让我惊奇的是,我们从没想到会出现这么多用 AWK 写的应用。可能这是一个好工具的标志,就像起子不仅仅只能拧螺丝一样。 + +**问:您今天还在用 AWK 吗?** + +  我现在还在用 AWK 处理数据,它很好用。举个例子,我写论文、写报告时会用它来做图片和示例的自动编号,这需要用到它的关联数组。比如说,它可以把“图片 AWK 程序”这样的注释转换为“图片 1.1”。我写了两行 AWK 来实现这个功能。我曾见过一片论文用来1000行C代码写了一个功能还不及我那两行 AWK 的程序。用过 AWK,你就会对它在表达上的简洁干练印象深刻。 + +**问:AWK 之父的声誉对您的职业生涯有什么影响吗?** + +  我说过,很多人知道我是因为 AWK,但在计算机科学这个研究圈子里人们对我在理论方面的工作更熟悉。所以最初我只是__把开发 AWK 视为一种实践__,而不是正儿八经的研究。但开发 AWK 的这段经历,对我日后教授编程语言、编译器、软件工程这些课程还是产生了很大的影响。 + +  我注意到,__人们知道某些科学家不是因为他们的研究成功,反而是因为他们发明的某个工具__。比如,世界上最著名的计算机科学家——Don Knuth,计算机算法领域的奠基人。他发明了一种文字排版的语言,Tex。文字排版不是他研究的主要方向,但 Tex 却得到很多非计算机专业的科学家的广泛使用。而 Knuth 之所以要发明一套数学排版系统只是因为他希望自己的论文和著作好看一些。 + +  很多计算机科学家在研究之外发明了很多好用的编程语言。另一个著名的例子就是 Bjarne Stroustrup 开发 C++ 最初只是为了写一个网络模拟器。 + +**问:如果现在重新开发 AWK,您会做出哪些改变?** + +  我会在__开发之初就制定严格的测试__。我们最初把 AWK 定位为**一种用过即扔的语言**,所以在最初的实现中没有做严格的质量控制。 + +  我之前提到过一个用 AWK 写了 CAD 系统的家伙。他最初来见我的原因就是为了报告一个 AWK 编译器里的 bug。他很生气地对我说,他浪费了三周时间来查错,却发现原来是编译器的问题!我和 Brian Kernighan 商定,__一定要引入质量控制__。所以我们为所有的特性制定了一套严格的回归测试。打那以后,__每次我们要给 AWK 添加什么特性总会先写测试。__ + +  多年来,我一直在哥伦比亚大学教程序语言和编译。这门课有一个工程实践,学生们四个或五个一组用一整学期来设计他们自己的小型语言,还要做出一个编译器。 + +  上这门课的学生之前都没有深入了解过编译器,但这些年来从没有一个组没能完成任务。这都要归功于我和 Kernighan、Weinberger 他们一起在开发 AWK 时积攒的经验。除了学习程序语言和编译器设计的__原则__,学生们还能(通过工程实践)了解到实际中的软件开发。__每个学生都应该从一开始就养成严格测试的习惯。__学生们还能学到工程管理、团队合作、口头交流和文档撰写方面的技巧。所以从这个角度讲,AWK 真的对我教程序语言、编译和软件开发都有很深的影响。 diff --git a/Zim/Interview/AWK之父访谈录/1 b/Zim/Interview/AWK之父访谈录/1 new file mode 100644 index 0000000..68c4e2d Binary files /dev/null and b/Zim/Interview/AWK之父访谈录/1 differ diff --git a/Zim/Interview/The_History_of_the_Floppy_Disk.txt b/Zim/Interview/The_History_of_the_Floppy_Disk.txt new file mode 100644 index 0000000..035c184 --- /dev/null +++ b/Zim/Interview/The_History_of_the_Floppy_Disk.txt @@ -0,0 +1,68 @@ +Content-Type: text/x-zim-wiki +Wiki-Format: zim 0.4 +Creation-Date: 2012-08-29T19:03:08+08:00 + +====== The History of the Floppy Disk ====== +Created Wednesday 29 August 2012 +http://h30565.www3.hp.com/t5/Feature-Articles/The-History-of-the-Floppy-Disk/ba-p/6434 + +**The History of the Floppy Disk** +by Steven Vaughan-Nichols (sjvn01) on 27-08-2012 08:00 AM - last edited on 27-08-2012 08:14 AM by estherschindler + +In the fall of 1977, I experimented with a newfangled PC, a Radio Shack TRS-80. For data storage it used—I kid you not—**a cassette tape player**. Tape had a long history with computing; I had used the IBM 2420 **9-track tape system** on IBM 360/370 mainframes to load software and to back-up data. Magnetic tape was common for storage in pre-personal computing days, but it had two main annoyances: it held **tiny amounts** of data, and it was **slower** than a slug on a cold spring morning. There had to be something better, for those of us excited about technology. And there was: the floppy disk. +{{./1.jpg}} +//Welcome to the floppy disk family: 8”, 5.25” and 3.5”// + +In the mid-70s I had heard about floppy drives, but they were expensive, exotic equipment. I didn't know that IBM had decided as early as 1967 that tape-drives, while fine for back-ups, simply weren't good enough to load software on mainframes. So it was that Alan Shugart assigned David L. Noble to lead the development of “a reliable and inexpensive system for loading **microcode** into the IBM System/370 mainframes using a process called **Initial Control Program Load (ICPL).**” From this project came the first 8-inch floppy disk. + +Oh yes, before the 5.25-inch drives you remember were the 8-inch floppy. By 1978 I was using them on mainframes; later I would use them on Online Computer Library Center (OCLC) dedicated cataloging PCs. + +The 8-inch drive began to show up in 1971. Since they enabled developers and users to stop using the dreaded paper tape (which were easy to fold, spindle, and mutilate, not to mention to pirate) and the loathed IBM 5081 punch card. Everyone who had ever twisted a some tape or—the horror!—dropped a deck of Hollerith cards was happy to adopt 8-inch drives. +{{./2.gif}} +//Before floppy drives, we often had to enter data using punch cards.// + +Besides, the early single-sided 8-inch floppy could hold the data of up to 3,000 punch cards, or __80K__ to you. I know that's nothing today — this article uses up 66K with the text alone – but then it was a big deal. + +Some early model microcomputers, such as the Xerox 820 and Xerox Alto, used 8-inch drives, but these first generation floppies never broke through to the larger consumer market. That honor would go to the next generation of the floppy: the 5.25 inch model. + +By 1972, Shugart had left IBM and founded his own company, Shugart Associates. In 1975, Wang, which at the time owned the then big-time dedicated word processor market, approached Shugart about creating a computer that would fit on top of a desk. To do that, Wang needed a smaller, cheaper floppy disk. + +According to Don Massaro (PDF link), another IBMer who followed Shugart to the new business, Wang’s founder Charles Wang said, “I want to come out with a much lower-end word processor. It has to be much lower cost and I can't afford to pay you $200 for your 8" floppy; I need a $100 floppy.” + +So, Shugart and company started working on it. According to Massaro, “We designed the 5 1/4" floppy drive in terms of the overall design, what it should look like, in a car driving up to Herkimer, New York to visit Mohawk Data Systems.” The design team stopped at a stationery store to buy cardboard while trying to figure out **what size** the diskette should be. “It's real simple, the reason why it was 5¼,” he said. “5 1/4 was the smallest diskette that you could make that would not __fit in your pocket__. We didn't want to put it in a pocket because we didn't want it bent, okay?” + +Shugart also designed the diskette to be that size because an analysis of the cassette tape drives and their bays in microcomputers showed that a 5.25” drive was as big as you could fit into the PCs of the day. + +According to another story from Jimmy Adkisson, a Shugart engineer, “Jim Adkisson and Don Massaro were discussing the proposed drive's size with Wang. The trio just happened to be doing their discussing at a bar. An Wang motioned to a drink napkin and stated 'about that size' which happened to be 5 1/4-inches wide.” +Wang wasn’t the most important element in the success of the 5.25-inch floppy. George Sollman, another Shugart engineer, took an early model of the 5.25” drive to a Home Brew Computer Club meeting. “The following Wednesday or so, Don came to my office and said, 'There's a bum in the lobby,’” Sollman says. “‘And, in marketing, you're in charge of cleaning up the lobby. Would you get the bum out of the lobby?’ So I went out to the lobby and this guy is sitting there with holes in both knees. He really needed a shower in a bad way but he had the most dark, intense eyes and he said, 'I've got this thing we can build.'” +The bum's name was Steve Jobs and the “thing” was the Apple II. +Apple had also used cassette drives for its first computers. Jobs knew his computers also needed a smaller, cheaper, and better portable data storage system. In late 1977, the Apple II was made available with optional 5.25” floppy drives manufactured by Shugart. One drive ordinarily held programs, while the other could be used to store your data. (Otherwise, you had to swap floppies back-and-forth when you needed to save a file.) +{{./3.png}} +The PC that made floppy disks a success: 1977's Apple II +The floppy disk seems so simple now, but it changed everything. As IBM's history of the floppy disk states, this was a big advance in user-friendliness. “But perhaps the greatest impact of the floppy wasn’t on individuals, but on the nature and structure of the IT industry. Up until the late 1970s, most software applications for tasks such as word processing and accounting were written by the personal computer owners themselves. But thanks to the floppy, companies could write programs, put them on the disks, and sell them through the mail or in stores. 'It made it possible to have a software industry,' says Lee Felsenstein, a pioneer of the PC industry who designed the Osborne 1, the first mass-produced portable computer. Before networks became widely available for PCs, people used floppies to share programs and data with each other—calling it the 'sneakernet.'” +In short, it was the floppy disk that turned microcomputers into personal computers. +{{./4.jpg}} + Which of these drives did you own? +The success of the Apple II made the 5.25” drive the industry standard. The vast majority of CP/M-80 PCs, from the late 70s to early 80s, used this size floppy drive. When the first IBM PC arrived in 1981 you had your choice of one or two 160 kilobyte (K – yes, just one K) floppy drives. +Throughout the early 80s, the floppy drive became the portable storage format. (Tape quickly was relegated to business back-ups.) At first, the floppy disk drives were only built with one read/write head, but another set of heads were quickly incorporated. This meant that when the IBM XT PC arrived in 1983, double-sided floppies could hold up to 360K of data. +There were some bumps along the road to PC floppy drive compatibility. Some companies, such as DEC with its DEC Rainbow, introduced its own non-compatible 5.25” floppy drives. They were single-sided but with twice the density, and in 1983 a single box of 10 disks cost $45 – twice the price of the standard disks. +In the end, though, market forces kept the various non-compatible disk formats from splitting the PC market into separate blocks. (How the data was stored was another issue, however. Data stored on a CP/M system was unreadable on a PC-DOS drive, for examples, so dedicated applications like Media Master promised to convert data from one format to another.) +That left lots of room for innovation within the floppy drive mainstream. In 1984, IBM introduced the IBM Advanced Technology (AT) computer. This model came with a high-density 5.25-inch drive, which could handle disks that could up hold up to 1.2MB of data. +A variety of other floppy drives and disk formats were tried. These included 2.0, 2.5, 2.8, 3.0, 3.25, and 4.0 inch formats. Most quickly died off, but one, the 3.5” size – introduced by Sony in 1980 – proved to be a winner. +The 3.5 disk didn't really take off until 1982. Then, the Microfloppy Industry Committee approved a variation of the Sony design and the “new” 3.5” drive was quickly adopted by Apple for the Macintosh, by Commodore for the Amiga, and by Atari for its Atari ST PC. The mainstream PC market soon followed and by 1988, the more durable 3.5” disks outsold the 5.25” floppy disks. (During the transition, however, most of us configured our PCs to have both a 3.5” drive and a 5.25” drive, in addition to the by-now-ubiquitous hard disks. Still, most of us eventually ran into at least one situation in which we had a file on a 5.25” disk and no floppy drive to read it on.) +{{./5.jpg}} + The one 3.5” diskette that everyone met at one time or another: An AOL install disk. +The first 3.5” disks could only hold 720K. But they soon became popular because of the more convenient pocket-size format and their somewhat-sturdier construction (if you rolled an office chair over one of these, you had a chance that the data might survive). Another variation of the drive, using Modified Frequency Modulation (MFM) encoding, pushed 3.5” diskettes storage up to 1.44Mbs in IBM's PS/2 and Apple's Mac IIx computers in the mid to late 1980s. +By then, though floppy drives would continue to evolve, other portable technologies began to surpass them. +In 1991, Jobs introduced the extended-density (ED) 3.5” floppy on his NeXT computer line. These could hold up to 2.8MBs. But it wasn't enough. A variety of other portable formats that could store more data came along, such as magneto-optical drives and Iomega's Zip drive, and they started pushing floppies out of business. +The real floppy killers, though, were read-writable CDs, DVDs, and, the final nail in the coffin: USB flash drives. Today, a 64GB flash drive can hold more data than every floppy disk I've ever owned all rolled together. +Apple prospered the most from the floppy drive but ironically was the first to abandon it as read-writable CDs and DVDs took over. The 1998 iMac was the first consumer computer to ship without any floppy drive. +However, the floppy drive took more than a decade to die. Sony, which at the end owned 70% of what was left of the market, announced in 2010 that it was stopping the manufacture of 3.5” diskettes. +Today, you can still buy new 1.44MB floppy drives and floppy disks, but for the other formats you need to look to eBay or yard sales. If you really want a new 3.5” drive or disks, I'd get them sooner than later. Their day is almost done. +But, as they disappear even from memory, we should strive to remember just how vitally important floppy disks were in their day. Without them, our current computer world simply could not exist. Before the Internet was open to the public, it was floppy disks that let us create and trade programs and files. They really were what put the personal in “personal computing.” +See also: +6 Products That Became Technology Roadkill +Searching the Internet B.G. (Before Google) +The Birth and Rise of Ethernet: A History +7 Awesome Bits of Tech That Just Freakin’ Disappeared +30 Years Later: an Unfair Comparison between an IBM PC and an Apple iPhone4 (Infographic) diff --git a/Zim/Interview/The_History_of_the_Floppy_Disk/1.jpg b/Zim/Interview/The_History_of_the_Floppy_Disk/1.jpg new file mode 100644 index 0000000..6f6ecaa Binary files /dev/null and b/Zim/Interview/The_History_of_the_Floppy_Disk/1.jpg differ diff --git a/Zim/Interview/The_History_of_the_Floppy_Disk/2.gif b/Zim/Interview/The_History_of_the_Floppy_Disk/2.gif new file mode 100644 index 0000000..9e6e225 Binary files /dev/null and b/Zim/Interview/The_History_of_the_Floppy_Disk/2.gif differ diff --git a/Zim/Interview/The_History_of_the_Floppy_Disk/3.png b/Zim/Interview/The_History_of_the_Floppy_Disk/3.png new file mode 100644 index 0000000..80557f3 Binary files /dev/null and b/Zim/Interview/The_History_of_the_Floppy_Disk/3.png differ diff --git a/Zim/Interview/The_History_of_the_Floppy_Disk/4.jpg b/Zim/Interview/The_History_of_the_Floppy_Disk/4.jpg new file mode 100644 index 0000000..4a0945f Binary files /dev/null and b/Zim/Interview/The_History_of_the_Floppy_Disk/4.jpg differ diff --git a/Zim/Interview/The_History_of_the_Floppy_Disk/5.jpg b/Zim/Interview/The_History_of_the_Floppy_Disk/5.jpg new file mode 100644 index 0000000..c554f3a Binary files /dev/null and b/Zim/Interview/The_History_of_the_Floppy_Disk/5.jpg differ diff --git a/Zim/Programme/C++/size_t_vs_size_type.txt b/Zim/Programme/C++/size_t_vs_size_type.txt new file mode 100644 index 0000000..c795c92 --- /dev/null +++ b/Zim/Programme/C++/size_t_vs_size_type.txt @@ -0,0 +1,86 @@ +Content-Type: text/x-zim-wiki +Wiki-Format: zim 0.4 +Creation-Date: 2012-08-30T14:15:04+08:00 + +====== size t vs size type ====== +Created Thursday 30 August 2012 + +http://stackoverflow.com/questions/918567/size-t-vs-containersize-type + +--------------------- +I'm wondering if there's a difference in using **size_t** and **container::size_type**? + +What I understand is size_t is more generic and can be used for any size_types.. + +Is container::size_type more optimized for a specific container though? + +------------------------ +The standard containers define **size_type** as a typedef to **Allocator::size_type** (Allocator is a template parameter), which for **std::allocator** is defined to be **size_t**. So for the standard case, they are __the same__. + +However, if you use a custom allocator a different underlying type could be used. So container::size_type is preferable for maximum portability. + +------------------------ +**size_t** is defined as the type used for the size of an object and is //platform dependent// +**container::size_type** is the type that is used for the number of elements in the container and is **container dependent** +All std containers __use size_t as the size_type__ but other library vendors choose a type that they find appropriate for their container. +If you look at the Qt, the size_type of Qt containers is version dependent in Qt3 it was unsigned int and in Qt4 they changed it to int. + +------------------------ +http://blog.csdn.net/lzx_bupt/article/details/6558566 + +size_type: + +由string类类型和vector类类型定义的类型,用以保存**任意**string对象或vector对象的长度,标准库类型将size_type定义为unsigned类型 +  string抽象意义是字符串, size()的抽象意义是字符串的尺寸, string::size_type抽象意义是尺寸单位类型 +  string::size_type它在不同的机器上,长度是可以不同的,并非固定的长度。但只要你使用了这个类型,就使得你的程序适合这个机器。与实际机器匹配。 +  string::size_type从本质上来说,是一个整型数。__关键是由于机器的环境,它的长度有可能不同__。 例如:我们在使用 string::find的函数的时候,它返回的类型就是 string::size_type类型。而当find找不到所要找的字符的时候,它返回的是 npos的值,这个值是与size_type相关的。假如,你是用 string s; int rc = s.find(.....); 然后判断,if ( rc == string::npos ) 这样在不同的机器平台上表现就不一样了。如果,你的平台的string::size_type的长度正好和int相匹配,那么这个判断会侥幸正确。但换成另外的平台,有可能 string::size_type的类型是64位长度的,那么判断就完全不正确了。 所以,正确的应该是: **string::size_type rc = s.find(.....);** 这个时候使用 if ( rc == string::npos )就回正确了。 +  st.size()表示st中的字符数量,字符数量的统计是由 1 开始累计计算的,所以字符数量正好比字符串的下标索引数(由 0 开始累计计算)大 1 ,这里的index != st.size();的效果等同于index < st.size(); + +size_t: + +size_t不是容器概念。size_type是容器概念,没有容器不能使用。 +见例程: + +#include +#include +using namespace std; +int main() +{ + cout<<" typeid(size_t).name() = "<::size_type).name() = "<::size_type).name()< bitvec; +**size_t** sz=bitvec.size(); + 另外sizeof操作符的返回值的类型也为size_t哦 + +from:网友 + +class container +{ +public: + __typedef size_t size_type;__ + //... +}; diff --git a/Zim/Research/Error_Notes/jffs2_scan_eraseblock()_Magic_bitmask_0x1985_not_found_at.txt b/Zim/Research/Error_Notes/jffs2_scan_eraseblock()_Magic_bitmask_0x1985_not_found_at.txt new file mode 100644 index 0000000..a27790f --- /dev/null +++ b/Zim/Research/Error_Notes/jffs2_scan_eraseblock()_Magic_bitmask_0x1985_not_found_at.txt @@ -0,0 +1,36 @@ +Content-Type: text/x-zim-wiki +Wiki-Format: zim 0.4 +Creation-Date: 2012-08-11T19:15:34+08:00 + +====== jffs2 scan eraseblock() Magic bitmask 0x1985 not found at ====== +Created Saturday 11 August 2012 + +如果在mount一个 jffs2文件系统到目录中出现: +jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000024: 0x2b10 instead ... +Further such events for this erase block will not be printed +类似的错误时,可能的原因是: +1. 该设备文件(/dev/mtdblock1)对应的存储单元并没有存放一个有效的jffs2文件系统,这时可以用LTIB或mtd-utils软件包中的mkfs.jffs2工具制作 +该jffs2文件系统映像,然后用uboot命令行着那个的nand或cp.b等命令或系统启动后用mtd-utils软件包中的nanderase,nandwrite工具烧写。 + +2. 如果设备对应的是一个有效的jffs2文件系统,那么很可能是在制作jffs2文件系统映像时 erase block size option not matches the one you have in your NAND. 对于LTIB而言,默认的擦出块大小是64KB,对于K9F5608的该值为16KB(参考其datasheet), 所以需要将下面该的值改为16. + --- Choose your root filesystem image type │ │ + │ │ Target image: (jffs2) ---> │ │ + │ │ [ ] Run a command after building the target image │ │ + │ │ (**64**) jffs2 erase block size in KB │ │ + │ │ [ ] read-only root filesystem + + +如果使用mkfs.jffs2命令行选项,则参数(针对K9F1G08U08 256MB NAND Flash)含义如下: +http://hi.baidu.com/_%CB%BC%CF%EB%B5%C4%D0%A1%D3%E3_/blog/item/ccb2d2d69c8bf9ca50da4b59.html + +mkfs.jffs2 -n -s 2048 -e 128KiB --pad=0x800000 -d root_fs -o kevin.jffs2 + +参数注释: + + -s 页大小,试验可以不特别要求,512亦可 + + __-e 擦除块大小(Block Erase)__,需和手册相匹配,此处为128(由手册可知),1 Block = (2K + 64)B + 64 Pages = (__128K__ + 4K)bytes + + 此处如果设置过大(如 256),将出现jffs2_scan_eraseblock():Magic bitmask......问题, 如果设置过小(如 64),将出现Empth flash at .......问题 + + --pad 设置**生成文件大小**,其实此处也不算是设置,因为此选项是填充的意思,当生成文件比参数规定大小大时, 此选项不起作用。只有当生成文件小于规定大小才会进行填充。 diff --git a/Zim/Research/Error_Notes/下载错误/minicom乱码.txt b/Zim/Research/Error_Notes/下载错误/minicom乱码.txt new file mode 100644 index 0000000..95570e4 --- /dev/null +++ b/Zim/Research/Error_Notes/下载错误/minicom乱码.txt @@ -0,0 +1,20 @@ +Content-Type: text/x-zim-wiki +Wiki-Format: zim 0.4 +Creation-Date: 2012-08-10T14:08:29+08:00 + +====== minicom乱码 ====== +Created Friday 10 August 2012 + +错误的可能原因: +1. 波特率不对,应该设置为115200 +2.串口的位数为8,无奇偶校验,停止位为1位,即:8N1 +3.**软件、硬件流控不设置**。 + +设置结果应该如下: +A - Serial Device : /dev/ttyUSB0 | +B - Lockfile Location : /var/lock | +C - Callin Program : | +D - Callout Program : | +E - Bps/Par/Bits : **115200 8N1** | +F - Hardware Flow Control : **No** | +G - Software Flow Control : **No** diff --git a/Zim/Research/Error_Notes/启动相关/VFS错误.txt b/Zim/Research/Error_Notes/启动相关/VFS错误.txt new file mode 100644 index 0000000..15f3818 --- /dev/null +++ b/Zim/Research/Error_Notes/启动相关/VFS错误.txt @@ -0,0 +1,7 @@ +Content-Type: text/x-zim-wiki +Wiki-Format: zim 0.4 +Creation-Date: 2012-08-11T21:15:04+08:00 + +====== VFS错误 ====== +Created Saturday 11 August 2012 +如果内核可以正常地启动,但是当执行到挂载root时出错,这可能与bootargs的ramdisk_size的值与ltib输出的不一致有关。 diff --git a/Zim/Research/Error_Notes/启动相关/内核不输出启动信息.txt b/Zim/Research/Error_Notes/启动相关/内核不输出启动信息.txt index 8c7694c..3c5bb00 100644 --- a/Zim/Research/Error_Notes/启动相关/内核不输出启动信息.txt +++ b/Zim/Research/Error_Notes/启动相关/内核不输出启动信息.txt @@ -8,5 +8,5 @@ Created Wednesday 22 February 2012 这可能与uboot的环境变量bootargs中console设置错误有关,正确的应该为: setenv bootargs root=/dev/ram rw console=ttyS0,115200 ramdisk_size=xxxx -注意:ramdisk_size大小要和ltib输出的一致,但可以比后者大,否则kernel启动的最后 -在mount该文件时,会出错。 +注意:ramdisk_size大小要和ltib输出的一致,但可以比后者大(有时设置较大时会出错,所以最好设为ltib的输出值),否则kernel启动的最后 +在mount该文件时,VFS子系统会出错。 diff --git a/Zim/Research/Error_Notes/启动相关/内核提示找不到rc.S文件.txt b/Zim/Research/Error_Notes/启动相关/内核提示找不到rc.S文件.txt new file mode 100644 index 0000000..49804aa --- /dev/null +++ b/Zim/Research/Error_Notes/启动相关/内核提示找不到rc.S文件.txt @@ -0,0 +1,19 @@ +Content-Type: text/x-zim-wiki +Wiki-Format: zim 0.4 +Creation-Date: 2012-08-11T15:57:47+08:00 + +====== 内核提示找不到rc.S文件 ====== +Created Saturday 11 August 2012 + +内核启动后输出如下内容: +RAMDISK: gzip image found at block 0 +VFS: Mounted root (ext2 filesystem) on device 1:0. +Freeing unused kernel memory: 152k freed +can't run '/etc/rc.d/rcS': No such file or directory +-------------------------------------------- +rcS是一个shell脚本文件,使用的解释器是/bin/sh,而该文件在ramdisk中并没由存在。 +这可能是busybox中的配置有误: + Choose which shell is aliased to 'sh' name (ash) ---> │ │ + Choose which shell is aliased to 'bash' name (ash) ---> + +选中上面两个选项即可。 diff --git a/Zim/Research/Error_Notes/编译错误/ltib.txt b/Zim/Research/Error_Notes/编译错误/ltib.txt index 408cf14..27f67fb 100644 --- a/Zim/Research/Error_Notes/编译错误/ltib.txt +++ b/Zim/Research/Error_Notes/编译错误/ltib.txt @@ -17,4 +17,22 @@ Created Friday 03 August 2012 4.执行/usr/sbin/visudo命令,在打开的文件中添加 geekard ALL = NOPASSWD: /bin/rpm, /opt/freescale/ltib/usr/bin/rpm -5. +5. 修改jffs2的erase block size 为16(按照K9F5608 datasheet上的Erase Block参数指定) + --- Choose your root filesystem image type │ │ + │ │ Target image: __(jffs2)__ ---> │ │ + │ │ [ ] Run a command after building the target image │ │ + │ │ __(16)__ jffs2 erase block size in KB │ │ + │ │ [ ] read-only root filesystem │ │ + │ │ (512k) tmpfs size │ │ + │ │ (/tmp /var) Place these dirs in writable RAM │ │ + │ │ () rootfs target directory + +6. ltib在编译某个软件包如busybox前,会先到rpm/RPMS/ppc/目录下查看busybox rpm软件包是否存在已经存在,如果存在的话将不会再 +编译它,而是在最后直接将其安装到rootfs目录下,所以如果想配置busybox则除了在package list中选中configure busybox before compile外 +还要删除rpm/RPMS/ppc目录下的busybox rpm包。如果该软件包的rpm包不存在,则ltib会到rpm/BUILD目录中查看该软件包的源代码目录是否存在 +如果存在则直接编译(编译完后并不删除该源代码目录),如果不存子则会从/opt/freescale/pkg目录下解压该软件包到BUILD目录中,编译完后会自动删除 +BUILD中的源代码目录,所以如果用户希望ltib在编译时使用自己的源代码,可以使用一下方法: +1. #./ltib -m prep -p busybox #将/opt/freescale/pkg目录中的busybox软件包解压到BUILD目录中,同时打补丁和配置源代码。 +2. # cp -rv MY-busybox/* rpm/BUILD/busybox #用户的代码替换就代码 +3. # ./ltib -m scbuild -p busybox +4. #./ltib -m scdeploy -p busybox diff --git a/Zim/Research/Error_Notes/编译错误/mtd-utils.txt b/Zim/Research/Error_Notes/编译错误/mtd-utils.txt new file mode 100644 index 0000000..730763a --- /dev/null +++ b/Zim/Research/Error_Notes/编译错误/mtd-utils.txt @@ -0,0 +1,37 @@ +Content-Type: text/x-zim-wiki +Wiki-Format: zim 0.4 +Creation-Date: 2012-08-11T20:46:27+08:00 + +====== mtd-utils ====== +Created Saturday 11 August 2012 + +**编译时出现下列错误:** +gcc -I./include -DWITHOUT_XATTR -O2 -g -Wall -c -o ftl_format.o ftl_format.c -g -Wp,-MD,./.ftl_format.c.dep +In file included from /home/geekard/PPC/sysroot/usr/include/endian.h:60:0, + from /home/geekard/PPC/sysroot/usr/include/sys/types.h:216, + from ftl_format.c:37: +./include/bits/byteswap.h:21:3: error: __#error "Never use directly; include instead."__ +make: *** [ftl_format.o] Error 1 +error: Bad exit status from /home/geekard/PPC/ltib-mpc8315erdb-20100719/tmp/rpm-tmp.69478 (%build) +--------------------------- +解决的方法是打开byteswap.h文件,将下面几行注释掉: +20 #if !defined _BYTESWAP_H && !defined _NETINET_IN_H + 21 # error "Never use directly; include instead." + 22 #endif +------------------------------------------------------------ +make -C ./ubi-utils +make[1]: Entering directory `/home/geekard/PPC/ltib-mpc8315erdb-20100719/rpm/BUILD/mtd-utils/ubi-utils' +gcc -I./inc -I./src -I../include -std=gnu99 -DPACKAGE_VERSION=\"1.0\" -O2 -g -Werror -Wall -Wwrite-strings -W -c -o pfiflash.o ./src/pfiflash.c -g -Wp,-MD,.pfiflash.c.dep +gcc -I./inc -I./src -I../include -std=gnu99 -DPACKAGE_VERSION=\"1.0\" -O2 -g -Werror -Wall -Wwrite-strings -W -c -o libpfiflash.o ./src/libpfiflash.c -g -Wp,-MD,.libpfiflash.c.dep +gcc -I./inc -I./src -I../include -std=gnu99 -DPACKAGE_VERSION=\"1.0\" -O2 -g -Werror -Wall -Wwrite-strings -W -c -o list.o ./src/list.c -g -Wp,-MD,.list.c.dep +gcc -I./inc -I./src -I../include -std=gnu99 -DPACKAGE_VERSION=\"1.0\" -O2 -g -Werror -Wall -Wwrite-strings -W -c -o reader.o ./src/reader.c -g -Wp,-MD,.reader.c.dep +gcc -I./inc -I./src -I../include -std=gnu99 -DPACKAGE_VERSION=\"1.0\" -O2 -g -Werror -Wall -Wwrite-strings -W -c -o error.o ./src/error.c -g -Wp,-MD,.error.c.dep +./src/error.c: In function 'info_msg': +./src/error.c:77:6: error: **variable 'n' set but not used [-Werror=unused-but-set-variable]** +cc1: all warnings being treated as errors +------------------ +解决方法是:将ubi-utils/Makefile中的-Werror去掉: + 11 CC := $(CROSS)gcc + 12 CFLAGS ?= -O2 -g __-Werror__ + 13 CFLAGS += -Wall -Wwrite-strings -W + diff --git a/Zim/Research/Error_Notes/编译错误/uboot.txt b/Zim/Research/Error_Notes/编译错误/uboot.txt index cefb661..17b4b53 100644 --- a/Zim/Research/Error_Notes/编译错误/uboot.txt +++ b/Zim/Research/Error_Notes/编译错误/uboot.txt @@ -5,7 +5,16 @@ Creation-Date: 2012-08-02T15:31:27+08:00 ====== uboot ====== Created Thursday 02 August 2012 -1. ltib在编译uboot时长时间地停在下面的命令行上: + +1.编译时提示 +make[1]: Leaving directory `/home/geekard/PPC/ltib-mpc8315erdb-20100719/rpm/BUILD/u-boot-2009.03-rc2/cpu/mpc83xx' +make[1]: Entering directory `/home/geekard/PPC/ltib-mpc8315erdb-20100719/rpm/BUILD/u-boot-2009.03-rc2/cpu/mpc83xx' +.depend:117: *** multiple target patterns. Stop. +错误。 +--------------- +解决方法是将cpu/mpc83xx/.depend文件删除即可。 + +2. ltib在编译uboot时长时间地停在下面的命令行上: powerpc-e300c3-linux-gnu-objcopy -O srec u-boot u-boot.srec powerpc-e300c3-linux-gnu-objcopy --gap-fill=0xff -O binary u-boot u-boot.bin 而且生成的uboot.bin文件非常大: diff --git a/Zim/Research/Error_Notes/编译错误/uboot/uboot-nand.txt b/Zim/Research/Error_Notes/编译错误/uboot/uboot-nand.txt new file mode 100644 index 0000000..98cf135 --- /dev/null +++ b/Zim/Research/Error_Notes/编译错误/uboot/uboot-nand.txt @@ -0,0 +1,37 @@ +Content-Type: text/x-zim-wiki +Wiki-Format: zim 0.4 +Creation-Date: 2012-08-10T16:52:25+08:00 + +====== uboot-nand ====== +Created Friday 10 August 2012 + +如果在编译nand型的uboot时提示如下错误: +[geekard@kb310 u-boot-2009.03-rc2]$ make distclean +[geekard@kb310 u-boot-2009.03-rc2]$ make MPC8315ERDB_NAND_config +... NAND Configuring for MPC8315ERDB board... +[geekard@kb310 u-boot-2009.03-rc2]$ make + -o /home/geekard/PPC/ltib-mpc8315erdb-20100719/rpm/BUILD/u-boot-2009.03-rc2/nand_spl/u-boot-spl +mpc8315erdb.o: In function `putc': +/home/geekard/PPC/ltib-mpc8315erdb-20100719/rpm/BUILD/u-boot-2009.03-rc2/nand_spl/board/freescale/mpc8315erdb/mpc8315erdb.c:324: undefined reference to __`_savegpr_31'__ +/home/geekard/PPC/ltib-mpc8315erdb-20100719/rpm/BUILD/u-boot-2009.03-rc2/nand_spl/board/freescale/mpc8315erdb/mpc8315erdb.c:332: undefined reference to __`_restgpr_31_x'__ +sdram.o: In function `initdram': +/home/geekard/PPC/ltib-mpc8315erdb-20100719/rpm/BUILD/u-boot-2009.03-rc2/nand_spl/board/freescale/mpc8315erdb/sdram.c:129: undefined reference to `_restgpr_29_x' +nand_init.o: In function `puts': +/home/geekard/PPC/ltib-mpc8315erdb-20100719/rpm/BUILD/u-boot-2009.03-rc2/nand_spl/board/freescale/mpc8315erdb/nand_init.c:112: undefined reference to `_restgpr_30_x' +time.o: In function `usec2ticks': +/home/geekard/PPC/ltib-mpc8315erdb-20100719/rpm/BUILD/u-boot-2009.03-rc2/nand_spl/board/freescale/mpc8315erdb/time.c:38: undefined reference to `_savegpr_31' +/home/geekard/PPC/ltib-mpc8315erdb-20100719/rpm/BUILD/u-boot-2009.03-rc2/nand_spl/board/freescale/mpc8315erdb/time.c:48: undefined reference to `_restgpr_31_x' +time.o: In function `udelay': +/home/geekard/PPC/ltib-mpc8315erdb-20100719/rpm/BUILD/u-boot-2009.03-rc2/nand_spl/board/freescale/mpc8315erdb/time.c:67: undefined reference to `_restgpr_28_x' +make[1]: *** [/home/geekard/PPC/ltib-mpc8315erdb-20100719/rpm/BUILD/u-boot-2009.03-rc2/nand_spl/u-boot-spl] Error 1 +make[1]: Leaving directory `/home/geekard/PPC/ltib-mpc8315erdb-20100719/rpm/BUILD/u-boot-2009.03-rc2/nand_spl/board/freescale/mpc8315erdb' +make: *** [nand_spl] Error 2 +[geekard@kb310 u-boot-2009.03-rc2]$ + +------------------------------ +http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43810#c4 +calls to _savegpr_32 and _restgpr_r31_x are only generated when compiling libgcc with -Os , but same compiled with -O2 does not emit the calls +所以解决的方法是,编辑uboot顶层目录中的config.mk文件将 +119 DBGFLAGS= -g # -DDEBUG +120 OPTFLAGS= -Os #-fomit-frame-pointer +上面的-Os改为-O2即可。 diff --git a/Zim/Research/u-boot.txt b/Zim/Research/u-boot.txt index f7f40a7..912a3e6 100644 --- a/Zim/Research/u-boot.txt +++ b/Zim/Research/u-boot.txt @@ -126,3 +126,6 @@ setenv bootargs root=/dev/ram rw ramdisk_size=24508 == ================== == setenv bootargs root=/dev/ram rw ramdisk_size=24508 + +== ============================== == +setenv bootargs root=/dev/ram rw ramdisk_size=20015 diff --git a/Zim/Research/u-boot/U-boot源代码全分析系列.txt b/Zim/Research/u-boot/U-boot源代码全分析系列.txt new file mode 100644 index 0000000..52fde8e --- /dev/null +++ b/Zim/Research/u-boot/U-boot源代码全分析系列.txt @@ -0,0 +1,7 @@ +Content-Type: text/x-zim-wiki +Wiki-Format: zim 0.4 +Creation-Date: 2012-01-15T19:23:01+08:00 + +====== U-boot源代码全分析系列 ====== +Created Sunday 15 January 2012 + diff --git a/Zim/Research/u-boot/U-boot源代码全分析系列/1.txt b/Zim/Research/u-boot/U-boot源代码全分析系列/1.txt new file mode 100644 index 0000000..6e12149 --- /dev/null +++ b/Zim/Research/u-boot/U-boot源代码全分析系列/1.txt @@ -0,0 +1,164 @@ +Content-Type: text/x-zim-wiki +Wiki-Format: zim 0.4 +Creation-Date: 2012-01-15T19:23:20+08:00 + +====== 1 ====== +Created Sunday 15 January 2012 +http://blog.csdn.net/juana1/article/details/6699785 +一、概述 + + U-Boot,全称Universal Boot Loader,是遵循GPL条款的开放源码项目,是从FADSROM、8xxROM、PPCBOOT逐步发展演化而来的。其源码目录、编译形式与Linux内核很相似,事实上,不少U-Boot源码就是相应的Linux内核源程序的简化,尤其是一些设备的驱动程序,这从U-Boot源码的注释中能体现这一点。但是U-Boot不仅仅支持嵌入式Linux系统的引导,当前,它还支持NetBSD, VxWorks, QNX, RTEMS, ARTOS, LynxOS嵌入式操作系统。其目前要支持的目标操作系统是OpenBSD, NetBSD, FreeBSD,4.4BSD, Linux, SVR4, Esix, Solaris, Irix, SCO, Dell, NCR, VxWorks, LynxOS, pSOS, QNX, RTEMS, ARTOS。这是U-Boot中Universal的一层含义,另外一层含义则是U-Boot除了支持PowerPC系列的处理器外,还能支持MIPS、 x86、ARM、NIOS、XScale等诸多常用系列的处理器。这两个特点正是U-Boot项目的开发目标,即支持尽可能多的嵌入式处理器和嵌入式操作系统。 + + 就目前来看,U-Boot对PowerPC系列处理器支持最为丰富,对Linux的支持最完善。其它系列的处理器和操作系统基本是在2002年11 月PPCBOOT改名为U-Boot后逐步扩充的。从PPCBOOT向U-Boot的顺利过渡,很大程度上归功于U-Boot的维护人德国DENX软件工程中心Wolfgang Denk[以下简称W.D]本人精湛专业水平和持着不懈的努力。当前,U-Boot项目正在他的领军之下,众多有志于开放源码BOOT LOADER移植工作的嵌入式开发人员正如火如荼地将各个不同系列嵌入式处理器的移植工作不断展开和深入,以支持更多的嵌入式操作系统的装载与引导。 + + 选择U-Boot的理由如下: + +1、开放源码; + +2、支持多种嵌入式操作系统内核,如Linux、NetBSD, VxWorks, QNX, RTEMS, ARTOS, LynxOS; + +3、支持多个处理器系列,如PowerPC、ARM、x86、MIPS、XScale; + +4、较高的可靠性和稳定性; + +5、较高的可靠性和稳定性; + +6、高度灵活的功能设置,适合U-Boot调试、操作系统不同引导要求、产品发布等; + +7、丰富的设备驱动源码,如串口、以太网、SDRAM、FLASH、LCD、NVRAM、EEPROM、RTC、键盘等; + +8、较为丰富的开发调试文档与强大的网络技术支持; + + 本文将从整体架构出发,尽自己的理解分析u-boot源码及其启动原理,之后再介绍下移植u-boot时的一些技巧,最后将以叙述移植的实例的方式来阐述其使用方法。 +二、程序架构 + + 要使用u-boot,首先需要搞清楚它的程序架构,要实现启动开发板需要修改哪些文件,下面列举了uboot的主要目录结构: + +- board:目标板相关文件,主要包含SDRAM、Flash的驱动; + +- common:独立于处理器体系结构的通用代码,如内存大小探测与故障检测等,它实现了u-boot的所有命令,其中内置了一个shell脚本解释器(hush.c,a prototype bourne shell grammar parser),busybox中也使用了它; + +- cpu:与处理器相关的文件,如mpc8xx子目录下有串口、网口、LCD驱动及中断初始化等文件。其中cpu.c负责初始化CPU、设置指令cache和数据cache等,interrupt.c负责设置系统的各种中断和异常,如快速中断、开关中断、时钟中断、软件中断、预取中止和未定义指令等,start.S负责u-boot启动时执行的第一个文件,它主要设置系统堆栈和工作方式,为跳转到C程序入口点做准备; + +- driver:通用设备驱动,如CFI Flash驱动(目前对INTEL Flash支持较好) + +- doc:U-Boot的说明文档; + +- examples:可在U-Boot下运行的示例程序,如hello_world.c、timer.c; + +- include:U-Boot头文件,注意:configs子目录下与目标板相关的配置头文件是移植过程中经常要修改的文件; + +- lib_xxx:处理器体系相关的文件,如lib_ppc, lib_arm目录分别包含与PowerPC、ARM体系结构相关的文件,lib_generic为通用的库函数实现; + +- net:与网络功能相关的文件目录,如bootp、nfs、sntp、tftp; + +- post:上电自检文件目录,目前仍有待于进一步完善; + +- rtc:RTC驱动程序; + +- tools:用于创建U-Boot S-RECORD和BIN镜像文件的工具; + +-fs:文件系统程序,包括ext2、Jffs2等; + +-disk:硬盘接口程序。 + + 在board目录下的每个子平台目录内,都有一个连接脚本文件u-boot.lds,从中可以找到u-boot的函数入口。另外,该目录下还有一个config.mk文件,用于设置TEXT_BASE的地址,该地址就是希望运行的地址、链接地址。 + + u-boot 是一个层次式结构,要让它跑起来,应当至少提供串口驱动(UART Driver)、以太网驱动(Ethernet Driver)、Flash 驱动(Flash 驱动)以及USB 驱动(USB Driver)。目前,通过USB 口下载程序显得不是十分必要,所以暂时没有移植USB 驱动。驱动层之上是u-boot 的应用,command 通过串口提供人机界面。 +三、代码分析 + + 本文的代码分析主要针对freescale的PowerPC芯片mpc83系列,从u-boot启动的过程来分析其源代码,目前大多数的bootloader都分为了Stage1和Stage2两个部分启动,依赖于CPU体系结构的代码常放在Stage1且常用汇编语言实现,在u-boot中功能代码集中在cpu/mpc83xx/start.S中,它包括从系统上电后在基地址开始执行的部分,它运行在flash中,包括对cpu寄存器的初始化和将Stage2的代码拷贝到SDRAM中的代码。而Stage2则用于实现复杂的应用,用C也有更好的可读性和移植性,主要功能代码集中在lib_ppc/board.c中,通过指定一系列的初始化函数表,实现对系统的初始化工作。一般情况下,u-boot编译后的程序不超过100k,且Stage1的代码编译后的大小一般不超过10k,。 + + 以下内容属转载,虽是ARM,但PowerPC与之类似: + +************************************************************************* + */ + +注:ARM微处理器支持字节(8位)、半字(16位)、字(32位)3种数据类型 +@向量跳转表,每条占四个字节(一个字),地址范围为0x0000 0000~@0x0000 0020 +@ARM体系结构规定在上电复位后的起始位置,必须有8条连续的跳 + +@转指令,通过硬件实现。他们就是异常向量表。ARM在上电复位后,@是从0x00000000开始启动的,其实如果bootloader存在,在执行 + +@下面第一条指令后,就无条件跳转到start_code,下面一部分并没@执行。设置异常向量表的作用是识别bootloader。以后系统每当有@异常出现,则CPU会根据异常号,从内存的0x00000000处开始查表@做相应的处理 + +/****************************************************** + +;当一个异常出现以后,ARM会自动执行以下几个步骤: +;1.把下一条指令的地址放到连接寄存器LR(通常是R14).---保存位置 +;2.将相应的CPSR(当前程序状态寄存器)复制到SPSR(备份的程序状态寄存器)中---保存CPSR +;3.根据异常类型,强制设置CPSR的运行模式位 +;4.强制PC(程序计数器)从相关异常向量地址取出下一条指令执行,从而跳转到相应的异常处理程序中 +*****************************************************************************/ + + 首先来看下Stage1的过程,系统主要实现了一下的功能: + +1、指定入口函数 + + 一个可执行的镜像必须要有且只有一个全局入口,通常情况下,这个入口函数是放在ROM的起始位置,而它是由处理器中断复位向量来决定的,代码如下: +[cpp] view plaincopy + + . = EXC_OFF_SYS_RESET + + .globl _start + _start: /* time t 0 */ + li r21, BOOTFLAG_COLD /* Normal Power-On: Boot from FLASH*/ + nop + b boot_cold + + . = EXC_OFF_SYS_RESET + 0x10 + + .globl _start_warm + _start_warm: + li r21, BOOTFLAG_WARM /* Software reboot */ + b boot_warm + + 需要注意的是,我们必须自己告诉编译器这个入口,而这个工作就是修改链接脚本文件(lds)。由上可见,函数执行开始后,一个立即读取指令后就是一个跳转语句。一般情况下(上电、复位等),程序都会执行boot_cold,通过调用系统复位中断从System reset偏移向量0x100来获取指令,每个中断向量有256个字节的空间。另外,与start.s文件在一起的也有一个config.mk文件,该文件用于定义编译选项。通过链接地址TEXT_BASE和运行地址.start的不同决定是否要复制代码。 + +2、设置异常向量(Exception Vector) + + 异常向量表也可称为中断向量表,在mpc83xx中,它是以0x100的偏移量连续分布的,基地址的值取决于MSR[IP],当它为0是,基地址为0x00000000,为1时,基地址为0xfff00000。该值是由启动方式决定的。源码如下: +[cpp] view plaincopy + + /* + * Vector Table + */ + + .globl _start_of_vectors + _start_of_vectors: + + /* Machine check */ + STD_EXCEPTION(0x200, MachineCheck, MachineCheckException) + + /* Data Storage exception. */ + STD_EXCEPTION(0x300, DataStorage, UnknownException) + + /* Instruction Storage exception. */ + STD_EXCEPTION(0x400, InstStorage, UnknownException) + + /* External Interrupt exception. */ + #ifndef FIXME + STD_EXCEPTION(0x500, ExtInterrupt, external_interrupt) + #endif + + /* Alignment exception. */ + . = 0x600 + Alignment: + EXCEPTION_PROLOG(SRR0, SRR1) + mfspr r4,DAR + stw r4,_DAR(r21) + mfspr r5,DSISR + stw r5,_DSISR(r21) + addi r3,r1,STACK_FRAME_OVERHEAD + li r20,MSR_KERNEL + rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */ + rlwimi r20,r23,0,25,25 /* copy IP bit from saved MSR */ + lwz r6,GOT(transfer_to_handler) + mtlr r6 + blrl + .L_Alignment: + .long AlignmentException - _start + EXC_OFF_SYS_RESET + .long int_return - _start + EXC_OFF_SYS_RESET + …. + + 这里的代码太长了,就没再粘贴,有兴趣的可以下载源码看一下,上面的只包括了机器校验、数据存储异常、指令存储异常等异常处理函数,由上也可以看到其连续存储的特性。 diff --git a/Zim/Research/u-boot/U-boot源代码全分析系列/2.txt b/Zim/Research/u-boot/U-boot源代码全分析系列/2.txt new file mode 100644 index 0000000..e47e68c --- /dev/null +++ b/Zim/Research/u-boot/U-boot源代码全分析系列/2.txt @@ -0,0 +1,300 @@ +Content-Type: text/x-zim-wiki +Wiki-Format: zim 0.4 +Creation-Date: 2012-01-15T19:23:41+08:00 + +====== 2 ====== +Created Sunday 15 January 2012 + +3、初始化CPU相关 + + 下面为初始化CPU的代码,实现的功能依次为屏蔽watchdog、初始化中断控制寄存器、清空Cache、关闭MMU等。 +[cpp] view plaincopy + + .globl init_e300_core + init_e300_core: /* time t 10 */ + /* Initialize machine status; enable machine check interrupt */ + + li r3, MSR_KERNEL /*设置MSR,允许数据\指令复制以及Machine check*/ + rlwimi r3, r5, 0, 25, 25 /* preserve IP bit set by HRCW */ + #ifdef DEBUG + rlwimi r3, r5, 0, 21, 22 /* debugger might set SE & BE bits */ + #endif + SYNC /* Some chip revs need this... */ + mtmsr r3 + SYNC + mtspr SRR1, r3 /* Make SRR1 match MSR 中断相关*/ + + lis r3, CFG_IMMR@h + #if defined(CONFIG_WATCHDOG) + /* Initialise the Wathcdog values and reset it (if req) */ + lis r4, CFG_WATCHDOG_VALUE + ori r4, r4, (SWCRR_SWEN | SWCRR_SWRI | SWCRR_SWPR) + stw r4, SWCRR(r3) + + /* and reset it */ + + li r4, 0x556C + sth r4, SWSRR@l(r3) + li r4, -0x55C7 + sth r4, SWSRR@l(r3) + #else + /* 关闭Wathcdog */ + lwz r4, SWCRR(r3) + /* Check to see if its enabled for disabling + once disabled by SW you can't re-enable */ + andi. r4, r4, 0x4 + beq 1f + xor r4, r4, r4 + stw r4, SWCRR(r3) + 1: + #endif /* CONFIG_WATCHDOG */ + + /* Initialize the Hardware Implementation-dependent Registers */ + /* HID0 also contains cache control */ + /*------------------------------------------------------*/ + + lis r3, CFG_HID0_INIT@h + ori r3, r3, CFG_HID0_INIT@l + SYNC + mtspr HID0, r3 + + lis r3, CFG_HID0_FINAL@h + ori r3, r3, CFG_HID0_FINAL@l + SYNC + mtspr HID0, r3 + + lis r3, CFG_HID2@h + ori r3, r3, CFG_HID2@l + SYNC + mtspr HID2, r3 + + /* 关闭MMU功能,先清空所有BAT (块地址转换)*/ + + xor r0, r0, r0 + mtspr DBAT0U, r0 + mtspr DBAT0L, r0 + mtspr DBAT1U, r0 + mtspr DBAT1L, r0 + mtspr DBAT2U, r0 + mtspr DBAT2L, r0 + mtspr DBAT3U, r0 + mtspr DBAT3L, r0 + mtspr IBAT0U, r0 + mtspr IBAT0L, r0 + mtspr IBAT1U, r0 + mtspr IBAT1L, r0 + mtspr IBAT2U, r0 + mtspr IBAT2L, r0 + mtspr IBAT3U, r0 + mtspr IBAT3L, r0 + SYNC + + /* 禁用tlb(快表) */ + + li r3, 32 + mtctr r3 + li r3, 0 + 1: tlbie r3 + addi r3, r3, 0x1000 + bdnz 1b + SYNC + + /* Done! */ + Blr + + 这里需要注意的是,当程序在Flash中运行时,执行程序跳转时使用了跳转指令,但是不是使用绝对地址的跳转(即直接对PC操作)。因为若使用绝对地址,那么程序的取址就是相对于当前PC位置向前或向后的一段空间,而不会跳进SDRAM中。 + +4、初始化内存控制器 + + PowerPC处理器初识化内存控制器就是通过操作BAT以及TLB来实现的,将IBAT0~7以及DBAT0~7初始化,并禁用TLB,代码如下: +[cpp] view plaincopy + + /* setup_bats - set them up to some initial state */ + .globl setup_bats + setup_bats: + addis r0, r0, 0x0000 + + /* IBAT 0 */ + addis r4, r0, CFG_IBAT0L@h + ori r4, r4, CFG_IBAT0L@l + addis r3, r0, CFG_IBAT0U@h + ori r3, r3, CFG_IBAT0U@l + mtspr IBAT0L, r4 + mtspr IBAT0U, r3 + isync + + /* DBAT 0 */ + addis r4, r0, CFG_DBAT0L@h + ori r4, r4, CFG_DBAT0L@l + addis r3, r0, CFG_DBAT0U@h + ori r3, r3, CFG_DBAT0U@l + mtspr DBAT0L, r4 + mtspr DBAT0U, r3 + isync + + #ifdef CONFIG_HIGH_BATS + /* IBAT 4 */ + addis r4, r0, CFG_IBAT4L@h + ori r4, r4, CFG_IBAT4L@l + addis r3, r0, CFG_IBAT4U@h + ori r3, r3, CFG_IBAT4U@l + mtspr IBAT4L, r4 + mtspr IBAT4U, r3 + isync + + /* DBAT 4 */ + addis r4, r0, CFG_DBAT4L@h + ori r4, r4, CFG_DBAT4L@l + addis r3, r0, CFG_DBAT4U@h + ori r3, r3, CFG_DBAT4U@l + mtspr DBAT4L, r4 + mtspr DBAT4U, r3 + isync + + #endif + + /* Invalidate TLBs. + * -> for (val = 0; val < 0x20000; val+=0x1000) + * -> tlbie(val); + */ + lis r3, 0 + lis r5, 2 + + 1: + tlbie r3 + addi r3, r3, 0x1000 + cmp 0, 0, r3, r5 + blt 1b + + blr + +上面只贴出了高低位各一个BAT的操作代码,其他的类似。 + +5、复制程序到RAM + + PowerPC中此段程序并不返回,在将程序代码全部复制到ROM中后,将会直接继续在RAM中运行: +[cpp] view plaincopy + + /*完成了代码复制,不返回,直接调用in_ram执行*/ + addi r0, r10, in_ram - _start + EXC_OFF_SYS_RESET + mtlr r0 + blr + .globl relocate_code + relocate_code: + mr r1, r3 /* 创建一个新的栈指针 */ + mr r9, r4 /* 备份 */ + mr r10, r5 + + mr r3, r5 /* r3:拷贝的终点 */ + lis r4, CFG_MONITOR_BASE@h /* r4:拷贝的起点 */ + ori r4, r4, CFG_MONITOR_BASE@l + lwz r5, GOT(__init_end) + sub r5, r5, r4 /* r5:拷贝的长度 */ + li r6, CFG_CACHELINE_SIZE /* Cache Line Size */ + + /* New GOT-PTR = (old GOT-PTR - CFG_MONITOR_BASE) + Destination Address */ + sub r15, r10, r4 + + /* First our own GOT */ + add r14, r14, r15 + /* then the one used by the C code */ + add r30, r30, r15 + + /* Now relocate code */ + cmplw cr1,r3,r4 + addi r0,r5,3 + srwi. r0,r0,2 + beq cr1,4f /* In place copy is not necessary */ + beq 7f /* Protect against 0 count */ + mtctr r0 + bge cr1,2f + la r8,-4(r4) + la r7,-4(r3) + + /* copy */ + 1: lwzu r0,4(r8) + stwu r0,4(r7) + bdnz 1b + + addi r0,r5,3 + srwi. r0,r0,2 + mtctr r0 + la r8,-4(r4) + la r7,-4(r3) + + /* and compare */ + 20: lwzu r20,4(r8) + lwzu r21,4(r7) + xor. r22, r20, r21 + bne 30f + bdnz 20b + b 4f + + /* compare failed */ + 30: li r3, 0 + blr + + 2: slwi r0,r0,2 /* re copy in reverse order ... y do we needed it? */ + add r8,r4,r0 + add r7,r3,r0 + 3: lwzu r0,-4(r8) + stwu r0,-4(r7) + bdnz 3b + + /* + * Now flush the cache: note that we must start from a cache aligned + * address. Otherwise we might miss one cache line. + */ + 4: cmpwi r6,0 + add r5,r3,r5 + beq 7f /* Always flush prefetch queue in any case */ + subi r0,r6,1 + andc r3,r3,r0 + mr r4,r3 + 5: dcbst 0,r4 + add r4,r4,r6 + cmplw r4,r5 + blt 5b + sync /* Wait for all dcbst to complete on bus */ + mr r4,r3 + 6: icbi 0,r4 + add r4,r4,r6 + cmplw r4,r5 + blt 6b + 7: sync /* Wait for all icbi to complete on bus */ + isync + +6、初始化堆栈 + + 对于mpc83xx系列,初始化堆栈代码如下: +[cpp] view plaincopy + + /* set up the stack pointer in our newly created cache-ram (r1) */ + lis r1, (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET)@h + ori r1, r1, (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET)@l + + li r0, 0 /* Make room for stack frame header and */ + stwu r0, -4(r1) /* clear final stack frame so that */ + stwu r0, -4(r1) /* stack backtraces terminate cleanly */ + +7、跳转到Stage2入口处 + + 这也是Stage1的最后一步,程序在执行到这一步后,基本的硬件初始化工作也就完成了,下面是跳转的代码: +[cpp] view plaincopy + + GET_GOT /* initialize GOT access */ + /* r3: IMMR */ + lis r3, CFG_IMMR@h + /* run low-level CPU init code (in Flash)*/ + bl cpu_init_f + + /* r3: BOOTFLAG */ + mr r3, r21 + /* run 1st part of board init code (in Flash)*/ + bl board_init_f + +其中board_init_f就是Stage2的函数入口。 + + 由上可以看出start.S的流程为:异常向量——上电复位后进入复位异常向量——跳到启动代码处——设置处理器进入管理模式——关闭看门狗——关闭中断——设置时钟分频——关闭MMU和CACHE——进入lowlever_init.S——检查当前代码所处的位置,如果在FLASH中就将代码搬移到RAM中。至此,Stage1分析到此结束。 + + 跳转到board_init_f后,程序开始执行Stage2阶段,代码多为C。 diff --git a/Zim/Research/u-boot/U-boot源代码全分析系列/3.txt b/Zim/Research/u-boot/U-boot源代码全分析系列/3.txt new file mode 100644 index 0000000..f7a8405 --- /dev/null +++ b/Zim/Research/u-boot/U-boot源代码全分析系列/3.txt @@ -0,0 +1,174 @@ +Content-Type: text/x-zim-wiki +Wiki-Format: zim 0.4 +Creation-Date: 2012-01-15T19:24:09+08:00 + +====== 3 ====== +Created Sunday 15 January 2012 + + 这里首先更正下上一篇中的一个错误,最后一步中的跳转代码当时一时仓促贴错了,先改正如下: + +7、跳转到Stage2入口处 + + 这也是Stage1的最后一步,程序在执行到这一步后,基本的硬件初始化工作也就完成了,下面是跳转的代码: +[cpp] view plaincopy + + clear_bss: + /* 执行清空bss操作 */ + lwz r3,GOT(__bss_start) + #if defined(CONFIG_HYMOD) + /* + * For HYMOD - the environment is the very last item in flash. + * The real .bss stops just before environment starts, so only + * clear up to that point. + * taken from mods for FADS board + * 检查当前代码位置 + */ + lwz r4,GOT(environment) + #else + lwz r4,GOT(_end) + #endif + + /* 计算跳转 */ + cmplw 0, r3, r4 + beq 6f + + li r0, 0 + 5: + stw r0, 0(r3) + addi r3, r3, 4 + cmplw 0, r3, r4 + bne 5b + 6: + + mr r3, r9 /* Global Data pointer */ + mr r4, r10 /* Destination Address */ + bl board_init_r + +其中board_init_r就是Stage2的函数入口。 + + 由上可以看出start.S的流程为:异常向量——上电复位后进入复位异常向量——跳到启动代码处——设置处理器进入管理模式——关闭看门狗——关闭中断——设置时钟分频——关闭MMU和CACHE——进入low level初始化代码——检查当前代码所处的位置,如果在FLASH中就将代码搬移到RAM中。至此,Stage1分析到此结束。 + + 跳转到board_init_r后,程序开始执行Stage2阶段,代码多为C。 + +望谅解。 + + 在上篇分析完Stage1的汇编代码后,又细看了两个C函数,也是属于很重要的初始化函数,所以,在分析Stage2的代码前,先还要看下Stage1的两个C代码程序,分别为cpu_init_f和board_init_f,二者在汇编程序in_flash中被调用,虽是C代码,但实现的仍是基本的初始化功能,且运行在ROM中,属于Stage1的范畴。 + + 先看cpu_init_f函数,它是用来初始化low-level CPU的,主要功能包括建立内存映射map、初始化一些寄存器和UPM(User-Programmable Machine)。 + 首先初始化一个结构体: +[cpp] view plaincopy + + gd = (gd_t *) (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET); + + /* Clear initial global data */ + memset ((void *) gd, 0, sizeof (gd_t)); + + 此处的结构体gd_t是一个放在启动后很早就可用的内存中的,就像mpc8xx、mpc82xx的DPRAM,或者是数据cache的locked parts,主要用于存放一小部分系统初始化时要用的全局变量,直到初始化内存控制器可用RAM之前,这是我们唯一能用的全局变量。这个区间是很小的,在本区间中只有256个字节。之后就开始配置各种设备的时钟模式,下面是对PCI和DMA的配置: +[cpp] view plaincopy + + #ifdef CFG_SCCR_PCICM + /* PCI & DMA clock mode */ + im->clk.sccr = (im->clk.sccr & ~SCCR_PCICM) | + (CFG_SCCR_PCICM << SCCR_PCICM_SHIFT); + #endif + + 这个配置的选项是要根据datasheet里的SCCR寄存器来定的,下面是mpc83xx的一个系统时钟控制寄存器的各位: + + + 根据说明来对应uboot中include/Mpc83xx.h中的相关配置,不过大多数的CPU型号都已经配置好了,一般无需改动。 + + 接下来初始化一些寄存器,如复位控制寄存器,DDR控制驱动寄存器等: +[cpp] view plaincopy + + /* RSR - Reset Status Register - clear all status */ + gd->reset_status = im->reset.rsr; + im->reset.rsr = ~(RSR_RES); + + /* RMR - Reset Mode Register contains checkstop reset enable*/ + im->reset.rmr = (RMR_CSRE & (1<lbus.lcrr = CFG_LCRR; + + /* Enable Time Base & Decrimenter ( so we will have udelay() )*/ + im->sysconf.spcr |= SPCR_TBEN; + + /* System General Purpose Register */ + im->sysconf.sicrh = CFG_SICRH; + + 这些都需要对照着Datasheet里的第四章:Reset,Clockig,and Initialization一一比对着看,这样才能加深印象(尽管大多数实际应用中都不用修改)。 + + 最后是初始化内存映射,下面代码作用为将bank0映射到Flash的bank0的初始地址,后面还有部分代码,将根据需要映射bank1~7的: +[cpp] view plaincopy + + im->lbus.bank[0].br = CFG_BR0_PRELIM; + im->lbus.bank[0].or = CFG_OR0_PRELIM; + im->sysconf.lblaw[0].bar = CFG_LBLAWBAR0_PRELIM; + im->sysconf.lblaw[0].ar = CFG_LBLAWAR0_PRELIM; + + 再来看下board_init_f函数,它主要用于在启动时尽快的提供一个控制台接口(串口)用于输出错误信息,并且初始化内存以便于复制代码。这段代码的编写需要注意:全局变量是只读的,BSS还未初始化,堆栈空间也很小(尽量不要有复杂操作)。最开始先进行一系列的初始化操作,和ARM系列类似,将初始化函数列表放在结构体init_sequence中: +[cpp] view plaincopy + + for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) { + if ((*init_fnc_ptr) () != 0) { + hang (); + } + } + + 主要包括板件前期初始化、获取CPU及总线时钟、初始化SDRAM时钟、初始化串口等操作。此时内存已经映射好了,就可以在DRAM中运行程序了,接下来我们需要在RAM的末端保存一些数据,包括uboot和Linux不能操作的区域、内核日志缓存、PRAM(被保护的RAM)、LCD帧缓存、监听代码、板件信息等。 +[cpp] view plaincopy + + /*通过修改gd->ram_size可以使uboot无法访问指定区间*/ + gd->ram_size -= CFG_MEM_TOP_HIDE; + addr = CFG_SDRAM_BASE + get_effective_memsize(); + + #ifdef CONFIG_LOGBUFFER + #ifndef CONFIG_ALT_LB_ADDR + /*保存内核日志*/ + addr -= (LOGBUFF_RESERVE); + debug ("Reserving %dk for kernel logbuffer at %08lx\n", LOGBUFF_LEN, addr); + #endif + #endif + + #ifdef CONFIG_PRAM + /* reserve protected RAM */ + i = getenv_r ("pram", (char *)tmp, sizeof (tmp)); + reg = (i > 0) ? simple_strtoul ((const char *)tmp, NULL, 10) : CONFIG_PRAM; + addr -= (reg << 10); /* size is in kB */ + debug ("Reserving %ldk for protected RAM at %08lx\n", reg, addr); + #endif /* CONFIG_PRAM */ + + #ifdef CONFIG_LCD + /* reserve memory for LCD display (always full pages) */ + addr = lcd_setmem (addr); + gd->fb_base = addr; + #endif /* CONFIG_LCD */ + + #if defined(CONFIG_VIDEO) && defined(CONFIG_8xx) + /* reserve memory for video display (always full pages) */ + addr = video_setmem (addr); + gd->fb_base = addr; + #endif /* CONFIG_VIDEO */ + + #ifdef CONFIG_AMIGAONEG3SE + gd->relocaddr = addr; + #endif + + /* reserve memory for malloc() arena */ + addr_sp = addr - TOTAL_MALLOC_LEN; + debug ("Reserving %dk for malloc() at: %08lx\n", + TOTAL_MALLOC_LEN >> 10, addr_sp); + + /* (permanently) allocate a Board Info struct and a permanent copy of the "global" dat*/ + addr_sp -= sizeof (bd_t); + bd = (bd_t *) addr_sp; + gd->bd = bd; + debug ("Reserving %zu Bytes for Board Info at: %08lx\n",sizeof (bd_t), addr_sp); + addr_sp -= sizeof (gd_t); + id = (gd_t *) addr_sp; + debug ("Reserving %zu Bytes for Global Data at: %08lx\n", + sizeof (gd_t), addr_sp); + + 接下来的代码比较容易理解,就是将板件信息存储到结构体board_info里,包括串口信息、PHY芯片信息、启动参数、RAM参数、flash信息等。 + + 分析完这两个C函数后,Stage1的分析就全部结束了。接下来跳入board_init_r函数中开始Stage2。 diff --git a/Zim/Research/u-boot/U-boot源代码全分析系列/MPC8314_(e300核)_uboot_调试_一.txt b/Zim/Research/u-boot/U-boot源代码全分析系列/MPC8314_(e300核)_uboot_调试_一.txt new file mode 100644 index 0000000..c4a06b6 --- /dev/null +++ b/Zim/Research/u-boot/U-boot源代码全分析系列/MPC8314_(e300核)_uboot_调试_一.txt @@ -0,0 +1,302 @@ +Content-Type: text/x-zim-wiki +Wiki-Format: zim 0.4 +Creation-Date: 2012-01-15T19:29:55+08:00 + +====== MPC8314 (e300核) uboot 调试 一 ====== +Created Sunday 15 January 2012 +http://blog.csdn.net/gorilla0123/article/details/5899452 + +历经2个多月,完成了MPC8314最小系统(uboot)及Linux内核和根文件系统的调试。这是我第一次从头开始做小系统和内核的移植工作,虽然调试的比较辛苦,但是收获还是很多的。下面就介绍一下调试的过程和一些原理性的东西。 + +1 MPC8314 上电流程 + +系统上电后,经过若干个时钟后,MPC8314会检测复位配置输入信号CFG_RESET_SOURCE[0:3]来确定硬件配置字源选择,在目标板上可以设置跳线来改变CFG_RESET_SOURCE[0:3],选择硬件配置字源。本系统中的硬件配置字存放在CPLD模拟的Flash空间中。 +{{./1.gif}} +从相应的地方读取硬件配置字(RCWL,RCWH)后,会设置相应的寄存器。其中RCWH中的BMS位值为1,定义了e300核心的MSR[IP]位初始值,如上图所示,MSR[IP]为1决定中断向量的前缀为0xFFF,启动存储空间的位置为0xFF80_0000~0xFFFF_FFFF;SWEN位为0,禁止软件看门狗;ROMLOC位为0b110,RLEXT位为0b00确定了选择local bus GPCM-16bit ROM为启动ROM。复位向量和本地地址映射的默认启动ROM访问将直接指向ROMLOC指定的接口。选中的启动ROM的本地访问窗口(LBLAW0)将被使能,并初始化基地址LBLAWBAR0为0xFF80_0000,窗口大小为8M。这时,Local Bus上的片选CS0的寄存器值为BR0:0000_0000,OR0:0000_0000。整个4G空间全是ROM,每16M重复一次。 + +中断向量的前缀为0xFFF,复位向量为100,决定了系统复位后的第一条指令从0xFFF0_0100处获得。 + +/cpu/mpc83xx/u-boot.lds文件时连接器脚本文件,其中 + +.text : + + { + + cpu/mpc83xx/start.o (.text) + + 。 。 。 。 。 + + } + +。 。 。 。 。 。 + +ENTRY(_start) + +规定了代码段从/cpu/mpc83xx/start.s开始。而ENTRY(_start)这一句告诉编译器uboot.bin的镜像入口点为start.s中的_start标号。 + +所以,我们要将UBOOT的代码烧写到16M Flash中偏移15M的地方,保证了从0xFFF0_0100的空间取到的指令为uboot代码。并且还需要保证0xFFF0_0100为start标号。 + + +2 uboot启动流程 +2.1 uboot启动概述 + + Uboot的启动是从/cpu/mpc83xx/start.s中的_start标号开始的,经历了 /cpu/mpc83xx/start.s,/cpu/mpc83xx/cpu_init.c ,/lib_ppc/Board.c等几个文件中的多个汇编和C函数,最后会在/lib_ppc/Board.c中的board_init_r函数中进入命令死循环,等待执行键入的命令。其具体的流程如下图所示: +{{./2.gif}} + + + + + + +2.2 init_e300_core 函数 + + + + 初始化e300核心,禁止中断响应,只允许machine check中断和system reset中断,禁止指令和数据地址转换,即关闭MMU,进行实地址转换,设置为supervisor级别,禁止看门狗,无效指令和数据cache,等,为系统创建一个干净可靠的初始环境。 + + + +2.3 窗口重映射 + + + +从前面MPC8314上电流程可以看出,上电之后,第一条代码是从0xFFF0_0100的地方开始执行的,但是flash并不一定会分配在0xFF00_0000到0xFFFF_FFFF的地方(以我们16M的为例)。在本系统中,Flash的地址就被分配到了0xFE00_0000到0xFEFF_FFFF的地方。所以这其中需要做一个跳转,这正是这段代码中map_flash_by_law1,remap_flash_by_law0等函数要做的,具体的流程可以由下面的五张图来说明: + + + +1 开始时,BR0,OR0为全零,4G全是重复的Flash,CPU通过LBLAW0访问Flash + +空间 FF80_0000到 FFFF_FFFF。 + + {{./3.gif}} + + + +2 map_flash_by_law1函数使用LBLAW1映射FE00_0000到FEFF_FFFF这段空间。 +{{./4.gif}} + + + + +3 跳转到FE00_0000这段空间执行代码,由于4G空间重复,只要偏移地址计算正确就 + +会顺序执行。 +{{./5.gif}} + + + + +4 remap_flash_by_law0函数设置BR0为FE00_0000,OR0大小为16M。 +{{./6.gif}} +5 remap_flash_by_law0函数设置LBLAW0窗口映射FE00_0000到FE7F_FFFF区域,并 + + {{./7.gif}} + +清除LBLAW1。 + + + + + +2.4 Dcache 中分配空间做堆栈 + + + + + +程序跑到这里,就要进入第一个C函数了,C函数的运行需要堆栈空间,但这时,RAM还没有初始化,只能在Dcache中锁定一定的空间,用于C的堆栈空间。 + +lock_ram_in_cache函数在Dcache中锁定4k的空间。 + +下面的几行代码将堆栈指针指向刚刚分配好的Dcache空间。 + +lis r1, (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET)@h + +ori r1, r1, (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET)@l + +li r0, 0 + +stwu r0, -4(r1) + + + + + + + +2.5 cpu_init_f 函数 + + + + 该函数是系统执行的第一个C语言的函数,主要是做一些CPU 寄存器的初始化,其中最重要的部分是初始化Local Access Windows的值和Local Bus上的片选BR,OR的值。这些值需要在/include/configs/MPC8315ERDB.h中配置好。 + + + +2.6 board_init_f 函数 + + + +该函数为板级初始化的第一个函数,会对板子上很多硬件外设做初始化,其中最重要的为init_sequence数组,该数组里面包含了很多板级的硬件初始化函数,在board_init_f函数中会依次的调用该数组中的函数去初始化各个硬件,该数组如下: + +init_fnc_t *init_sequence[] = { + + + +#if defined(CONFIG_BOARD_EARLY_INIT_F) + + board_early_init_f, + +#endif + + + +#if !defined(CONFIG_8xx_CPUCLK_DEFAULT) + + get_clocks, /* get CPU and bus clocks (etc.) */ + +#if defined(CONFIG_TQM8xxL) && !defined(CONFIG_TQM866M) / + + && !defined(CONFIG_TQM885D) + + adjust_sdram_tbs_8xx, + +#endif + + init_timebase, + +#endif + +#ifdef CFG_ALLOC_DPRAM + +#if !defined(CONFIG_CPM2) + + dpram_init, + +#endif + +#endif + +#if defined(CONFIG_BOARD_POSTCLK_INIT) + + board_postclk_init, + +#endif + + env_init, + +#if defined(CONFIG_8xx_CPUCLK_DEFAULT) + + get_clocks_866, /* get CPU and bus clocks according to the environment variable */ + + sdram_adjust_866, /* adjust sdram refresh rate according to the new clock */ + + init_timebase, + +#endif + + init_baudrate, + + serial_init, + + console_init_f, + + display_options, + +#if defined(CONFIG_8260) + + prt_8260_rsr, + + prt_8260_clks, + +#endif /* CONFIG_8260 */ + +#if defined(CONFIG_MPC83XX) + + prt_83xx_rsr, + +#endif + + checkcpu, + +#if defined(CONFIG_MPC5xxx) + + prt_mpc5xxx_clks, + +#endif /* CONFIG_MPC5xxx */ + +#if defined(CONFIG_MPC8220) + + prt_mpc8220_clks, + +#endif + + checkboard, + + INIT_FUNC_WATCHDOG_INIT + +#if defined(CONFIG_MISC_INIT_F) + + misc_init_f, + +#endif + + INIT_FUNC_WATCHDOG_RESET + +#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) + + init_func_i2c, + +#endif + +#if defined(CONFIG_DTT) /* Digital Thermometers and Thermostats */ + + dtt_init, + +#endif + +#ifdef CONFIG_POST + + post_init_f, + +#endif + + INIT_FUNC_WATCHDOG_RESET + + init_func_ram, + +#if defined(CFG_DRAM_TEST) + + testdram, + +#endif /* CFG_DRAM_TEST */ + + INIT_FUNC_WATCHDOG_RESET + + + + NULL, /* Terminate this list */ + +}; + +可以看到时钟,内存,串口,控制台等初始化函数的调用,其中串口的初始化要先于内存初始化。 + + + +2.7 relocate_code 函数 + + + +到目前为止,boot代码都是在Flash中运行,但是代码最终是要到RAM中运行的,在上面的board_init_f函数中已经将RAM初始化好了,具备了在RAM中运行程序的能力,现在relocate_code函数需要做两个事情: + +1 从Flash中拷贝uboot的代码到RAM + + 2 记下现在执行代码的偏移,跳转到RAM中相应的位置执行。 + + + +2.8 board_init_r 函数 + + + + 该函数为板级初始化的第二阶段,主要是初始化PCI,PCIE,网口,Flash等设备,关闭看门狗,把前面借dcache做堆栈的空间解锁,还给cache。在一切设备都初始化好后,便会进去main_loop的死循环中。 + diff --git a/Zim/Research/u-boot/U-boot源代码全分析系列/MPC8314_(e300核)_uboot_调试_一/1.gif b/Zim/Research/u-boot/U-boot源代码全分析系列/MPC8314_(e300核)_uboot_调试_一/1.gif new file mode 100644 index 0000000..bddea6a Binary files /dev/null and b/Zim/Research/u-boot/U-boot源代码全分析系列/MPC8314_(e300核)_uboot_调试_一/1.gif differ diff --git a/Zim/Research/u-boot/U-boot源代码全分析系列/MPC8314_(e300核)_uboot_调试_一/2.gif b/Zim/Research/u-boot/U-boot源代码全分析系列/MPC8314_(e300核)_uboot_调试_一/2.gif new file mode 100644 index 0000000..0cd242c Binary files /dev/null and b/Zim/Research/u-boot/U-boot源代码全分析系列/MPC8314_(e300核)_uboot_调试_一/2.gif differ diff --git a/Zim/Research/u-boot/U-boot源代码全分析系列/MPC8314_(e300核)_uboot_调试_一/3.gif b/Zim/Research/u-boot/U-boot源代码全分析系列/MPC8314_(e300核)_uboot_调试_一/3.gif new file mode 100644 index 0000000..b2249d7 Binary files /dev/null and b/Zim/Research/u-boot/U-boot源代码全分析系列/MPC8314_(e300核)_uboot_调试_一/3.gif differ diff --git a/Zim/Research/u-boot/U-boot源代码全分析系列/MPC8314_(e300核)_uboot_调试_一/4.gif b/Zim/Research/u-boot/U-boot源代码全分析系列/MPC8314_(e300核)_uboot_调试_一/4.gif new file mode 100644 index 0000000..29d362e Binary files /dev/null and b/Zim/Research/u-boot/U-boot源代码全分析系列/MPC8314_(e300核)_uboot_调试_一/4.gif differ diff --git a/Zim/Research/u-boot/U-boot源代码全分析系列/MPC8314_(e300核)_uboot_调试_一/5.gif b/Zim/Research/u-boot/U-boot源代码全分析系列/MPC8314_(e300核)_uboot_调试_一/5.gif new file mode 100644 index 0000000..e0fc38a Binary files /dev/null and b/Zim/Research/u-boot/U-boot源代码全分析系列/MPC8314_(e300核)_uboot_调试_一/5.gif differ diff --git a/Zim/Research/u-boot/U-boot源代码全分析系列/MPC8314_(e300核)_uboot_调试_一/6.gif b/Zim/Research/u-boot/U-boot源代码全分析系列/MPC8314_(e300核)_uboot_调试_一/6.gif new file mode 100644 index 0000000..6159b6f Binary files /dev/null and b/Zim/Research/u-boot/U-boot源代码全分析系列/MPC8314_(e300核)_uboot_调试_一/6.gif differ diff --git a/Zim/Research/u-boot/U-boot源代码全分析系列/MPC8314_(e300核)_uboot_调试_一/7.gif b/Zim/Research/u-boot/U-boot源代码全分析系列/MPC8314_(e300核)_uboot_调试_一/7.gif new file mode 100644 index 0000000..8a8b7fc Binary files /dev/null and b/Zim/Research/u-boot/U-boot源代码全分析系列/MPC8314_(e300核)_uboot_调试_一/7.gif differ diff --git a/Zim/Research/u-boot/U-boot源代码全分析系列/U-Boot源码分析之Makefile.txt b/Zim/Research/u-boot/U-boot源代码全分析系列/U-Boot源码分析之Makefile.txt new file mode 100644 index 0000000..85f67df --- /dev/null +++ b/Zim/Research/u-boot/U-boot源代码全分析系列/U-Boot源码分析之Makefile.txt @@ -0,0 +1,261 @@ +Content-Type: text/x-zim-wiki +Wiki-Format: zim 0.4 +Creation-Date: 2012-01-15T19:25:07+08:00 + +====== U-Boot源码分析之Makefile ====== +Created Sunday 15 January 2012 + + 之前用过两个版本u-boot,分析过它的Start.S文件(PowerPC、ARM)源代码,也移植过内部的各部分硬件驱动及组件(串口、I2C、SPI、Flash文件系统、USB、DMA等)源码,自我感觉比较熟悉了。但最近逛CSDN论坛发现有不少人在问U-Boot中的Makefile的一些参数含义及配置方法,这才觉得忽视了U-Boot源码中最重要的组织者。正好,又在ChinaUnix上看见了一篇http://blog.chinaunix.net/u3/90973/showart_1815948.html,解析的是1.1.6版本,2410平台的Makefile。参考了一下,这里分析2011.6版,FreeScale的mpc83xx系列处理器平台。 + + u-boot的源代码包含了对几十种处理器、数百种开发板的支持,可是对于特定的开发板,配置编译过程只需要其中部分程序。这里就需要用到Makefile了。 +编译 + 以mpc8313erdb板为例,编译的过程分两部: +# make mpc8313erdb_config +# make +顶层Makefile分析 + 要了解一个LINUX工程的结构必须看懂Makefile,尤其是顶层的,没办法,UNIX世界就是这么无奈,什么东西都用文档去管理、配置。还是以mpc8313为例,顺序分析Makefile大致的流程及结构如下: + 1) Makefile中定义了源码及生成的目标文件存放的目录,目标文件存放目录BUILD_DIR可以通过make O=dir或者export BUILD_DIR=dir两种方式指定。如果没有指定,则设定为源码的根目录,一般编译的时候都建议指定输出目录,这样可以不影响其他的源码结构,便于管理,至于它的控制流程,每一步指令都有详细注释,感兴趣的可以看一下,再看下其它目录变量的定义: + +OBJTREE和LNDIR为存放生成文件的目录,TOPDIR与SRCTREE为源码所在目录 +OBJTREE := $(if $(BUILD_DIR),$(BUILD_DIR),$(CURDIR)) +SRCTREE := $(CURDIR) +TOPDIR := $(SRCTREE) +LNDIR := $(OBJTREE) +export TOPDIR SRCTREE OBJTREE + 2)定义变量MKCONFIG:这个变量指向一个脚本,即顶层目录的mkconfig。 +MKCONFIG := $(SRCTREE)/mkconfig +export MKCONFIG + 在编译U-BOOT之前,先要执行 +#make mpc8313erdb_33_config(u-boot中有两种主频的8313处理器,所以也要添加配置) +mpc8313erdb_33_config是Makefile的一个目标,定义如下: +mpc8313erdb_33_config : unconfig +@$(MKCONFIG) -a MPC8313ERDB ppc mpc8313 mpc8313erdb freescale +unconfig:: +@mkdir -p $(obj)include + + @if [ "$(findstring _33_,$@)" ] ; then \ + + $(XECHO) -n "...33M ..." ; \ + + echo "#define CFG_33MHZ" >>$(obj)include/config.h ; \ + + fi ; \ + + if [ "$(findstring _66_,$@)" ] ; then \ + + $(XECHO) -n "...66M..." ; \ + + echo "#define CFG_66MHZ" >>$(obj)include/config.h ; \ + + fi ; + + 显然,在执行# make mpc8313erdb_33__config时,先执行unconfig目标,注意不指定输出目标时,obj,src变量均为空,unconfig下面的命令清理上一次执行make *_config时生成的头文件和makefile的包含文件。主要是include/config.h和include/config.tmp文件。 + 然后才执行命令@$(MKCONFIG) -a MPC8313ERDB ppc mpc8313 mpc8313erdb freescale +MKCONFIG 是顶层目录下的mkcofig脚本文件,后面五个是传入的参数。 + 对于mpc8313erdb_33_config而言,mkconfig主要做三件事: +在include文件夹下建立相应的文件(夹)软连接,如果是PowerPC体系将执行以下操作: +#ln -s asm-ppc asm +#ln -s arch-mpc8313erdb asm-ppc + +生成Makefile包含文件include/config.mk,内容很简单,定义了四个变量: +ARCH = ppc +CPU = mpc83xx +BOARD = mpc8313erdb + +VENDOR = freescale +生成include/config.h头文件,只有一行: +/* Automatically generated - do not edit */ +#include "config/ mpc8313erdb.h" + +mkconfig脚本文件的执行至此结束,继续分析Makefile剩下部分。 + 3)包含include/config.mk,其实也就相当于在Makefile里定义了上面四个变量而已。 + 4) 指定交叉编译器前缀: +ifeq ($(ARCH),ppc)#这里根据ARCH变量,指定编译器前缀。 +CROSS_COMPILE = ppc-8xx- +endif + 5)包含config.mk: +#包含顶层目录下的config.mk,这个文件里面主要定义了交叉编译器及选项和编译规则 +# load other configuration +include $(TOPDIR)/config.mk + 下面分析config.mk的内容: +@包含体系,开发板,CPU特定的规则文件: +ifdef ARCH #指定预编译体系结构选项 +sinclude $(TOPDIR)/$(ARCH)_config.mk # include architecture dependend rules +endif +ifdef CPU #定义编译时对齐,浮点等选项 +sinclude $(TOPDIR)/cpu/$(CPU)/config.mk # include CPU specific rules +endif +ifdef SOC #没有这个文件 +sinclude $(TOPDIR)/cpu/$(CPU)/$(SOC)/config.mk # include SoC specific rules +endif +ifdef BOARD #指定特定板子的镜像连接时的内存基地址,重要! +sinclude $(TOPDIR)/board/$(BOARDDIR)/config.mk # include board specific rules +endif +@定义交叉编译链工具 +# Include the make variables (CC, etc...) +# +AS = $(CROSS_COMPILE)as +LD = $(CROSS_COMPILE)ld +CC = $(CROSS_COMPILE)gcc +CPP = $(CC) -E +AR = $(CROSS_COMPILE)ar +NM = $(CROSS_COMPILE)nm +STRIP = $(CROSS_COMPILE)strip +OBJCOPY = $(CROSS_COMPILE)objcopy +OBJDUMP = $(CROSS_COMPILE)objdump +RANLIB = $(CROSS_COMPILE)RANLIB +@定义AR选项ARFLAGS,调试选项DBGFLAGS,优化选项OPTFLAGS + 预处理选项CPPFLAGS,C编译器选项CFLAGS,连接选项LDFLAGS + LDFLAGS += -Bstatic -T $(LDSCRIPT) -Ttext $(TEXT_BASE) $(PLATFORM_LDFLAGS)  + +指定了起始地址TEXT_BASE +@指定编译规则: +$(obj)%.s: %.S +$(CPP) $(AFLAGS) -o $@ $ +回到顶层makefile文件: +6)U-boot需要的目标文件。 +OBJS = cpu/$(CPU)/start.o # 顺序很重要,start.o必须放第一位 + +OBJS := $(addprefix $(obj),$(OBJS)) + 7)需要的库文件: +LIBS = lib_generic/libgeneric.a +LIBS += $(shell if [ -f board/$(VENDOR)/common/Makefile ]; then echo \ + + "board/$(VENDOR)/common/lib$(VENDOR).a"; fi) 上面的意思是根据厂商选择编译通用文件,这里为freescale +LIBS += cpu/$(CPU)/lib$(CPU).a +LIBS += lib_$(ARCH)/lib$(ARCH).a +LIBS += fs/cramfs/libcramfs.a fs/fat/libfat.a fs/fdos/libfdos.a fs/jffs2/libjffs2.a \ + + fs/reiserfs/libreiserfs.a fs/ext2/libext2fs.a + +LIBS += net/libnet.a + +LIBS += disk/libdisk.a + +LIBS += drivers/bios_emulator/libatibiosemu.a + +LIBS += drivers/block/libblock.a + +LIBS += drivers/dma/libdma.a + +LIBS += drivers/hwmon/libhwmon.a + +LIBS += drivers/i2c/libi2c.a + +LIBS += drivers/input/libinput.a + +LIBS += drivers/misc/libmisc.a + +LIBS += drivers/mmc/libmmc.a + +LIBS += drivers/mtd/libmtd.a + +LIBS += drivers/mtd/nand/libnand.a + +LIBS += drivers/mtd/nand_legacy/libnand_legacy.a + +LIBS += drivers/mtd/onenand/libonenand.a + +LIBS += drivers/mtd/spi/libspi_flash.a + +LIBS += drivers/net/libnet.a + +LIBS += drivers/net/sk98lin/libsk98lin.a + +LIBS += drivers/pci/libpci.a + +LIBS += drivers/pcmcia/libpcmcia.a + +LIBS += drivers/spi/libspi.a + +ifeq ($(CPU),mpc83xx) + +LIBS += drivers/qe/qe.a + +endif +LIBS += drivers/rtc/librtc.a + +LIBS += drivers/serial/libserial.a + +LIBS += drivers/usb/libusb.a + +LIBS += drivers/video/libvideo.a + +LIBS += common/libcommon.a + +LIBS += libfdt/libfdt.a + +LIBS += api/libapi.a + +LIBS += post/libpost.a + +LIBS := $(addprefix $(obj),$(LIBS)) + +.PHONY : $(LIBS) $(VERSION_FILE) + +LIBBOARD = board/$(BOARDDIR)/lib$(BOARD).a + +LIBBOARD := $(addprefix $(obj),$(LIBBOARD)) + +根据上面的include/config.mk文件定义的ARCH、CPU、BOARD、SOC这些变量。硬件平台依赖的目录文件可以根据这些定义来确定。 + 8)最终生成的各种镜像文件: +ALL = $(obj)u-boot.srec $(obj)u-boot.bin $(obj)System.map $(U_BOOT_NAND) $(U_BOOT_ONENAND) +all: $(ALL) +$(obj) u-boot.bin: $(obj)u-boot + + $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@ +分析一下最关键的u-boot ELF文件镜像的生成: + +依赖目标depend :生成各个子目录的.depend文件,.depend列出每个目标文件的依赖文件。生成方法,调用每个子目录的make _depend。 +depend dep: $(VERSION_FILE) + +for dir in $(SUBDIRS) ; do $(MAKE) -C $$dir _depend ; done +@依赖目标version:生成版本信息到版本文件VERSION_FILE中。 +$(VERSION_FILE): + +@( printf '#define U_BOOT_VERSION "U-Boot %s%s"\n' "$(U_BOOT_VERSION)" \ + +'$(shell $(CONFIG_SHELL) $(TOPDIR)/tools/setlocalversion $(TOPDIR))' \ + +) > $@.tmp + +@cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@ +@伪目标SUBDIRS: 执行tools ,examples ,post,post\cpu 子目录下面的make文件。 +SUBDIRS = tools \ + examples \ + post \ + post/cpu +.PHONY : $(SUBDIRS) +$(SUBDIRS): + $(MAKE) -C $@ all +@依赖目标$(OBJS),即cpu/start.o +$(OBJS): + $(MAKE) -C cpu/$(CPU) $(if $(REMOTE_BUILD),$@,$(notdir $@)) +@依赖目标$(LIBS),这个目标太多,都是每个子目录的库文件*.a ,通过执行相应子目录下的make来完成: +$(LIBS): + $(MAKE) -C $(dir $(subst $(obj),,$@)) +@依赖目标$(LDSCRIPT): +$(LDSCRIPT): depend $(obj)include/autoconf.mk + +$(MAKE) -C $(dir $@) $(notdir $@) +LDFLAGS += -Bstatic -T $(LDSCRIPT) -Ttext $(TEXT_BASE) $(PLATFORM_LDFLAGS) +对于mpc8313,LDSCRIPT即连接脚本文件是board/freescale/mpc8313erdb/u-boot.lds,定义了连接时各个目标文件是如何组织的。 + +@执行连接命令: +cd $(LNDIR) && $(LD) $(LDFLAGS) $$UNDEF_SYM $(__OBJS) \ + --start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \ + -Map u-boot.map -o u-boot +其实就是把start.o和各个子目录makefile生成的库文件按照LDFLAGS连接在一起,生成ELF文件u-boot 和连接时内存分配图文件u-boot.map。 +9)对于各子目录的makefile文件,主要是生成*.o文件然后执行AR生成对应的库文件。如lib_generic文件夹Makefile: +LIB = $(obj)libgeneric.a +COBJS = bzlib.o bzlib_crctable.o bzlib_decompress.o \ + bzlib_randtable.o bzlib_huffman.o \ + crc32.o ctype.o display_options.o ldiv.o \ + string.o vsprintf.o zlib.o +SRCS := $(COBJS:.o=.c) +OBJS := $(addprefix $(obj),$(COBJS)) +$(LIB): $(obj).depend $(OBJS) #项层Makefile执行make libgeneric.a +$(AR) $(ARFLAGS) $@ $(OBJS) + 整个makefile剩下的内容全部是各种不同的开发板的*_config:目标的定义了。 + 概括起来,工程的编译流程也就是通过执行执行一个make *_config传入ARCH,CPU,BOARD,VENDOR参数,mkconfig根据参数将include头文件夹相应的头文件夹连接好,生成config.h。然后执行make分别调用各子目录的makefile 生成所有的obj文件和obj库文件*.a,最后连接所有目标文件,生成镜像。不同格式的镜像都是调用相应工具由elf镜像直接或者间接生成的。 + 剩下的工作就是分析U-Boot源代码了,有兴趣的可以看下我对Start.S分析的文章。 diff --git a/Zim/Research/vanet.txt b/Zim/Research/vanet.txt new file mode 100644 index 0000000..0f577a5 --- /dev/null +++ b/Zim/Research/vanet.txt @@ -0,0 +1,7 @@ +Content-Type: text/x-zim-wiki +Wiki-Format: zim 0.4 +Creation-Date: 2012-08-10T13:58:34+08:00 + +====== vanet ====== +Created Friday 10 August 2012 + diff --git a/Zim/Research/vanet/MPC8315E-RDB启动输出.txt b/Zim/Research/vanet/MPC8315E-RDB启动输出.txt new file mode 100644 index 0000000..9c1926f --- /dev/null +++ b/Zim/Research/vanet/MPC8315E-RDB启动输出.txt @@ -0,0 +1,268 @@ +Content-Type: text/x-zim-wiki +Wiki-Format: zim 0.4 +Creation-Date: 2012-06-25T19:48:32+08:00 + +====== MPC8315E-RDB启动输出 ====== +Created Monday 25 June 2012 + + +U-Boot 2009.03-rc2 (Aug 04 2012 - 17:31:28) MPC83XX + +Reset Status: + +CPU: e300c3, MPC8315, Rev: 1.2 at 400 MHz, CSB: 133.333 MHz +Board: Freescale MPC8315ERDB Rev +I2C: ready +DRAM: 512 MB +FLASH: 8 MB +NAND: 32 MiB +PCIE0: No link +PCIE1: No link +In: serial +Out: serial +Err: serial +Net: eTSEC0 +Hit any key to stop autoboot: 0 +=> tftp 1000000 uImage +Speed: 100, full duplex +Using eTSEC0 device +TFTP from server 192.168.2.102; our IP address is 192.168.2.33 +Filename 'uImage'. +Load address: 0x1000000 +Loading: ################################################################# + ################################################################# +done +Bytes transferred = 1902018 (1d05c2 hex) +=> tftp 2000000 rootfs.ext2.gz.uboot +Speed: 100, full duplex +Using eTSEC0 device +TFTP from server 192.168.2.102; our IP address is 192.168.2.33 +Filename 'rootfs.ext2.gz.uboot'. +Load address: 0x2000000 +Loading: ################################################################# + ################################################################# + ################################################################# + ################################################################# + ################################################################# + ################################################################# + ################################################################# + ################################################################# + ######### +done +Bytes transferred = 7761685 (766f15 hex) +=> tftp c00000 mpc8315.dtb +Speed: 100, full duplex +Using eTSEC0 device +TFTP from server 192.168.2.102; our IP address is 192.168.2.33 +Filename 'mpc8315.dtb'. +Load address: 0xc00000 +Loading: ## +done +Bytes transferred = 20000 (4e20 hex) +=> bootm 1000000 2000000 c00000 +## Booting kernel from Legacy Image at 01000000 ... + Image Name: Linux-3.2.4-g390c4dd + Created: 2012-08-08 8:44:26 UTC + Image Type: PowerPC Linux Kernel Image (gzip compressed) + Data Size: 1901954 Bytes = 1.8 MB + Load Address: 00000000 + Entry Point: 00000000 + Verifying Checksum ... OK +## Loading init Ramdisk from Legacy Image at 02000000 ... + Image Name: uboot ext2 ramdisk rootfs + Created: 2012-08-08 9:29:42 UTC + Image Type: PowerPC Linux RAMDisk Image (gzip compressed) + Data Size: 7761621 Bytes = 7.4 MB + Load Address: 00000000 + Entry Point: 00000000 + Verifying Checksum ... OK +## Flattened Device Tree blob at 00c00000 + Booting using the fdt blob at 0xc00000 + Uncompressing Kernel Image ... OK + Loading Ramdisk to 1f7c2000, end 1ff28ed5 ... OK + Loading Device Tree to 007f8000, end 007ffe1f ... OK +Using MPC831x RDB machine description +Cannot reserve gpages without hugetlb enabled +Linux version 3.2.4-g390c4dd (geekard@kb310) (gcc version 4.7.1 (GCC) ) #2 Wed Aug 8 16:44:25 CST 2012 +Found initrd at 0xdf7c2000:0xdff28ed5 +bootconsole [udbg0] enabled +setup_arch: bootmem +mpc831x_rdb_setup_arch() +Found FSL PCI host bridge at 0x00000000e0008500. Firmware bus number: 0->0 +PCI host bridge /pci@e0008500 (primary) ranges: + MEM 0x0000000090000000..0x000000009fffffff -> 0x0000000090000000 + MEM 0x0000000080000000..0x000000008fffffff -> 0x0000000080000000 Prefetch + IO 0x00000000e0300000..0x00000000e03fffff -> 0x0000000000000000 +arch: exit +Zone PFN ranges: + DMA 0x00000000 -> 0x00020000 + Normal empty +Movable zone start PFN for each node +early_node_map[1] active PFN ranges + 0: 0x00000000 -> 0x00020000 +Built 1 zonelists in Zone order, mobility grouping on. Total pages: 130048 +Kernel command line: root=/dev/ram rw console=ttyS0,115200 ramdisk_size=22242 +PID hash table entries: 2048 (order: 1, 8192 bytes) +Dentry cache hash table entries: 65536 (order: 6, 262144 bytes) +Inode-cache hash table entries: 32768 (order: 5, 131072 bytes) +Memory: 508204k/524288k available (3692k kernel code, 16084k reserved, 136k data, 80k bss, 164k init) +Kernel virtual memory layout: +* 0xfffdf000..0xfffff000 : fixmap +* 0xfdefb000..0xfe000000 : early ioremap +* 0xe1000000..0xfdefb000 : vmalloc & ioremap +NR_IRQS:512 nr_irqs:512 16 +IPIC (128 IRQ sources) at e1000700 +clocksource: timebase mult[7800001] shift[22] registered +pid_max: default: 32768 minimum: 301 +Mount-cache hash table entries: 512 +NET: Registered protocol family 16 + +PCI: Probing PCI hardware +bio: create slab at 0 +vgaarb: loaded +SCSI subsystem initialized +Switching to clocksource timebase +NET: Registered protocol family 2 +IP route cache hash table entries: 4096 (order: 2, 16384 bytes) +TCP established hash table entries: 16384 (order: 5, 131072 bytes) +TCP bind hash table entries: 16384 (order: 4, 65536 bytes) +TCP: Hash tables configured (established 16384 bind 16384) +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: 7580k freed +WDT driver for MPC8xxx initialized. mode:reset timeout=65535 (32 seconds) +JFFS2 version 2.2. (NAND) �© 2001-2006 Red Hat, Inc. +msgmni has been set to 1007 +io scheduler noop registered +io scheduler deadline registered +io scheduler cfq registered (default) +Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled +serial8250.0: ttyS0 at MMIO 0xe0004500 (irq = 16) is a 16550A +console [ttyS0] enabled, bootconsole disabled +console [ttyS0] enabled, bootconsole disabled +serial8250.0: ttyS1 at MMIO 0xe0004600 (irq = 17) is a 16550A +brd: module loaded +loop: module loaded +fsl-sata e0018000.sata: Sata FSL Platform/CSB Driver init +scsi0 : sata_fsl +ata1: SATA max UDMA/133 irq 44 +fsl-sata e0019000.sata: Sata FSL Platform/CSB Driver init +scsi1 : sata_fsl +ata2: SATA max UDMA/133 irq 45 +fe000000.flash: Found 1 x16 devices at 0x0 in 16-bit bank. Manufacturer ID 0x000001 Chip ID 0x000c01 +Amd/Fujitsu Extended Query Table at 0x0040 + Amd/Fujitsu Extended Query version 1.3. +number of CFI chips: 1 +4 ofpart partitions found on MTD device fe000000.flash +Creating 4 MTD partitions on "fe000000.flash": +0x000000000000-0x000000100000 : "u-boot" +0x000000100000-0x000000500000 : "fs" +0x000000500000-0x000000700000 : "kernel" +0x000000700000-0x000000800000 : "dtb" +NAND device: Manufacturer ID: 0xec, Chip ID: 0x75 (Samsung NAND 32MiB 3,3V 8-bit) +Bad block table found at page 65504, version 0x01 +Bad block table found at page 65472, version 0x01 +nand_read_bbt: bad block at 0x0000000a8000 +nand_read_bbt: bad block at 0x0000000ac000 +nand_read_bbt: bad block at 0x0000000b0000 +nand_read_bbt: bad block at 0x0000000b4000 +6 ofpart partitions found on MTD device e0600000.flash +Creating 6 MTD partitions on "e0600000.flash": +0x000000000000-0x000000100000 : "U-Boot-NAND" +0x000000100000-0x000000900000 : "JFFS2-NAND" +0x000000900000-0x000000d00000 : "Ramdisk-NAND" +0x000000d00000-0x000001d00000 : "Reserved-NAND" +0x000001d00000-0x000001f00000 : "Kernel-NAND" +0x000001f00000-0x000002000000 : "DTB-NAND" +eLBC NAND device at 0xe0600000, bank 1 +Freescale PowerQUICC MII Bus: probed +mdio_bus mdio@e0024520: error probing PHY at address 0 +Freescale PowerQUICC MII Bus: probed +fsl-gianfar e0024000.ethernet: eth0: mac: 04:00:00:00:00:0a +fsl-gianfar e0024000.ethernet: eth0: Running with NAPI enabled +fsl-gianfar e0024000.ethernet: eth0: RX BD ring size for Q[0]: 256 +fsl-gianfar e0024000.ethernet: eth0: TX BD ring size for Q[0]: 256 +fsl-gianfar e0025000.ethernet: eth1: mac: 04:00:00:00:00:0b +fsl-gianfar e0025000.ethernet: eth1: Running with NAPI enabled +fsl-gianfar e0025000.ethernet: eth1: RX BD ring size for Q[0]: 256 +fsl-gianfar e0025000.ethernet: eth1: TX BD ring size for Q[0]: 256 +i2c /dev entries driver +mpc-i2c e0003000.i2c: timeout 1000000 us +rtc-ds1307 0-0068: SET TIME! +rtc-ds1307 0-0068: rtc core: registered ds1339 as rtc0 +TCP cubic registered +NET: Registered protocol family 17 +Registering the dns_resolver key type +rtc-ds1307 0-0068: setting system clock to 2000-01-01 00:00:00 UTC (946684800) +ata1: No Device OR PHYRDY change,Hstatus = 0xa0000000 +ata1: SATA link down (SStatus 0 SControl 300) +ata2: No Device OR PHYRDY change,Hstatus = 0xa0000000 +ata2: SATA link down (SStatus 0 SControl 300) +RAMDISK: gzip image found at block 0 +VFS: Mounted root (ext2 filesystem) on device 1:0. +Freeing unused kernel memory: 164k freed +Mounting /proc and /sys +Starting the hotplug events dispatcher udevd +Synthesizing initial hotplug eveudevd (859): /proc/859/oom_adj is deprecated, please use /proc/859/oom_score_adj instead. +nts +cfg80211: Calling CRDA to update world regulatory domain +cfg80211: World regulatory domain updated: +cfg80211: (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp) +cfg80211: (2402000 KHz - 2472000 KHz @ 40000 KHz), (300 mBi, 2000 mBm) +cfg80211: (2457000 KHz - 2482000 KHz @ 20000 KHz), (300 mBi, 2000 mBm) +cfg80211: (2474000 KHz - 2494000 KHz @ 20000 KHz), (300 mBi, 2000 mBm) +cfg80211: (5170000 KHz - 5250000 KHz @ 40000 KHz), (300 mBi, 2000 mBm) +cfg80211: (5735000 KHz - 5835000 KHz @ 40000 KHz), (300 mBi, 2000 mBm) +ath5k 0000:00:0e.0: registered as 'phy0' +ath5k channel bandwidth setting 10MHz default +VANET-debug: ieee80211_register_hw +VANET-debug: ieee80211_rate_control_ops_get select minstrel_ht +VANET-debug: register vanet network interface +VANET-debug: ieee80211_if_add, name: ath5k%d +ath5k phy0: Atheros AR5414 chip found (MAC: 0xa5, PHY: 0x61) +cfg80211: Calling CRDA for country: US +cfg80211: Regulatory domain changed to country: US +cfg80211: (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp) +cfg80211: (2402000 KHz - 2472000 KHz @ 40000 KHz), (300 mBi, 2700 mBm) +cfg80211: (5170000 KHz - 5250000 KHz @ 40000 KHz), (300 mBi, 1700 mBm) +cfg80211: (5250000 KHz - 5330000 KHz @ 40000 KHz), (300 mBi, 2000 mBm) +cfg80211: (5490000 KHz - 5600000 KHz @ 40000 KHz), (300 mBi, 2000 mBm) +cfg80211: (5650000 KHz - 5710000 KHz @ 40000 KHz), (300 mBi, 2000 mBm) +cfg80211: (5735000 KHz - 5835000 KHz @ 40000 KHz), (300 mBi, 3000 mBm) +Setting the hostname to mpc8315erdb +Mounting filesystems +mount: mounting usbfs on /proc/bus/usb failed: No such file or directory +Starting syslogd and klogd +Running sysctl +Setting up networking on loopback device: + +Warning: no IPADDR is set, please set this from the ltib +config screen, or directly in /etc/rc.d/rc.conf. +IP address setup bypassed + +Setting up networking on eth1: +Starting inetd: + + + Welcome to the LTIB Embedded Linux Environment + +!!!!! WARNING !!!!!!! + +The default password for the root account is: root +please change this password using the 'passwd' command +and then edit this message (/etc/issue) to remove this message + +mpc8315erdb login: PHY: mdio@e0024520:01 - Link is Up - 100/Full +root +Password: +[root@mpc8315erdb root]# uname -a +Linux mpc8315erdb 3.2.4-g390c4dd #2 Wed Aug 8 16:44:25 CST 2012 ppc GNU/Linux +[root@mpc8315erdb root]# diff --git a/Zim/Research/vanet/uboot打印的板子信息.txt b/Zim/Research/vanet/uboot打印的板子信息.txt new file mode 100644 index 0000000..2c91da0 --- /dev/null +++ b/Zim/Research/vanet/uboot打印的板子信息.txt @@ -0,0 +1,85 @@ +Content-Type: text/x-zim-wiki +Wiki-Format: zim 0.4 +Creation-Date: 2012-08-10T13:58:44+08:00 + +====== uboot打印的板子信息 ====== +Created Friday 10 August 2012 + +**=> clocks** +Clock configuration: + Core: 400 MHz + Coherent System Bus: 133.333 MHz + Local Bus Controller:133.333 MHz + Local Bus: 66.667 MHz + DDR: 266.667 MHz + SEC: 133.333 MHz + I2C1: 133.333 MHz + I2C2: 133.333 MHz + TDM: 133.333 MHz + TSEC1: 133.333 MHz + TSEC2: 133.333 MHz + USB DR: 133.333 MHz + SATA: 133.333 MHz +=> +**=> coninfo** +List of available devices: +serial 80000003 SIO stdin stdout stderr +=> + +**=> flinfo #NOR flash信息** + +Bank # 1: CFI conformant FLASH (16 x 16) Size: 8 MB in 128 Sectors + AMD Standard command set, Manufacturer ID: 0x01, Device ID: 0x227E + Erase timeout: 16384 ms, write timeout: 2 ms + Buffer write timeout: 5 ms, buffer size: 32 bytes + + Sector Start Addresses: + FE000000 RO FE010000 RO FE020000 RO FE030000 RO FE040000 RO + FE050000 FE060000 RO FE070000 FE080000 FE090000 + FE0A0000 FE0B0000 FE0C0000 FE0D0000 FE0E0000 + FE0F0000 FE100000 FE110000 FE120000 FE130000 + FE140000 FE150000 FE160000 FE170000 FE180000 + FE190000 FE1A0000 FE1B0000 FE1C0000 FE1D0000 + FE1E0000 FE1F0000 FE200000 FE210000 FE220000 + FE230000 FE240000 FE250000 FE260000 FE270000 + FE280000 FE290000 FE2A0000 FE2B0000 FE2C0000 + FE2D0000 FE2E0000 FE2F0000 FE300000 FE310000 + FE320000 FE330000 FE340000 FE350000 FE360000 + FE370000 FE380000 FE390000 FE3A0000 FE3B0000 + FE3C0000 FE3D0000 FE3E0000 FE3F0000 FE400000 + FE410000 FE420000 FE430000 FE440000 FE450000 + FE460000 FE470000 FE480000 FE490000 FE4A0000 + FE4B0000 FE4C0000 FE4D0000 FE4E0000 FE4F0000 + FE500000 FE510000 FE520000 FE530000 FE540000 + FE550000 FE560000 FE570000 FE580000 FE590000 + FE5A0000 FE5B0000 FE5C0000 FE5D0000 FE5E0000 + FE5F0000 FE600000 FE610000 FE620000 FE630000 + FE640000 FE650000 FE660000 FE670000 FE680000 + FE690000 FE6A0000 FE6B0000 FE6C0000 FE6D0000 + FE6E0000 FE6F0000 FE700000 FE710000 FE720000 + FE730000 FE740000 FE750000 FE760000 FE770000 + FE780000 FE790000 FE7A0000 FE7B0000 FE7C0000 + FE7D0000 FE7E0000 FE7F0000 +=> +**=> tftp 1000000 uImage** +Speed: 100, full duplex +Using eTSEC0 device +TFTP from server 192.168.2.101; our IP address is 192.168.2.33 +Filename 'uImage'. +Load address: 0x1000000 +Loading: ################################################################# + ################################################################# +done +Bytes transferred = 1902018 (1d05c2 hex) +**=> iminfo 1000000 #查看Image的header info。** + +## Checking Image at 01000000 ... + Legacy image found + Image Name: Linux-3.2.4-g390c4dd + Created: 2012-08-08 8:44:26 UTC + Image Type: PowerPC Linux Kernel Image (gzip compressed) + Data Size: 1901954 Bytes = 1.8 MB + Load Address: 00000000 + Entry Point: 00000000 + Verifying Checksum ... OK +=> diff --git a/Zim/Research/vanet/从nor自动启动.txt b/Zim/Research/vanet/从nor自动启动.txt new file mode 100644 index 0000000..4e78a1b --- /dev/null +++ b/Zim/Research/vanet/从nor自动启动.txt @@ -0,0 +1,10 @@ +Content-Type: text/x-zim-wiki +Wiki-Format: zim 0.4 +Creation-Date: 2012-08-11T18:06:55+08:00 + +====== 从nor自动启动 ====== +Created Saturday 11 August 2012 + +从NOR Flash启动的话,需要将uboot, uImage,rootfs和dtb分别烧写到flash中。 +启动时,只需将后面三者在flash中的起始地址传给bootm即可。具体过程如下: + diff --git a/Zim/Research/vanet/使用minicom向uboot下载文件.txt b/Zim/Research/vanet/使用minicom向uboot下载文件.txt new file mode 100644 index 0000000..b0c2c3a --- /dev/null +++ b/Zim/Research/vanet/使用minicom向uboot下载文件.txt @@ -0,0 +1,16 @@ +Content-Type: text/x-zim-wiki +Wiki-Format: zim 0.4 +Creation-Date: 2012-08-10T14:24:46+08:00 + +====== 使用minicom向uboot下载文件 ====== +Created Friday 10 August 2012 + +1. 设置好minicom的环境,如[[../../Error_Notes/下载错误/minicom乱码.txt]] +2. 复位开发板,启动uboot,在命令行界面输入loady命令,这是uboot处于文件下载等待状态。注意,必须先在minicom环境中与uboot相连而且使uboot处于 + 等待状态后才进行第三步. +3. 如下配置minicom的文件传输: + a. Ctrl + a进入minicom的配置环境。 + b. 按s, 进入send file配置界面。 + c. 选择列表中的ymodem协议模式 + d. 这时出现“待上传的文件选择列表”菜单,使用上下键在目录项中移动,按两次空格进入光标所在的目录,然后按一次空格选中文件,确保[Okey]被选中 +然后按回车。 这时会出现文件上传的进度窗口。 diff --git a/Zim/Research/vanet/制作jffs2根文件系统.txt b/Zim/Research/vanet/制作jffs2根文件系统.txt new file mode 100644 index 0000000..f03d4f0 --- /dev/null +++ b/Zim/Research/vanet/制作jffs2根文件系统.txt @@ -0,0 +1,91 @@ +Content-Type: text/x-zim-wiki +Wiki-Format: zim 0.4 +Creation-Date: 2012-08-11T18:43:56+08:00 + +====== 制作jffs2根文件系统 ====== +Created Saturday 11 August 2012 + +http://www.embedu.org/Column/Column17.htm + +JFFS2是Flash上应用最广的一个日志结构文件系统。它提供的垃圾回收机制,不需要马上对擦写越界的块进行擦写,而只需要将其设置一个标志,标明为脏块,当可用的块数不足时,垃圾回收机制才开始回收这些节点。同时,由于JFFS2基于日志结构,在意外掉电后仍然可以保持数据的完整性,而不会丢失数据。 + +本文阐述如何在nand flash上实现JFFS2根文件文件系统。实验环境是:FS2410开发平台及ubantu7.04主机环境。 + +**1.下载MTD工具包** +制作jffs2根文件系统需要使用__mtd-utils__软件包提供的**mkfs.jffs2**命令,所以先要安装该软件包。完成此步骤后,系统中就有了mkfs.jffs2的工具。注意:这个工具不同于mkfs.ext2工具,它只能制作相应的JFFS2文件系统的镜像,__而不具有进行格式化的功能__,而mkfs.ext2具备这以上两种功能。然后用这个工具就可以制作JFFS2文件系统的镜像了。 + +**2、制作JFFS2文件镜像** + +实验平台用到的nand flash 是K9F1208,在制作镜像过程添加的参数需要和它对应。 + +farsight#mkfs.jffs2 -r /source/rootfs -o rootfs.jffs2 **-e 0x4000** **--pad=0x800000** -n + +这样就会生成一个8M大小的rootfs.jffs2的镜像,它也正是JFFS2文件系统的镜像,关于这个命令行里的选项的内容,可以用man a mkfs.jffs2命令来查看内容。 +也可以参考:[[../../Error_Notes/jffs2_scan_eraseblock()_Magic_bitmask_0x1985_not_found_at.txt]] + +JFFS2 维护了几个链表来管理擦写块,根据擦写块上的内容,一个擦写块会在不同的链表上。具体来说,当一个擦写块上都是合法(valid)的节点时,它会在 clean_list 上;当一个擦写块包含至少一个过时(obsolete)的节点时,它会在 dirty_list 上;当一个擦写块被擦写完毕,并被写入 CLEANMARKER 节点后,它会在 free_list 上。而当你在挂载这个文件系统的时候,如果出现CLEANMARKER node found at 0x0042c000 has totlen 0xc != normal 0x0的警告的时候,可以加一个“-n”的选项,这个主要是由于针对Nand Flash不需要在每个擦除块的开始写入CLEANMARKER 节点。 + +**3、设置内核启动参数** + +本处用的bootloader是U-BOOT.所以在U-BOOT的命令终端设置如下: + +FS2410#setenv bootargs __root=/dev/mtdblock2 rootfstype=jffs2__ rw console=ttySAC0,115200 + +__注意:bootargs参数是传给kernel的启动参数,设备分区mtdblock2所对应的flash空间是通过设备树文件指定的,在内核启动前要通过uboot等工具将制作的__ +__jffs2文件系统映像烧写到该空间中。__ + + +**4、配置内核支持JFFS2文件系统** + +File systems ---> Miscellaneous filesystems ---> + + <*>JournallingFlash File System v2 (JFFS2) support + + [*]JFFS2write-bufferingsupport + + [*]AdvancedcompressionoptionsforJFFS2 + + [*]JFFS2ZLIBcompressionsupport + + [*]JFFS2RTIMEcompressionsupport + + [*] JFFS2 RUBIN compression support + +**5、下载rootfs.jffs2镜像** + +通过uboot命令行,将jffs2映像__下载到Nand Flash第二个分区(Flash分区情况是由dtb文件指明的)__。 + +FS2410#nand erase 200000 800000 + +FS2410#nand write.jffs2 300008000 200000 800000 + +这里说明下关于nand flash操作的几个常用命令的含义 + +nand write:向Nand Flash写入数据,如果NandFlash相应的区域有坏块,则直接报错。 +nand write.jffs2:向Nand Flash写入数据,如果NandFlash相应的区域有坏块,可以跳过坏块。 +nand read:读取Nand Flash相应区域的数据,如果NandFlash相应的区域有坏块,则直接报错。 +nand read.jffs2s:读取Nand Flash相应区域的数据,如果NandFlash相应的区域有坏块,将对应坏块区域的缓冲填充0xff,然后跳过此坏块继续读取。 +nand read.jffs2:读取Nand Flash相应区域的数据,如果NandFlash相应的区域有坏块,直接跳过坏块。 + +具体的参考代码参看U-BOOT源码:common/cmd_nand.c文件。 + +下载完JFFS2文件系统镜像后,需要把Linux内核NandFlash的驱动关于第二个分区的大小改为8M(和镜像一样大,__对于MPC8315而言,由于使用了设备树文件,所以不需要修改内核__),否则会出现类似如下错误: + +Freeing init memory: 124K +Warning: unable to open an initial console. +Argh. Special inode #171 with mode 0xa1ff had more than one node +Kernel panic: No init found. Try passing init= option to kernel. +Argh. Specia inode #63 with mode 0xa1ff had more than one node +Returned error for crccheck of ino #63. Expect badness... +Argh. Special inode #67 with mode 0xa1ff had more than one node +Returned error for crccheck of ino #67. Expect badness... +Argh. Special inode #68 with mode 0xa1ff had more than one node + +到此,一个JFFS2文件系统的镜像制作成功。可以启动系统并测试JFFS2的性能了。还有一种制作JFFS2文件系统镜像的方法,在制作镜像的参数中可以不加—pad选项,过程如下: + +farsight#mkfs.jffs2 -r /source/rootfs -o rootfs.jffs2 -e 0x4000 -n + +启动开发板烧写rootfs.jffs2镜像 + +FS2410#**nand erase 200000 800000/**/(注意把整个存放文件系统的分区全部给擦除)。 +FS2410#**nand write.jffs2 30008000 200000 31a28c**//(必须是rootfs.jffs2的实际大小。如果是你写成了4M,那么分区的其余部分JFFS2文件系统将无法识别)。 diff --git a/Zim/Research/vanet/制作jffs2根文件系统并将其烧写到flash中.txt b/Zim/Research/vanet/制作jffs2根文件系统并将其烧写到flash中.txt new file mode 100644 index 0000000..2ac4b8b --- /dev/null +++ b/Zim/Research/vanet/制作jffs2根文件系统并将其烧写到flash中.txt @@ -0,0 +1,334 @@ +Content-Type: text/x-zim-wiki +Wiki-Format: zim 0.4 +Creation-Date: 2012-08-11T19:45:03+08:00 + +====== 制作jffs2根文件系统并将其烧写到flash中 ====== +Created Saturday 11 August 2012 + +1. **配置ltib**,指定生成的目标文件系统映像类型为__jffs2__,同时__erase block 大小与Flash datasheet上指定的一致__(这里为16KB): + --- Choose your root filesystem image type │ │ + │ │ Target image: __(jffs2)__ ---> │ │ + │ │ [ ] Run a command after building the target image │ │ + │ │ __(16)__ jffs2 erase block size in KB │ │ + │ │ [ ] read-only root filesystem │ │ + │ │ (512k) tmpfs size │ │ + │ │ (/tmp /var) Place these dirs in writable RAM │ │ + │ │ () rootfs target directory + +2. **复位开发板,进入uboot命令行状态** + +**3. 将生成的rootfs.jffs2映像下载到内存中** + +=> tftp 1000000 rootfs.jffs2 +Speed: 100, full duplex +Using eTSEC0 device +TFTP from server 192.168.2.105; our IP address is 192.168.2.100 +Filename 'rootfs.jffs2'. +Load address: 0x1000000 +Loading: ################################################################# + ################################################################# + ################################################################# + ################################################################# + ################################## +done +Bytes transferred = 4308992 (41c000 hex) + +**4.按照dtb中的Flash分区配置,擦出将要保存rootfs.jffs2文件的flash存储区域** +例如对于mpc8315dtb-defaults.dts中的配置如下: +flash@0,0 { #NOR flash + #address-cells = <0x1>; + #size-cells = <0x1>; + compatible = "cfi-flash"; + reg = <0x0 0x0 0x800000>; + bank-width = <0x2>; + device-width = <0x1>; + + u-boot@0 { + reg = <0x0 0x100000>; + read-only; + }; + + fs@100000 { + reg = <0x100000 0x400000>; + }; + + kernel@500000 { + reg = <0x500000 0x200000>; + }; + + dtb@700000 { + reg = <0x700000 0x100000>; + }; + }; + + nand@1,0 { + #address-cells = <0x1>; + #size-cells = <0x1>; + compatible = "fsl,mpc8315-fcm-nand", "fsl,elbc-fcm-nand"; + reg = <0x1 0x0 0x2000>; + + u-boot@0 { + reg = <0x0 0x100000>; + read-only; + label = "U-Boot-NAND"; + }; + + __jffs2@100000 {__ + reg = <0x100000 0x800000>; + label = "JFFS2-NAND"; + }; + + ramdisk@900000 { + reg = <0x900000 0x400000>; + label = "Ramdisk-NAND"; + }; + + reserved@d00000 { + reg = <0xd00000 0x1000000>; + label = "Reserved-NAND"; + }; + + kernel@1d00000 { + reg = <0x1d00000 0x200000>; + read-only; + label = "Kernel-NAND"; + }; + + dtb@1f00000 { + reg = <0x1f00000 0x100000>; + read-only; + label = "DTB-NAND"; + }; + }; +当我们想将rootfs.jffs2烧写到label为"JFFS2-NAND"的NAND Flash区域时,可以使用下列的擦出命令: +**=> nand erase 100000 800000** + +NAND erase: device 0 offset 0x100000, size 0x800000 +Bad block table found at page 65504, version 0x01 +Bad block table found at page 65472, version 0x01 +nand_read_bbt: Bad block at 0x000a8000 +nand_read_bbt: Bad block at 0x000ac000 +nand_read_bbt: Bad block at 0x000b0000 +nand_read_bbt: Bad block at 0x000b4000 +Erasing at 0x8fc000 -- 100% complete. +OK +=> + +5. **将下载到内存0x1000000开始的大小为$filesize的rootfs.jffs2文件烧写到NAND Flash 0x100000开始的地方。** +=> nand write 1000000 100000 $filesize + +NAND write: device 0 offset 0x100000, size 0x41c000 + 4308992 bytes written: OK +=> + +6. **设置kernel命令行参数,指定root为刚才烧写到的nand partition。** + => setenv bootargs __root=/dev/mtdblock5 rw rootfstype=jffs2__ console=ttyS0,115200 + +7. **设置uboot自动启动时的bootcmd参数,注意fe500000和fe700000两个flash内存区域事先已经用uboot命令行写入了uImage和mpc8315.dtb文件。** +=> setenv bootcmd bootm fe500000 - fe700000 +=> saveenv __#这样下次启动时,如果过了6秒时间uboot会按照bootcmd环境变量的值启动。__ +=>boot +## Booting kernel from Legacy Image at fe500000 ... + Image Name: Linux-3.2.4-gfd2812f + Created: 2012-08-10 7:58:18 UTC + Image Type: PowerPC Linux Kernel Image (gzip compressed) + Data Size: 1551548 Bytes = 1.5 MB + Load Address: 00000000 + Entry Point: 00000000 + Verifying Checksum ... OK +## Flattened Device Tree blob at fe700000 + Booting using the fdt blob at 0xfe700000 + Uncompressing Kernel Image ... OK + Loading Device Tree to 007f8000, end 007ffe1f ... OK +Using MPC831x RDB machine description +Cannot reserve gpages without hugetlb enabled +Linux version 3.2.4-gfd2812f (geekard@kb310) (gcc version 4.7.1 (GCC) ) #4 Fri Aug 10 15:58:17 CST 2012 +bootconsole [udbg0] enabled +setup_arch: bootmem +mpc831x_rdb_setup_arch() +Found FSL PCI host bridge at 0x00000000e0008500. Firmware bus number: 0->0 +PCI host bridge /pci@e0008500 (primary) ranges: + MEM 0x0000000090000000..0x000000009fffffff -> 0x0000000090000000 + MEM 0x0000000080000000..0x000000008fffffff -> 0x0000000080000000 Prefetch + IO 0x00000000e0300000..0x00000000e03fffff -> 0x0000000000000000 +arch: exit +Zone PFN ranges: + DMA 0x00000000 -> 0x00020000 + Normal empty +Movable zone start PFN for each node +early_node_map[1] active PFN ranges + 0: 0x00000000 -> 0x00020000 +Built 1 zonelists in Zone order, mobility grouping on. Total pages: 130048 +Kernel command line: root=/dev/mtdblock5 rw rootfstype=jffs2 console=ttyS0,115200 +PID hash table entries: 2048 (order: 1, 8192 bytes) +Dentry cache hash table entries: 65536 (order: 6, 262144 bytes) +Inode-cache hash table entries: 32768 (order: 5, 131072 bytes) +Memory: 516520k/524288k available (2992k kernel code, 7768k reserved, 124k data, 59k bss, 152k init) +Kernel virtual memory layout: + * 0xfffdf000..0xfffff000 : fixmap + * 0xfdefb000..0xfe000000 : early ioremap + * 0xe1000000..0xfdefb000 : vmalloc & ioremap +NR_IRQS:512 nr_irqs:512 16 +IPIC (128 IRQ sources) at e1000700 +clocksource: timebase mult[7800001] shift[22] registered +pid_max: default: 32768 minimum: 301 +Mount-cache hash table entries: 512 +NET: Registered protocol family 16 + +PCI: Probing PCI hardware +bio: create slab at 0 +vgaarb: loaded +SCSI subsystem initialized +Switching to clocksource timebase +NET: Registered protocol family 2 +IP route cache hash table entries: 4096 (order: 2, 16384 bytes) +TCP established hash table entries: 16384 (order: 5, 131072 bytes) +TCP bind hash table entries: 16384 (order: 4, 65536 bytes) +TCP: Hash tables configured (established 16384 bind 16384) +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 +WDT driver for MPC8xxx initialized. mode:reset timeout=65535 (32 seconds) +JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc. +msgmni has been set to 1008 +io scheduler noop registered +io scheduler deadline registered +io scheduler cfq registered (default) +Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled +serial8250.0: ttyS0 at MMIO 0xe0004500 (irq = 16) is a 16550A +console [ttyS0] enabled, bootconsole disabled +console [ttyS0] enabled, bootconsole disabled +serial8250.0: ttyS1 at MMIO 0xe0004600 (irq = 17) is a 16550A +brd: module loaded +loop: module loaded +fe000000.flash: Found 1 x16 devices at 0x0 in 16-bit bank. Manufacturer ID 0x000001 Chip ID 0x000c01 +Amd/Fujitsu Extended Query Table at 0x0040 + Amd/Fujitsu Extended Query version 1.3. +number of CFI chips: 1 +__4 ofpart partitions found on MTD device fe000000.flash #NOR Flash和NAND Flash中的分区情况是由dtb文件配置的。这只是一个指示,该分区是否含有jffs2文件系统映像则不确定(需要实现用上面的步骤烧入)。下面的分区标号从mtdblock0开始。__ +__Creating 4 MTD partitions on "fe000000.flash":__ +0x000000000000-0x000000100000 : "u-boot" +0x000000100000-0x000000500000 : "fs" +0x000000500000-0x000000700000 : "kernel" +0x000000700000-0x000000800000 : "dtb" + +NAND device: Manufacturer ID: 0xec, Chip ID: 0x75 (Samsung NAND 32MiB 3,3V 8-bit) +Bad block table found at page 65504, version 0x01 +Bad block table found at page 65472, version 0x01 +nand_read_bbt: bad block at 0x0000000a8000 +nand_read_bbt: bad block at 0x0000000ac000 +nand_read_bbt: bad block at 0x0000000b0000 +nand_read_bbt: bad block at 0x0000000b4000 +6 ofpart partitions found on MTD device e0600000.flash +Creating 6 MTD partitions on "e0600000.flash": +0x000000000000-0x000000100000 : "U-Boot-NAND" +0x000000100000-0x000000900000 : __"JFFS2-NAND" #对应的是mtdblock5__ +0x000000900000-0x000000d00000 : "Ramdisk-NAND" +0x000000d00000-0x000001d00000 : "Reserved-NAND" +0x000001d00000-0x000001f00000 : "Kernel-NAND" +0x000001f00000-0x000002000000 : "DTB-NAND" +eLBC NAND device at 0xe0600000, bank 1 +Freescale PowerQUICC MII Bus: probed +mdio_bus mdio@e0024520: error probing PHY at address 0 +Freescale PowerQUICC MII Bus: probed +fsl-gianfar e0024000.ethernet: eth0: mac: 04:00:00:00:00:0a +fsl-gianfar e0024000.ethernet: eth0: Running with NAPI enabled +fsl-gianfar e0024000.ethernet: eth0: RX BD ring size for Q[0]: 256 +fsl-gianfar e0024000.ethernet: eth0: TX BD ring size for Q[0]: 256 +fsl-gianfar e0025000.ethernet: eth1: mac: 04:00:00:00:00:0b +fsl-gianfar e0025000.ethernet: eth1: Running with NAPI enabled +fsl-gianfar e0025000.ethernet: eth1: RX BD ring size for Q[0]: 256 +fsl-gianfar e0025000.ethernet: eth1: TX BD ring size for Q[0]: 256 +i2c /dev entries driver +mpc-i2c e0003000.i2c: timeout 1000000 us +rtc-ds1307 0-0068: SET TIME! +rtc-ds1307 0-0068: rtc core: registered ds1339 as rtc0 +TCP cubic registered +NET: Registered protocol family 17 +Registering the dns_resolver key type +rtc-ds1307 0-0068: setting system clock to 2000-01-01 00:00:00 UTC (946684800) +__VFS: Mounted root (jffs2 filesystem) on device 31:5. #可以看到正确地挂载了mtdblock5设备为root。__ +Freeing unused kernel memory: 152k freed +Mounting /proc and /sys +Starting the hotplug events dispatcher mdev +Setting the hostname to mpc8315erdb +Mounting filesystems +mount: mounting usbfs on /proc/bus/usb failed: No such file or directory +Starting syslogd and klogd +Running sysctl +Setting up networking on loopback device: + +Warning: no IPADDR is set, please set this from the ltib +config screen, or directly in /etc/rc.d/rc.conf. +IP address setup bypassed + +Setting up networking on eth1: + + + Welcome to the LTIB Embedded Linux Environment + +!!!!! WARNING !!!!!!! + +The default password for the root account is: root +please change this password using the 'passwd' command +and then edit this message (/etc/issue) to remove this message + +mpc8315erdb login: PHY: mdio@e0024520:01 - Link is Up - 100/Full + + + Welcome to the LTIB Embedded Linux Environment + +!!!!! WARNING !!!!!!! + +The default password for the root account is: root +please change this password using the 'passwd' command +and then edit this message (/etc/issue) to remove this message + +mpc8315erdb login: root +Password: +[root@mpc8315erdb /root]# +[root@mpc8315erdb /root]# __ls /dev/mtd __ +mtd0 mtd2ro mtd5 mtd7ro mtdblock0 mtdblock5 +mtd0ro mtd3 mtd5ro mtd8 mtdblock1 mtdblock6 +mtd1 mtd3ro mtd6 mtd8ro mtdblock2 mtdblock7 +mtd1ro mtd4 mtd6ro mtd9 mtdblock3 mtdblock8 +mtd2 mtd4ro mtd7 mtd9ro mtdblock4 mtdblock9 +[root@mpc8315erdb /root]# cat [[/proc/mtd]] __#查看系统中所有的mtd分区情况__ +dev: size erasesize name +mtd0: 00100000 00010000 "u-boot" __#name和size是在dtb文件中配置的而eraseize是在制作jffs2映像时用-e参数指定的(LTIB有相应的配置选项)。__ +mtd1: 00400000 00010000 "fs" +mtd2: 00200000 00010000 "kernel" +mtd3: 00100000 00010000 "dtb" +mtd4: 00100000 00004000 "U-Boot-NAND" +__mtd5__: 00800000 __00004000__ "JFFS2-NAND" #注意,这里的erasesize并不准确,实际大小由相应的jffs2映像决定。 +mtd6: 00400000 00004000 "Ramdisk-NAND" +mtd7: 01000000 00004000 "Reserved-NAND" +mtd8: 00200000 00004000 "Kernel-NAND" +mtd9: 00100000 00004000 "DTB-NAND" +[root@mpc8315erdb /root]# cat /proc/filesystems +nodev sysfs +nodev rootfs +nodev bdev +nodev proc +nodev tmpfs +nodev sockfs +nodev pipefs +nodev anon_inodefs +nodev devpts + ext2 +nodev ramfs + vfat + msdos + iso9660 +__nodev jffs2 #内核的确支持jffs2文件系统__ +__nodev mtd_inodefs__ +[root@mpc8315erdb /root]# +[root@mpc8315erdb /root]# mkdir jffs2 +[root@mpc8315erdb /root]# mount -t jffs2 /dev/mtdblock5 jffs2/ __#将jffs2分区挂载到文件系统中。__ +[root@mpc8315erdb /root]# ls jffs2/ __#可见列出的内容即为我们制作的root分区。__ +bin etc lib mnt proc sbin sys usr +dev home linuxrc opt root smbshare tmp var +[root@mpc8315erdb /root]# + +然后就可以项jffs2目录中读写文件了,在掉电后这些文件的更改并不会丢失。 diff --git a/Zim/Research/vanet/烧写固件到NAND然后启动时读取.txt b/Zim/Research/vanet/烧写固件到NAND然后启动时读取.txt new file mode 100644 index 0000000..00b1826 --- /dev/null +++ b/Zim/Research/vanet/烧写固件到NAND然后启动时读取.txt @@ -0,0 +1,390 @@ +Content-Type: text/x-zim-wiki +Wiki-Format: zim 0.4 +Creation-Date: 2012-08-11T18:10:24+08:00 + +====== 烧写固件到NAND然后启动时读取 ====== +Created Saturday 11 August 2012 + +经过实验,板子的NOR Flash可以正常启动,但是从NAND Flash中启动失败。但是NAND Flash可以正常工作。 +所以,可以将NOR Flash作为启动设备,只保留uboot(或再加上uImage),而将其余的固件内容放到NAND中, +由uboot启动时读取到内存中。具体步骤如下: + +1. **查看uboot提供的nand命令语法** +=> help nand +nand info - show available NAND devices +nand device [dev] - show or set current device +nand read - addr off|partition size +nand write - addr off|partition size + read/write 'size' bytes starting at offset 'off' + to/from memory address 'addr', skipping bad blocks. +nand erase [clean] [off size] - erase 'size' bytes from + offset 'off' (entire device if not specified) +nand bad - show bad blocks +nand dump[.oob] off - dump page +nand scrub - really clean NAND erasing bad blocks (UNSAFE) +nand markbad off - mark bad block at offset (UNSAFE) +nand biterr off - make a bit error at offset (UNSAFE) + +**=> nand info** #查看nand设备信息 +Device 0: NAND 32MiB 3,3V 8-bit, sector size 16 KiB + +**=> nand erase #擦出整个设备(也可以指定擦出范围)** +NAND erase: device 0 whole chip +Bad block table found at page 65504, version 0x01 +Bad block table found at page 65472, version 0x01 +nand_read_bbt: Bad block at 0x000a8000 +nand_read_bbt: Bad block at 0x000ac000 +nand_read_bbt: Bad block at 0x000b0000 +nand_read_bbt: Bad block at 0x000b4000 +Skipping bad block at 0x000a8000 +Skipping bad block at 0x000ac000 +Skipping bad block at 0x000b0000 +Skipping bad block at 0x000b4000 +Skipping bad block at 0x01ff0000 +Skipping bad block at 0x01ff4000 +Skipping bad block at 0x01ff8000 +Skipping bad block at 0x01ffc000 + +OK +**=> nand dump 0 #dump第一个page(512Bytes)的内容,确认全为1.** +Page 00000000 dump: + ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff + ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff + ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff + ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff + ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff + ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff + ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff + ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff + ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff + ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff + ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff + ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff + ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff + ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff + ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff + ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff + ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff + ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff + ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff + ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff + ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff + ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff + ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff + ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff + ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff + ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff + ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff + ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff + ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff + ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff + ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff + ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff +OOB: + ff ff ff ff ff ff ff ff + ff ff ff ff ff ff ff ff +**=> tftp 1000000 uImage #将**__内核__**下载到内存中** +Speed: 100, full duplex +Using eTSEC0 device +TFTP from server 192.168.2.101; our IP address is 192.168.2.100 +Filename 'uImage'. +Load address: 0x1000000 +Loading: ################################################################# + ######################################### +done +**Bytes transferred = 1551612 (17acfc hex)** + +**=> nand write 1000000 0 $filesize #写flash前必须要对相应区域擦出过,最后一个参数指定写入的**__字节数__**。** + +NAND write: device 0 offset 0x0, size 0x17acfc +Attempt to write __non page aligned data #Flash写入时以page为单位(即512Bytes为单位)所以写入的大小不是页对齐时会出错。__ + 1551612 bytes written: ERROR + +**=> nand write 1000000 0 200000** **#指定一个比实际要写的内容稍大(可由tftp命令的最后一行输出指示)且页对齐的大小。** +NAND write: device 0 offset 0x0, size 0x200000 +Skip bad block 0x000a8000 +Skip bad block 0x000ac000 +Skip bad block 0x000b0000 +Skip bad block 0x000b4000 + 2097152 bytes written: OK + +=> tftp 2000000 rootfs.ext2.gz.uboot **#将根文件系统ramdisk下载到内存中** +Speed: 100, full duplex +Using eTSEC0 device +TFTP from server 192.168.2.101; our IP address is 192.168.2.100 +Filename 'rootfs.ext2.gz.uboot'. +Load address: 0x2000000 +Loading: ################################################################# + ################################################################# + ################################################################# + ######################################## +done +Bytes transferred = **3447604** (349b34 hex) + +**=> nand write 2000000 300000 400000** +NAND write: device 0 offset 0x300000, size 0x400000 + 4194304 bytes written: OK + +**=> tftp c00000 mpc8315.dtb #设备树下载到内存中** +Speed: 100, full duplex +Using eTSEC0 device +TFTP from server 192.168.2.101; our IP address is 192.168.2.100 +Filename 'mpc8315.dtb'. +Load address: 0xc00000 +Loading: ## +done +Bytes transferred = 20000 (4e20 hex) +=> nand write c00000 800000 100000 + +NAND write: device 0 offset 0x800000, size 0x100000 + 1048576 bytes written: OK + +=> setenv bootcmd nand read 1000000 0 200000;nand read 2000000 300000 400000;nand read c00000 800000 100000;bootm 1000000 2000000 c00000 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +=> +=> +=> printenv +ramboot=setenv bootargs root=/dev/ram rw console=$consoledev,$baudrate $othbootargs;tftp $ramdiskaddr $ramdiskfile;tftp $loadaddr $bootfile;tftp $fdtaddr $fdtfile;bootm $loadaddr $ramdiskaddr $fdtr +nfsboot=setenv bootargs root=/dev/nfs rw nfsroot=$serverip:$rootpath ip=$ipaddr:$serverip:$gatewayip:$netmask:$hostname:$netdev:off console=$consoledev,$baudrate $othbootargs;tftp $loadaddr $bootfr +bootdelay=6 +baudrate=115200 +loads_echo=1 +ethaddr=04:00:00:00:00:0A +eth1addr=04:00:00:00:00:0B +loadaddr=500000 +netdev=eth0 +consoledev=ttyS0 +ramdiskaddr=1000000 +ramdiskfile=ramfs.83xx +fdtaddr=400000 +fdtfile=mpc8315erdb.dtb +pciconfighost=yes +ethact=eTSEC0 +bootargs=root=/dev/ram rw console=ttyS0,115200 ramdisk_size=65535 +stdin=serial +stdout=serial +stderr=serial +filesize=4E20 +fileaddr=C00000 +ipaddr=192.168.2.100 +serverip=192.168.2.101 +bootcmd=nand read 1000000 0 2 + +Environment size: 915/8188 bytes +=> setenv bootcmd nand read 1000000 0 200000;nand read 2000000 300000 400000;nand read c00000 800000 100000;bootm 1000000 2000000 c00000 + +NAND read: device 0 offset 0x300000, size 0x400000 + 4194304 bytes read: OK + +NAND read: device 0 offset 0x800000, size 0x100000 + 1048576 bytes read: OK +## Booting kernel from Legacy Image at 01000000 ... + Image Name: Linux-3.2.4-gfd2812f + Created: 2012-08-10 7:58:18 UTC + Image Type: PowerPC Linux Kernel Image (gzip compressed) + Data Size: 1551548 Bytes = 1.5 MB + Load Address: 00000000 + Entry Point: 00000000 + Verifying Checksum ... OK +## Loading init Ramdisk from Legacy Image at 02000000 ... + Image Name: uboot ext2 ramdisk rootfs + Created: 2012-08-11 8:00:23 UTC + Image Type: PowerPC Linux RAMDisk Image (gzip compressed) + Data Size: 3447540 Bytes = 3.3 MB + Load Address: 00000000 + Entry Point: 00000000 + Verifying Checksum ... OK +## Flattened Device Tree blob at 00c00000 + Booting using the fdt blob at 0xc00000 + Uncompressing Kernel Image ... OK + Loading Ramdisk to 1fbdf000, end 1ff28af4 ... OK + Loading Device Tree to 007f8000, end 007ffe1f ... OK +Using MPC831x RDB machine description +Cannot reserve gpages without hugetlb enabled +Linux version 3.2.4-gfd2812f (geekard@kb310) (gcc version 4.7.1 (GCC) ) #4 Fri Aug 10 15:58:17 CST 2012 +Found initrd at 0xdfbdf000:0xdff28af4 +bootconsole [udbg0] enabled +setup_arch: bootmem +mpc831x_rdb_setup_arch() +Found FSL PCI host bridge at 0x00000000e0008500. Firmware bus number: 0->0 +PCI host bridge /pci@e0008500 (primary) ranges: + MEM 0x0000000090000000..0x000000009fffffff -> 0x0000000090000000 + MEM 0x0000000080000000..0x000000008fffffff -> 0x0000000080000000 Prefetch + IO 0x00000000e0300000..0x00000000e03fffff -> 0x0000000000000000 +arch: exit +Zone PFN ranges: + DMA 0x00000000 -> 0x00020000 + Normal empty +Movable zone start PFN for each node +early_node_map[1] active PFN ranges + 0: 0x00000000 -> 0x00020000 +Built 1 zonelists in Zone order, mobility grouping on. Total pages: 130048 +Kernel command line: root=/dev/ram rw console=ttyS0,115200 ramdisk_size=65535 +PID hash table entries: 2048 (order: 1, 8192 bytes) +Dentry cache hash table entries: 65536 (order: 6, 262144 bytes) +Inode-cache hash table entries: 32768 (order: 5, 131072 bytes) +Memory: 513152k/524288k available (2992k kernel code, 11136k reserved, 124k data, 59k bss, 152k init) +Kernel virtual memory layout: + * 0xfffdf000..0xfffff000 : fixmap + * 0xfdefb000..0xfe000000 : early ioremap + * 0xe1000000..0xfdefb000 : vmalloc & ioremap +NR_IRQS:512 nr_irqs:512 16 +IPIC (128 IRQ sources) at e1000700 +clocksource: timebase mult[7800001] shift[22] registered +pid_max: default: 32768 minimum: 301 +Mount-cache hash table entries: 512 +NET: Registered protocol family 16 + +PCI: Probing PCI hardware +bio: create slab at 0 +vgaarb: loaded +SCSI subsystem initialized +Switching to clocksource timebase +NET: Registered protocol family 2 +IP route cache hash table entries: 4096 (order: 2, 16384 bytes) +TCP established hash table entries: 16384 (order: 5, 131072 bytes) +TCP bind hash table entries: 16384 (order: 4, 65536 bytes) +TCP: Hash tables configured (established 16384 bind 16384) +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 +Trying to unpack rootfs image as initramfs... +rootfs image is not initramfs (no cpio magic); looks like an initrd +Freeing initrd memory: 3368k freed +WDT driver for MPC8xxx initialized. mode:reset timeout=65535 (32 seconds) +JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc. +msgmni has been set to 1008 +io scheduler noop registered +io scheduler deadline registered +io scheduler cfq registered (default) +Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled +serial8250.0: ttyS0 at MMIO 0xe0004500 (irq = 16) is a 16550A +console [ttyS0] enabled, bootconsole disabled +console [ttyS0] enabled, bootconsole disabled +serial8250.0: ttyS1 at MMIO 0xe0004600 (irq = 17) is a 16550A +brd: module loaded +loop: module loaded +fe000000.flash: Found 1 x16 devices at 0x0 in 16-bit bank. Manufacturer ID 0x000001 Chip ID 0x000c01 +Amd/Fujitsu Extended Query Table at 0x0040 + Amd/Fujitsu Extended Query version 1.3. +number of CFI chips: 1 +4 ofpart partitions found on MTD device fe000000.flash +Creating 4 MTD partitions on "fe000000.flash": +0x000000000000-0x000000100000 : "u-boot" +0x000000100000-0x000000500000 : "fs" +0x000000500000-0x000000700000 : "kernel" +0x000000700000-0x000000800000 : "dtb" +NAND device: Manufacturer ID: 0xec, Chip ID: 0x75 (Samsung NAND 32MiB 3,3V 8-bit) +Bad block table found at page 65504, version 0x01 +Bad block table found at page 65472, version 0x01 +nand_read_bbt: bad block at 0x0000000a8000 +nand_read_bbt: bad block at 0x0000000ac000 +nand_read_bbt: bad block at 0x0000000b0000 +nand_read_bbt: bad block at 0x0000000b4000 +6 ofpart partitions found on MTD device e0600000.flash +Creating 6 MTD partitions on "e0600000.flash": +0x000000000000-0x000000100000 : "U-Boot-NAND" +0x000000100000-0x000000900000 : "JFFS2-NAND" +0x000000900000-0x000000d00000 : "Ramdisk-NAND" +0x000000d00000-0x000001d00000 : "Reserved-NAND" +0x000001d00000-0x000001f00000 : "Kernel-NAND" +0x000001f00000-0x000002000000 : "DTB-NAND" +eLBC NAND device at 0xe0600000, bank 1 +Freescale PowerQUICC MII Bus: probed +mdio_bus mdio@e0024520: error probing PHY at address 0 +Freescale PowerQUICC MII Bus: probed +fsl-gianfar e0024000.ethernet: eth0: mac: 04:00:00:00:00:0a +fsl-gianfar e0024000.ethernet: eth0: Running with NAPI enabled +fsl-gianfar e0024000.ethernet: eth0: RX BD ring size for Q[0]: 256 +fsl-gianfar e0024000.ethernet: eth0: TX BD ring size for Q[0]: 256 +fsl-gianfar e0025000.ethernet: eth1: mac: 04:00:00:00:00:0b +fsl-gianfar e0025000.ethernet: eth1: Running with NAPI enabled +fsl-gianfar e0025000.ethernet: eth1: RX BD ring size for Q[0]: 256 +fsl-gianfar e0025000.ethernet: eth1: TX BD ring size for Q[0]: 256 +i2c /dev entries driver +mpc-i2c e0003000.i2c: timeout 1000000 us +rtc-ds1307 0-0068: rtc core: registered ds1339 as rtc0 +TCP cubic registered +NET: Registered protocol family 17 +Registering the dns_resolver key type +rtc-ds1307 0-0068: setting system clock to 2000-01-01 00:00:00 UTC (946684800) +RAMDISK: gzip image found at block 0 +VFS: Mounted root (ext2 filesystem) on device 1:0. +Freeing unused kernel memory: 152k freed +Mounting /proc and /sys +Starting the hotplug events dispatcher mdev +Setting the hostname to mpc8315erdb +Mounting filesystems +mount: mounting usbfs on /proc/bus/usb failed: No such file or directory +Starting syslogd and klogd +Running sysctl +Setting up networking on loopback device: + diff --git a/Zim/Research/vanet/部署.txt b/Zim/Research/vanet/部署.txt new file mode 100644 index 0000000..a225e83 --- /dev/null +++ b/Zim/Research/vanet/部署.txt @@ -0,0 +1,7 @@ +Content-Type: text/x-zim-wiki +Wiki-Format: zim 0.4 +Creation-Date: 2012-08-11T21:48:28+08:00 + +====== 部署 ====== +Created Saturday 11 August 2012 + diff --git a/Zim/Research/vanet/部署/jffs2_flash方式.txt b/Zim/Research/vanet/部署/jffs2_flash方式.txt new file mode 100644 index 0000000..03d100a --- /dev/null +++ b/Zim/Research/vanet/部署/jffs2_flash方式.txt @@ -0,0 +1,7 @@ +Content-Type: text/x-zim-wiki +Wiki-Format: zim 0.4 +Creation-Date: 2012-08-11T21:48:46+08:00 + +====== jffs2 flash方式 ====== +Created Saturday 11 August 2012 + diff --git a/Zim/Research/vanet/部署/jffs2_flash方式/jffs2部署.txt b/Zim/Research/vanet/部署/jffs2_flash方式/jffs2部署.txt new file mode 100644 index 0000000..ae29428 --- /dev/null +++ b/Zim/Research/vanet/部署/jffs2_flash方式/jffs2部署.txt @@ -0,0 +1,7 @@ +Content-Type: text/x-zim-wiki +Wiki-Format: zim 0.4 +Creation-Date: 2012-08-11T21:47:58+08:00 + +====== jffs2部署 ====== +Created Saturday 11 August 2012 + diff --git a/Zim/Research/vanet/部署/ramdisk方式.txt b/Zim/Research/vanet/部署/ramdisk方式.txt new file mode 100644 index 0000000..3f72aa2 --- /dev/null +++ b/Zim/Research/vanet/部署/ramdisk方式.txt @@ -0,0 +1,7 @@ +Content-Type: text/x-zim-wiki +Wiki-Format: zim 0.4 +Creation-Date: 2012-08-11T21:48:35+08:00 + +====== ramdisk方式 ====== +Created Saturday 11 August 2012 + diff --git a/Zim/Research/vanet/部署/ramdisk方式/ramdisk部署--通过flash.txt b/Zim/Research/vanet/部署/ramdisk方式/ramdisk部署--通过flash.txt new file mode 100644 index 0000000..1344757 --- /dev/null +++ b/Zim/Research/vanet/部署/ramdisk方式/ramdisk部署--通过flash.txt @@ -0,0 +1,369 @@ +Content-Type: text/x-zim-wiki +Wiki-Format: zim 0.4 +Creation-Date: 2012-08-11T21:21:44+08:00 + +====== ramdisk部署--通过flash ====== +Created Saturday 11 August 2012 + +一、NOR Flash方式: +这种部署方式是将ramdisk格式的根文件系统、内核、设备树烧写到flash中,然后复位后摘bootcmd中指定三个文件在flash中起始地址即可。适合与较小的固件。 + +首先要规划NOR Flash的空间安排,在mpc8315dtb-default.dts文件中,安排如下: + flash@0,0 { + #address-cells = <0x1>; + #size-cells = <0x1>; + compatible = "cfi-flash"; + reg = <0x0 0x0 0x800000>; + bank-width = <0x2>; + device-width = <0x1>; + + u-boot@0 { + reg = <0x0 0x100000>; + read-only; + }; + + fs@100000 { + reg = <0x100000 0x400000>; + }; + + kernel@500000 { + reg = <0x500000 0x200000>; + }; + + dtb@700000 { + reg = <0x700000 0x100000>; + }; + }; +由于MPC831ERDB上的NOR Flash只有8MB空间,因此三个文件的大小加起来不能超过8MB。由于使用ramdisk方式时,是使用SDRAM作为根文件系统,所以 +实际为这三个文件分配空间时可以任意,只要够用就行。 + +二、 NAND Flash方式: +当固件较大时,可以将其烧写到容量较大的NAND Flash中,然后启动时将这三个文件读取到内存中(通过nand read命令)启动。__注意如果是NOR Flash则bootm的三个参数可以直接是文件在NOR Flash中烧写的首地址,因为NOR Flash支持在芯片执行(XIP).__ + +可以将NOR Flash和NAND Flash烧写相结合的方式启动,如将较小的uImage和dtb烧写到NOR中,将较大的rootfs烧写到NAND中,然后在bootm前将NAND 中的文件读到内存中即可。 + +**=> help nand** +nand info - show available NAND devices +nand device [dev] - show or set current device +nand read - addr off|partition size +nand write - addr off|partition size + read/write 'size' bytes starting at offset 'off' + to/from memory address 'addr', skipping bad blocks. +nand erase [clean] [off size] - erase 'size' bytes from + offset 'off' (entire device if not specified) +nand bad - show bad blocks +nand dump[.oob] off - dump page +nand scrub - really clean NAND erasing bad blocks (UNSAFE) +nand markbad off - mark bad block at offset (UNSAFE) +nand biterr off - make a bit error at offset (UNSAFE) + +**=> nand erase #擦出整个NAND Flash** + +NAND erase: device 0 whole chip +Bad block table found at page 65504, version 0x01 +Bad block table found at page 65472, version 0x01 +nand_read_bbt: Bad block at 0x000a8000 +nand_read_bbt: Bad block at 0x000ac000 +nand_read_bbt: Bad block at 0x000b0000 +nand_read_bbt: Bad block at 0x000b4000 +Skipping bad block at 0x000a8000 +Skipping bad block at 0x000ac000 +Skipping bad block at 0x000b0000 +Skipping bad block at 0x000b4000 +Skipping bad block at 0x01ff0000 +Skipping bad block at 0x01ff4000 +Skipping bad block at 0x01ff8000 +Skipping bad block at 0x01ffc000 + +OK +**=> nand write 1000000 0 $filesize** + +NAND write: device 0 offset 0x0, size 0x17acfc +Attempt to write __non page aligned data #K9F5608的page大小为512Bytes__ + 1551612 bytes written: ERROR + +**=> nand write 1000000 0 200000** + +NAND write: '$200000' is not a number +=> nand write 1000000 0 200000 + +NAND write: device 0 offset 0x0, size 0x200000 +Skip bad block 0x000a8000 +Skip bad block 0x000ac000 +Skip bad block 0x000b0000 +Skip bad block 0x000b4000 + 2097152 bytes written: OK +**=> tftp 2000000 rootfs.ext2.gz.uboot** +Speed: 100, full duplex +Using eTSEC0 device +TFTP from server 192.168.2.105; our IP address is 192.168.2.100 +Filename 'rootfs.ext2.gz.uboot'. +Load address: 0x2000000 +Loading: ################################################################# + ################################################################# + ################################################################# + ################################################################# + ################################################################# + ################################################################# + #################################### +done +Bytes transferred = 6252712 (5f68a8 hex) +**=> nand write 2000000 300000 700000** + +NAND write: device 0 offset 0x300000, size 0x700000 + 7340032 bytes written: OK +**=> tftp c00000 mpc8315.dtb** +Speed: 100, full duplex +Using eTSEC0 device +TFTP from server 192.168.2.105; our IP address is 192.168.2.100 +Filename 'mpc8315.dtb'. +Load address: 0xc00000 +Loading: ## +done +Bytes transferred = 20000 (4e20 hex) +**=> nand write c00000 a00000 100000** + +NAND write: device 0 offset 0xa00000, size 0x100000 + 1048576 bytes written: OK +**=> setenv bootargs root=/dev/ram rw console=ttyS0,115200 ramdisk_size=19034** +**=> setenv bootcmd "nand read 1000000 0 200000;nand read 2000000 300000 700000;nand read c00000 a00000 100000;bootm 1000000 2000000 c00000" #设置环境变量bootcmd的参数,注意前后的引号和命令间的分号。** +**=> saveenv #将环境变量保存,这样下次重启时6秒后将自动自行bootcmd环境变量对应的命令** +Saving Environment to Flash... +. done +Un-Protected 1 sectors +Erasing Flash... +. done +Erased 1 sectors +Writing to Flash... done +. done +Protected 1 sectors +=> +__=> boot__ + +NAND read: device 0 offset 0x0, size 0x200000 +Bad block table found at page 65504, version 0x01 +Bad block table found at page 65472, version 0x01 +nand_read_bbt: Bad block at 0x000a8000 +nand_read_bbt: Bad block at 0x000ac000 +nand_read_bbt: Bad block at 0x000b0000 +nand_read_bbt: Bad block at 0x000b4000 +Skipping bad block 0x000a8000 +Skipping bad block 0x000ac000 +Skipping bad block 0x000b0000 +Skipping bad block 0x000b4000 + 2097152 bytes read: OK + +NAND read: device 0 offset 0x300000, size 0x700000 + 7340032 bytes read: OK + +NAND read: device 0 offset 0xa00000, size 0x100000 + 1048576 bytes read: OK +## Booting kernel from Legacy Image at 01000000 ... + Image Name: Linux-3.2.4-gfd2812f + Created: 2012-08-10 7:58:18 UTC + Image Type: PowerPC Linux Kernel Image (gzip compressed) + Data Size: 1551548 Bytes = 1.5 MB + Load Address: 00000000 + Entry Point: 00000000 + Verifying Checksum ... OK +## Loading init Ramdisk from Legacy Image at 02000000 ... + Image Name: uboot ext2 ramdisk rootfs + Created: 2012-08-11 12:56:37 UTC + Image Type: PowerPC Linux RAMDisk Image (gzip compressed) + Data Size: 6252648 Bytes = 6 MB + Load Address: 00000000 + Entry Point: 00000000 + Verifying Checksum ... OK +## Flattened Device Tree blob at 00c00000 + Booting using the fdt blob at 0xc00000 + Uncompressing Kernel Image ... OK + Loading Ramdisk to 1f932000, end 1ff28868 ... OK + Loading Device Tree to 007f8000, end 007ffe1f ... OK +Using MPC831x RDB machine description +Cannot reserve gpages without hugetlb enabled +Linux version 3.2.4-gfd2812f (geekard@kb310) (gcc version 4.7.1 (GCC) ) #4 Fri Aug 10 15:58:17 CST 2012 +Found initrd at 0xdf932000:0xdff28868 +bootconsole [udbg0] enabled +setup_arch: bootmem +mpc831x_rdb_setup_arch() +Found FSL PCI host bridge at 0x00000000e0008500. Firmware bus number: 0->0 +PCI host bridge /pci@e0008500 (primary) ranges: + MEM 0x0000000090000000..0x000000009fffffff -> 0x0000000090000000 + MEM 0x0000000080000000..0x000000008fffffff -> 0x0000000080000000 Prefetch + IO 0x00000000e0300000..0x00000000e03fffff -> 0x0000000000000000 +arch: exit +Zone PFN ranges: + DMA 0x00000000 -> 0x00020000 + Normal empty +Movable zone start PFN for each node +early_node_map[1] active PFN ranges + 0: 0x00000000 -> 0x00020000 +Built 1 zonelists in Zone order, mobility grouping on. Total pages: 130048 +Kernel command line: root=/dev/ram rw console=ttyS0,115200 ramdisk_size=19034 +PID hash table entries: 2048 (order: 1, 8192 bytes) +Dentry cache hash table entries: 65536 (order: 6, 262144 bytes) +Inode-cache hash table entries: 32768 (order: 5, 131072 bytes) +Memory: 510412k/524288k available (2992k kernel code, 13876k reserved, 124k data, 59k bss, 152k init) +Kernel virtual memory layout: +* 0xfffdf000..0xfffff000 : fixmap +* 0xfdefb000..0xfe000000 : early ioremap +* 0xe1000000..0xfdefb000 : vmalloc & ioremap +NR_IRQS:512 nr_irqs:512 16 +IPIC (128 IRQ sources) at e1000700 +clocksource: timebase mult[7800001] shift[22] registered +pid_max: default: 32768 minimum: 301 +Mount-cache hash table entries: 512 +NET: Registered protocol family 16 + +PCI: Probing PCI hardware +bio: create slab at 0 +vgaarb: loaded +SCSI subsystem initialized +Switching to clocksource timebase +NET: Registered protocol family 2 +IP route cache hash table entries: 4096 (order: 2, 16384 bytes) +TCP established hash table entries: 16384 (order: 5, 131072 bytes) +TCP bind hash table entries: 16384 (order: 4, 65536 bytes) +TCP: Hash tables configured (established 16384 bind 16384) +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 +Trying to unpack rootfs image as initramfs... +rootfs image is not initramfs (no cpio magic); looks like an initrd +Freeing initrd memory: 6108k freed +WDT driver for MPC8xxx initialized. mode:reset timeout=65535 (32 seconds) +JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc. +msgmni has been set to 1008 +io scheduler noop registered +io scheduler deadline registered +io scheduler cfq registered (default) +Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled +serial8250.0: ttyS0 at MMIO 0xe0004500 (irq = 16) is a 16550A +console [ttyS0] enabled, bootconsole disabled +console [ttyS0] enabled, bootconsole disabled +serial8250.0: ttyS1 at MMIO 0xe0004600 (irq = 17) is a 16550A +brd: module loaded +loop: module loaded +fe000000.flash: Found 1 x16 devices at 0x0 in 16-bit bank. Manufacturer ID 0x000001 Chip ID 0x000c01 +Amd/Fujitsu Extended Query Table at 0x0040 + Amd/Fujitsu Extended Query version 1.3. +number of CFI chips: 1 +4 ofpart partitions found on MTD device fe000000.flash +Creating 4 MTD partitions on "fe000000.flash": +0x000000000000-0x000000100000 : "u-boot" +0x000000100000-0x000000500000 : "fs" +0x000000500000-0x000000700000 : "kernel" +0x000000700000-0x000000800000 : "dtb" +NAND device: Manufacturer ID: 0xec, Chip ID: 0x75 (Samsung NAND 32MiB 3,3V 8-bit) +Bad block table found at page 65504, version 0x01 +Bad block table found at page 65472, version 0x01 +nand_read_bbt: bad block at 0x0000000a8000 +nand_read_bbt: bad block at 0x0000000ac000 +nand_read_bbt: bad block at 0x0000000b0000 +nand_read_bbt: bad block at 0x0000000b4000 +6 ofpart partitions found on MTD device e0600000.flash +Creating 6 MTD partitions on "e0600000.flash": +0x000000000000-0x000000100000 : "U-Boot-NAND" +0x000000100000-0x000000900000 : "JFFS2-NAND" +0x000000900000-0x000000d00000 : "Ramdisk-NAND" +0x000000d00000-0x000001d00000 : "Reserved-NAND" +0x000001d00000-0x000001f00000 : "Kernel-NAND" +0x000001f00000-0x000002000000 : "DTB-NAND" +eLBC NAND device at 0xe0600000, bank 1 +Freescale PowerQUICC MII Bus: probed +mdio_bus mdio@e0024520: error probing PHY at address 0 +Freescale PowerQUICC MII Bus: probed +fsl-gianfar e0024000.ethernet: eth0: mac: 04:00:00:00:00:0a +fsl-gianfar e0024000.ethernet: eth0: Running with NAPI enabled +fsl-gianfar e0024000.ethernet: eth0: RX BD ring size for Q[0]: 256 +fsl-gianfar e0024000.ethernet: eth0: TX BD ring size for Q[0]: 256 +fsl-gianfar e0025000.ethernet: eth1: mac: 04:00:00:00:00:0b +fsl-gianfar e0025000.ethernet: eth1: Running with NAPI enabled +fsl-gianfar e0025000.ethernet: eth1: RX BD ring size for Q[0]: 256 +fsl-gianfar e0025000.ethernet: eth1: TX BD ring size for Q[0]: 256 +i2c /dev entries driver +mpc-i2c e0003000.i2c: timeout 1000000 us +rtc-ds1307 0-0068: rtc core: registered ds1339 as rtc0 +TCP cubic registered +NET: Registered protocol family 17 +Registering the dns_resolver key type +rtc-ds1307 0-0068: setting system clock to 2000-01-01 00:00:00 UTC (946684800) +RAMDISK: gzip image found at block 0 +VFS: Mounted root (ext2 filesystem) on device 1:0. +Freeing unused kernel memory: 152k freed +Mounting /proc and /sys +Starting the hotplug events dispatcher udevd +Synthesizing initial hotplug eveudevd (807): /proc/807/oom_adj is deprecated, please use /proc/807/oom_score_adj instead. +nts +cfg80211: Calling CRDA to update world regulatory domain +cfg80211: World regulatory domain updated: +cfg80211: (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp) +cfg80211: (2402000 KHz - 2472000 KHz @ 40000 KHz), (300 mBi, 2000 mBm) +cfg80211: (2457000 KHz - 2482000 KHz @ 20000 KHz), (300 mBi, 2000 mBm) +cfg80211: (2474000 KHz - 2494000 KHz @ 20000 KHz), (300 mBi, 2000 mBm) +cfg80211: (5170000 KHz - 5250000 KHz @ 40000 KHz), (300 mBi, 2000 mBm) +cfg80211: (5735000 KHz - 5835000 KHz @ 40000 KHz), (300 mBi, 2000 mBm) +ath5k 0000:00:0e.0: registered as 'phy0' +ath5k channel bandwidth setting 10MHz default +VANET-debug: ieee80211_register_hw +VANET-debug: ieee80211_rate_control_ops_get select minstrel_ht +VANET-debug: register vanet network interface +VANET-debug: ieee80211_if_add, name: ath5k%d +ath5k phy0: Atheros AR5414 chip found (MAC: 0xa5, PHY: 0x61) +cfg80211: Calling CRDA for country: US +cfg80211: Regulatory domain changed to country: US +cfg80211: (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp) +cfg80211: (2402000 KHz - 2472000 KHz @ 40000 KHz), (300 mBi, 2700 mBm) +cfg80211: (5170000 KHz - 5250000 KHz @ 40000 KHz), (300 mBi, 1700 mBm) +cfg80211: (5250000 KHz - 5330000 KHz @ 40000 KHz), (300 mBi, 2000 mBm) +cfg80211: (5490000 KHz - 5600000 KHz @ 40000 KHz), (300 mBi, 2000 mBm) +cfg80211: (5650000 KHz - 5710000 KHz @ 40000 KHz), (300 mBi, 2000 mBm) +cfg80211: (5735000 KHz - 5835000 KHz @ 40000 KHz), (300 mBi, 3000 mBm) +Setting the hostname to mpc8315erdb +Mounting filesystems +mount: mounting usbfs on /proc/bus/usb failed: No such file or directory +Starting syslogd and klogd +Running sysctl +Setting up networking on loopback device: + +Warning: no IPADDR is set, please set this from the ltib +config screen, or directly in /etc/rc.d/rc.conf. +IP address setup bypassed + +Setting up networking on eth1: + + + Welcome to the LTIB Embedded Linux Environment + +!!!!! WARNING !!!!!!! + +The default password for the root account is: root +please change this password using the 'passwd' command +and then edit this message (/etc/issue) to remove this message + +mpc8315erdb login: PHY: mdio@e0024520:01 - Link is Up - 100/Full + + + Welcome to the LTIB Embedded Linux Environment + +!!!!! WARNING !!!!!!! + +The default password for the root account is: root +please change this password using the 'passwd' command +and then edit this message (/etc/issue) to remove this message + +mpc8315erdb login: root +Password: +root +Login incorrect +mpc8315erdb login: root +Password: +[root@mpc8315erdb root]# uname -a +Linux mpc8315erdb 3.2.4-gfd2812f #4 Fri Aug 10 15:58:17 CST 2012 ppc GNU/Linux +[root@mpc8315erdb root]# + + + + + diff --git a/Zim/Research/vanet/部署/ramdisk方式/ramdisk部署--通过tftp.txt b/Zim/Research/vanet/部署/ramdisk方式/ramdisk部署--通过tftp.txt new file mode 100644 index 0000000..59b0e26 --- /dev/null +++ b/Zim/Research/vanet/部署/ramdisk方式/ramdisk部署--通过tftp.txt @@ -0,0 +1,267 @@ +Content-Type: text/x-zim-wiki +Wiki-Format: zim 0.4 +Creation-Date: 2012-08-11T21:16:50+08:00 + +====== ramdisk部署--通过tftp ====== +Created Saturday 11 August 2012 + +这种部署方式适合开发环境,通过tftp将内核、根文件系统和设备树下载到内存中,然后使用bootm命令从内存中启动。 +步骤如下: + +U-Boot 2009.03-rc2 (Aug 11 2012 - 13:22:34) MPC83XX + +Reset Status: + +CPU: e300c3, MPC8315, Rev: 1.2 at 400 MHz, CSB: 133.333 MHz +Board: Freescale MPC8315ERDB Rev +I2C: ready +DRAM: 512 MB +FLASH: 8 MB +NAND: 32 MiB +PCIE0: No link +PCIE1: No link +In: serial +Out: serial +Err: serial +Net: eTSEC0 +Hit any key to stop autoboot: 0 +=> setenv **serverip** 192.168.2.105 +=> setenv **ipaddr** 192.168.2.100 +**=> setenv bootargs **__root=/dev/ram__** rw console=ttyS0,115200 **__ramdisk_size=19034 #注意ramdisk_size要与ltib的输出一致。__ +**=> tftp 1000000 uImage** +Speed: 100, full duplex +Using eTSEC0 device +TFTP from server 192.168.2.105; our IP address is 192.168.2.100 +Filename 'uImage'. +Load address: 0x1000000 +Loading: ################################################################# + ######################################### +done +Bytes transferred = 1551612 (17acfc hex) +**=> tftp 2000000 rootfs.ext2.gz.uboot** +Speed: 100, full duplex +Using eTSEC0 device +TFTP from server 192.168.2.105; our IP address is 192.168.2.100 +Filename 'rootfs.ext2.gz.uboot'. +Load address: 0x2000000 +Loading: ################################################################# + ################################################################# + ################################################################# + ################################################################# + ################################################################# + ################################################################# + #################################### +done +Bytes transferred = 6252712 (5f68a8 hex) +**=> tftp c00000 mpc8315.dtb** +Speed: 100, full duplex +Using eTSEC0 device +TFTP from server 192.168.2.105; our IP address is 192.168.2.100 +Filename 'mpc8315.dtb'. +Load address: 0xc00000 +Loading: ## +done +Bytes transferred = 20000 (4e20 hex) +**=> bootm 1000000 2000000 c00000** + +## Booting kernel from Legacy Image at 01000000 ... + Image Name: Linux-3.2.4-gfd2812f + Created: 2012-08-10 7:58:18 UTC + Image Type: PowerPC Linux Kernel Image (gzip compressed) + Data Size: 1551548 Bytes = 1.5 MB + Load Address: 00000000 + Entry Point: 00000000 + Verifying Checksum ... OK +## Loading init Ramdisk from Legacy Image at 02000000 ... + Image Name: uboot ext2 ramdisk rootfs + Created: 2012-08-11 12:56:37 UTC + Image Type: PowerPC Linux RAMDisk Image (gzip compressed) + Data Size: 6252648 Bytes = 6 MB + Load Address: 00000000 + Entry Point: 00000000 + Verifying Checksum ... OK +## Flattened Device Tree blob at 00c00000 + Booting using the fdt blob at 0xc00000 + Uncompressing Kernel Image ... OK + Loading Ramdisk to 1f933000, end 1ff29868 ... OK + Loading Device Tree to 007f8000, end 007ffe1f ... OK +Using MPC831x RDB machine description +Cannot reserve gpages without hugetlb enabled +Linux version 3.2.4-gfd2812f (geekard@kb310) (gcc version 4.7.1 (GCC) ) #4 Fri Aug 10 15:58:17 CST 2012 +Found initrd at 0xdf933000:0xdff29868 +bootconsole [udbg0] enabled +setup_arch: bootmem +mpc831x_rdb_setup_arch() +Found FSL PCI host bridge at 0x00000000e0008500. Firmware bus number: 0->0 +PCI host bridge /pci@e0008500 (primary) ranges: + MEM 0x0000000090000000..0x000000009fffffff -> 0x0000000090000000 + MEM 0x0000000080000000..0x000000008fffffff -> 0x0000000080000000 Prefetch + IO 0x00000000e0300000..0x00000000e03fffff -> 0x0000000000000000 +arch: exit +Zone PFN ranges: + DMA 0x00000000 -> 0x00020000 + Normal empty +Movable zone start PFN for each node +early_node_map[1] active PFN ranges + 0: 0x00000000 -> 0x00020000 +Built 1 zonelists in Zone order, mobility grouping on. Total pages: 130048 +Kernel command line: root=/dev/ram rw console=ttyS0,115200 ramdisk_size=19034 +PID hash table entries: 2048 (order: 1, 8192 bytes) +Dentry cache hash table entries: 65536 (order: 6, 262144 bytes) +Inode-cache hash table entries: 32768 (order: 5, 131072 bytes) +Memory: 510412k/524288k available (2992k kernel code, 13876k reserved, 124k data, 59k bss, 152k init) +Kernel virtual memory layout: +* 0xfffdf000..0xfffff000 : fixmap +* 0xfdefb000..0xfe000000 : early ioremap +* 0xe1000000..0xfdefb000 : vmalloc & ioremap +NR_IRQS:512 nr_irqs:512 16 +IPIC (128 IRQ sources) at e1000700 +clocksource: timebase mult[7800001] shift[22] registered +pid_max: default: 32768 minimum: 301 +Mount-cache hash table entries: 512 +NET: Registered protocol family 16 + +PCI: Probing PCI hardware +bio: create slab at 0 +vgaarb: loaded +SCSI subsystem initialized +Switching to clocksource timebase +NET: Registered protocol family 2 +IP route cache hash table entries: 4096 (order: 2, 16384 bytes) +TCP established hash table entries: 16384 (order: 5, 131072 bytes) +TCP bind hash table entries: 16384 (order: 4, 65536 bytes) +TCP: Hash tables configured (established 16384 bind 16384) +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 +Trying to unpack rootfs image as initramfs... +rootfs image is not initramfs (no cpio magic); looks like an initrd +Freeing initrd memory: 6108k freed +WDT driver for MPC8xxx initialized. mode:reset timeout=65535 (32 seconds) +JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc. +msgmni has been set to 1008 +io scheduler noop registered +io scheduler deadline registered +io scheduler cfq registered (default) +Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled +serial8250.0: ttyS0 at MMIO 0xe0004500 (irq = 16) is a 16550A +console [ttyS0] enabled, bootconsole disabled +console [ttyS0] enabled, bootconsole disabled +serial8250.0: ttyS1 at MMIO 0xe0004600 (irq = 17) is a 16550A +brd: module loaded +loop: module loaded +fe000000.flash: Found 1 x16 devices at 0x0 in 16-bit bank. Manufacturer ID 0x000001 Chip ID 0x000c01 +Amd/Fujitsu Extended Query Table at 0x0040 + Amd/Fujitsu Extended Query version 1.3. +number of CFI chips: 1 +4 ofpart partitions found on MTD device fe000000.flash +Creating 4 MTD partitions on "fe000000.flash": +0x000000000000-0x000000100000 : "u-boot" +0x000000100000-0x000000500000 : "fs" +0x000000500000-0x000000700000 : "kernel" +0x000000700000-0x000000800000 : "dtb" +NAND device: Manufacturer ID: 0xec, Chip ID: 0x75 (Samsung NAND 32MiB 3,3V 8-bit) +Bad block table found at page 65504, version 0x01 +Bad block table found at page 65472, version 0x01 +nand_read_bbt: bad block at 0x0000000a8000 +nand_read_bbt: bad block at 0x0000000ac000 +nand_read_bbt: bad block at 0x0000000b0000 +nand_read_bbt: bad block at 0x0000000b4000 +6 ofpart partitions found on MTD device e0600000.flash +Creating 6 MTD partitions on "e0600000.flash": +0x000000000000-0x000000100000 : "U-Boot-NAND" +0x000000100000-0x000000900000 : "JFFS2-NAND" +0x000000900000-0x000000d00000 : "Ramdisk-NAND" +0x000000d00000-0x000001d00000 : "Reserved-NAND" +0x000001d00000-0x000001f00000 : "Kernel-NAND" +0x000001f00000-0x000002000000 : "DTB-NAND" +eLBC NAND device at 0xe0600000, bank 1 +Freescale PowerQUICC MII Bus: probed +mdio_bus mdio@e0024520: error probing PHY at address 0 +Freescale PowerQUICC MII Bus: probed +fsl-gianfar e0024000.ethernet: eth0: mac: 04:00:00:00:00:0a +fsl-gianfar e0024000.ethernet: eth0: Running with NAPI enabled +fsl-gianfar e0024000.ethernet: eth0: RX BD ring size for Q[0]: 256 +fsl-gianfar e0024000.ethernet: eth0: TX BD ring size for Q[0]: 256 +fsl-gianfar e0025000.ethernet: eth1: mac: 04:00:00:00:00:0b +fsl-gianfar e0025000.ethernet: eth1: Running with NAPI enabled +fsl-gianfar e0025000.ethernet: eth1: RX BD ring size for Q[0]: 256 +fsl-gianfar e0025000.ethernet: eth1: TX BD ring size for Q[0]: 256 +i2c /dev entries driver +mpc-i2c e0003000.i2c: timeout 1000000 us +rtc-ds1307 0-0068: rtc core: registered ds1339 as rtc0 +TCP cubic registered +NET: Registered protocol family 17 +Registering the dns_resolver key type +rtc-ds1307 0-0068: setting system clock to 2000-01-01 00:00:00 UTC (946684800) +RAMDISK: gzip image found at block 0 +VFS: Mounted root (ext2 filesystem) on device 1:0. +Freeing unused kernel memory: 152k freed +Mounting /proc and /sys +Starting the hotplug events dispatcher udevd +Synthesizing initial hotplug events +udevd (807): /proc/807/oom_adj is deprecated, please use /proc/807/oom_score_adj instead. +cfg80211: Calling CRDA to update world regulatory domain +cfg80211: World regulatory domain updated: +cfg80211: (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp) +cfg80211: (2402000 KHz - 2472000 KHz @ 40000 KHz), (300 mBi, 2000 mBm) +cfg80211: (2457000 KHz - 2482000 KHz @ 20000 KHz), (300 mBi, 2000 mBm) +cfg80211: (2474000 KHz - 2494000 KHz @ 20000 KHz), (300 mBi, 2000 mBm) +cfg80211: (5170000 KHz - 5250000 KHz @ 40000 KHz), (300 mBi, 2000 mBm) +cfg80211: (5735000 KHz - 5835000 KHz @ 40000 KHz), (300 mBi, 2000 mBm) +ath5k 0000:00:0e.0: registered as 'phy0' +ath5k channel bandwidth setting 10MHz default +VANET-debug: ieee80211_register_hw +VANET-debug: ieee80211_rate_control_ops_get select minstrel_ht +VANET-debug: register vanet network interface +VANET-debug: ieee80211_if_add, name: ath5k%d +ath5k phy0: Atheros AR5414 chip found (MAC: 0xa5, PHY: 0x61) +cfg80211: Calling CRDA for country: US +cfg80211: Regulatory domain changed to country: US +cfg80211: (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp) +cfg80211: (2402000 KHz - 2472000 KHz @ 40000 KHz), (300 mBi, 2700 mBm) +cfg80211: (5170000 KHz - 5250000 KHz @ 40000 KHz), (300 mBi, 1700 mBm) +cfg80211: (5250000 KHz - 5330000 KHz @ 40000 KHz), (300 mBi, 2000 mBm) +cfg80211: (5490000 KHz - 5600000 KHz @ 40000 KHz), (300 mBi, 2000 mBm) +cfg80211: (5650000 KHz - 5710000 KHz @ 40000 KHz), (300 mBi, 2000 mBm) +cfg80211: (5735000 KHz - 5835000 KHz @ 40000 KHz), (300 mBi, 3000 mBm) +Setting the hostname to mpc8315erdb +Mounting filesystems +mount: mounting usbfs on /proc/bus/usb failed: No such file or directory +Starting syslogd and klogd +Running sysctl +Setting up networking on loopback device: + +Warning: no IPADDR is set, please set this from the ltib +config screen, or directly in /etc/rc.d/rc.conf. +IP address setup bypassed + +Setting up networking on eth1: + + + Welcome to the LTIB Embedded Linux Environment + +!!!!! WARNING !!!!!!! + +The default password for the root account is: root +please change this password using the 'passwd' command +and then edit this message (/etc/issue) to remove this message + +mpc8315erdb login: PHY: mdio@e0024520:01 - Link is Up - 100/Full + + + Welcome to the LTIB Embedded Linux Environment + +!!!!! WARNING !!!!!!! + +The default password for the root account is: root +please change this password using the 'passwd' command +and then edit this message (/etc/issue) to remove this message + +mpc8315erdb login: root +Password: +[root@mpc8315erdb root]# ls +diskinit-1.1.sh recv setIPv6Addr +joinvanet send xath5k +[root@mpc8315erdb root]# diff --git a/Zim/Utils/cscope.txt b/Zim/Utils/cscope.txt new file mode 100644 index 0000000..52be79b --- /dev/null +++ b/Zim/Utils/cscope.txt @@ -0,0 +1,71 @@ +Content-Type: text/x-zim-wiki +Wiki-Format: zim 0.4 +Creation-Date: 2012-08-31T20:26:26+08:00 + +====== cscope ====== +Created Friday 31 August 2012 +http://cscope.sourceforge.net/large_projects.html + +Using Cscope on large projects (example: the Linux kernel) + +Cscope can be a particularly useful tool if you need to wade into a large code base. You can save yourself a lot of time by being able to do fast, **targeted searches** rather than randomly grepping through the source files by hand (especially since grep starts to take a while with a truly large code base). +In this tutorial you'll learn how to set up Cscope with a large project. We'll use as our example the Linux kernel source code, but the basic steps are the same for any other large project, including C++ or Java projects. + +===== Get the source. ===== + First get the source code. You can download the Linux kernel source from http://www.kernel.org. For the rest of this tutorial, I'll assume you've downloaded Linux 2.4.18 and installed it into [[/home/jru/linux-2.4.18.]] + +Note: Make sure you've got enough disk space: the kernel tarball alone is 30 MB, it expands into 150 MB of source code, and the Cscope database we'll generate will gobble up another 20-100+ MB (depending on how much of the kernel code you decide to include in the database). You can put the Cscope database on a different disk partition than the source code if you need to. + +===== Figure out where you want to put your Cscope database files. ===== +I'll assume you'll use /home/jru/cscope as the directory to store your database and associated files. + +===== Generate cscope.files with a list of files to be scanned. ===== +For some projects, you may want to include **every** C source file in the project's directories in your Cscope database. In that case you can skip this step, and just use '__cscope -R__' in the project's top-level directory to build your Cscope database. But if there's some code that you wish to **exclude**, and/or your project contains C++ or Java source code (by default Cscope __only parses__ files with the .c, .h, .y, or .l extensions), you'll need to generate a file called **cscope.files**, which should contain the name of all files that you **wish to** have Cscope scan (one file name per line). + +You'll probably want to **use absolute paths** (at least if you're planning to use the Cscope database within an editor), so that you can use the database from directories other than the one you create. The commands I show will first cd to root, so that find prints out absolute paths. + +For many projects, your find command may be as as simple as + + cd / + find /my/project/dir -name '*.java' >/my/cscope/dir/cscope.files + +For the Linux kernel, it's a little trickier, since we want to exclude all the code in the //docs// and //scripts// directories, plus all of the architecture and assembly code for all chips except for the beloved Intel x86 (which I'm guessing is the architecture you're interested in). Additionally, I'm excluding all kernel driver code in this example (they more than double the amount of code to be parsed, which bloats the Cscope database, and they contain many duplicate definitions, which often makes searching harder. If you are interested in the driver code, omit the relevant line below, or modify it to print out only the driver files you're interested in): + LNX=/home/jru/linux-2.4.18 + cd / + find $LNX \ + -path "$LNX/arch/*" ! -path "$LNX/arch/i386*" -prune -o \ + -path "$LNX/include/asm-*" ! -path "$LNX/include/asm-i386*" -prune -o \ + -path "$LNX/tmp*" -prune -o \ + -path "$LNX/Documentation*" -prune -o \ + -path "$LNX/scripts*" -prune -o \ + -path "$LNX/drivers*" -prune -o \ + -name "*.[chxsS]" -print >/home/jru/cscope/cscope.files + +While find commands can be a little tricky to write, for large projects they are much easier than editing a list of files manually, and you can also cut and paste a solution from someone else. + +===== Generate the Cscope database. ===== +Now it's time to generate the Cscope database: + cd /home/jru/cscope # the directory **with** 'cscope.files' + __cscope -b -q -k__ + +The -b flag tells Cscope to just build the database, and not launch the **Cscope GUI**. +The -q causes an additional, **'inverted index'** file to be created, which makes searches run **much faster** for large databases. +Finally, -k sets Cscope's **'kernel' mode**--it will not look in /usr/include for any header files that are #included in your source files (this is mainly useful when you are using Cscope with operating system and/or C library source code, as we are here). + +On my 900 MHz Pentium III system (with a standard IDE disk), parsing this subset of the Linux source takes only 12 seconds, and results in 3 files (//cscope.out, cscope.in.out, and cscope.po.out//) that take up a total of 25 megabytes. + +===== Using the database. ===== +If you like to use vim or emacs/xemacs, I recommend that you learn how to run Cscope within one of these editors, which will allow you to run searches easily within your editor. We have a tutorial for Vim, and emacs users will of course be __clever enough__ to figure everything out from the helpful comments in the cscope/contrib/xcscope/ directory of the Cscope distribution. + +Otherwise, you can use the standalone Cscope curses-based GUI, which lets you run searches, then launch your favorite editor (i.e., whatever **$EDITOR** is set to in your environment, or 'vi' by default) to open on the exact line of the search result. + +If you use the standalone Cscope browser, make sure to invoke it via + + cscope -d + +This tells Cscope not to regenerate the database. Otherwise you'll have to wait while Cscope checks for modified files, which can take a while for large projects, even when no files have changed. If you accidentally run 'cscope', without any flags, you will also cause the database to be recreated from scratch without the fast index or kernel modes being used, so you'll probably need to rerun your original cscope command above to correctly recreate the database. + +===== Regenerating the database when the source code changes. ===== +If there are new files in your project, rerun your **'find'** command to update cscope.files if you're using it. + +Then simply invoke cscope the same way (and in the same directory) as you did to generate the database initially (i.e., cscope -b -q -k). diff --git a/Zim/内核开发/驱动/内核模块内存分配全攻略.txt b/Zim/内核开发/驱动/内核模块内存分配全攻略.txt index fc272f7..4dd2fc9 100644 --- a/Zim/内核开发/驱动/内核模块内存分配全攻略.txt +++ b/Zim/内核开发/驱动/内核模块内存分配全攻略.txt @@ -12,7 +12,7 @@ http://www.embexperts.com/forum.php/forum.php?mod=viewthread&tid=20&extra=page%3 **1. kmalloc 和 kfree** __基于page和slab之上__的内存分配函数。Linux初始化时构造13个大小分别为32, 64, 128, 256, 512, 1,024, 2,048, 4,096, 8,192, 16,384, 32,768, 65,536, 和 131,072 字节的Cache.因此如果调用kmalloc(100, GFP_KERNEL)实际上内核分配的空间为128. -2. kzalloc +2. **kzalloc** 3. **vmalloc和vfree** 4. **get_free_page** **5.kmem_cache_create** diff --git a/Zim/内核开发/驱动/内核模块的makefile.txt b/Zim/内核开发/驱动/内核模块的makefile.txt new file mode 100644 index 0000000..6e6d3b8 --- /dev/null +++ b/Zim/内核开发/驱动/内核模块的makefile.txt @@ -0,0 +1,120 @@ +Content-Type: text/x-zim-wiki +Wiki-Format: zim 0.4 +Creation-Date: 2012-08-15T15:31:21+08:00 + +====== 内核模块的makefile ====== +Created Wednesday 15 August 2012 +http://blog.csdn.net/hansel/article/details/1872008 + +hansel@163.com 2007.11.07 +编译模块的make file 必须是Makefile,不能是makefile. + +Linux 2.6的内核使用Kbuild来编译内核模块。Kbuild能够编译内核树目录内的内核模块,也__能够编译内核目录树外的内核模块__(外部内核模块)。 + +* **编译外部内核模块的命令:** + #cd + #make -C M=`pwd` + + 其中为要编译的内核模块所在目录, 为内核源码所在的目录。 对于发行版本的Linux,可以用: + #make -C /lib/modules/`uname -r`/build M=`pwd` + + 注意:使用Kbuild之前,必须先成功编译过内核源码。 + 说明: + * #make -C M=`pwd` **modules** + 作用与上面的命令一样 + * 以前的内核版本可以使用 + #make -C SUBDIRS=`pwd` modules + +* **安装外部内核模块** + #make -C M=`pwd` **modules_install** + 默认安装目录为:/lib/modules/`uname -r`/extra,可以通过__INSTALL_MOD_PATH__宏在默认安装路径前加前缀。 + 例如: + #make -C INSTALL_MOD_PATH=/opt M=`pwd` modules_install + 则编译后的模块会放在/opt/lib/modules/`uname -r`/extra + + 通过宏__INSTALL_MOD_DIR__可以修改是否放在'extra'下,例如: + #make -C INSTALL_MOD_DIR=**golf** M=`pwd` modules_install + 则编译后的模块会放在/lib/modules/`uname -r`/golf + +* **编译单个文件** + #make -C M=`pwd` + +* **其他命令** + #make -C M=`pwd` clean + #make -C M=`pwd` help + +* **Kbuild文件** + Linux的Kbuild会在内核模块目录下查找Kbuild文件,如果有,则在编译时会使用该文件。 + +==== 示例: ==== + 假设有这么几个文件:8123_if.c 8123_if.h 8123_pci.c 8123_bin.o_shipped(二进制的模块文件) + + **Kbuild文件的内容:** + obj-m := 8123.o + **8123-y**:8123_if.o 8123_pci.o 8123_bin.o + + **Makefile的内容:** + #为了兼容旧版本的Kbuild + ifneq($(KERNELRELEASE),) + include Kbuild + else + #正常的Makefile + KDIR:=/lib/modules/`uname -r`/build + all:: + $(MAKE) -C $(KDIR) M=`pwd` $@ + + #其他target + genbin: + echo "X" > 8123_bin_shipped + endif + + 注意,没有源码的二进制.o文件必须以原文件名加_shipped结尾,例如8123_bin.o_shipped,KBuild会把8123_bin.o_shipped + 复制为8123_bin.o,然后一起编译。 + +Makefile中如何包括自己的include文件 + 由于__采用Kbuild编译外部内核模块时,编译路径切换到了内核源码树的目录__,因此如果在Makefile中使用相对路径来包含另一个文件 + 时,会找不到该文件。因此,不能用 + include ../config.mk + + 应该用: + ifeq ($(obj),) + obj= . + endif + include $(obj)/../config.mk +--------------------------------------------------- +一般用下面的Makefile, +http://www.cnblogs.com/hnrainll/archive/2011/06/15/2081136.html + + # Makefile2.6 + ifneq ($(KERNELRELEASE),) + #__kbuild syntax__. dependency relationshsip of files and target modules are listed here. + + mymodule-objs := hello.o + obj-m := hello.o + + else + PWD := $(shell pwd) + + KVER ?= $(shell uname -r) + KDIR := /lib/modules/$(KVER)/build #KDIR目录其实是链接到上面那个Makefile中的那个 + /usr/src/linux-source-2.6.15/*中 + all: + $(MAKE) -C $(KDIR) M=$(PWD) modules + + clean: + rm -rf .*.cmd *.o *.mod.c *.ko .tmp_versions + + endif + +KERNELRELEASE 是在内核源码的顶层Makefile中定义的一个变量,在第一次读取执行此Makefile时,KERNELRELEASE没有被定义,所以make将读取执行else之后的内容。 + +当make的目标为all时,__-C $(KDIR) 指明跳转到内核源码目录下读取那里的Makefile__;M=$(PWD) 表明然后返回到当前目录重新读入、执行当前的Makefile。 + +当从内核源码目录返回时,KERNELRELEASE已被被定义,__kbuild也被启动去解析kbuild语法的语句__,make将继续读取else之前的内容。else之前的内容为kbuild语法的语句, 指明模块源码中各文件的依赖关系,以及要生成的目标模块名。 + +------------------------------------- +**关于GNU make工具扩展的说明** + 在上面的Makefile中使用了 + obj-m := 这个赋值语句的含义说明要使用目标文件helloworld.o建立一个模块,最后生成的模块的名字就是helloworld.ko,如果你有一个名为module.ko的模块依赖于两个文件file1.o和file2.o,那么我们可以使用module-obj扩展,如下所示 + obj-m := module.o + module-objs := file1.o file2.o diff --git a/Zim/嵌入式/MMC和SD卡.txt b/Zim/嵌入式/MMC和SD卡.txt index a8f53c2..c85567a 100644 --- a/Zim/嵌入式/MMC和SD卡.txt +++ b/Zim/嵌入式/MMC和SD卡.txt @@ -5,102 +5,66 @@ Creation-Date: 2011-12-01T21:16:45+08:00 ====== MMC和SD卡 ====== Created Thursday 01 December 2011 -目录 - - MMC引1.MMC卡 - 2.Microsoft 管理控制台 (MMC) - 3.丝裂霉素(mmc) - 4.金属基复合材料(mmc) - 5、三坐标测量机 - 6、广东石油化工学院 - 7、最大实体状态 - ===== MMC ===== +MMC存贮卡可以分为__MMC和SPI两种工作模式__,MMC模式是标准的默认模式,具有MMC的全部特性。而SPI模式则是MMC存贮卡可选的第二种模式,这个模式是MMC协议的一个子集,主要用于只需要小数量的卡(通常是1个)和低数据传输率(和MMC协议相比)的系统,这个模式可以把设计花费减到最小,但性能就不如MMC。 -  MMC存贮卡可以分为__MMC和SPI两种工作模式__,MMC模式是标准的默认模式,具有MMC的全部特性。而SPI模式则是MMC存贮卡可选的第二种模式,这个模式是MMC协议的一个子集,主要用于只需要小数量的卡(通常是1个)和低数据传输率(和MMC协议相比)的系统,这个模式可以把设计花费减到最小,但性能就不如MMC。 -  MMC被设计作为一种低成本的__数据平台和通讯介质__,它的接口设计非常简单:只有7针!接口成本低于0.5美元,相比之下SmartMedia和Memory Stick的接口成本都要高于1美元。在接口中,电源供应是3针,而数据操作只用3针的串行总线即可(SPI模式再加上1针用于选择芯片)。 -  MMC的操作电压为2.7伏到3.6伏,写/读电流只有27mA和23mA,功耗很低。它的读写模式包括**流式、多块和单块**。最小的数据传送是以块为单位的,缺省的块大小为512bytes。 - +MMC被设计作为一种低成本的__数据平台和通讯介质__,它的接口设计非常简单:只有7针!接口成本低于0.5美元,相比之下SmartMedia和Memory Stick的接口成本都要高于1美元。在接口中,电源供应是3针,而数据操作只用3针的串行总线即可(SPI模式再加上1针用于选择芯片)。 +MMC的操作电压为2.7伏到3.6伏,写/读电流只有27mA和23mA,功耗很低。它的读写模式包括**流式、多块和单块**。最小的数据传送是以块为单位的,缺省的块大小为512bytes。 ===== 移动存储器全面解析 ===== - -似乎每天都有新的海量存储器标准问世。__CompactFlash(CF)__曾一度独步天下,但是今天,新设备制造商不得不在CF、__安全数据(SD)__、SDIO、__多媒体存储卡(MMC)__、RS-MMC、MMC Plus、__MemoryStick__、XD-Picture(XD)和CE-ATA等等这些海量存储器之间做出选择。有时,一种新标准具有明显优势;而另外一些时候,新标准和已有标准又像是在重蹈Betamax与VHS格式间的对决,在先期很难看到谁将取得胜利。 +似乎每天都有新的海量存储器标准问世。__CompactFlash(CF)__曾一度独步天下,但是今天,新设备制造商不得不在CF、__安全数据(SD)__、SDIO、__多媒体存储卡(MMC)__、RS-MMC、MMC Plus、__MemoryStick__、XD-Picture(XD)和CE-ATA等等这些海量存储器之间做出选择。有时一种新标准具有明显优势;而另外一些时候,新标准和已有标准又像是在重蹈Betamax与VHS格式间的对决,在先期很难看到谁将取得胜利。 CF标准是所有小型海量存储器的鼻祖,10多年前由SanDisk开发出来。它具有8或16位并行数据总线,传输速率在3~66MBPS之间。在许多需要16位宽UDMA总线(66Mbps)的高传输速率和高容量设备中,仍需要CF标准。目前CF+格式硬盘的可用容量最高可达10GB,而CF闪存卡可用的最高容量是8GB。 - 因为首款CF卡使用的是**NOR闪存**,所以CF标准要求CF卡隐匿与NAND闪存接口的部分。主机在与CF卡通信时会将其看作是一个__IDE硬盘__,而**CF卡上的控制器**则负责坏块管理、平均读写(wear leveling)算法和与NAND闪存协同工作时所需的逻辑-物理映射。 - CF卡虽然一直未能成为手机用可移动存储器的主流,但它却在**数码相机**领域保持着极高的市场份额,特别是在大容量和高速度极为重要的高端市场。目前其它几种外设也可与**CF+版本的接口**进行连接,包括以太网、RS-232、传真/调制解调器、USB、蓝牙以及802.11b WLAN。 ===== 多媒体存储卡(MMC) ===== - 1997年,西门子和SanDisk推出了多媒体卡,其外形比CF卡小,从而可实现更小巧的便携式设备。在基本应用中,MMC可通过标准三线__SPI接口__外加一条片选线来控制。SPI接口的时钟频率最高可达20MHz。对需要更高带宽的应用,该规范提供拓宽了的4和8位带宽。MMC规范的4.0版增加了52MHz频率,从而支持50MBPS的传输速率。 - 与CF不同,MMC规范不免除授权费用。根据www.MMCA.org上提供的信息:如果你不是MMC制造商,你可以分别花500美元或1,000美元订购MMC3.1或4.1版(MMCmobile和MMCplus)规范,而你的公司也并不需要成为MMCA成员。 - 目前有三种类型的存储卡以MMC框架为基础,它们分别是:MMC Plus、MMC Mobile和MMC Micro。MMCplus是一种标称尺寸的MMC卡,它工作在2.7~3.6V电压下;具有1、4或8位的总线带宽;最低2.4MBPS的读写性能和26MHz频率(可以选择52MHz)。MMCmobile的体积更小,支持的电压也更低:1.65~1.95 V及2.7~3.6V。MMC mobile还必须支持MMCplus所需要提供的性能。__MicroSD__是该系列的最新补充。MicroSD的体积不到miniSD的1/3,是目前可用的最小存储卡(表1)。 - -{{~/sync/notes/zim/Research/MMC和SD卡/1142380.jpg}} +{{./1142380.jpg}} 表1:各种存储卡的主要参数比较。 - ===== MMC和SD卡:区别在哪里? ===== - - 常常有人将MMC标准和SD标准混为一谈,但实际上,它们是**两个不同的标准**。SD卡规范由以松下、东芝和SanDisk牵头的一个组织所有,而MMC规范由一个由涵盖广泛的行业组织领导的MMCA(多媒体卡协会)控制。 有些出人意料的是,SD卡背后的推动力量从未得到行业的广泛认可。SD卡具有与索尼MagicGate类似的__加密硬件__,MagicGate被用于索尼的MemoryStick产品中。在音乐界接受以数字方式传播音乐之前,SD卡花了8年多的时间希望得到行业认可,而现在,SD卡已经成为该领域的附属产品。去年初,MMC协会接纳了具有竞争性的安全卡标准——Secure MMC 1.1版规范。在三星网站www.samsung.com上可查到Secure MMC的概览。 - __MMC卡可插在为SD卡设计的物理槽内__,该槽有两种形态:薄形和标准形。薄SD卡可插入MMC槽,但标准SD卡却因为厚度而无法插进。MMC和SD卡所用的协议在SD卡规范rev 2.11中完全兼容,但自此后,两种规范出现了某种程度的分道扬镳。 -{{~/sync/notes/zim/Research/MMC和SD卡/1142381.jpg}} - +{{./1142381.jpg}} 图1:7脚MMC卡和9脚SD卡的区别清楚可见。 MMC和SD卡的管脚排列是兼容的(图1)。SD卡上最多有9个管脚,而MMC卡上最多有13个管脚(图2)。MMC卡上多出管脚的唯一功能是增加总线宽度(表2)。因为可以对总线宽度进行编程,所以控制器可容易地找到共同特性并据此进行设置。__所有带内置MMC支持能力的微处理器也支持SD卡。__ +{{./1142383.jpg}} -{{~/sync/notes/zim/Research/MMC和SD卡/1142382.jpg}} ===== 更小体积:MMC micro vs. MicroSD ===== - - MMC和SD组织为小型闪存卡创建的两种不同标准为业界带来了困惑。通过使用__机械适配器__,MMC micro和MicroSD(也称为TransFlash)都后向兼容现有的SD/MMC插槽(图3)。两种存储卡体积都很小,但MMC micro比MicroSD更快。MMC micro采用MMC规范定义的较高的52MHz时钟速率,而MicroSD则继续采用25MHz。另外,MMCmicro卡拥有4位数据总线,而MicroSD仅支持串行数据传输。再有,MMCmicro支持1.8V电压,而MicroSD仅能工作于2.7~3.6 V电压。 - -{{~/sync/notes/zim/Research/MMC和SD卡/1142383.jpg}} - +{{./1142382.jpg}} 图2:13脚MMC卡后向兼容7脚版本。 -{{~/sync/notes/zim/Research/MMC和SD卡/1142384.jpg}} +{{./1142384.jpg}} 图3:MMCmicro与MMC和SD的管脚排布。 ===== XD-Picture卡 ===== XD-Picture卡(以下简称“XD”卡)是在2002年7月推出的。与索尼的MemoryStick一样,它也是一种专属格式,所以很难从XD卡官方网站(www.xd-picture.com)中找到更多信息。如果想要了解你的公司需要花多少钱才能得到XD卡的使用许可,你必须与XD卡授权许可方签定保密协议。 +XD卡与SmartMedia标准有一点类似,即它们__都是针对原始NAND闪存的封装技术__。XD卡中没有嵌入控制器,所以控制CPU负责维护逻辑-物理表、管理坏区并执行纠错。该架构的优点是减小了硅面积,并且允许管理CPU拥有更多的接口控制能力,从而缩短写入时间。该架构的不利面,是管理CPU必须执行全部SmartMedia控制功能。 -XD卡与SmartMedia标准有一点类似,即它们都是针对原始NAND闪存的封装技术。XD卡中没有嵌入控制器,所以控制CPU负责维护逻辑-物理表、管理坏区并执行纠错。该架构的优点是减小了硅面积,并且允许管理CPU拥有更多的接口控制能力,从而缩短写入时间。该架构的不利面,是管理CPU必须执行全部SmartMedia控制功能。 - - -SDIO - - +===== SDIO ===== SDIO在SD标准上定义了一种外设接口。目前,SDIO有两类主要应用——可移动和不可移动。目前的可移动设备作为Palm和Windows Mobile的扩展设备,用来增加蓝牙、照相机、GPS和802.11b功能。不可移动设备遵循相同的电气标准,但不要求符合物理标准。某些手机内包含通过SDIO连接CPU的802.11芯片。此举将“珍贵”的I/O管脚资源用于更重要的功能。 - 蓝牙、照相机、GPS和802.11b设备有专为它们定义的应用规范。这些应用规范与为PCI和USB设备定义的类规范很相像。它们允许任何宿主设备与任意外设“通话”,只要它们都支持应用规范。 - SDIO和SD卡规范间的一个重要区别是增加了低速标准。SDIO卡只需要SPI和1位SD传输模式。低速卡的目标应用是以最小的硬件开支支持低速I/O能力。低速卡支持类似调制解调器、条码扫描仪和GPS接受器等应用。对“组合”卡(存储器+ SDIO)而言,全速和4位操作对卡内存储器和SDIO部分都是强制要求的。 - -CE-ATA - - +===== CE-ATA ===== CE-ATA有助于简化消费电子(CE)和ATA硬盘的结合。消费电子中有越来越多使用硬盘的趋向,但在小巧的手持设备中,40脚的ATA连接器和50脚的CF连接器实在占用了太多I/O资源。在CE-ATA规范中,ATA指令结构被覆盖在MMC物理层顶部。这种处理允许重新利用内置在当今常用应用处理器内的现有MMC控制器。CE-ATA连接器利用12个管脚实现9脚SD/MMC接口。多余的3个脚提供保留脚和额外的一对电源地,以便硬盘电机可工作在与信号线不同的电压。CE-ATA接口性能与4位SD/MMC一样。当采用25MHz和52MHz时钟时,其最高传输速率可分别达12.5MBPS和26MBPS。 diff --git a/Zim/嵌入式/以太网PHY芯片.txt b/Zim/嵌入式/以太网PHY芯片.txt index 121dd51..8a91292 100644 --- a/Zim/嵌入式/以太网PHY芯片.txt +++ b/Zim/嵌入式/以太网PHY芯片.txt @@ -76,7 +76,4 @@ PHY指物理层,OSI的最底层,一般指与外部信号接口的芯片。 PCMCIA接口是笔记本电脑专用接口,PCMCIA总线分为两类,一类为16位的__PCMCIA__,另一类为32位的__CardBus__,CardBus网卡的最大吞吐量接近90Mbps,其是目前市售笔记本网卡的主流。 ⑦Mini-PCI接口网卡 MiniPCI接口是在台式机PCI接口基础上扩展出的适用于笔记本电脑的接口标准,其速度和PCI标准相当,很多此类产品都是无线网卡。 -除此而外,市场上还有AMR等接口的网卡等等 - - - +除此而外,市场上还有AMR等接口的网卡等。 diff --git a/Zim/嵌入式/关与上拉和下拉电阻.txt b/Zim/嵌入式/关与上拉和下拉电阻.txt new file mode 100644 index 0000000..0161898 --- /dev/null +++ b/Zim/嵌入式/关与上拉和下拉电阻.txt @@ -0,0 +1,97 @@ +Content-Type: text/x-zim-wiki +Wiki-Format: zim 0.4 +Creation-Date: 2012-08-14T19:38:56+08:00 + +====== 关与上拉和下拉电阻 ====== +Created Tuesday 14 August 2012 +本文出自 “宋宝华的博客” 博客,请务必保留此出处http://21cnbao.blog.51cto.com/109393/120080 + +上拉电阻: +1、当TTL电路驱动COMS电路时,如果TTL电路输出的高电平低于COMS电路的最低高电平(一般为3.5V), +这时就需要在TTL的输出端接上拉电阻,以提高输出高电平的值。 + +2、OC/OD门电路必须加上拉电阻,才能使用。 + +3、为加大输出引脚的驱动能力,有的单片机管脚上也常使用上拉电阻。 + +4、在COMS芯片上,为了防止静电造成损坏,**不用的管脚不能悬空**,一般接上拉电阻产生降 +低输入阻抗,提供泄荷通路。 + +5、芯片的管脚加上拉电阻来提高输出电平,从而提高芯片输入信号的噪声容限增强抗干扰 +能力。 + +6、提高总线的抗电磁干扰能力。管脚悬空就比较容易接受外界的电磁干扰。 + +7、长线传输中电阻不匹配容易引起__反射波干扰__,加上下拉电阻是电阻匹配,有效的抑制反射波干扰。 + + +上拉电阻阻值的选择原则包括: + 1、从节约功耗及芯片的灌电流能力考虑应当足够大;电阻大,电流小。 + 2、从确保足够的驱动电流考虑应当足够小;电阻小,电流大。 + 3、对于高速电路,过大的上拉电阻可能边沿变平缓。 + +综合考虑以上三点,__通常在1k到10k之间选取__。对下拉电阻也有类似道理 。 + +对上拉电阻和下拉电阻的选择应__结合开关管特性和下级电路的输入特性__进行设定,主要需要考虑以下几个 +因素: + 1. 驱动能力与功耗的平衡。以上拉电阻为例,一般地说,上拉电阻越小,驱动能力越强,但功耗越大, + 设计是应注意两者之间的均衡。 + + 2. 下级电路的驱动需求。同样以上拉电阻为例,当输出高电平时,开关管断开,上拉电阻应适当选择以 + 能够向下级电路提供足够的电流。 + + 3. 高低电平的设定。不同电路的高低电平的__门槛电平__会有不同,电阻应适当设定以确保能输出正确的电 + 平。以上拉电阻为例,当输出低电平时,开关管导通,__上拉电阻和开关管导通电阻分压值应确保在零电平__ + __门槛之下。__ + + 4. 频率特性。以上拉电阻为例,上拉电阻和开关管漏源级之间的电容和下级电路之间的输入电容会形成 + RC延迟,电阻越大,延迟越大。上拉电阻的设定应考虑电路在这方面的需求。 + +OC门输出高电平时是一个高阻态,其上拉电流要由上拉电阻来提供,设输入端每端口不大于100uA,设输出 +口驱动电流约500uA,标准工作电压是5V,输入口的高低电平门限为:0.8V(低于此值为低电平);2V(高电平 +门限值)。 +选上拉电阻时: +500uA x 8.4K= 4.2即选大于8.4K时输出端能下拉至0.8V以下,此为__最小阻值__,再小就拉不下来了。如果 +输出口驱动电流较大,则阻值可减小,保证下拉时能低于0.8V即可。 + +当输出高电平时,忽略管子的漏电流,两输入口需200uA 。200uA x15K=3V即上拉电阻压降为3V,输出 +口可达到2V,此阻值为__最大阻值__,再大就拉不到2V了。选10K可用。COMS门的可参考74HC系列 + +设计时管子的漏电流不可忽略,IO口实际电流在不同电平下也是不同的,上述仅仅是原理,一句话概括为 +:__输出高电平时要喂饱后面的输入口,输出低电平不要把输出口喂撑了__(否则多余的电流喂给了级联的输 +入口,高于低电平门限值就不可靠了) + +在数字电路中不用的输入脚都要接固定电平,**通过1k电阻接高电平或接地**。 +1. 电阻作用: + l 接电组就是为了防止输入端悬空 + l 减弱外部电流对芯片产生的干扰 + l 保护cmos内的保护二极管,一般电流不大于10mA + l 上拉和下拉、限流 + l 改变电平的电位,常用在TTL-CMOS匹配 +2. 在引脚悬空时有确定的状态 +3.增加高电平输出时的驱动能力。 +4、为OC门提供电流 +l 那要看输出口驱动的是什么器件,如果该器件需要高电压的话,而输出口的输出电压又不够,就需要加 +上拉电阻。 +l 如果有上拉电阻那它的端口在默认值为高电平你要控制它必须用低电平才能控制如三态门电路三极管的 +集电极,或二极管正极去控制把上拉电阻的电流拉下来成为低电平。反之, l 尤其用在接口电路中,为了 +得到确定的电平,一般采用这种方法,以保证正确的电路状态,以免发生意外,比如,在电机控制中,逆变桥上 +下桥臂不能直通,如果它们都用同一个单片机来驱动,必须设置初始状态.防止直通! +2、定义: +l 上拉就是将不确定的信号通过一个电阻嵌位在高电平!电阻同时起限流作用!下拉同理! 上拉是对器 +件注入电流,下拉是输出电流 弱强只是上拉电阻的阻值不同,没有什么严格区分 对于非集电极(或漏 +极)开路输出型电路(如普通门电路)提升电流和电压的能力是有限的,上拉电阻的功能主要是为集电极 +开路输出型电路输出电流通道。 +3、为什么要使用拉电阻: +l 一般作单键触发使用时,如果IC本身没有内接电阻,为了使单键维持在不被触发的状态或是触发后回到 +原状态,必须在IC外部另接一电阻。 +l 数字电路有三种状态:高电平、低电平、和高阻状态,有些应用场合不希望出现高阻状态,可以通过上 +拉电阻或下拉电阻的方式使处于稳定状态,具体视设计要求而定! +l 一般说的是I/O端口,有的可以设置,有的不可以设置,有的是内置,有的是需要外接,I/O端口的输出 +类似与一个三极管的C,当C接通过一个电阻和电源连接在一起的时候,该电阻成为上C拉电阻,也就是说 +,如果该端口正常时为高电平,C通过一个电阻和地连接在一起的时候,该电阻称为下拉电阻,使该端口 +平时为低电平,作用吗: +比如:当一个接有上拉电阻的端口设为输如状态时,他的常态就为高电平,用于检测低电平的输入。 上 +拉电阻是用来解决总线驱动能力不足时提供电流的。一般说法是拉电流,下拉电阻是用来吸收电流的,也 +就是你同学说的灌电流 。 + diff --git a/Zim/嵌入式/总结及接口/GPIO.txt b/Zim/嵌入式/总结及接口/GPIO.txt index ca2b7dc..022aebf 100644 --- a/Zim/嵌入式/总结及接口/GPIO.txt +++ b/Zim/嵌入式/总结及接口/GPIO.txt @@ -73,4 +73,4 @@ C语言版本: (2)注意C语言下**实现寄存器读写**的(*(volatile unsigned long *)(addr))。其实就是要掌握volatile和指针的用法,明白在嵌入式环境中,为什么要这样操作。 (3)写c时,要注意头文件如何处理。写Makefile时,要注意是否采用隐含规则,如果不采用,就要自己定义明确规则,就像vivi里面的Rules.make。在这里,因为只是涉及到.s的编译不采用隐含规则,所以没有把Rules.make单独拿出,事实上可以单独写为Rules.make,然后在Makefile后加入include Rules.make就可以了。 (4)要调用C子程序,必须分配__堆栈空间__。因为子程序调用时,要进行入栈出栈处理。又因为从nand flash启动,而nand flash在S3C2410下的特点规定堆栈不能超过4K。 - 经过测试,两个程序都可以很好的运行。四个灯循环点亮^_^ + 经过测试,两个程序都可以很好的运行。四个灯循环点亮 ^_^ diff --git a/Zim/嵌入式/总结及接口/SPI总线知识点.txt b/Zim/嵌入式/总结及接口/SPI总线知识点.txt index 17baab8..2ce302d 100644 --- a/Zim/嵌入式/总结及接口/SPI总线知识点.txt +++ b/Zim/嵌入式/总结及接口/SPI总线知识点.txt @@ -6,7 +6,6 @@ Creation-Date: 2012-02-29T14:40:53+08:00 Created Wednesday 29 February 2012 http://blog.csdn.net/ling1874/article/details/5786080 - __SPI 串行外设接口总线__,最早由 Motorola 提出,出现在其 M68 系列单片机中,由于其简单实用,又不牵涉到专利问题,因此许多厂家的设备都支持该接口,广泛应用于外设控制领域。 SPI 接口是一种事实标准 ,__并没有标准协议__,大部分厂家都是参照 Motorola 的 SPI 接口定义来设计的。但正因为没有确切的版本协议,不同家产品的 SPI 接口在技术上存在一定的差别,容易引起歧义,有的甚至无法直接互连(需要软件进行必要的修改)。 @@ -14,10 +13,7 @@ SPI 接口是一种事实标准 ,__并没有标准协议__,大部分厂家 虽然 SPI 接口的内容非常简单,但本文仍将就其中的一些容易忽视的问题进行讨论。 ===== SPI ( Serial Peripheral Interface ) ===== - -SPI 接口是 Motorola 首先提出的__全双工三线同步串行外围接口__,采用__主从模式__( Master Slave )架构;支持__多 slave 模式__应用,一般仅支持__单 Master __。 - -__时钟由 Master 控制__,在时钟移位脉冲下,数据按位传输,__高位在前,低位在后__( MSB first ); SPI 接口有 2 根单向数据线,为**全双工通信**,目前应用中的数据速率可达几 Mbps 的水平。 +SPI 接口是 Motorola 首先提出的__全双工三线同步串行外围接口__,采用__主从模式__( Master Slave )架构;支持__多 slave 模式__应用,一般仅支持__单 Master __。__时钟由 Master 控制__,在时钟移位脉冲下,数据按位传输,__高位在前,低位在后__( MSB first ); SPI 接口有 2 根单向数据线,为**全双工通信**,目前应用中的数据速率可达几 Mbps 的水平。 * **时钟极性选择位 CPOL :** 在设备被使能激活后,还未进行数据传输时或两个字节数据传输间歇期间(见图 3 中的○ 1 与○ 2 处), SCLK 处于**空闲**( Idle )电平,通过 "CPOL 空闲状态极性控制位 " 可以选择此__空闲电平电平是 0 还是 1__ 。 @@ -26,6 +22,7 @@ __时钟由 Master 控制__,在时钟移位脉冲下,数据按位传输,__ 该控制位用来选择__数据接收端设备的采样时刻__。可能在 Idle to Active 的跳变沿(见图 3 中的红色圈处),也可能在 Active to Idle 的跳变沿(见图 3 中的蓝色圈处)。在该采样时刻,线上数据必须已经稳定可靠,因此数据发送端设备应提前将数据移出到数据线上。为了降低设计难度,大部分接口电路都是用__同一时钟周期中前一个时钟沿__(即相反时钟变化方向)将数据移出。 SPI 线上的 Master , Slave 设备必须根据具体情况__设置匹配的传输时序模式__,时序只有匹配,数据传输才能正常进行。如果设置的不匹配,可能导致数据接收方和发送方在同一时钟沿作用,导致数据传输失败。 + {{./1.jpg}} 我们以手机设计中非常流行的**触摸屏控制器 TSC2046** 为例,介绍 SPI 接口的实际应用。 @@ -38,13 +35,12 @@ TSC2046 是在时钟的第一个 Idle to Active 沿采集数据(下图 1 处 ===== 多 Slave 的应用 ===== {{./3.jpg}} + SPI 也支持多 Slave 应用。多个 Slave 共享时钟线、数据线,可以**直接并接在一起**;而各 Slave 的__片选线 SS __则单独与 Master 连接,受 Master 控制。在一段时间内, Master 只能**通过某根 SS 线激活一个 Slave **,进行数据传输,而此时其他 Slave 的时钟线和数据线端口则都应保持__高阻状态__,以免影响当前数据传输的进行。 + - - -===== SPI Vs I2C ===== - -SPI 协议没有定义寻址机制,需通过外部 SS 信号线选择设备,当出现多 slave 应用时,需要多根 SS 信号线,实施起来较 I2C 要复杂。此外, SPI 总线__不支持总线控制权仲裁__,故只能用在**单 Master** 的场合;而 I2C 可以支持多 Master 的应用。 +===== SPI VS I2C ===== +SPI 协议没有定义寻址机制,需通过外部 SS 信号线选择设备,当出现多 slave 应用时,需要多根 SS 信号线,实施起来较 I2C 要复杂。此外, SPI 总线__不支持总线控制权仲裁__,故只能用在**单Master** 的场合;而 I2C 可以支持多 Master 的应用。 SPI 协议相对 I2C 要简单,没有握手机制,数据传输效率高,速率也更快,通常应用中可达__几 Mbps__ ;此外 SPI 是全双工通信,可同时发送和接收数据,因此, SPI 比较__适合用于数据传输的场合__。比如需要较大批量数据传输的场合(比如 MMC/SD 卡的数据传输就支持 SPI 模式),或者无需寻址传输的场合。 而 I2C 协议功能较丰富,但也相对复杂,__多用在传输一些控制命令字等有意义数据的场合__。 diff --git a/Zim/嵌入式/漏极开漏和集电极开漏.txt b/Zim/嵌入式/漏极开漏和集电极开漏.txt new file mode 100644 index 0000000..b6d8cde --- /dev/null +++ b/Zim/嵌入式/漏极开漏和集电极开漏.txt @@ -0,0 +1,69 @@ +Content-Type: text/x-zim-wiki +Wiki-Format: zim 0.4 +Creation-Date: 2012-08-14T17:05:48+08:00 + +====== 漏极开漏和集电极开漏 ====== +Created Tuesday 14 August 2012 +http://blog.csdn.net/jamestaosh/article/details/4371400 + +推挽输出与开漏输出的区别: + + 推挽输出: 可以输出高,低电平,连接数字器件;是两个参数相同的三极管或MOSFET,以推挽方式存在于电路中,各负责正负半周的波形放大任务。电路工作时,两只对称的功率开关管每次只有一个导通,所以导通损耗小,效率高。输出既可以向负载灌电流,也可以从负载抽取电流。 + + 开漏输出: 输出端相当于三极管的集电极. 要得到高电平状态需要上拉电阻才行. 适合于做**电流型的驱动**,其吸收电流的能力相对强(一般20ma以内). + + **推挽结构一般是指两个三极管分别受两互补信号的控制,总是在一个三极管导通的时候另一个截止.** + +开漏电路特点及应用 + + 在电路设计时我们常常遇到开漏(open drain)和开集(open collector)的概念。所谓开漏电路概念中提到的“漏”就是指MOSFET的漏极。同理,开集电路中的“集”就是指三极管的集电极。开漏电路就是指以MOSFET的漏极为输出的电路。一般的用法是会在漏极外部的电路添加__上拉电阻__。完整的开漏电路应该由开漏器件和开漏上拉电阻组成。如图1所示: +{{./1.jpg}} + + 图1 + +组成开漏形式的电路有以下几个特点: +1. 利用外部电路的驱动能力,减少IC内部的驱动(或驱动比芯片电源电压高的负载)。当IC内部MOSFET导通时,驱动电流是从外部的VCC流经R pull-up ,MOSFET到GND。IC内部仅需很下的栅极驱动电流。如图1。 + +2. 可以将多个开漏输出的Pin,连接到一条线上。形成 “__与逻辑”__ 关系。如图1,当PIN_A、PIN_B、PIN_C任意一个变低后,开漏线上的逻辑就为0了。这也是 __I2C__,SMBus等总线判断__总线占用状态__的原理。如果作为输出必须接上拉电阻。接容性负载时,下降延是芯片内的晶体管,是有源驱动,速度较快;上升延是无源的外接电阻,速度慢。如果要求速度高电阻选择要小,功耗会大。所以负载电阻的选择要兼顾功耗和速度。 + +3. 可以利用改变上拉电源的电压,__改变传输电平__。如图2, __IC的逻辑电平由电源Vcc1决定,而输出高电平则由Vcc2__(上拉电阻的电源电压)决定。这样我们就可以用低电平逻辑控制输出高电平逻辑了(这样你就可以进行任意电平的转换)。(例如加上上拉电阻就可以提供TTL/CMOS电平输出等。) +{{./2.jpg}} + + + 图2 + +4. 开漏Pin不连接外部的上拉电阻,则__只能输出低电平__(因此对于经典的51单片机的P0口而言,要想做输入输出功能必须加外部上拉电阻,否则无法输出高电平逻辑)。一般来说,开漏是用来连接不同电平的器件,匹配电平用的。 + +5. 标准的开漏脚一般只有输出的能力。添加其它的判断电路,才能具备双向输入、输出的能力。 + +6.正常的CMOS输出级是上、下两个管子,把上面的管子去掉就是OPEN-DRAIN了。这种输出的主要目的有两个:__电平转换、线与__。 + +7.线与功能主要用于有多个电路对同一信号进行拉低操作的场合,如果本电路不想拉低,就输出高电平,因为OPEN-DRAIN上面的管子被拿掉,高电平是靠外接的上拉电阻实现的。(__而正常的CMOS输出级,如果出现一个输出为高另外一个为低时,等于电源短路__。) + +8.OPEN-DRAIN提供了灵活的输出方式,但是也有其弱点,就是带来__上升沿的延时__。因为上升沿是通过外接上拉无源电阻对负载充电,所以当电阻选择小时延时就小,但功耗大;反之延时大功耗小。所以如果对延时有要求,则建议用下降沿输出。 + + +应用中需注意: +1. 开漏和开集的原理类似,在许多应用中我们利用开集电路代替开漏电路。例如,某输入Pin要求由开漏电路驱动。则我们常见的驱动方式是利用一个三极管组成开集电路来驱动它,即方便又节省成本。如图3。 + +2. 上拉电阻R pull-up的阻值决定了逻辑电平转换的沿的速度。阻值越大,速度越低功耗越小。反之亦然。 + + +一.什么是OC、OD + +集电极开路门(集电极开路 OC 或源极开路OD) +open-drain是漏极开路输出的意思,相当于集电极开路(open-collector)输出,即ttl中的集电极开路(oc)输出。一般用于线或、线与,也有的用于电流驱动。 +open-drain是对mos管而言,open-collector是对双极型管而言,在用法上没啥区别。 + + +二.什么是线或逻辑与线与逻辑? + + 线与逻辑,即两个输出端(包括两个以上)直接互连就可以实现“AND”的逻辑功能。在总线传输等实际应用中需要多个门的输出端并联连接使用,而一般TTL门输出端并不能直接并接使用,否则__这些门的输出管之间由于低阻抗形成很大的短路电流(灌电流)__,而烧坏器件。在硬件上,可用OC门或三态门(ST门)来实现。用OC门实现线与,应同时在输出端口应加一个上拉电阻。 + + 三态门(ST门)主要用在应用于__多个门输出共享数据总线__,为避免多个门输出同时占用数据总线,这些门的使能信号(EN)中只允许有一个为有效电平(如高电平),由于三态门的输出是推拉式的低阻输出,且不需接上拉(负载)电阻,所以开关速度比 OC门快,常用三态门作为输出缓冲器。 + + 在一个结点(线)上, 连接一个上拉电阻到电源 VCC 或 VDD 和 n 个 NPN 或 NMOS 晶体管的集电极 C 或漏极 D, 这些晶体管的发射极 E 或源极 S 都接到地线上, 只要有一个晶体管饱和, 这个结点(线)就被拉到地线电平上. + + 因为这些晶体管的基极注入电流(NPN)或栅极加上高电平(NMOS), 晶体管就会饱和, 所以这些基极或栅极对这个结点(线)的关系是或非 NOR 逻辑. 如果这个结点后面加一个反相器, 就是或 OR 逻辑. + + 这些晶体管常常是一些逻辑电路的集电极开路 OC 或源极开路 OD 输出端. 这种逻辑通常称为线与/线或逻辑, 当你看到一些芯片的 OC 或 OD 输出端连在一起, 而有一个上拉电阻时, 这就是线或/线与了, 但__有时上拉电阻做在芯片的输入端内__. 顺便提示如果不是 OC 或 OD 芯片的输出端是不可以连在一起的, 总线 BUS 上的双向输出端连在一起是有管理的, 同时只能有一个作输出, 而其他是高阻态只能输入. diff --git a/Zim/嵌入式/漏极开漏和集电极开漏/1.jpg b/Zim/嵌入式/漏极开漏和集电极开漏/1.jpg new file mode 100644 index 0000000..8a001d5 Binary files /dev/null and b/Zim/嵌入式/漏极开漏和集电极开漏/1.jpg differ diff --git a/Zim/嵌入式/漏极开漏和集电极开漏/2.jpg b/Zim/嵌入式/漏极开漏和集电极开漏/2.jpg new file mode 100644 index 0000000..a635afe Binary files /dev/null and b/Zim/嵌入式/漏极开漏和集电极开漏/2.jpg differ diff --git a/Zim/嵌入式/漏极开漏和集电极开漏/3.jpg b/Zim/嵌入式/漏极开漏和集电极开漏/3.jpg new file mode 100644 index 0000000..459c609 Binary files /dev/null and b/Zim/嵌入式/漏极开漏和集电极开漏/3.jpg differ