In-depth brew development-Chapter 1 hardware Basics

Source: Internet
Author: User
All copyrights shall not be reproduced without the consent of the author. Otherwise, they shall be deemed as infringement and the right to be held accountable shall be reserved.

Chapter 1 hardware BasicsHardware is the operating platform of software, and software without hardware support will no longer exist. Can you imagine how graphics will be displayed without the display software and how will no CPU software run? I cannot imagine it! However, if you ask the question in turn, you will be asked about the essence. What hardware support is required for software operation? See Figure 1.1:

CPU

Ram

Rom

Output device

Input Device

Storage Device

Figure 1.1 system architecture diagram we leave aside the electrical features of hardware and so on. This figure is the figure above. If the program runs without a CPU, it won't work. The CPU needs to quickly exchange data without Ram. Therefore, CPU and RAM are essential for any system. Will you always remind me that the Rom will not change? This statement is not entirely true, because the ROM function between the PC system and the embedded system is different. In the PC system, Rom is the BIOS chip used to provide the system startup code and basic input and output functions. In the embedded system, Rom stores all the code, it has mixed the bios and hard disk code-related functions in the PC.
Device Typical PC hardware Typical hardware devices of Embedded Systems
CPU Any CPU Any CPU
Ram Any Ram Any Ram
Rom BIOS chip Flash Chip
Storage Device Hard Disk Flash Chip
Input Device Keyboard Keyboard
Output device Display Card + display LCD display
In PC Rom, the BIOS chip can use the flash chip. The reason why the flash chip is not written here is that the BIOS function is not the same as the flash function of the embedded system. 1.1 CPU and RamFrom the software point of view, any CPU and RAM can be applied to various systems. There is no obvious difference, as long as the CPU can execute command control devices. However, considering the power consumption and volume (embedded devices usually require low power consumption and small size), embedded systems have developed dedicated CPU chips. Arm cpu is the most widely used currently. Arm cpu is designed by arm companies in the UK. It is widely used in embedded systems due to its high execution efficiency, small size, and low power consumption. Because embedded systems require high integration, there is usually no separate CPU chip. Instead, the CPU is integrated with many peripheral circuits to form a chip, therefore, arm uses authorization to provide kernel chip design, so that users can integrate the chip. The data bandwidth of CPU commands can be divided into 16-bit, 32-bit, and 64-bit. A 32-bit CPU can only process 32-bit data at a time, that is, 4 bytes of data. A 64-bit CPU can process 64-bit or 8 bytes of data at a time. If we edit the 128-bit command in units of 16-bit, 32-bit, and 64-bit, the old 16-bit CPU (such as Intel 80286 CPU) requires 8 commands, A 32-bit cpu requires four commands, while a 64-bit cpu requires only two commands. Obviously, when the operating frequency is the same, the 64-bit CPU processing speed is faster than that of 16-bit and 32-bit. In addition to computing power, compared with 32-bit CPUs, the advantage of 64-bit CPUs is also reflected in the system's memory control. Because the address uses a special integer, a 64-bit cpu alu and a register can process larger integers, that is, a larger address. The traditional 32-bit CPU has a maximum addressing space of 4 GB, which makes a lot of large-sized data processing programs that require large memory appear stretched at this moment, forming a bottleneck of operational efficiency. In theory, the 64-bit processor can reach 18 million TB (1 TB = 1024 GB), which will completely solve the bottleneck encountered by 32-bit computing systems. Of course, the 64-bit addressing space also has some disadvantages: the memory address value doubles as the number of digits increases, so that the memory address will occupy more space in the cache, other useful data cannot be loaded into the cache, resulting in a certain degree of decline in overall performance. During system design, the addressing space is allocated based on the CPU with different addressing capabilities. Since the CPU controls the device through the device register (this register can be understood as the device's own ram), it is very important to divide the address space. For example, a 32-bit addressing CPU cannot allocate all the address space to ram, for example, a PC system needs to allocate storage space to the BIOS. That is to say, all external devices that require direct CPU control need to allocate CPU address space for them. Ram is a memory that can be accessed randomly and read and written quickly. The CPU can directly obtain data from Ram (the CPU can obtain data from all device registers allocated with the address space) or code instructions. Therefore, the RAM access speed will directly affect the system performance. 1.2 Rom storage chipRom is essential to every computer system, but its implementation methods are different. In the familiar PC system, Rom is a chip called BIOS (base input & Output System. When the CPU is powered on, it reads commands from the Rom. Therefore, a system without a rom cannot run, because without a Rom, the CPU cannot obtain the starting execution command. In the PC system, BIOS not only provides the starting command, but also scans the hardware device and initializes the hardware interface on the main board. Because the interfaces on the PC follow a set of common protocols, the BIOS can implement drivers of all hardware interfaces (such as USB interfaces, display cards, keyboards, and mouse) and hardware data input and output functions, which is also the origin of the BIOS (Basic Input and Output System) Name. The hardware interface controlled by the BIOS also contains the hard disk control interface. After the BIOS Initialization is complete, it will find the boot file on the primary partition of the hard disk ( Note 3), The subsequent tasks are handed over to the PC operating system. See Figure 1.2 for this process. Generally, there is a primary Boot Record area in the hard disk. When the operating system is installed, the boot program is written into the operating system, and the BIOS extracts the program and runs it. Since the boot program is written by the operating system, from this boot program, the Operation permission of the system is controlled by the operating system. Take windows as an example. When executing this code area, the system file named "ntldr" is searched. The reason for dividing the boot program into ntldr files is that the Boot Sector of the hard disk is very small (only 466 bytes) and cannot accommodate all the boot programs. Figure 1.2 is just a startup. Here I am not listing every required step in detail, because my goal is to let us understand the role of the BIOS hardware chip in the system. Compared with the pc bios, the embedded system places all the Boot Code and operating system code into the flash chip of the system due to the small size of the software. As we know, most of the operating system code on the PC is put on the hard disk, and then the program is loaded into the memory for execution from the hard disk. In embedded systems, most of them use direct addressing to read and execute code from the nor flash chip. Therefore, in fact, the embedded system simplifies the design of the PC system, and the bios and hard disk code in the PC system are all concentrated on a flash chip. Therefore, although the BIOS can also use flash chips, their meanings and functions are different from those of embedded systems.

BiOS self-check

Video Card BIOS Detection

CPU model detection and memory testing

Read hard disk Boot Sector

Get the OS Startup File

Figure 1.2 The PC boot process flash chip is no stranger to us. The BIOS chips that can update BIOs are also implemented using flash chips, and the SD cards used for MP3 are also flash chips. Flash chip is a storage chip that can be erased multiple times and is widely used in embedded systems. Flash is characterized by low power consumption and large capacity (compared with embedded systems). It must be erased before writing (because the storage unit of the flash chip can only be changed from 1 to 0 ). Currently, there are popular options: nor flash and NAND Flash. The main differences between NAND and nor Flash are as follows: 1. NAND Flash space is larger than nor flash space 2. NAND Flash access speed is faster than nor flash 3. NAND Flash only has page access mode, nor flash can perform page and direct address access (direct address access, that is, the CPU can be directly addressable or called random access) 4. NAND Flash allows bad blocks, but nor flash cannot have bad blocks. 5. NAND Flash is cheaper than nor flash in embedded systems. Nor and NAND can both be used as code and file systems. In general, neither nor as an embedded file system zone uses the page mode. The page mode allows you to read multiple bytes at a time, just as the smallest read/write unit of a hard disk is a sector, but the smallest read/write unit of Flash is page. In page mode, you can speed up flash read/write. Since NAND Flash only supports page read/write mode, you need to add a control circuit when using NAND Flash as the code area. Currently, using NAND as the code area is becoming a popular trend (because the cost of NAND Flash is lower). There are two main implementation methods: one is to add a simulation circuit so that NAND flash can support random access; the other is to add a boot area (usually the first page) similar to a hard disk ), when the system starts, use the boot code to copy all the code in NAND to ram for execution. Of course, we can imagine that with the development of the embedded operating system in the future, the form of dynamic memory loading may appear, but the embedded system has not yet developed to this point. Furthermore, micro-hard disks used in embedded systems have also emerged, and more complex operating systems may also be applied to embedded systems. Here we mainly introduce the ROM storage chip Flash. in a strict sense, flash cannot be called Rom, because Rom is read-only memory ), flash is a readable and writable chip. However, Rom is being replaced by flash chips due to its "one-time molding and permanent replacement" feature, which is not easy to be upgraded, however, its functional title "Rom" is still used by everyone. In computer systems, user data, program data, and code are mainly binary. User data refers to user files. program data refers to non-code content that needs to be modified or used when the program is running. The following table compares the three binary data types in the PC system and embedded system:
Binary format PC System Embedded System
User Data Stored in a file system, a typical device is a hard disk. Stored in a file system, a typical device is a flash storage chip.
Program Data Read/write data is stored in Ram. read-only data is stored in the hard disk and read into RAM together with the code at runtime. Readable and writable data is stored in Ram; read-only data is stored in flash, and the code is stored in the same region.
Code Files stored in the file system, read into RAM at run time is executed by the CPU If it is stored in a space that can be accessed randomly, such as nor flash, the CPU directly runs the command in the chip. If it is stored in a space that cannot be accessed randomly, it needs to be read to ram for running.
Details about program data are described in the compiler basics section. 1.3 output deviceThere are many output devices, such as monitors and printers. Here we will focus on display devices. Any display device is dot-matrix, at least for the moment. I was surprised when I first saw the characters on TV. The world was so amazing! Later, I learned that if I want to, I can buy 640*480 bulbs to form a 640*480 square matrix, and then control the light-off of each bulb. I can also display a person. Finally, I understand that all the display devices are implemented based on this principle. I think there is no need to say more about this. After all, it will never be the same. Currently, the popular display devices include CRT Display (that is, a large computer-type display) and LCD (LCD) and so on (even though I used LED lights that show numbers in my college lab, they were too simple ). The physical evolution of the CRT Display from spherical to flat, while the LCD changes from black and white to color. According to the number of colors that can be displayed at each point of the display, it can be divided into two colors: black and white, gray, 8-bit color, 16-bit color, 24-bit real color and other display devices. The number of colors is the so-called color depth. The larger the color depth, the more colors each vertex can express. This is a "pixel ". In the embedded system, the LCD display device is used. The LCD integrates a storage space for display and stores the values of each pixel. For example, for a 16-bit LCD, each pixel must be represented by two bytes. If the screen size is 100*100, therefore, 2*100*100 = 20000 bytes of storage space is required. The program controls the LCD display by updating the content in the bucket. The pixel spacing is also used to measure the LCD display effect. The smaller the pixel spacing, the more delicate the screen is, the better the display effect. For example, if a pixel is as big as the entire LCD, you can only see the "light bulb" of a pixel point, and the image cannot be displayed. You can calculate the display size by the number of pixels and the size of each point, such as the commonly used XX inch screen. 1.4 Input DeviceThere are also many input devices, the most typical of which is the keyboard and touch screen. In this section, I will briefly introduce their implementation principles. The keyboard is usually a matrix circuit. when the key is pressed, the circuit is connected to generate a signal, 1.3:

