Application of BootLoader based on network loading

From the perspective of software structure level, the embedded system generally consists of a Boot Loader (BSP), an operating system, and an application. However, in some embedded systems, the operating system and applications are stored in devices other than the system, such as network, hard disk, etc., and the entire system only has a boot loader. Therefore, BootLoader is a more important part of embedded system design.

In the boot of the embedded system, depending on the location where the application is stored, there are three different loading methods: solid-state storage media, disk, and network, each of which has its own unique configuration and usage. The three types of settings have their own advantages and disadvantages. The solid-state storage media startup mode is generally applicable to embedded systems with ROM/FLASH. It is the preferred solution for most embedded devices such as mobile phones, mp3, etc., but when the application is larger In order to reduce the unit price of embedded devices, the disk boot mode is also widely used. Typical applications such as SDH telecom network equipment tester ANT-20, etc., based on network loading mode is the cheapest embedded device application. Solution, the application is stored on the network server. When the embedded device starts up, it only needs to be used to run the memory through the network. On the one hand, it can quickly solve the application upgrade problem, and on the other hand, it can reduce the overall cost of the embedded device. In the early stage of development, this method can also greatly improve the debugging speed. Typical applications are thin clients of embedded devices.

1 Design of BootLoader based on network loading

This solution focuses on solving two problems. One is the communication and connection between the embedded device and the server before power-on, and the other is the implementation of the application download mode during the startup process. The former needs to drive the embedded device to realize the communication capability. The network card driver is a necessary step. The latter needs to download the application to the system memory through the relevant protocol stack and run it. This paper focuses on the design of UDP/IP stack-based (DHCP, TFIP, NFS) loading schemes.

1.1 Design of NIC driver in BooiLoader

The network adapter (network card) generally consists of a programmable data link controller, a Manchester code/decoder, a transceiver interface, and a control circuit. The programmable data link controller is composed of a microprocessor and a network management part. Composition, as shown in Figure 1.

In the BootLoader NIC driver design, there are mainly three basic operations (the Realtek8139 NIC is used as an example for specific analysis):

1) Initialization of the network card

The work that should be completed is to initialize the relevant hardware in the network card, including the setting of the network card interrupt vector, the mapping of the network card receiving and sending buffers in the memory, and the initialization of the network card data structure.

2) Packet transmission

The transmission and transmission control section is responsible for the transmission of the frame. The transmitting section accepts the data of the Manchester code from the "NBZ Manchester Converter" and transmits the data to the media under the condition permitted by the transmission control section, and the transmitted data is called TxD. The transmission control section determines whether or not to transmit, and this determination is made based on the LAN management section and TxD.

3) Reception of data packets

The receiving and receiving control section is responsible for receiving the frame. This part generates a signal on whether the network has a carrier, and the basis for the generation is obtained from RxD. Therefore, the signal from the network is fed to the receiver on the one hand and to the reception control portion on the other hand. The reception control section determines whether to operate the receiver based on signals received by the LAN management section and the medium.

1.2 Design of network server application

In the network load BootLoader, the application layer protocols used are DHCP, TFTP, and NFS. The target platform is in operation and requires the server to provide the services of the above protocol:

1) Establish server-side DHCP service

The function completed by the service is to provide a valid IP address allocation for the target platform to ensure that the address is unique when the target platform and the server communicate normally. The configuration process is as follows:

After you are sure that the DHCP protocol has been properly installed, you need to modify the /etc/dhcpd.conf file, for example:

The subnet is the subnet shared by the target and the host, and netmask is their subnet mask. Hardware ethernet is the network hardware address of the target machine. It can be assigned a fixed IP address to the target through fixed-address. When the target machine starts, it will obtain the IP address itself. OpTIon host-name is the machine name of the target machine. When the host is directly connected to the target, opTIon routers points to the address of the host. When they are not directly connected, but through routing, the value of opTIon routers is the true router address value. Similarly, opTIonsubnet-mask is the child of the option routers network. Net mask. Filename is the name of the file that the target machine downloads from the TFTP server. The next-server is the location where the TFTP service is provided.

Finally, check if the /var/state/dhcp/dhcpd.leases file exists. When everything is ready, you can run the DHCP service:

#/etc/init.d/dhcpd start

2) Establish server-side TFTP service

The service is used when the web-based BootLoader downloads the application. It is similar to the FTP service, but it does not need to provide the username and password to the server, and it downloads faster than FTP. The configuration process is as follows:

After convinced that the TFTP protocol has been properly installed,

1 modify the file /etc/xinetd.conf to open tftp support;

2 modify the file /etc/xinetd.d/tftp, for example:

The parameter server_args is the directory specified by the tftp service, and the rest of the parameters are easier to understand.

After setting up, please restart xinetd and run the tap service.

