Chapter 5
Manufacturing

“Give me six hours to chop down a tree and I will spend the first four sharpening the axe.”

― Abraham Lincoln

The motherboard is finished. Screws hold it down within the shiny new case. Memory is inserted. Peripherals secured. Cables run from source to destination. Firmware image flashed. Enclosure sealed. Power applied.

Now what?

It’s a box. A very complicated box, yes. Yet still a box. There isn’t much there yet. The firmware is just sitting there on a flash chip and a CPU anxious to execute that firmware. Then the spark of life as power is applied and line after line of preprogrammed instructions carry the system forward until…until what?

The box doesn’t know. It is a tabula rasa—a clean slate—waiting to be given a purpose. While manufacturing starts with the correct placement and connection of electrical components, it finishes by ensuring that the assembled hardware is prepared for use.

Before that box can be useful, the box must be:

Provisioned. The hard drive must contain a copy of the golden image—the latest validated operating system and pre-installed applications. See Chapter 6, “Bare Metal Provisioning,” for more information.

Configured. The firmware must contain the golden configuration—the optimized settings for the specific hardware configuration and target operating system. See Chapter 7, “Configuration of Provisioned Material,” for more information.

Tested. The hardware must quickly pass system and subsystem functionality tests before leaving the factory. See Chapter 8, “The Use of UEFI for Diagnostics,” for more information.

This is not a book about manufacturing, which is a vast subject in and of itself. But even the cursory analysis in this chapter shows how the UEFI Shell can play a valuable role in helping each box pass through these stages in the factory reliably and quickly. This chapter focuses on the vital role that manufacturing tools can play in making your product successful.

Throughput

Speed is essential. With 10 or 100 or 1,000 boxes the speed of testing, configuring, and provisioning each box is not a significant factor. But with 1,000,000?

Take a single hypothetical assembly line that runs for 24 hours a day where each box takes only 5 minutes to manufacture. One million boxes means 3,472 days or slightly over 9.5 years. Each additional second for a single box adds almost 12 days to the length of the production run. Consider that even with 100 such manufacturing lines, it is still over one month of non-stop, around-the-clock, no-down-time factory effort.

There are no more dreaded words than “line down.” For a firmware engineer, a line down issue means travel to the factory floor on the next available flight, no sleep, and hourly executive management status reports. Why? Because any delay means idle people and production equipment, delayed product launches, delayed delivery schedules, and delayed sales.

For many companies, the manufacturing environment is still Microsoft’s MSDOS, or one of the various alternatives (PC-DOS, DR-DOS). Companies (and engineers!) are risk-averse: they don’t like to change what has been working. Considerable expertise has been developed over time. Special-purpose tools have been created for a company’s specific needs. Manufacturing-line servers that manage the whole process often have a fragile relationship with those tools. So, why break what works?

The trouble is that Microsoft hasn’t updated MS-DOS in over 20 years (version 6.22, 1994), and it and the related tool chains are moribund. Many times it is hard to even find them, and precious floppy disks are hoarded. Even more significant: it is hard to find engineers who understand the unique APIs and batch file syntax of DOS and the quirks of the 16-bit C compiler included with Visual Studio 1.52 (we are now at Visual Studio 14.0!). Python? Forget about it! More than 4GB (much less 640KB)? Unlikely!

Many alternatives have been proposed, from Windows PE to various versions of Linux, but the substantial hardware requirements for these environments makes it likely that the environment itself will be configured improperly.

The UEFI Shell provides a unique environment for testing the boxes at an early stage because:

The UEFI Shell is powerful, including a full scripting language, logging capabilities, and access to the UEFI driver model. It is optimized for working without an attached storage device.

The UEFI Shell is small. Some implementations require as little as 100KB of flash space. This means it can be burned into the flash device during the manufacturing process without requiring a larger flash device. UEFI Shell applications can be stored in the flash, on external storage devices or on a network server, accessed via TFTP, FTP or HTTP.

The UEFI Shell has a fast boot time. This allows critical seconds to be shaved off of the testing time, since there is no wait for the hard drive to spin up or the network download to complete.

The UEFI Shell has unrestricted hardware access—including access to all CPU cores and threads, all hardware registers, all system memory and all hardware interrupts.

The UEFI Shell has few hardware dependencies. Basically, if memory, the timer, the timer interrupt, and a console device are working, the UEFI Shell is working. That means the UEFI Shell applications can test more.

The UEFI Shell supports the latest hardware, including more than 4GB of memory, PCI Express, USB 3.x, and more. Since it runs directly on top of UEFI, it has access to all of the devices that UEFI does.

The UEFI Shell provides a complete, Posix-compliant C library and supports dozens of toolchains, including every major version of Microsoft’s Visual Studio and GCC. This allows manufacturing tools to be migrated easily from the current manufacturing environment to the UEFI Shell.

