hardware,firmware,software

来源:互联网 发布:网络支付审理风险 编辑:程序博客网 时间:2024/06/01 07:54
hardware/firmware/software
2008年04月17日 星期四 08:21 P.M.
Book给我发了一封email,说他是台湾的一名firmware engineer,也在研究S3C2410。由此我想,firmware是什么,firmware engineer与software engineer的工作有什么不同。。。当然,核心的问题就在于firmware这个概念。以前听过但是没有留意。下面要解决的问题就是理顺hardware/firmware/software这几个概念,由此为出发点加深对嵌入式系统的认识。

    在搜索资料,逐步形成认识的过程中,找到了一本书,《Embedded Systems Firmware Demystified》,在Preface中,不仅基本解决了firmware是什么,而且对嵌入式系统的特点还有独到的见解。英文很简洁,不难理解。引用如下:

   

An embedded system is just a computer buried inside some other product. Surprisingly, you can know a great deal about programming and computing and still get lost in the arcane world of embedded systems hardware software firmware differ. In the world of embedded systems programming, countless details — both hardware- and-related — make the development process seem like a path that few have traveled and even fewer have survived. How do software,firmware and hardware? How in the world does a 100,000-line program end up inside a device smaller than my fingernail? What is flash memory and why do I need a cache? What is the difference between a task and a process? Do I need to worry about reentrancy? As we progress through Embedded Systems Firmware Demystified, you will come to see that these questions are not as complex as they first appear.

Embedded systems programming spans a wide range of activities from building programmable logic at the most concrete end to writing a UNIX process at the most abstract end. Bracketed by these poles, the industry has exploded in the last 20 years. In the late seventies, assemblers were considered luxuries. A typical embedded system used less than 64Kb of system memory (bits, not There was no hardware hand-off to the firmware developer. The same person that drew the schematics and soldered the prototype also wrote the firmware that pulled the whole thing together. By the time Intel introduced the 8085 chip, it was clear that those pesky microprocessors were here to stay. In the eighties, the Motorola versus Intel CPU wars started, and C became a popular choice for the elite few who dared to mess with a high-level language and an EPROM programmer. Today, microprocessors are everywhere and range from the 4- and 8-bit workhorses still dominating the industry to 1GHz 64-bit processors that almost need a freezer (microprocessor-controlled, no doubt) to keep them cool.

Over the years, the complexity of these systems has snowballed. The industry has transitioned from programming a DEC PDP machine with binary codes on the front panel to applying object-oriented design to a microcontroller in a toaster. If you let the trend get to you, the changes can seem frazzling. There are microprocessors and microcontrollers; RAM, DRAM, and SDRAM; pipelining and superscalar; EPROM and flash memory; RISC and CISC; and RAS and CAS and cache — and that’s just the beginning.

Now, everything from toothbrushes (no kidding) to fighter jets are likely to have a version controlled by a microprocessor of some kind. With this trend come tools and technologies. One can easily be overwhelmed by the available choices in hardware (integrated circuits that the firmware must make work) and software (tools that are used to build the firmware application).


    可见,firmware是适应技术发展而出现的一种手段,既不是硬件,也不是软件。它形态上是硬件,但是功能上是软件。有几个特点:

    首先,firmware的形态为非易失性存储介质,比如ROM,EPROM,EEPROM,Flash等。也就是系统断电后,存储信息不会丢失。发展历程上,经历了不可升级到可升级两个阶段。

    其次,firmware必须固化。举个例子来说,在嵌入式系统中,kernel映象和bootloader都存储于flash上,但它们都是firmware吗?并非如此,实际上,kernel映象可以不存储于flash上,可以通过nfs等网络手段下载到内存中。而bootloader必须固化于flash上。所以,boot loader是firmware,而OS不是firmware,而是系统软件。

    也就是说,firmware的非易失性载体和固化特性是最为主要的部分。很多时候,我们感受不到firmware的存在,比如USB器件,内部是有firmware的。

    这样说其实还有些抽象。Book的解释则非常直观,整理email如下:

In my opinion, coding is growing up to a wild range in this world.

somebody writes code that runs on 8051 mcu;

somebody writes code that runs on arm;

somebody writes code that runs on rtos...real time operation system...ucos-ii, ecos,uclinux,vxworks...

somebody writes code that runs on os...windows xp, linux, unix...

In the past years, i write code with 8051 mcu to make products. my code need to access each special funtion register in 8051,then 8051 mcu works, and then the platform works.

the term firmware used to mean that code runs on a plateform without a os. Before os runs, there must be a firmware runs on that plateform. it just like bios in a mainboard.(bios is firmware that runs on mainboard will check cpu,chipset,hd,floppy,sdram....when every thing is ready bios will go to load os image into sdram to run that whole os.)

the term software used to mean that code run on os. you don't need to take care hardware level issue. just only need to call functions that are built in os.

i think this is the major difference between firmware and software.

in 8 bit mcu world, os is not needed. and code called firmware runs on it.

in 32 bit mcu world, os is needed. and code called software runs on os that runs on the platform. before os image loaded to run, there need a bootloader to load os image into sdram. this bootlaoder is a firmware, and its job is to load os image into sdram. after this job is done, bootloader becomes useless and is like a piece of garbage in memory.



由此可以建立一个模型。

----------------------------------
        applications
----------------------------------middleware
    OS(driver/kernel/utility)
----------------------------------firmware
          Hardware
----------------------------------

    刚看过计算机体系结构,经典计算机体系结构概念的实质是计算机系统中软硬件界面的确定,界面之上是软件的功能,界面之下是硬件/固件的功能。嵌入式系统是嵌入式计算机系统,具备计算机系统的一般特性,又具有自己独特的地方。在嵌入式系统中要想清晰的区分这些概念,确实会比较困难。从应用的角度来说,没有必要费时间来区分这些概念,关注如何实现才是应用的重点;从学习的角度来说,这倒是必要的。把所学知识理顺,不局限于表层,才能走的更远。

    其实通用计算机系统和嵌入式计算机系统实际上形成了两个不同的分支,有着各自的独立发展历史。通用计算机系统在技术上往往要超前于嵌入式计算机系统,在深入学习嵌入式系统的时候,一是注意对比借鉴,二是了解发展历史。很多的术语是与发展历史紧密结合在一起的,如果不放到当时环境中去理解,是很难想象的。
原创粉丝点击