3) Establish server-side NFS service

The target platform needs to use the service to mount the root file system when the Linux runtime is initialized. The configuration process is as follows:

After making sure that NFS is properly installed, modify the file /etc/exports, for example:

/home/karim/ctrl—rooffs 192.168.172.10 (rw,no_root_squash)

The directory /home/karim/ctrl-rooffs can be modified to the directory where the root file system of the server is stored. 192.168.172.10 is the IP address of the server.

After the modification is complete, you only need to restart the NFS service. The NFS service provides the network file system function to facilitate the management and use of the application.

1. 3 client embedded BootLoader design

In a network-loaded BootLoader system, application files are typically stored on a network server. After the system is started, the BootLoader needs to drive the network adapter first, and download the image file to the SDRAM of the target machine through the UDP/IP protocol stack (BOOTP/DHCP, TFTP protocol, etc.). When the embedded Linux operating system is initialized, it uses the The NFS protocol mounts the root file system to the server.

In this scenario, the main working steps of the BootLoader program are as follows:

1) Initialization of basic hardware: including masking all interrupts, initializing all hardware, setting/loading system setup values, setting CPU clock and frequency, RAM initialization, etc.

2) Read the network parameter configuration file:

The configuration file mainly stores some parameters required by the system to use the network, including the MAC address, the IP address of the tftp server, the Kernel file name, and the application file name.

3) Initialize the PCI interface and drive the network card;

4) Obtain the IP address of the target platform through the DHCP protocol;

The target platform first broadcasts and sends an ARP packet. When the DHCP server receives the ARP packet, it allocates a valid IP address from the address table according to the hardware address in the ARP packet, and sends a response packet to the target platform.

5) download the kernel code to the memory SDRAM through the tftp protocol;

6) Run the Linux kernel and system applications.

2 Application implementation of BootLoader based on network loading

The embedded LoadLoader based on network loading designed in this paper is applied to DVB-C TV set-top box products. In DVB-C set-top box, there are generally network ports for interacting with content servers, such as VOD and web browser. Its hardware block diagram is composed as shown in Figure 3.

In the DVB-C TV set-top box, the CPU is a 32-bit dual-core RISC microcontroller SPH1003 manufactured by Sunplus. In addition, the system is also integrated with the Sensung company's Tuner, whose function is to modulate the TS stream from the cable, and its content is TV program stream and TV program auxiliary information (such as EPG, TV graphic information). The download and start of the TV set-top box software (mainly embedded Linux kernel, root file system and application) can be realized through the integrated network port of the TV set-top box.

In the DVB-C set-top box, the BootLoader loader mainly implements downloading the embedded Linux kernel from the network and starting the system. After the hardware initialization of the system is completed by the BootLoader, the program will jump to the network Loader program, which drives the network card and starts the tftp request. The specified file is downloaded from the network server through the tftp protocol, and the software runs as shown. Section 1.3. This kind of application can effectively utilize the network card network structure in the box, thereby reducing the overall cost of the set-top box (less to the flash/ROM chip and its peripheral control hardware, etc.), and also facilitates timely updating of applications and embedded kernels, etc. Realize the purpose and timely maintenance of the set-top box thin client.

3 BootLoader boot load process test and analysis

3.1 Test case design

In the test of the DVB-C set-top box boot loading process, it mainly includes two aspects of unit testing and integration testing. Therefore, when design testing is used, there are mainly unit test cases and integrated test cases. The test case design is shown in Table 1 and Table 2.

3.2 Analysis of test results

According to the design of the test case in the above table, the analysis results are as follows:

1) In the unit test, according to the function of each function and the test result requirements, the code coverage test, the parameter boundary value test and the function running result test are respectively performed, and the test results can all meet the program requirements;

2) In the integration test, the test of the network environment is mainly focused on: normal network environment, abnormal network environment, the program can correctly identify and respond differently to these two situations; The target file was downloaded and tested, and the original file and the content downloaded to the SDRAM were compared. The two were completely consistent, and the success rate reached 100% in the multiple download test. The special test of the startup process and time of the DVB-C set-top box was carried out. This test is the most important performance test of the BootLoader boot loader. The success rate of the boot process is 100% and the boot time is approximately 1 s.

4 Conclusion

The network load-based BootLoader design and solution described in the paper has a good module structure and scalability, which lays a foundation for application to other systems. At the same time, it has been widely used in DVB-C set-top boxes in actual product design. Compared with general set-top boxes, the DVB-C set-top box saves about 20 yuan. In mass production (about 100,000 units), it can realize millions of yuan. The economic benefits, so the program has a strong market competitiveness.

Electric Motorcycle Battery Pack

Shenzhen Sunbeam New Energy Co., Ltd , https://www.sunbeambattery.com

Posted on