The document discusses the basic knowledge of hard drive firmware. It explains that hard drives contain a CPU and memory, and can be considered specialized computers that run firmware rather than traditional operating systems. The firmware contains several subsystems and modules that control hardware functions like motor control (servo subsystem) and read/write operations. The firmware is layered and boots in a process where the bootloader loads code from ROM which initializes subsystems and loads additional firmware from the disk surface. Understanding the firmware structure can help diagnose hardware issues.
The document discusses the basic knowledge of hard drive firmware. It explains that hard drives contain a CPU and memory, and can be considered specialized computers that run firmware rather than traditional operating systems. The firmware contains several subsystems and modules that control hardware functions like motor control (servo subsystem) and read/write operations. The firmware is layered and boots in a process where the bootloader loads code from ROM which initializes subsystems and loads additional firmware from the disk surface. Understanding the firmware structure can help diagnose hardware issues.
The development trend of hard drive has always been greater capacity, more advanced technology and more complex functionalities. Nowadays, hard drive is no just a simple peripheral, but a complex smart device. In fact, modern hard drive has complete CPU and memory, with firmware adopting the management program similar to operating system. Therefore, it can totally be seen as a microcomputer except the fact that it is dedicated for data storage, which doesn’t need to be connected with keyboard or mouse for operation. So it can be seen as a computer for specific application.
2. Firmware structure of hard drive
Since hard drive is a special-purpose computer, there must be software to run it. The "software" is different from the user software stored in hard drive and used on PC. Internal software that ensures the proper work of hard drive is transparent to upper-level device and operating system. To distinguish it from user software, we usually call it "firmware." Firmware is internal software of hard drive and run by CPU of hard drive. So, if we see hard drive as a standalone computer, firmware is like Windows operating system, and a series of programs installed in it. Since firmware is the lowest-level software, it depends on specific hardware. Firmware used by different manufactures differ in structure. It is like the differences between Windows and Linux operating systems. However, various firmware have something in common, so we can divide firmware into several parts. Firmware system used by most hard drive manufacturers will generally follows the same design principles. Generally speaking, it can be divided into the following parts: (1) Servo subsystem. When we install printer, scanner, or network cards etc. for PC, we need to install corresponding drivers, printer driver, scanner driver and network card driver etc. Computer needs driver to make corresponding hardware work. This is also true for hard drive. As for hard drive, spindle motor and head assembly are both important components. They also need drivers to work. Servo subsystem in firmware can be understood as driver of head and motor. Servo subsystem drives motor to rotate, and controls head to seek. Typically, it needs servo adaptive parameters to work. If this part of the firmware is damaged, hard drive motor and head will be unable to work properly. Since this part of the firmware is the closest to hardware level. Therefore sometimes the symptom of servo firmware damage appears like that of hardware damage (such as motor does not rotate or head clicks). (2) Read/write subsystem. In the firmware design of most hard drives, servo subsystem usually uses the lowest-level physical parameters to drive head. At this time, there is no concept of track. The task of read/write subsystem is to establish the concept of track and sector to provide CHS and LBA addressing for upper level. Read/write subsystem is very complicated. There are two types of data that are most important to ensure read/write subsystem work properly. They are ZONE table (also called zone allocation table) and defect list (such as G-List and P- List), which can be collectively referred to as read/write parameters. (3) Main firmware. This part plays a role of integrated management and task scheduling, similar to the core of operating system. It makes all parts of firmware work together effectively. (4) Various function routines. These programs are various, just like those installed on computer. The common ones are low-level formatting routine, self-test routine etc. They are called by main firmware. (5) Interface / Shell program. This is the topmost part of firmware. It is responsible for communication of SATA interface, terminal COM interface etc. They are the bridge of communication between hard disk and host.
Firmware is designed to be layered. The upper layer depends on the
function of lower layer, and the lower layer serves the upper layer. Damaged low-level firmware can cause upper layer unable to work. Damage in different parts of firmware manifests as different symptoms. Therefore, understanding the hierarchical structure of firmware can help understanding the mechanism of disk fault and locating it. Firmware level of hard disk can generally be shown in the following figure: ATA Interface Terminal Serial Interface
Main Firmware Various Function Routines
Read/Write Parameters Read/Write Subsystem
Servo Parameters Servo Subsystem
Hardware
3. Physical storage location of firmware
In hard drives of early stage, firmware is stored in ROM chip on PCB. As hard disk develops to be more and more complicated with bigger and bigger firmware, ROM chip can no longer store complete firmware. In modern hard drives, firmware is generally divided into two parts for storage: The most important basic firmware is stored in ROM chip on PCB, while the other part is stored in service area (SA) of disk platter. According to the design, tracks on platter are divided to user area and system area. Tracks of user area can be accessed by operating system while tracks of system area are transparent to operating system. 4. Boot process of disk firmware. Same as boot of PC, there is boot process of hard drive. Then what are the procedures after hard drive powered on? Now let’s explain from the perspective of firmware. (1) After powered on, Boot Loader acquires control first. Boot Loader is a program solidified in main control chip of hard drive. In embedded devices, typically Boot Loader is responsible for booting the system and loading programs of ROM to memory. In most documents, ROM of hard drive is compared as BIOS of PC. Actually, in terms of computer architecture, what acts as BIOS is Boot Loader – It gains control as soon as hard drive is powered on, executes initialization of early stage and loads "operating system". However, Boot Loader is much simpler than BIOS. The most important task of Boot Loader is to load code in ROM chip to memory, and then hand over control to ROM code. (2) After ROM program is loaded, main firmware begins to execute its boot process. The first activated is servo subsystem. At this time, spindle motor begins to rotate, heads begin to fly, and makes preparation for seeking. (3) Then read/write subsystem is activated. At this time, ZONE allocation table is loaded. Main firmware will initialize to establish a "minimum read/write subsystem". Minimum read/write subsystem can access physical tracks of hard disk and service area on the platter, but cannot access user sectors because P-List or the address decoder module has not been loaded. (4) Then main firmware will call read/ write subsystem to access SA tracks on platter and load peripheral firmware on SA tracks to memory. The peripheral firmware typically consists of APP code, address decoder module and SMART module etc. All are top-level features. When address decoder module is loaded, minimum read/write subsystem becomes complete read/write subsystem, with the ability to access user sectors and convert LBA linear address. (5) When all firmware is loaded, the boot of hard drive is completed. It becomes ready and waits for command sent by host. Appendix: Two important firmware modules of Seagate F3 HDD 1. Address decoder module As there is no possibility that modern manufacturing techniques can produce platters with no defects, each platter has some defects when leaving factory. Manufacturers recorded these defects to defect list, and skip these defects by using software in firmware, so as to produce the space with no logical defects. Since defects have been ruled out in logical address and the underlying servo system only receives physical address with defect, read/write subsystem needs to perform the conversion from logical address to physical address. To accomplish this conversion, read/write subsystem must load address decoder module. Address decoder module of Seagate contains a lot of data, among which the most important is integrated defect list. This list records all the defect sectors of platter. If address decoder module is damaged, user sectors can no longer be read. The figure below shows the situation where there are defects in sectors. Usually we call the original physical sector address PBA, and the logical address with defects ruled out is called LBA. After all, operating system uses LBA to address sectors.
PBA (Physical Block Address)
LBA (Logical Block Address)
2. SMART module SMART module is used for automatic detection, analysis and report of hard drive. In short, it records the log information when hard drive is working so as to send some alarm when the hard drive is about to go wrong. Typically, the boot count, operating temperature of hard drive are also recorded in SMART information. As SMART module is actually running log, which is frequently written and modified, it has greater chance of reporting error than other modules. Much operation in hard drive can trigger the SMART mechanism, and write data to SMART module. Therefore, if SMART module is damaged, hard drive cannot work.