简体   繁体   English

如何从用户空间更新固件?

[英]How is it possible to update the firmware from userspace?

This is one of those things that has always blown my mind. 这是一直让我震惊的事情之一。 How is it possible that when I am logged into windows I can run an application that allows me to upgrade my devive BIOS or install firmware for my hard disk and etc. 登录Windows时,如何运行一个应用程序,可以升级我的devive BIOS或为硬盘等安装固件。

I have not found any satisfactory answer on how this is even possible. 我什至没有找到令人满意的答案。

The reason why this seems so magical to me is that: 这对我来说如此神奇的原因是:

Firmware resides on a device which the OS can't access directly(AFAIK it has to go through the driver) secondly firmware resides on a read only memory section how can a user space application even have access to something like that much less change it. 固件驻留在OS无法直接访问的设备上(必须通过驱动程序来访问AFAIK);其次,固件驻留在只读存储器部分上,用户空间应用程序甚至可以访问诸如此类的东西,而很少进行更改。

One of the purposes of having an OS is that it will talk to the devices that the user space is not allow to talk to. 拥有操作系统的目的之一是,它将与不允许用户空间进行通话的设备进行通话。 For example, even printing to the screen is talking to a device that your application space does not own. 例如,即使打印到屏幕也正在与您的应用程序空间不拥有的设备通信。 Your application space program will make a call to the OS saying something like "please display this stuff" and the OS will do it for you. 您的应用程序空间程序将调用OS,并说“请显示此内容”,然后OS会为您完成。

In the case of updating firmware, you call a service which is there to perform the update for you. 在更新固件的情况下,您致电那里的服务来为您执行更新。 The device where the firmware is stored is usually a chip of a device type called "flash memory". 存储固件的设备通常是称为“闪存”的设备类型的芯片。 This chip is hard to write to, but it can be erased and reprogrammed if you know how and have proper access privileges. 该芯片很难写,但是如果您知道如何操作并拥有适当的访问权限,则可以将其擦除并重新编程。 The OS will call a driver which is there to serve the OS, and knows the specific details of the device it is supporting. 操作系统将调用驱动该操作系统的驱动程序,并知道其支持的设备的详细信息。 So you call the OS service, and give it the new firmware image which you downloaded from the manufacturer. 因此,您将调用OS服务,并为其提供从制造商处下载的新固件映像。 The image is usually cryptographically signed so that the OS can determine that it really came from the manufacturer and has not been modified, which means that it is safe to use as the new firmware. 该映像通常经过加密签名,以便操作系统可以确定它确实来自制造商并且尚未修改,这意味着可以安全地用作新固件。 After checking that the image passes the signature test, the OS can erase a portion of the flash memory, and re-write it with the new firmware. 在检查映像通过签名测试后,操作系统可以擦除闪存的一部分,并使用新固件对其进行重写。 Also, it is likely that there will be a backup copy of the firmware in the flash memory which can be used in case something goes wrong during this process. 同样,闪存中可能会存在固件的备份副本,以防万一在此过程中出现问题。

For example, if you power off the computer after the erase, but before writing the new firmware, you would have no firmware an could not boot. 例如,如果在擦除之后但在写入新固件之前关闭计算机的电源,则您将没有固件并且无法启动。 That is why during some updates the OS will warm you not to turn off your computer, and make sure you are connected to a power source. 因此,在进行某些更新时,操作系统会温暖您的电源,不要关闭计算机,并确保已连接电源。 Sometimes a backup copy of the firmware can make this step a little less risky. 有时,固件的备份副本可以使此步骤的风险降低一些。

I'm just scratching the surface with generalities; 我只是在泛泛而谈。 This is a large topic. 这是一个大话题。 Hope this helps a little. 希望这有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM