﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>IT博客-一桶浆糊-文章分类-网文摘抄</title><link>http://www.cnitblog.com/SmartJacky/category/1673.html</link><description>风起云涌，我笑熬浆糊</description><language>zh-cn</language><lastBuildDate>Sat, 08 Oct 2011 07:36:04 GMT</lastBuildDate><pubDate>Sat, 08 Oct 2011 07:36:04 GMT</pubDate><ttl>60</ttl><item><title>About CPLD</title><link>http://www.cnitblog.com/SmartJacky/articles/CPLD.html</link><dc:creator>一桶浆糊</dc:creator><author>一桶浆糊</author><pubDate>Wed, 08 Feb 2006 01:14:00 GMT</pubDate><guid>http://www.cnitblog.com/SmartJacky/articles/CPLD.html</guid><wfw:comment>http://www.cnitblog.com/SmartJacky/comments/6493.html</wfw:comment><comments>http://www.cnitblog.com/SmartJacky/articles/CPLD.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/SmartJacky/comments/commentRss/6493.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/SmartJacky/services/trackbacks/6493.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;随着电子技术的不断发展与进步，电子系统的设计方法发生了很大的变化，传统的设计方法正逐步退出历史舞台，而基于EDA技术的芯片设计正在成为电子系统设计的主流。大规模可编程逻辑器件CPLD和FPGA是当今应用最广泛的两类可编程专用集成电路（ASIC），电子设计工程师利用它可以在办公室或实验室里设计出所需的专用集成电路，从而大大缩短了产品上市时间，降低了开发成本。此外，可编程逻辑器件还具有静态可重复编程和动态在系统重构的特性，使得硬件的功能可以像软件一样通过编程来修改，这样就极大地提高了电子系统设计的灵活性和通用性。<BR>&nbsp;&nbsp;&nbsp; 由于具备上述两方面特点，CPLD和FPGA受到了世界范围内广大电子设计工程师的普遍欢迎，应用日益广泛。与此同时，可编程ASIC本身也在近几年得到了迅速的发展，其集成度、工作速度不断提高。目前已有单片可用门数超过300万门、工作频率可达200&nbsp; MHz以上的可编程ASIC芯片问世。由于结构和工艺的改进，可编程ASIC芯片上包含的资源越来越丰富，可实现的功能越来越强，它们已成为当今实现电子系统集成化的重要手段。<BR>&nbsp;&nbsp;&nbsp; Xilinx公司是全球著名的可编程逻辑器件供应商，也是FPGA器件的发明者，它在多年用户需求的基础上开发了多种性能优越的系列产品，其售后服务周全，用户涉及面广，是开发和研制产品的最佳选择之一。<BR><BR><BR><STRONG><FONT size=5>cpld与fpga的区别<BR><BR></FONT></STRONG>尽管ＦＰＧＡ和ＣＰＬＤ都是可编程ＡＳＩＣ器件,有很多共同特点,但由于ＣＰＬＤ和ＦＰＧＡ结构上的差异,具有各自的特点:<BR>①ＣＰＬＤ更适合完成各种算法和组合逻辑,ＦＰ ＧＡ更适合于完成时序逻辑。换句话说,ＦＰＧＡ更适合于触发器丰富的结构,而ＣＰＬＤ更适合于触发器有限而乘积项丰富的结构。
<P>②ＣＰＬＤ的连续式布线结构决定了它的时序延迟是均匀的和可预测的,而ＦＰＧＡ的分段式布线结构决定了其延迟的不可预测性。</P>
<P>③在编程上ＦＰＧＡ比ＣＰＬＤ具有更大的灵活性。ＣＰＬＤ通过修改具有固定内连电路的逻辑功能来编程,ＦＰＧＡ主要通过改变内部连线的布线来编程;ＦＰ ＧＡ可在逻辑门下编程,而ＣＰＬＤ是在逻辑块下编程。</P>
<P>④ＦＰＧＡ的集成度比ＣＰＬＤ高,具有更复杂的布线结构和逻辑实现。</P>
<P>⑤ＣＰＬＤ比ＦＰＧＡ使用起来更方便。ＣＰＬＤ的编程采用Ｅ2ＰＲＯＭ或ＦＡＳＴＦＬＡＳＨ技术,无需外部存储器芯片,使用简单。而ＦＰＧＡ的编程信息需存放在外部存储器上,使用方法复杂。</P>
<P>⑥ＣＰＬＤ的速度比ＦＰＧＡ快,并且具有较大的时间可预测性。这是由于ＦＰＧＡ是门级编程,并且ＣＬＢ之间采用分布式互联,而ＣＰＬＤ是逻辑块级编程,并且其逻辑块之间的互联是集总式的。</P>
<P>⑦在编程方式上,ＣＰＬＤ主要是基于Ｅ2ＰＲＯＭ或ＦＬＡＳＨ存储器编程,编程次数可达1万次,优点是系统断电时编程信息也不丢失。ＣＰＬＤ又可分为在编程器上编程和在系统编程两类。ＦＰＧＡ大部分是基于ＳＲＡＭ编程,编程信息在系统断电时丢失,每次上电时,需从器件外部将编程数据重新写入ＳＲＡＭ中。其优点是可以编程任意次,可在工作中快速编程,从而实现板级和系统级的动态配置。</P>
<P>⑧ＣＰＬＤ保密性好,ＦＰＧＡ保密性差。</P>
<P>⑨一般情况下,ＣＰＬＤ的功耗要比ＦＰＧＡ大,且集成度越高越明显。</P><img src ="http://www.cnitblog.com/SmartJacky/aggbug/6493.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/SmartJacky/" target="_blank">一桶浆糊</a> 2006-02-08 09:14 <a href="http://www.cnitblog.com/SmartJacky/articles/CPLD.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>  mp3文件格式（frame header ）</title><link>http://www.cnitblog.com/SmartJacky/articles/5852.html</link><dc:creator>一桶浆糊</dc:creator><author>一桶浆糊</author><pubDate>Wed, 28 Dec 2005 09:42:00 GMT</pubDate><guid>http://www.cnitblog.com/SmartJacky/articles/5852.html</guid><wfw:comment>http://www.cnitblog.com/SmartJacky/comments/5852.html</wfw:comment><comments>http://www.cnitblog.com/SmartJacky/articles/5852.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cnitblog.com/SmartJacky/comments/commentRss/5852.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/SmartJacky/services/trackbacks/5852.html</trackback:ping><description><![CDATA[<TABLE cellSpacing=0 cellPadding=0 width=760 align=center border=0>
<TBODY>
<TR>
<TD width="3%"></TD>
<TD style="LINE-HEIGHT: 150%" width="94%" height=30>
<P><BR>mp3文件格式（frame header ）<BR><BR>MPEG Audio Layer I/II/III frame header <BR>An MPEG audio file is built up from smaller parts called frames.MPEG audio文件是由称为frames的小部分组成的。 Generally, frames are independent items通常frames是由items决定的. Each frame has its own header and audio informations每一个frame有自己的头和audio信息. As there is no file header, you can cut any part of MPEG file and play it correctly (this should be done on frame boundaries but most applications will handle incorrect headers)如果没有文件头，你可以删减掉任何一个部分的MPEG文件来正常播放(这个…..). However, for Layer III, this is not 100% correct但是在Layer III,就不是完全这样了. Due to internal data organization in MPEG Layer III files, frames are often dependent of each other and they cannot be cut off just like that由于文件内部组织，frames之间是相互关联的，所以不能象前面一样剪裁出单独的部分播放. <BR>When you want to read info about an MPEG file, it is usually enough to find the first frame, read its header and assume that the other frames are the same 当你想要读MPEG文件，通常先读第一个头，然后假设其他头也是一样的. But this may not be always the case但是情况并不总是如此. Variable bitrate MPEG files may use so called bitrate switching, which means that bitrate changes according to the content of each frame可变比特率 MPEG文件使用比特率改变――比特率随着每一frame内容改变. This way lower bitrates may be used in frames where it will not reduce sound quality这样就可以减小文件尺寸，但是声音的质量却不会降低. This allows making better compression while keeping high quality of sound. 这样就可以在更大的压缩率下保持高音质。<BR>The frame header is constituted by the very first four bytes (32bits) in a frame在frame开头有4个字节. The first eleven bits (or first twelve bits, see below about frame sync) of a frame header are always set and they are called "frame sync"开始11个比特位(或者是12位，见后面同步帧)被称为同步帧. Therefore, you can search through the file for the first occurence of frame sync (meaning that you have to find a byte with a value of 255, and followed by a byte with its three (or four) most significant bits set)这样你就可以搜索文件定位同步帧（）. Then you read the whole header and check if the values are correct然后你就读入整个header然后检测是否有效. You will see in the following table the exact meaning of each bit in the header在后面的表你就可以看见每一位的意思. Each value that is specified as reserved, invalid, bad, or not allowed should indicate an invalid header. 每一个值分别表示保留、无效、坏、禁止<BR>Frames may have a CRC check帧可能有CRC校验. The CRC is 16 bits long and, if it exists, it follows the frame header如果由，其长度为16bie,紧跟frame后. After the CRC comes the audio data.音频文件就在crc后面。 You may calculate the CRC of the frame你应该校验帧的CRC, and compare it with the one you read from the file然后与你读的文件校验. This is actually a very good method to check the MPEG frame validity. 这是检查MGEG帧的好办法<BR>Here is a presentation of the header content一下是header的内容. Characters from A to M are used to indicate different fields字母A~M表示不同的Field. In the table below, you can see details about the content of each field. 你要仔细看下面的内容<BR>AAAAAAAA AAABBCCD EEEEFFGH IIJJKLMM<BR>Sign&nbsp;Length<BR>(bits)&nbsp;Position<BR>(bits)&nbsp;Description<BR>A&nbsp;11&nbsp;(31-21)&nbsp;Frame sync (all bits set)<BR>B&nbsp;2&nbsp;(20,19)&nbsp;MPEG Audio version ID<BR>00 - MPEG Version 2.5 (unofficial)<BR>01 - reserved<BR>10 - MPEG Version 2 (ISO/IEC 13818-3)<BR>11 - MPEG Version 1 (ISO/IEC 11172-3)<BR>Note: MPEG Version 2.5 is not official standard. It is an extension of the standard used for very low bitrate files. If your decoder does not support this extension, it is recommended for you to use 12 bits for synchronization instead of 11 bits.<BR>C&nbsp;2&nbsp;(18,17)&nbsp;Layer description<BR>00 - reserved<BR>01 - Layer III<BR>10 - Layer II<BR>11 - Layer I<BR>D&nbsp;1&nbsp;(16)&nbsp;Protection bit<BR>0 - Protected by CRC (16bit crc follows header)<BR>1 - Not protected<BR>E&nbsp;4&nbsp;(15,12)&nbsp;Bitrate index<BR>bits&nbsp;V1,L1&nbsp;V1,L2&nbsp;V1,L3&nbsp;V2,L1&nbsp;V2, L2 &amp; L3<BR>0000&nbsp;free&nbsp;free&nbsp;free&nbsp;free&nbsp;free<BR>0001&nbsp;32&nbsp;32&nbsp;32&nbsp;32&nbsp;8<BR>0010&nbsp;64&nbsp;48&nbsp;40&nbsp;48&nbsp;16<BR>0011&nbsp;96&nbsp;56&nbsp;48&nbsp;56&nbsp;24<BR>0100&nbsp;128&nbsp;64&nbsp;56&nbsp;64&nbsp;32<BR>0101&nbsp;160&nbsp;80&nbsp;64&nbsp;80&nbsp;40<BR>0110&nbsp;192&nbsp;96&nbsp;80&nbsp;96&nbsp;48<BR>0111&nbsp;224&nbsp;112&nbsp;96&nbsp;112&nbsp;56<BR>1000&nbsp;256&nbsp;128&nbsp;112&nbsp;128&nbsp;64<BR>1001&nbsp;288&nbsp;160&nbsp;128&nbsp;144&nbsp;80<BR>1010&nbsp;320&nbsp;192&nbsp;160&nbsp;160&nbsp;96<BR>1011&nbsp;352&nbsp;224&nbsp;192&nbsp;176&nbsp;112<BR>1100&nbsp;384&nbsp;256&nbsp;224&nbsp;192&nbsp;128<BR>1101&nbsp;416&nbsp;320&nbsp;256&nbsp;224&nbsp;144<BR>1110&nbsp;448&nbsp;384&nbsp;320&nbsp;256&nbsp;160<BR>1111&nbsp;bad&nbsp;bad&nbsp;bad&nbsp;bad&nbsp;bad<BR>NOTES: All values are in kbps<BR>V1 - MPEG Version 1<BR>V2 - MPEG Version 2 and Version 2.5<BR>L1 - Layer I<BR>L2 - Layer II<BR>L3 - Layer III</P>
<P>"free" means free format. If the correct fixed bitrate (such files cannot use variable bitrate) is different than those presented in upper table it must be determined by the application. This may be implemented only for internal purposes since third party applications have no means to findout correct bitrate. Howewer, this is not impossible to do but demands lots of efforts.<BR>"bad" means that this is not an allowed value<BR>MPEG files may have variable bitrate (VBR). Each frame may be created with different bitrate. It may be used in all layers. Layer III decoders must support this method. Layer I &amp; II decoders may support it.<BR>For Layer II there are some combinations of bitrate and mode which are not allowed. Here is a list of allowed combinations. <BR>bitrate&nbsp;single channel&nbsp;stereo&nbsp;intensity stereo&nbsp;dual channel<BR>free&nbsp;yes&nbsp;yes&nbsp;yes&nbsp;yes<BR>32&nbsp;yes&nbsp;no&nbsp;no&nbsp;no<BR>48&nbsp;yes&nbsp;no&nbsp;no&nbsp;no<BR>56&nbsp;yes&nbsp;no&nbsp;no&nbsp;no<BR>64&nbsp;yes&nbsp;yes&nbsp;yes&nbsp;yes<BR>80&nbsp;yes&nbsp;no&nbsp;no&nbsp;no<BR>96&nbsp;yes&nbsp;yes&nbsp;yes&nbsp;yes<BR>112&nbsp;yes&nbsp;yes&nbsp;yes&nbsp;yes<BR>128&nbsp;yes&nbsp;yes&nbsp;yes&nbsp;yes<BR>160&nbsp;yes&nbsp;yes&nbsp;yes&nbsp;yes<BR>192&nbsp;yes&nbsp;yes&nbsp;yes&nbsp;yes<BR>224&nbsp;no&nbsp;yes&nbsp;yes&nbsp;yes<BR>256&nbsp;no&nbsp;yes&nbsp;yes&nbsp;yes<BR>320&nbsp;no&nbsp;yes&nbsp;yes&nbsp;yes<BR>384&nbsp;no&nbsp;yes&nbsp;yes&nbsp;yes</P>
<P>F&nbsp;2&nbsp;(11,10)&nbsp;Sampling rate frequency index (values are in Hz) <BR>bits&nbsp;MPEG1&nbsp;MPEG2&nbsp;MPEG2.5<BR>00&nbsp;44100&nbsp;22050&nbsp;11025<BR>01&nbsp;48000&nbsp;24000&nbsp;12000<BR>10&nbsp;32000&nbsp;16000&nbsp;8000<BR>11&nbsp;reserv.&nbsp;reserv.&nbsp;reserv.</P>
<P>G&nbsp;1&nbsp;(9)&nbsp;Padding bit<BR>0 - frame is not padded<BR>1 - frame is padded with one extra slot<BR>Padding is used to fit the bit rates exactly. For an example: 128k 44.1kHz layer II uses a lot of 418 bytes and some of 417 bytes long frames to get the exact 128k bitrate. For Layer I slot is 32 bits long, for Layer II and Layer III slot is 8 bits long.<BR>H&nbsp;1&nbsp;(8)&nbsp;Private bit. It may be freely used for specific needs of an application.<BR>I&nbsp;2&nbsp;(7,6)&nbsp;Channel Mode<BR>00 - Stereo<BR>01 - Joint stereo (Stereo)<BR>10 - Dual channel (2 mono channels)<BR>11 - Single channel (Mono)</P>
<P>Note: Dual channel files are made of two independant mono channel. Each one uses exactly half the bitrate of the file. Most decoders output them as stereo, but it might not always be the case.<BR>????One example of use would be some speech in two different languages carried in the same bitstream, and and appropriate decoder would decode only the choosen language<BR>另外一篇文章的描述<BR>Mpeg 1.0/2.0 LayersI, II and III header and trailer formats<BR>-----------------------------------------------------------<BR><A href="mailto:Laurent.Clevy@alcatel.fr">Laurent.Clevy@alcatel.fr</A><BR>* HEADER</P>
<P>bits name comments<BR>--------------------------------------------------<BR>12 sync 0xFFF<BR>1 version 1=mpeg1.0, 0=mpeg2.0<BR>2 lay 4-lay = layerI, II or III<BR>1 error protection 0=yes, 1=no<BR>4 bitrate_index see table below<BR>2 sampling_freq see table below<BR>1 padding<BR>1 extension see table below<BR>2 mode see table below<BR>2 mode_ext used with "joint stereo" mode<BR>1 copyright 0=no 1=yes<BR>1 original 0=no 1=yes<BR>2 emphasis see table below<BR>--------------------------------------------------<BR>- bitrate_index<BR>. mpeg1.0<BR>1 2 3 4 5 6 7 8 9 10 11 12 13 14<BR>layer1 32 64 96 128 160 192 224 256 288 320 352 384 416 448<BR>layer2 32 48 56 64 80 96 112 128 160 192 224 256 320 384<BR>layer3 32 40 48 56 64 80 96 112 128 160 192 224 256 320<BR>. mpeg2.0<BR>1 2 3 4 5 6 7 8 9 10 11 12 13 14<BR>layer1 32 48 56 64 80 96 112 128 144 160 176 192 224 256<BR>layer2 8 16 24 32 40 48 56 64 80 96 112 128 144 160<BR>layer3 8 16 24 32 40 48 56 64 80 96 112 128 144 160</P>
<P>- sampling_freq<BR>. mpeg1.0<BR>0 1 2 <BR>44100 48000 32000 <BR>. mpeg2.0<BR>0 1 2 <BR>22050 24000 16000 </P>
<P>- mode:<BR>0 "stereo"<BR>1 "joint stereo"<BR>2 "dual channel"<BR>3 "single channel"</P>
<P>- mode extension:</P>
<P>0 MPG_MD_LR_LR<BR>1 MPG_MD_LR_I<BR>2 MPG_MD_MS_LR <BR>3 MPG_MD_MS_I<BR>jsbound :<BR>mode_ext 0 1 2 3<BR>layer<BR>1 4 8 12 16<BR>2 4 8 12 16<BR>3 0 4 8 16</P>
<P>- emphasis:<BR>0 "none"<BR>1 "50/15 microsecs"<BR>2 "reserved" must not be used !<BR>3 "CCITT J 17"</P>
<P>* TRAILER<BR>at end of file - 128 bytes<BR>offset type len name<BR>--------------------------------------------<BR>0 char 3 "TAG"<BR>3 char 30 title<BR>33 char 30 artist<BR>63 char 30 album<BR>93 char 4 year<BR>97 char 30 comments<BR>127 byte 1 genre<BR>--------------------------------------------<BR>- genre :<BR>0 "Blues"<BR>1 "Classic Rock"<BR>2 "Country"<BR>3 "Dance"<BR>4 "Disco"<BR>5 "Funk"<BR>6 "Grunge"<BR>7 "Hip-Hop"<BR>8 "Jazz"<BR>9 "Metal"<BR>10 "New Age"<BR>11 "Oldies"<BR>12 "Other"<BR>13 "Pop"<BR>14 "R&amp;B"<BR>15 "Rap"<BR>16 "Reggae"<BR>17 "Rock"<BR>18 "Techno"<BR>19 "Industrial"<BR>20 "Alternative"<BR>21 "Ska"<BR>22 "Death Metal"<BR>23 "Pranks"<BR>24 "Soundtrack"<BR>25 "Euro-Techno"<BR>26 "Ambient"<BR>27 "Trip-Hop"<BR>28 "Vocal"<BR>29 "Jazz+Funk"<BR>30 "Fusion"<BR>31 "Trance"<BR>32 "Classical"<BR>33 "Instrumental"<BR>34 "Acid"<BR>35 "House"<BR>36 "Game"<BR>37 "Sound Clip"<BR>38 "Gospel"<BR>39 "Noise"<BR>40 "AlternRock"<BR>41 "Bass"<BR>42 "Soul"<BR>43 "Punk"<BR>44 "Space"<BR>45 "Meditative"<BR>46 "Instrumental Pop"<BR>47 "Instrumental Rock"<BR>48 "Ethnic"<BR>49 "Gothic"<BR>50 "Darkwave"<BR>51 "Techno-Industrial"<BR>52 "Electronic"<BR>53 "Pop-Folk"<BR>54 "Eurodance"<BR>55 "Dream"<BR>56 "Southern Rock"<BR>57 "Comedy"<BR>58 "Cult"<BR>59 "Gangsta"<BR>60 "Top 40"<BR>61 "Christian Rap"<BR>62 "Pop/Funk"<BR>63 "Jungle"<BR>64 "Native American"<BR>65 "Cabaret"<BR>66 "New Wave"<BR>67 "Psychadelic"<BR>68 "Rave"<BR>69 "Showtunes"<BR>70 "Trailer"<BR>71 "Lo-Fi"<BR>72 "Tribal"<BR>73 "Acid Punk"<BR>74 "Acid Jazz"<BR>75 "Polka"<BR>76 "Retro"<BR>77 "Musical"<BR>78 "Rock &amp; Roll"<BR>79 "Hard Rock"<BR>80 "Unknown"<BR>- frame length :<BR>. mpeg1.0<BR>layer1 :<BR>(48000*bitrate)/sampling_freq + padding<BR>layer2&amp;3:<BR>(144000*bitrate)/sampling_freq + padding<BR>. mpeg2.0<BR>layer1 :<BR>(24000*bitrate)/sampling_freq + padding<BR>layer2&amp;3 :<BR>(72000*bitrate)/sampling_freq + padding</P>
<P></P></TD>
<TD width="3%"></TD></TR>
<TR>
<TD align=middle colSpan=3>
<SCRIPT language=JavaScript src="/js/article_down.js" type=text/JavaScript></SCRIPT>
</TD></TR></TBODY></TABLE>
<SCRIPT src="/tong.php?article_type=105&amp;id=66924"></SCRIPT>
<BR>
<SCRIPT language=JavaScript src="/js/article_footer.js" type=text/JavaScript></SCRIPT>
<A HREF="/Files/SmartJacky/MP3_Fomat.rar">中文的文档<BR></A>
<SCRIPT language=JavaScript src="http://www.cnitblog.com/images/footer.htm" type=text/JavaScript></SCRIPT><img src ="http://www.cnitblog.com/SmartJacky/aggbug/5852.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/SmartJacky/" target="_blank">一桶浆糊</a> 2005-12-28 17:42 <a href="http://www.cnitblog.com/SmartJacky/articles/5852.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>WinCE系统下BootLoader的开发</title><link>http://www.cnitblog.com/SmartJacky/articles/5839.html</link><dc:creator>一桶浆糊</dc:creator><author>一桶浆糊</author><pubDate>Wed, 28 Dec 2005 03:47:00 GMT</pubDate><guid>http://www.cnitblog.com/SmartJacky/articles/5839.html</guid><wfw:comment>http://www.cnitblog.com/SmartJacky/comments/5839.html</wfw:comment><comments>http://www.cnitblog.com/SmartJacky/articles/5839.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/SmartJacky/comments/commentRss/5839.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/SmartJacky/services/trackbacks/5839.html</trackback:ping><description><![CDATA[<SPAN class=Normal id=_ctl0__ctl0__ctl0_lblContent><SPAN class=postbody><FONT size=2><SPAN style="FONT-WEIGHT: bold">摘要：</SPAN>介绍WinCE.NET系统的旧方法；说明板级支持包（BSP）的基本构成；从开发实际出发，详细阐述如何开发BSP中的重要部件--BootLoader。 <BR><SPAN style="FONT-WEIGHT: bold">关键词：</SPAN>WinCE.NET BSP BootLoader DOC <BR><BR><SPAN style="FONT-WEIGHT: bold">引言</SPAN> <BR><BR>Windows CE.NET是微软公司向嵌入式领域推出的一款操作系统。它最大程度继承了桌面版Windows操作系统的丰富功能，同时又副入了许多新特性，以适应嵌入式领域的实际情况和要求。无论是商业应用需求，还是人们的多媒体消费需求，都能被采用CE操作系统的设备很轻松的满足。最新的.NET版本较之3.0版本，在实时性和稳定性上有大幅度提高，开始广泛地被平板电脑、数码相机、彩屏手机、PDA等多种高性能产品所采用。 <BR><BR>但是，CE并不是一个通用的安装版操作系统，在形形色色的嵌入式硬件设备世界里， 一款CE系统通常只会针对某一种硬件平台生成。所以，作为原始设备生产商，必须根据自己的硬件平台和应用场合定制CE，最主要的工作就是编写适合于自己的板级支持包（BSP）。在BSP中，包含了一个重要的组成部分——BootLoader。创建一未功能完善的BootLoader，是开发WinCE系统的第一步，也是极为关键的一步。本文将结合开发实例，介绍如何开发适合于自己硬件的BootLoader。 <BR><BR><SPAN style="FONT-WEIGHT: bold">1 定制CE操作系统的基本知识</SPAN> <BR><BR>定制CE操作系统是采用微软的工具软件：Platform Builder（PB）。该工具能够根据用户的需求，选择构建具有不同内核功能的CE系统。同时，它也是一个集成的编译环境，可以为所有CE支持的CPU目标代码编译C/C++程序。前面所说的BSP和BootLoader程序就是在该环境下编译，并整合到CE系统中去的。一旦成功地编译了一个CE系统，就会得到一个名为nk.bin的映像文件。只要将该文件下载到目标平台（device端），就能够运行CE了。 <BR><BR><SPAN style="FONT-WEIGHT: bold">2 BootLoader</SPAN> <BR><BR>BootLoader是一段单独的程序代码，它存放于目标平台的非易失存储介质中，如ROM或Flash。在开发CE的过程中，它主要用于启动硬件和下载nk.bin到目标板上，并有一定的监控作用。 <BR><BR><IMG src="file:///C:/Documents%20and%20Settings/gas/桌面/wince/WinCE系统下BootLoader的开发.files/284-10750.gif" border=0> <BR>图1描述了WinCE的BSP基本结构以及BootLoader所处的位置。 <BR><BR>一般来说，对于BootLoader的功能要求并不是严格定义的，不同的场合区别很大。比如，在PC的硬件平台上，由于硬件启动根本就不是通过BootLoader（而是通过BIOS），所以BootLoader就不需要对CPU加电后的初始化做任何工作；而在笔者的开发平台（MIPS32）上，BootLoader是最先被执行的程序，所以就必须包括加电初始化程序。通常，BootLoader必须包含下载CE映像文件的功能。另外，管理监控硬件设备通常也是必须的，因为这可以极大地方便工程开发。由于BootLoader涉及到基本的硬件操作，如CPU的结构、指令等，同时又涉及到以太网下载协议（TFTP，当然也可能通过串口）和策软设定的映像文件格式。因此从零实现的话，会需要相当长的过程。好在微软为每种类型的CPU都提供了某种标准开发板的BootLoader例程，因此通常的做法是：从这些例程中寻找与硬件平台最接近的作为标本程序，然后再从自己的硬件平台上入手做相应的改动。一些新的评估板可能会由第三方的厂商来提供Bootloader。如果硬件平台是从这样的基板设计而来的话，那么最好去寻求这些厂商获取Bootloader来移植，以减少工作量。 <BR><BR>笔者使用的硬件平台基于MIPS32架构，下载端口采用的是以太网口，同时还具备一个串口，主机相连，通过超级终端对该平台加以控制。该平台是参考AMD的一款标准估计板设计的，BootLoader以该板的BootLoader为参考进行了移植。 <BR><BR><SPAN style="FONT-WEIGHT: bold">3 编写BootLoader源程序</SPAN> <BR><BR>前面已经提到，由于硬件的不同，BootLoader的功能可能有多有少，此处笔者以自己开发BootLoader的过程进行叙述。 <BR><BR><IMG src="file:///C:/Documents%20and%20Settings/gas/桌面/wince/WinCE系统下BootLoader的开发.files/284-11234.gif" border=0> <BR>图2是笔者BootLoader的工程流程。 <BR><BR><SPAN style="FONT-WEIGHT: bold">3.1 启动部分</SPAN> <BR><BR>首先要实现初台化硬件的功能。在参考板的BootLoader目录下，会发现一些.s文件，可能会是init.s或者是reset.s等，这样的文件是CPU加电后最先执行的代码。由于此处是用汇编语言编写的，所以与CPU关系紧密。一般参考板的CPU与开发平台的CPU会是相同或者是同一个架构的。笔者使用的是属于同一种CPU的情况，所以对寄存器的定义和初始化流程都可以不加改动。接着就是对于平台配置的分析，包括平台存储空间的分配、外围设备的工作设定等。一般这里的区别是非常大的。所以必须要对CPU寄存器的值作相应设定。这部分工作可能需要CPU提供商方面的帮助。 <BR><BR>应该说，这部分工作是BootLoader的一大重点，但由于和实际的硬件非常大，所以不可能做进一步的详细叙述。 <BR><BR><SPAN style="FONT-WEIGHT: bold">3.2 主控部分</SPAN> <BR><BR>从这一部分开始，均用C语言编写。 <BR><BR>为了增加BootLoader对平台的控制，一般BootLoader都会设计成支持命令输入的方式，通过串口来接收用户的命令。这种机制中，如果参考板有Loader支持的话，那么可以自己添加有实用价值的命令，完成一些需要的功能。 <BR><BR>从图2中可以看出，一般在平台调试完毕后，可以在不用人工干预的情况下自动加载CE（这也是BootLoader必需的功能之一）；而在调试阶段，基本上是通过Loader所支持的命令来进行操作的。提供足够丰富的命令，能极大简化和全面测试开发平台。如表1所列，是笔者Loader所提供的命令。 <BR><BR>表1 <BR><BR>命令 说明 <BR><BR>Help_______列出所有支持的命令并加以说明 <BR>Eboot _____从开发台下载CE映像并加载 <BR>Write______向某一内存地址写入数据 <BR>Read______显示某一内存地址的数据 <BR>Jump______跳转到某一地址执行程序 <BR>Xmodem___从计算机的超级终端接收以Xmodem协议传送的文件 <BR>Toy_______测试平台CPU的计数器是否运转 <BR>Flash______擦除或者更新Flash中的数据 <BR>Tlbread____显示CPU的所有TLB表 <BR>Tlbwrit____设置CPU的TLB <BR>Macaddr___设置CPU的MAC地址 <BR>Seti_______设置平台的IP地址 <BR><BR>这些命令涉及到平台调试的各个方面，像内存检测、Flash操作、文件下载等。借助于这些命令，不仅可以完成硬件平台的部分测试，还完成了作为CE的BootLoader程序最为重要的一个功能——下载CE映像。 <BR><BR><SPAN style="FONT-WEIGHT: bold">3.3 下载部分</SPAN> <BR><BR>在用Platform Builder编译生成CE的映像文件后，接下来就需要将该文件下载到目标板上。如果说硬件调试功能可以由其它的程序代替而不放入BootLoader中，但是下载映像文件却是BootLoader必需的功能。 <BR><BR>CE映像文件通常叫做nk.bin，它是Windows CE二进制数据格式文件，不仅包含了有效的程序代码，还有按照一定规则加入的控制信息。当然，也可以选择生成.sre格式的代码文件，但是相于对前一种格式，它的代码要长很多，所需要的下载时间也更长。在这里，我们以下载.bin格式的文件来说明下载的实现。 <BR><BR><IMG src="file:///C:/Documents%20and%20Settings/gas/桌面/wince/WinCE系统下BootLoader的开发.files/284-11250.gif" border=0> <BR>首先看一下图3所示的BootLoader下载部分的流程图。 <BR><BR>通常，在Platform Builder自带的代码中，会包含完成TFTP连接的了基本的函数。 <BR><BR><SPAN style="FONT-WEIGHT: bold">*</SPAN>初始化TFTP连接：用函数<SPAN style="COLOR: blue">EbootInitTFtp</SPAN>()和<SPAN style="COLOR: blue">EbootInitTFtpd</SPAN>（）完成。 <BR><BR><SPAN style="FONT-WEIGHT: bold">*</SPAN>登记解析.bin格式数据的回调函数：用<SPAN style="COLOR: blue">EbootTFtpdServerRegister</SPAN>（）完成。 <BR><BR><SPAN style="FONT-WEIGHT: bold">*</SPAN>发出连接请求：用<SPAN style="COLOR: blue">EbootSendBootme</SPAN>（）完成。 <BR><BR><SPAN style="FONT-WEIGHT: bold">*</SPAN>接收主机端发出的数据包：用<SPAN style="COLOR: blue">EbootTFtpReceiver</SPAN>()完成。 <BR><BR>在这里，需要重点说明的有两点。 <BR><BR><SPAN style="FONT-WEIGHT: bold">①</SPAN>对于接收数据包的函数<SPAN style="COLOR: blue">EbootTFtpReceiver</SPAN>()，它只能处理已经存入内存的以太网包，也就是说，从以太网控制器接收数据的功能必须要用户去完成。由于这一功能与硬件密切相关，所以不能使用PB自带的函数来完成。 <BR><BR><SPAN style="FONT-WEIGHT: bold">②</SPAN>函数<SPAN style="COLOR: blue">EbootTFtpdServerRegister</SPAN>()会登记一个回调函数，一般用户可以自己定义这个函数，该函数用于完成，bin格式数据的解析和保存，有效数据至目的地RAM。PB有自带的例程函数可作参考。一般来说，如果目的地就是RAM的话，直接参考例程函数即可。但是如果目的地就是Flash，不要直接存入Flash（字为单位），应先存入内存中待下载完毕以后再导入Flash。当然，这种方法必须要有足够的内存。如果没有足够的内存，也可以缓存部分数据后，分段写入Flash。 <BR><BR><SPAN style="FONT-WEIGHT: bold">3.4 支持DOC</SPAN> <BR><BR>对于WinCE操作系统而言，丰富的多媒体功能是其一大特点，使其成为当前消费类电子产品操作系统中的一个不错选择。但是随之而来的问题是，系统的容易已经大大超过出了传统嵌入式系统上百KB的数量级。一般来说，如果选择了图形界面和汉语支持，容量一般会超过16MB。DOC（Disk On Chip）则提供了一种相对廉价的大存储容量的解决方案。 <BR><BR>DOC本质上是一种加以软件控制的NAND格式的Flash，通过TFFS这一软件层提供对WinCE的支持。 <BR><BR>由于DOC不能像内存一样被直接访问，所以其加载WinCE的过程有些特殊，必须要在BootLoader中加入专门的代码，才能使用DOC来存放WinCE映像文件。 <BR><BR>为了说明怎样在Loader文件中提供对DOC的支持，先看一下如何采用DOC系统启动CE，如图4所示。 <BR><BR><IMG src="file:///C:/Documents%20and%20Settings/gas/桌面/wince/WinCE系统下BootLoader的开发.files/284-11265.gif" border=0> <BR><BR>从图4可以看出，当采用DOC作为存储体的时候，实际上是在启动的时候把映像文件拷贝到内存中执行。为了实现这一启动过程，就必须涉及到DOC的读写操作。首先要从M-SYSTEM的网站上获取DOC的BOOT软件开发包。在这个开发包里，提供了一系列DOC的操作函数。将此开发包嵌入到CE的BootLoader中去，然后按照图4的步骤，调用相应的读写函数完成这一过程。对于开发包中相关函数的说明，笔者就不具体介绍了，可以参考开发包的说明文档。 <BR><BR><SPAN style="FONT-WEIGHT: bold">4 BootLoader的编译、链接和下载</SPAN> <BR><BR>BootLoader程序可以通过PB的集成编译环境编译链接，控制文件为.bib文件，下面是一个简单的BootLoader的.bib文件。 <BR><BR></FONT><FONT size=2><SPAN style="COLOR: blue">MEMORY <BR><BR>CLI 9fc00000 00050000 RAMIMAGE <BR><BR>RAM 80080000 00070000 RAM <BR><BR>CONFIG <BR><BR>COMPRESSION=ON <BR><BR>SRE=ON <BR><BR>ROMSTART=9fc00000 <BR><BR>ROMSIZE=00020000 <BR><BR>ROMWIDTH=32 <BR><BR>ROMOFFET=000000 <BR><BR>MODULES <BR><BR>Nk.exe $(_FLATRELEASEDIR).exe CLI</SPAN> <BR><BR><SPAN style="FONT-WEIGHT: bold">MEMORY部分</SPAN> 定义了生成的映像文件的目标地址，以及程序运行可以使用的内存空间。 <BR><BR><SPAN style="FONT-WEIGHT: bold">CONFIG部分</SPAN> COMPRESSION是否对目标代码进行压缩；SRE是否生成格式为sre的目标代码；ROMSTART与ROMSIZE、ROMWIDTH、ROMOFFSET共同定义了开发平台上存放BootLoader物理介质的起始地址、大小、宽度和偏移量。 <BR><BR><SPAN style="FONT-WEIGHT: bold">MODULES部分</SPAN> 定义了BootLoader所包含的文件，一般就只有一个文件：cli.exe。 <BR><BR>编译过程中，首先用命令build-c编译生成文件cli.exe，然后用romimage cli.bib命令产生最后的映像文件cli.sre。 <BR><BR>对于BootLoader文件的下载；有很多种方法：可以通过仿真器下载；也可以通过其它调试程序下载；还可以直接烧写到Flash中。需要说明的一点是，这些方法可能会要求不同的映像格式。在PB环境下，可以生成的有.sre格式、纯二进制格式（用于直接烧写Flash）以及和CE映像一样的.bin格式。 <BR><BR><SPAN style="FONT-WEIGHT: bold">结语</SPAN> <BR><BR>从CE的BootLoader开发流程可以看出，BootLoader在完成下载CE映像和加载映像的主要功能外，还具有一些调试硬件的功能。当然，这些功能不是必需的，随不同的用户可能有自己的定义。但是不管Loader的功能设计得多么简单或者是多么复杂，都是在开发CE系统中不可跳过的一环。实际上，由于Loader有和CE系统交互数据的区域，所以还有对CE启动过程的控制作用，也是PB控制目标板CE启动的一个窗口。可以说，一个功能齐全的Loader，不论是对调试硬件，还是控制和检测CE系统，甚至是成为产品之后的维护工作，都是大有帮助的。 <BR><BR>编写BootLoader是开发WinCE系统第一步，也是关键的一步。只有得到一个稳定工作的Loader程序，才能够更进一步开发WinCE的BSP，直至最后整个系统的成功。</FONT></SPAN></SPAN> <img src ="http://www.cnitblog.com/SmartJacky/aggbug/5839.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/SmartJacky/" target="_blank">一桶浆糊</a> 2005-12-28 11:47 <a href="http://www.cnitblog.com/SmartJacky/articles/5839.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>杰出人士的20个好习惯 </title><link>http://www.cnitblog.com/SmartJacky/articles/Management.html</link><dc:creator>一桶浆糊</dc:creator><author>一桶浆糊</author><pubDate>Wed, 21 Dec 2005 09:48:00 GMT</pubDate><guid>http://www.cnitblog.com/SmartJacky/articles/Management.html</guid><wfw:comment>http://www.cnitblog.com/SmartJacky/comments/5670.html</wfw:comment><comments>http://www.cnitblog.com/SmartJacky/articles/Management.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/SmartJacky/comments/commentRss/5670.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/SmartJacky/services/trackbacks/5670.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 在研究大量成功企业领导者的案例后，我们发现，这些最优秀的企业领导人知道自己需要什么，并能尽全部的努力去达到自己的目标，他们懂得做人、善于决策、充满热忱、持续创新、架构关系、激励团队以及赢得拥戴……最成功的企业家所共同具有的良好习惯和素质，使得这些企业领导人能够脱颖而出&nbsp;&nbsp;<a href='http://www.cnitblog.com/SmartJacky/articles/Management.html'>阅读全文</a><img src ="http://www.cnitblog.com/SmartJacky/aggbug/5670.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/SmartJacky/" target="_blank">一桶浆糊</a> 2005-12-21 17:48 <a href="http://www.cnitblog.com/SmartJacky/articles/Management.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>