Please enable javascript, or click here to visit my ecommerce web site powered by Shopify.
Jump to: navigation, search

Difference between revisions of "Rockpi4/dev/u-boot/pxe"

< Rockpi4‎ | dev‎ | u-boot
(Step 2: run pxe boot cammand)
Line 193: Line 193:
  
 
and now,your kernel is booting up
 
and now,your kernel is booting up
 +
 +
==Diskless start==

Revision as of 06:12, 29 June 2020

    ROCK Pi 4 >  Development >  U-boot >  PXE BOOT

PXE boot, Preboot eXecution Environment is a specification describes a standardized client-server environment that boots a software assembly, retrieved from a network. U-boot of ROCK Pi 4 supports PXE boot and it's enabled by default. This page describe how to use PXE boot on ROCK Pi 4.

Server setting

this document is used tftp server to test pxe boot to ramdisk,next,we will instruct on installing and configuring the tftp server in ubuntu 16.04LTS,and preparing some boot files.

Step 1: Install TFTP and TFTP server

 sudo apt-get install tftp-hpa tftpd-hpa

Step 2: Configure TFTP server

1.Create a folder,like this:

 mkdir /data/tftp_server

2.modify configuration file,like this:

 $ cat /etc/default/tftpd-hpa 
 # /etc/default/tftpd-hpa
 
 TFTP_USERNAME="tftp"
 TFTP_DIRECTORY="/data/tftp_server"
 TFTP_ADDRESS="0.0.0.0:69"
 TFTP_OPTIONS="-l -c -s"

Step 3: Restart tftp

 service tftpd-hpa restart

Step 4:Preparing boot file

copy all files from debian os boot partition,as follows:

 #:/data/tftp_server$ tree
 .
 ├── config-4.4.154-88-rockchip-00030-g90239a6      //copy from debian
 ├── dtbs                                           //.dtb file,we need rockpi-4b-linux.dtb,copy from debian
 │   └── 4.4.154-88-rockchip-00030-g90239a6
 │       └── rockchip
 │           ├── ficus-linux.dtb
 │           ├── px30-evb-ddr3-lvds-v10.dtb
   .
   .
   .
 │           └── rockpi-4b-linux.dtb
 ├── extlinux                                            //copy from debian
 │   ├── extlinux.conf
 ├── hw_intfc.conf                                       //copy from debian                          
 ├── initrd.img-4.4.154-88-rockchip-00030-g90239a6       //ramdisk,copy from debian
 ├── overlays                                            //.dtbo files,copy from debian
 │   ├── at24c02.dtbo
 │   ├── console-on-ttyS2.dtbo
 │   ├── console-on-ttyS4.dtbo
   .
   .
   .
 │   ├── spi1-waveshare35c.dtbo
 │   └── two-color-led.dtbo
 ├── pxelinux.cfg                                    //this folder is important,you can make the folder by yourself
 │   ├── 01-be-73-e6-4e-04-2b                        //named it by env ethaddr of uboot.i will introduce this file
 │   └── extlinux.conf
 └── vmlinuz-4.4.154-88-rockchip-00030-g90239a6      //this is a kernel image,copy from debian or build by yourself

Pxelinux.cfg

named pxe configaration file,run to uboot and print ethaddr:

 ...
   hclk_perilp1 100000 KHz                                                                                                                 
   pclk_perilp1 50000 KHz                                                                                                                  
 Net:   eth0: ethernet@fe300000                                                                                                            
 Hit key to stop autoboot('CTRL+C'):  0                                                                                                    
 => print ethaddr                                                                                                                          
 ethaddr=be:73:e6:4e:04:2b