1

2

3

A

B

C

Figure 1.3 keyboard principle Figure 1.3 is a simplified keyboard schematic. In the diagram, the horizontal and vertical links of any intersection are not connected. If the intersection is connected, then the corresponding rows and columns can be connected and the status changes. Among them, 1, 2, 3 and A, B, and C are connected to the control chip. By scanning rows and columns, determine whether A, B, and C of rows are connected, scan the columns 1, 2, and 3 to determine whether the node is connected. Please note that this is only a keyboard schematic. Touch screens are more and more input devices recently used. The working part of a typical touch screen is generally composed of three parts: Two transparent resistance conductor layer, an isolation layer and an electrode between two conductors. The resistance conductor layer is composed of resistance materials, such as indium tin oxide (ITO) coated on the substrate. The upper substrate is plastic and the lower substrate is glass. The isolation layer is a viscous insulating Liquid material, such as a Polyurethane film. The electrode consists of materials with excellent conductivity (such as silver ink. When the touch screen is working, the upper and lower conductor layers are equivalent to the resistance network. When a layer of electrode is added with voltage, a voltage gradient is formed on the network. If an external force is used to make the upper and lower layers in a certain point of contact, the voltage at the point of contact can be measured on another layer without voltage on the electrode, so as to know the coordinates at the point of contact. For example, if a voltage is added to the top-layer electrode (x +, X-), a voltage gradient is formed on the top-layer conductor layer. When an external force is applied, the upper and lower layers are exposed at a certain point, at the bottom layer, the voltage at the contact point can be measured, and the X coordinates of the contact point can be determined based on the distance between the voltage and the electrode (x +. Then, switch the voltage to the underlying electrode (Y +, Y-), and measure the voltage at the contact point on the top layer to know the Y coordinate. There are usually dedicated control chips. Obviously, the control chip of the touch screen has two things to do: one is to switch the electrode voltage, and the other is to collect the voltage value at the contact point (A/D ). Although there are other implementation methods, I will not go into details, because the purpose of this book is not to explain the principles of hardware, but to let us understand them. Conclusion 1.5This chapter introduces the features and principles of various hardware, including the introduction of various components of the minimum system, in order to prevent us from getting confused when we see these things. As long as we can see that these hardware are no longer mysterious, this foundation is even better. QuestionsIn PC computer systems, what are the differences between hard disks, bios, ram, and file flash, program flash, and ram in embedded systems? What are their roles in the system?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.