Book给我发了一封email,说他是台湾的一名firmware engineer,也在研究S3C2410。由此我想,firmware是什么,firmware engineer与software engineer的工作有什么不同。。。当然,核心的问题就在于firmware这个概念。以前听过但是没有留意。下面要解决的问题就是理顺hardware/firmware/software这几个概念,由此为出发点加深对嵌入式系统的认识。
在搜索资料,逐步形成认识的过程中,找到了一本书,《Embedded Systems Firmware Demystified》,在Preface中,不仅基本解决了firmware是什么,而且对嵌入式系统的特点还有独到的见解。英文很简洁,不难理解。引用如下:
|
可见,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
----------------------------------
刚看过计算机体系结构,经典计算机体系结构概念的实质是计算机系统中软硬件界面的确定,界面之上是软件的功能,界面之下是硬件/固件的功能。嵌入式系统是嵌入式计算机系统,具备计算机系统的一般特性,又具有自己独特的地方。在嵌入式系统中要想清晰的区分这些概念,确实会比较困难。从应用的角度来说,没有必要费时间来区分这些概念,关注如何实现才是应用的重点;从学习的角度来说,这倒是必要的。把所学知识理顺,不局限于表层,才能走的更远。
其实通用计算机系统和嵌入式计算机系统实际上形成了两个不同的分支,有着各自的独立发展历史。通用计算机系统在技术上往往要超前于嵌入式计算机系统,在深入学习嵌入式系统的时候,一是注意对比借鉴,二是了解发展历史。很多的术语是与发展历史紧密结合在一起的,如果不放到当时环境中去理解,是很难想象的。