so i named my pxe configaration file 01-be-73-e6-4e-04-2b,or you can named it default

 :/data/tftp_server/pxelinux.cfg$ cat 01-be-73-e6-4e-04-2b
 label kernel-4.4.154-88-rockchip-00030-g90239a6
     kernel /vmlinuz-4.4.154-88-rockchip-00030-g90239a6           //choose your kernel image
     devicetreedir /dtbs/4.4.154-88-rockchip-00030-g90239a6      //choose your dtb folder
     initrd initrd.img-4.4.154-88-rockchip-00030-g90239a6       //choose your ramdisk
     append earlycon=uart8250,mmio32,0xff1a0000 swiotlb=1 coherent_pool=1m earlyprintk console=ttyFIQ0,1500000n8 rw root=PARTUUID=b921b045-1d   rootfstype=ext4 init=/sbin/init rootwait        //this is bootargs for kernel

Rock Pi 4

we must install uboot on spi flash or emmc or microSD,this document is used spi flash,so please see spi-install to install uboot in spi flash

Step 1: Configure ip addr

enter uboot,and set some env:

 => setenv ipaddr xx.xx.xx.xx         //set rockpi4 ip
 => setenv serverip xx.xx.xx.xx        //set ip of tftp

Step 2: run pxe boot cammand

when you run pxe cammand,uboot will get some boot files from your tftp server.as follows:

 =>pxe get  
 missing environment variable: pxeuuid                                                                                                     
 missing environment variable: bootfile                                                                                                    
 Retrieving file: pxelinux.cfg/01-be-73-e6-4e-04-2b                                                                                        
 Speed: 1000, full duplex                                                                                                                  
 Using ethernet@fe300000 device                                                                                                            
 TFTP from server 192.168.2.140; our IP address is 192.168.2.205                                                                           
 Filename 'pxelinux.cfg/01-be-73-e6-4e-04-2b'.                                                                                             
 Load address: 0x600000                                                                                                                    
 Loading: #                                                                                                                                
          391.6 KiB/s                                                                                                                      
 done                                                                                                                                      
 Bytes transferred = 401 (191 hex)                                                                                                         
 Config file found
 =>pxe boot                                                                                                                                                                                                                                          
 missing environment variable: bootfile                                                                                                    
 Retrieving file: /hw_intfc.conf                                                                                                           
 Speed: 1000, full duplex                                                                                                                  
 Using ethernet@fe300000 device                                                                                                            
 TFTP from server 192.168.2.140; our IP address is 192.168.2.205                                                                           
 Filename '/hw_intfc.conf'.                                                                                                                
 Load address: 0x700000                                                                                                                    
 Loading: #                                                                                                                                
          840.8 KiB/s                                                                                                                      
 done                                                                                                                                      
 Bytes transferred = 1722 (6ba hex)                                                                                                        
 dtoverlay number: 0, name:/overlays/console-on-ttyS2.dtbo                                                                                 
 hw_conf.valid = 1                                                                                                                         
 hw_conf.pwm0 = 0                                                                                                                          
 hw_conf.pwm1 = 0                                                                                                                          
 hw_conf.uart2 = 0                                                                                                                         
 hw_conf.uart4 = 0                                                                                                                         
 hw_conf.spi1 = 0                                                                                                                          
 hw_conf.spi2 = 0                                                                                                                          
 hw_conf.i2c2 = 0                                                                                                                          
 hw_conf.i2c6 = 0                                                                                                                          
 hw_conf.i2c7 = 0                                                                                                                          
 hw_conf.dts_overlay_count = 1                                                                                                             
 hw_conf.dts_overlay[0] = /overlays/console-on-ttyS2.dtbo                                                                                  
 1:      kernel-4.4.154-88-rockchip-00030-g90239a6                                                                                         
 missing environment variable: bootfile                                                                                                    
 Retrieving file: initrd.img-4.4.154-88-rockchip-00030-g90239a6                                                                            
 Speed: 1000, full duplex                                                                                                                  
 Using ethernet@fe300000 device                                                                                                            
 TFTP from server 192.168.2.140; our IP address is 192.168.2.205                                                                           
 Filename 'initrd.img-4.4.154-88-rockchip-00030-g90239a6'.                                                                                 
 Load address: 0xa200000                                                                                                                   
 Loading: ########......                                                                                                                        
          ##################                                                                                                               
          5.2 MiB/s                                                                                                                        
 done                                                                                                                                      
 Bytes transferred = 4072215 (3e2317 hex)                                                                                                  
 missing environment variable: bootfile                                                                                                    
 Retrieving file: /vmlinuz-4.4.154-88-rockchip-00030-g90239a6                                                                              
 Speed: 1000, full duplex                                                                                                                  
 Using ethernet@fe300000 device                                                                                                            
 TFTP from server 192.168.2.140; our IP address is 192.168.2.205                                                                           
 Filename '/vmlinuz-4.4.154-88-rockchip-00030-g90239a6'.                                                                                   
 Load address: 0x280000                                                                                                                    
 Loading: ################# ......                                                    
          ########################                                                                                                         
        5 MiB/s                                                                                                                          
 done                                                                                                                                      
 Bytes transferred = 19427336 (1287008 hex)                                                                                                
 append: earlycon=uart8250,mmio32,0xff1a0000 swiotlb=1 coherent_pool=1m earlyprintk console=ttyFIQ0,1500000n8 rw root=PARTUUID=b921b045-1dt
 missing environment variable: bootfile                                                                                                    
 Retrieving file: /dtbs/4.4.154-88-rockchip-00030-g90239a6/rockchip/rockpi-4b-linux.dtb                                                    
 Speed: 1000, full duplex                                                                                                                  
 Using ethernet@fe300000 device                                                                                                            
 TFTP from server 192.168.2.140; our IP address is 192.168.2.205                                                                           
 Filename '/dtbs/4.4.154-88-rockchip-00030-g90239a6/rockchip/rockpi-4b-linux.dtb'.                                                         
 Load address: 0x8300000                                                                                                                   
 Loading: #######                                                                                                                          
          5 MiB/s                                                                                                                          
 done                                                                                                                                      
 Bytes transferred = 93561 (16d79 hex)                                                                                                     
 fdt addr 0000000008300000                                                                                                                 
 fdt magic number edfe0dd0                                                                                                                 
 fdt size 1048576                                                                                                                          
 merge_dts_overlay                                                                                                                         
 missing environment variable: bootfile                                                                                                    
 Retrieving file: /overlays/console-on-ttyS2.dtbo                                                                                          
 Speed: 1000, full duplex                                                                                                                  
 Using ethernet@fe300000 device                                                                                                            
 TFTP from server 192.168.2.140; our IP address is 192.168.2.205                                                                           
 Filename '/overlays/console-on-ttyS2.dtbo'.                                                                                               
 Load address: 0x8200000                                                                                                                   
 Loading: #                                                                                                                                
          755.9 KiB/s                                                                                                                      
 done                                                                                                                                      
 Bytes transferred = 774 (306 hex)                                                                                                         
 overlay dtb(0x0000000008200000) is valid                                                                                                  
 fdt_overlay_apply 0000000008300000 0000000008200000                                                                                       
 ## Flattened Device Tree blob at 08300000                                                                                                 
    Booting using the fdt blob at 0x8300000                                                                                                
    Loading Ramdisk to e99e3000, end e9dc5317 ... OK                                                                                       
    Loading Device Tree to 00000000e98e0000, end 00000000e99e2fff ... OK                                                                   
 Adding bank: 0x00200000 - 0xf8000000 (size: 0xf7e00000)                                                                                   
 Total: 717296.593 ms                                                                                                                      
                                                                                                                                           
 Starting kernel ...                                                                                                                       
                                                                                                                                           
                                                                                                                                           
 [    0.000000] Booting Linux on physical CPU 0x0                                                                                          
 [    0.000000] Initializing cgroup subsys cpuset

and now,your kernel is booting up

Diskless start