PXE boot + serial console + official Debian image

I wanted to try PXE boot from a serial console and followed this guide. I used this Debian image to get files. All was good until this line when booting.

bootconsole [uart0] disabled

Is it disabled when kernel was compiled or I can enable it editing some configuration file? Can someone advise?

You need to edit your hw_intfc.conf to enable the serial console. Check:

https://wiki.radxa.com/Rockpi4/hardware/devtree_overlays

I am a bit confused. I see the option to enable UART2. Then I should uncomment UART2 overlay.
What should I use in pxelinux.cfg/01-be-73-e6-4e-04-2b at the line

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

Should I change console=ttyFIQ0 to something else like ttyS2? Also I enable UART2 but kernel complains about uart0. Does it matter?

@jack Would you be able to clarify my question above because I am not sure about what values I should put to get uart0 to work? I tried to enable uart2 overlay and add ttyS2 into kernel bootargs but it didn’t work for me.

Also it looks uart0 is enabled when kernel is started

[ 0.000000] earlycon: Early serial console at MMIO32 0xff1a0000 (options ‘’)
[ 0.000000] bootconsole [uart0] enabled

But then at the end I get

[ 1.985460] Key type dns_resolver registered
[ 1.986579] Registered cp15_barrier emulation handler
[ 1.987190] Registered setend emulation handler
[ 1.988878] bootconsole [uart0] disabled

@radxa Can you advise if pxe boot can mount root partition on nvm? Also can any version of kernel do an pxe boot in diskless mode with something like this

append earlycon=uart8250,mmio32,0xff1a0000 swiotlb=1 coherent_pool=1m earlyprintk console=ttyFIQ0,1500000n8 rw nfsroot=192.168.1.2:/nfsroot ip=dhcp

Can you advise if pxe boot can mount root partition on nvm?

I think you mean root on NVMe/SSD?

append earlycon=uart8250,mmio32,0xff1a0000 swiotlb=1 coherent_pool=1m earlyprintk console=ttyFIQ0,1500000n8 rw nfsroot=192.168.1.2:/nfsroot ip=dhcp

I think you need at least add rootwait in the kernel parameter.

@Shine is looking at this issue and will get back to you.

Yes, exactly. I think in the original wiki page about PXE it is assumed that you continue to boot from SD card then. But I am wondering if you can boot from NVM. I have the latest non-testing u-boot flashed and spi enabled but it looks I cannot continue boot from nvm with PXE.

And, yes I am eager to know if it is possible to boot in diskless mode too using NFS root.

For your serial port problem, you only need to modify its contents according to the hw_intfc.conf instructions. booting from NVM with PXE, I haven’t found out how to implement it yet;

And, yes I am eager to know if it is possible to boot in diskless mode too using NFS root.

For the diskless boot you mentioned, I’m trying to implement it on RockPI4. I used TFTP to download the kernel and DTB, and using NFS network file system enabled me to start rockpi4 completely from the network.

modify hw_intfc.conf contant:

...
intfc:uart2=on
...
intfc:dtoverlay=console-on-ttyS2
...

@Shine Were you able to run in diskless mode?

Hello, diskless mode has passed the test, but we need to update the kernel, so please wait a moment, after we update the kernel, we will tell you how to use diskless mode.

Thanks. Sounds great. It would be nice to have this feature available.

[Diskless start]:
Diskless startup means that the operating system can be started without a disk (EMMC or sdcard or nvme). Diskless startup usually uses the DHCP, TFTP and NFS functions of uboot,
This time, we will use another way to realize diskless startup. We will combine PXE of network card with NFS of uboot to realize diskless startup.

You nead to prepare:

  1. rockpi4;
  2. server host (ubuntu);
  3. Ethernet Cable;
  4. Serial port line;

How to do:

  1. Download uboot to SPI flash on rockpi4;
  2. Install TFTP and NFS server on the server host(PC):
    (1). NFS server installation:
xxx@xxx:~$ sudo apt-get install nfs-kernel-server
xxx@xxx:~$ mkdir -p /home/xxx/nfs_rootfs
xxx@xxx:~$ sudo vim /etc/exports
/home/xxx/nfs_rootfs  *(rw,nohide,insecure,no_subtree_check,async,no_root_squash)
xxx@xxx:~$ sudo service nfs-kernel-server restart	#Restart service
xxx@xxx:~$ sudo  mount  -t  nfs  127.0.0.1:/home/xxx/nfs_rootfs  /mnt	#Test services for NFS

(2). TFTP server installation:

xxx@xxx:~$ sudo apt-get install tftp-hpa tftpd-hpa
xxx@xxx:~$ mkdir -p /home/xxx/tftpboot
xxx@xxx:~$ chmod 777 /home/xxx/tftpboot
xxx@xxx:~$ sudo vim /etc/default/tftpd-hpa
TFTP_DIRECTORY="/home/xxx/tftpboot"
TFTP_OPTIONS="-l -c -s"
xxx@xxx:~$ sudo service tftpd-hpa restart	#Restart service
  1. Put the kernel and DTB in the TFTP directory, and extract the root file system to the NFS directory. The operation is as follows:
    (1). Update the kernel in Debian of rockpi4:
root@linaro-alip:~# apt-get update
root@linaro-alip:~# apt install linux-4.4-latest -y
...
Setting up linux-headers-4.4.154-110-rockchip-gcef30e88a9f5 (4.4.154-110-rockchip) ...
Setting up linux-4.4-latest (4.4.154-110-rockchip) ...
root@linaro-alip:~#

(2). Copy the latest kernel and other files in the boot directory of Debian (you need to update the kernel to version 110):

root@linaro-alip:/boot# cp * /media/linaro/1877-4F6E/boot/ -r    #This is my U stick

(3). In the server (PC), copy all files in the boot directory of the U disk to the TFTP Directory:

xxx@xxx:/data/tftp_server$ cp /media/yulingle/1877-4F6E/boot/* . -r

(4). Create a configuration file for PXE to read:

xxx@xxx:/data/tftp_server$ mkdir pxelinux.cfg
xxx@xxx:/data/tftp_server$ cd pxelinux.cfg/
xxx@xxx:/data/tftp_server/pxelinux.cfg$ cp ../extlinux/extlinux.conf .
xxx@xxx:/data/tftp_server/pxelinux.cfg$ vim 01-d2-13-dc-b9-d4-10   #The physical address of the network card can be obtained by entering **print ehaddr** in the command line of **uboot**
timeout 10
menu title select kernel
	 
label kernel-4.4.154-110-rockchip-gcef30e88a9f5
kernel /vmlinuz-4.4.154-110-rockchip-gcef30e88a9f5
devicetreedir /dtbs/4.4.154-110-rockchip-gcef30e88a9f5
initrd initrd.img-4.4.154-110-rockchip-gcef30e88a9f5
append earlyprintk console=ttyFIQ0,1500000n8 init=/sbin/init root=/dev/nfs rw nfsroot=192.168.2.181:/home/xxx/nfs_rootfs,v3 ip=192.168.2.244:192.168.2.181:192.168.2.1:255.255.255.0:xxx::off rootwait
#The contant of 01-d2-13-dc-b9-d4-10 file can copy from pxelinux.cfg/extlinux.conf
#192.168.2.181 is IP of server.
#/home/xxx/nfs_rootfs is the directory where the root file system resides.
#v3 is version number of nfs.
#xxx is hostname of your server host.
#192.168.2.1 is gateway.

(5). Next, unzip the root file system to the NFS directory:
Unzip the file system:

$ tar -xzf linaro-stretch-alip-20200623-1.tar.gz -C /home/xxx/  #After unzipping, you will get the binary folder.
$ mv binary nfs_rootfs  #nfs_rootfs is the directory name specified in the /etc/exports file.

linaro-stretch-alip-20200623-1.tar.gz The creation of the root file system can refer to here.

(6). done.

4、Start rockpi4, enter the uboot command line, and set IP:

=> setenv ipaddr xx.xx.xx.xx
=> setenv serverip xx.xx.xx.xx	#The IP address of rockpi4 and server must be in the same network segment.

Using PXE

=> pxe get
=> pxe boot

5、When the kernel is started successfully and the NFS file system is mounted, the following is displayed:

Starting Update UTMP about System Runlevel Changes...
[  OK  ] Started Update UTMP about System Runlevel Changes.
[   27.195702] tty_port_close_start: tty->count = 1 port count = 2.

Debian GNU/Linux 9 linaro-alip ttyFIQ0

linaro-alip login: root (automatic login)

Linux linaro-alip 4.4.154-110-rockchip-gcef30e88a9f5 #1 SMP Mon Jun 22 07:37:10 UTC 2020 aarch64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
root@linaro-alip:~# 
root@linaro-alip:~# 
root@linaro-alip:~# 
root@linaro-alip:~# 

6、done

Thanks a lot. I will try it soon and let you know if I can replicate your steps. I am wondering can I extract rootfs from the current latest debian image or the only option is to build it?

Yes, you can extract rootfs from the latest Debian image.
In Debian:

$ cd /
$ tar cvpzf backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys --exclude=/media /
$ cp /backup.tgz /mnt/rootfs            #/mnt/rootfs is my U disk

In Server host:

$ cd /home/xxx/nfs_rootfs
$ cp /media/xxx/1877-4F6E/rootfs/backup.tgz .         #/media/xxx/1877-4F6E is my U disk
$ tar -xzf backup.tgz
$ sudo mkdir proc lost+found mnt sys media
$ service nfs-kernel-server restart