Also, the UEFI Shell supports multiple file systems, including FAT12/16/32 and El Torito (used on optical media), and there are multiple sources for UEFI support of NTFS, EX4 and more.

Finally, the UEFI Shell shares many development principles with UEFI itself, which allows engineers who are an expert in one to also develop code for the other.

Manufacturing Test Tools

Testing plays a big part in the length of time that a box stays on the manufacturing line. The raw box may have defects. These defects may appear consistently or sporadically. The earlier in the manufacturing process these defects are detected, the less time is wasted on that box.

Some test failures only occur on some boxes. The testing phase also detects patterns among failing boxes, such as shared faulty components, shared malfunctioning assembly equipment, or shared suppliers. Then steps can be taken to correct the problems, possibly through something as simple as a modified configuration, a corrected process, or a firmly inserted cable.

Before the manufacturing line started, there was a golden system. Poked and prodded by technicians and firmware engineers, it passed every test thrown at it. The thousands or tens of thousands, or hundreds of thousands that follow must have the same level of quality. Will the other boxes maintain this level?

After the box has been put through circuit testing, making sure that there is continuity for the signals, the new box is put through tests to verify that it functions as expected. Since the UEFI Shell has access to the UEFI networking stack, a simple script downloads these tests from a network server on the factory floor, executes them, and then sends the log back to the network server. The network server quickly scans the log for errors and, if detected, flags the box and alerts the supervisor.

Some of the tests require more time, or require special environments, or are less likely to occur (but expensive if they do). Rather than hold up all of the manufacturing lines, a sample of the boxes from each of the lines is set aside. In the initial runs, all units go through this more intensive testing. Later, during volume production, the sample size is reduced.

Some of these tests are long-run tests, consisting of repeating a single action over the course of thousands of reboots. For example, entering the standby or power-off state repeatedly to stress the hardware and the firmware. Some of these tests are environment tests, consisting of exposing the system for hours or days to high humidity, low humidity, high temperature, and low temperature. Some of these might be subsystem tests, such as memory, which are prone to failure because of slight variations in manufacturing lines, or component supplies.

The good news is that, if these failures can be isolated and diagnosed, many times a UEFI firmware-level fix can be implemented and then that UEFI firmware image can be fed back into the process. In addition, the update can be applied to those units that were diverted because of the issues found.

These benefits are not just reserved for the original equipment manufacturers. Other companies that provided integrated solutions, where they take a box and add specific peripherals, operating systems, components and applications can use the UEFI Shell to make sure that all of the systems they ship have the correct configuration by updating the firmware, checking the installed devices against a known-good list, configuring those devices, and provisioning the hard drive, all from the UEFI Shell.

Hardware Access with Manufacturing Tools

When writing tests during manufacturing, you need access to different levels of information or control. DOS gives you one level of control: INT 0x21 for the file system, and legacy BIOS gave you one more level of control: INT 0x13 for block I/ O (or INT 0x10 for video). Of course, a library like the C library could abstract this, but it could not give you more control.

So your application looks something like Figure 5.1:

Figure 5.1: DOS Application Hardware Access

If your application needed more control, it must have intimate knowledge of the file systems, partitions, buses, and devices. With UEFI Shell applications, however, applications have access to the same file system level abstractions and block I/O abstractions that DOS offers. But they also have access to so much more, as shown in Figure 5.2:

Figure 5.2: UEFI Application Hardware Access

Through the use of the UEFI programming model, it is possible to enumerate all of the devices of a specific type in the system. UEFI provides a standard data structure, the device path, which describes exactly how a device is attached to the box. The device path can be walked all the way from the host bus through the block device to the file system and even to an individual file. This gives numerous options for a UEFI Shell application so that it can insert its test at exactly the right level of abstraction.

Shell I/O: The UEFI Shell itself provides file system mappings (that is, FS0:) for each of the mounted devices in the system.

File System I/O: UEFI abstracts access to the file systems installed in each partition of each device through the use of the Simple File System protocol. Using this information, it is possible to manipulate the one or more file systems installed on a particular device.

Partition I/O: UEFI abstracts access to each partition on a device as a logical block I/O device using the Block I/O protocols. It also gives byte-oriented access to the device via the Disk I/O protocols. So a UEFI Shell application can easily read and write the contents of a storage device partition.

Block I/O: UEFI abstracts access to each storage device via the physical Block I/O and Disk I/O protocols. So a UEFI Shell application can easily read and write to individual blocks on the disk.

Bus I/O: UEFI abstracts direct access to the device on its native bus via the bus I/O or pass-through protocols. The bus I/O protocols allow sending and receiving data across an I/O bus such as USB, PCI, or serial. The pass-through protocols are similar, allowing sending and receiving storage-bus specific packets directly to storage devices (for example, SATA, IDE, SCSI). This frees up the application from having to know the details of specific device registers or how the bus has been configured.

