Embedded Linux network boot

Source: Internet
Author: User
The embedded Linux Network guides the development of embedded Linux. During kernel transplantation and root file system establishment, the establishment of the root file system is feasible to verify whether kernel transplantation is successful, they need to burn their image files to flash for repeated tests. Burning flash with such frequent writing will not only waste time, reduce development efficiency, but also cause damage to flash. Therefore, network guidance is generally used during the establishment of internal nuclear transfer and root file systems. The specific procedure is as follows: 1. Set the boot loader environment variables and kernel parameters. The Boot Loader of my Development Board uses U-boot. The environment variables are set as follows: uboot> printenvbootdelay = 3 baudrate = 115200 ethaddr = 00: 12: 34: 56: 78: 9 aipaddr = 192.168.0.9 ① serverip = 192.168.0.1 ② netmask = 255.255.255.0rootpath =/home/zht/rfsys ③ stdin = serialstdout = serialstderr = serialbootcmd = TFTP 21000000 uimage; bootm 21000000 ④ bootargs = root =/dev/nfs RW nfsroot = 192.168.0.1:/home/zht/rfsys nfsaddrs = 192.168.0.48: 192.168. 0.1: 192.168.0.1: 255.255.255.0 console = ttys0, 115200 mem = 32 m ⑤ ① set the target board IP address ② set the Server IP address ③ set the path of the root file system on the server, note that the path must be set to the NFS directory on the server. ④ Bootcmd is the command executed after U-boot is started. commands are separated by semicolons. TFTP 21000000 uimage indicates to download the kernel image to ram through TFTP. The address is 0x21000000. bootm 21000000 starts Linux operating system ⑤ defines the command line parameters U-boot transmits to the Linux kernel, this command line specifies the Network File System as the root file system. Root =/dev/NFS is not a real device, but a flag that tells the kernel to obtain the root file system through the network. The nfsroot parameter tells the kernel to use the machine, directory, and Network File System option as the root file system. The parameter format is as follows: nfsroot = [<server-IP >:] <root-dir> [, <nfs-Options>] If the nfsroot parameter is not specified in the Command column, the default value '/tftpboot/% s' is used. Other options are as follows: <server-ip> -- specify the Internet address (IP address) of the Network File System server ). If this field is not specified, the value determined by the nfsaddrs variable (see the following) is used. One of the purposes of this parameter is to allow different machines as the Reverse Address Resolution Protocol (RARP) and Network File System server. Usually you can ignore it (set as blank ). <Root-dir> -- Name of the directory to be mounted as the root on the server. If the string contains a '% s' token, this token is replaced by the ASCII representation of the client Internet address. <Nfs-Options> -- standard Network File System Options. All options are separated by commas. If this field is not specified, use the following default values: port = as given by server Portmap daemon rsize = 1024 wsize = 1024 timeo = 7 retrans = 3 acregmin = 3 acregmax = 60 acdirmin = 30 acdirmax = 60 flags = hard, nointr, noposix, the CTO and AC parameters nfsaddrs set the network interface addresses required for network communication. If this parameter is not specified, the kernel tries to use the Reverse Address Resolution Protocol and/or the startup protocol (BOOTP) to find these parameters. The format is as follows: nfsaddrs = <my-IP >:< Serv-IP >:< GW-IP >:< netmask >:< name >:< Dev>: <auto> <my-ip> -- Internet address of the client. If not, this address is determined by the Reverse Address Resolution Protocol or startup protocol. The protocol used depends on the options enabled when the core is configured and the <auto> parameter. If this parameter is set, the Reverse Address Resolution Protocol or startup protocol is not used. <Serv-ip> -- Internet address of the Network File System server. If the Reverse Address Resolution Protocol is used to determine the client address and set this parameter, only responses from the specified server are accepted. If you want to use different machines as the Reverse Address Resolution and Network File System server, specify your Reverse Address Resolution Protocol server (leave blank) and set the nfsroot parameter (see the above) specify your Network File System server. If this project is blank, use the address of the server that answers the Reverse Address Resolution Protocol or startup protocol. <GW-ip> -- The Internet address of the Gateway. If the server is on a different sub-network. If this project is blank, no gateway is used, and the server is assumed to be on a local network, unless the value is received by the startup protocol. <Netmask> -- the network mask of the local network. If it is blank, The netmask is exported from the client's Internet address, unless the value is received by the startup protocol. <Name> -- client name. If it is blank, use the ascii-flag method of the client Internet address or the value received by the startup protocol. <Dev> -- Name of the network device to be used. If it is blank, all devices will send a reverse address resolution request, and the START protocol request is sent by the first device found. The Network File System uses the device that receives the Reverse Address Resolution Protocol or the startup Protocol response. If you only have one device, you can ignore it. <Auto> -- used as the automatic configuration method. If it is 'rarp 'or 'bootp', the Protocol indicated is used. If this value is 'both 'or blank, it is used if both protocols are enabled when the core is configured. 'None' indicates that automatic configuration is not used. In this case, you must specify the values necessary in the preceding field. This <auto> parameter can be used independently as an nfsaddrs parameter (without any ':' character before it). In this case, automatic configuration is used. However, 'none' cannot be used as the value in this case. Two Kernel configuration requirements add Kernel support for NFS: Select networking options-"IP: select the root file system on NFS and NFS file system support under file systems-> network file systems-> kernel level aulosponalion to log on as the root user, run the setup command # setup, select development me services, and select TFTP. Open the TFTP configuration file/etc/xinetd. d/TFTP set server_args to the directory where the kernel image file is located. The default is/tftpboot my kernel image in the/home/zht/sources/kernel/linux-2.4.27 directory. The settings are as follows: service tftp {disable = No socket_type = dgram protocol = udp wait = Yes user = root server =/usr/sbin/in. tftpd server_args =-S/home/zht/sources/kernel/linux-2.4.27 per_source = 11 CPS = 100 2 flags = IPv4} restart the PC Linux operating system or run the service xinetd restart command to start TFTP server. Run netstat-A | grep TFTP to check whether the TFTP server is configured successfully. 4. log on to the Linux server as root, edit the exports shared directory configuration file under the/etc directory, and specify the shared directory and permissions. Run the following command to edit the file/etc/exports: # vi/etc/exports and add the following content to the file:/home/zht/rfsys 192.168.0. * (RW, sync, no_root_squash) Save and exit after editing. Then run the command exports-rav to check whether the input is correct. The added content indicates that the computer with the IP address range of 192.168.0. * can access the/home/zht/rfsys directory with the read and write permissions. /Home/work is also called the server output shared directory. The parameter meanings in the brackets are described as follows: RW: read/write permission. The parameter of read-only permission is RO; Sync: Data Synchronization writes to memory and hard disk, or async, at this time, the data is saved in the memory, instead of immediately written to the hard disk. No_root_squash: attributes of the NFS server shared directory user. If the user is root, the shared directory has root permissions. Run the following command to start port ing: #/etc/rc. d/init. d/Portmap start run the following command to start the NFS service. At this time, NFS will activate the daemon and then start listening to client requests: #/etc/rc. d/init. d/nfs start after the NFS server is started, you also need to check the firewall and other settings of the Linux Server (usually you need to disable the Firewall Service and execute iptables-f ), ensure that the port used by NFS and the host that allows communication are not blocked. Check the settings of iptables, ipchains, and other options on the Linux server and/etc/hosts. deny,/etc/hosts. allow file. We first perform a loop test on the NFS server on the Linux server to verify whether the shared directory can be accessed. Run the following command on the Linux Server: # Mount-t nfs 192.168.0.20: the/home/zht/rfsys/mnt # ls/mnt command mounts the NFS output shared directory of the Linux server to the/mnt directory. Therefore, if NFS works properly, you should be able to see the content in the/home/work shared directory in the/mnt directory. 5. Copy the kernel image file uimage to the/tftpboot directory, and copy the created root file system to the/home/zht/rfsys directory. Then restart the target board.

 

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.