Bus Host I/O: UEFI abstracts direct access to the device’s host controller beyond sending and receiving data to devices that are on the bus. Many of the bus controllers, such as PCI, USB, SCSI, and even (in the PI specifications) I2C and SPI have direct host controller protocols that allow even greater access for testing.

Using the right level of abstraction means that tests for a specific class of devices can be done without worrying about unnecessary details. This, in turn, means that the test will be more portable from one generation of boxes to the next generation of boxes. It also means it is more applicable, to other devices of the same type, but which are located on another similar bus. For example, many tests for IDE also work for SATA. Many tests for optical disks also work for SCSI.

Using the right abstraction level for access also means that the tests are less likely to destabilize the box (or subsystem in that box) under test. Since the box (or subsystem) is usually running many tests during the manufacturing process, it is important for them to be run one after the other to save time. This can only be done if the box (or subsystem, or device) is still in a working state after finishing the previous test. The worst case is that there must be either a physical intervention (that is, cable inserted or removed) with the box, or the box must be reset. While these are sometimes unavoidable, each one adds time to the manufacturing test. (Yes, ResetSystem() is disruptive and adds time.)

Using the right abstraction also allows third-party tests to be inserted into the manufacturing process. For example, each component vendor can provide tests of the condition of their individual component and even, in some cases, the UEFI-compatible driver that supports it. Since they use standard APIs provided by UEFI, they can be used over and over again, often with no more modification than changing a few command-line arguments. In addition, while they test their component, additional tests that use that component can be inserted in the same script.

Converting Manufacturing Tools

So, how do you convert tools to work in the UEFI Shell environment? Even though the UEFI Shell has many advantages, there is still work required to make the leap from the 16-bit, 1980’s MS-DOS environment tools.

The clock is ticking. Every month that you defer converting over to a more modern tool environment simply makes the job harder. It is harder to find a system that can host the operating system and compiler necessary to build the tools. It is harder to find engineers in your company who still remember how the tools are supposed to work. It is harder to find documentation that describes the process.

Here are some key steps:

UEFI. This may seem obvious, but converting the tools requires familiarity with the basic concepts behind UEFI and the UEFI Shell. The UEFI specifications are great reference material, but they aren’t constructed to teach UEFI and the UEFI driver model. You are already taking a big step by reading this book. We would also recommend the authors’ book Beyond BIOS: Developing with the Unified Extensible Firmware Interface.

UEFI Build Environment. Since UEFI Shell applications are a specialized type of PE/COFF format executable, there are multiple build environments for creating them, including open-source (EDK2, gnu-efi) and those provided by UEFI firmware vendors. All of these build environments provide sample C applications that can be used as a starting point. Most of them do not support standard C style make files, so there will be a learning curve. See Chapter 10, “UEFI Shell Programming,” for more information on the EDK2 build files.

Tool Status. Make sure that you have access to the tool’s source code and the necessary tools to recreate the original too.

Review the code to see if the code flow is easy to understand.

Identify the areas in the code where there is direct hardware access.

Take note of direct calls to DOS and BIOS services (via INT 0x10 and INT 0x13) via some sort of library wrapper.

Watch out for Software SMIs! Many older tools use an output to a hardware I/O port (such as 0xb2). These indicate a dependency between the tool and the underlying firmware code written in (System) Management Mode.

Mark these to revisit later.

Key Engineers. Find the key engineers in your company who have knowledge about these tools. Engineers are often, by nature, hoarders. Somewhere they may have design documents, however incomplete or out of date. Spend some time with them to understand the tools and then write down what you find out. This will save time later, both for you and whoever has to do this job again later.

New Goals. Many times, once you decide to do the conversion, everyone presents their wish lists. These are the things that others in your company wished they could do, but didn’t because the cost and difficulty of updating the old manufacturing tools was too high. This may include new tests, new logging formats, new manufacturing server infrastructure, or something else. So be prepared!

Clean Up. One of the goals may simply be to streamline the code.

Just one final note on converting manufacturing tools: accept the new interface! Sometimes there is a temptation to create some sort of “interface layer” that makes UEFI look like DOS or Linux or some other favorite environment. Resist the temptation. Don’t try to make UEFI look like Linux or DOS.

Conclusion

The UEFI Shell has a lot to offer during the manufacturing process:

Fast Boot

Small Siz.

Direct Hardware Access

Network Connectivity (Including Network Boot)

Support for the Latest Hardware

Optimized Scripting

Generation-to-Generation Stability

Now is the time to make the upgrade to UEFI Shell-based manufacturing tools.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset