Difference between revisions of "IMX8/Nitrogen8M/Yocto/Advanced image loading"

From RidgeRun Developer Connection
< IMX8‎ | Nitrogen8M‎ | Yocto
Jump to: navigation, search
m
 
(15 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<noinclude>{{IMX8/Head|carrier,carrier board,base board,SOM,System on Module,Boundary Devices,Nitrogen8M,yocto,boot configuration,emmc boot,usb boot,advanced boot}}</noinclude>
+
<noinclude>
 +
{{IMX8/Head|previous=Nitrogen8M/Yocto/Installing_an_Image|next=Nitrogen8M/Yocto/Customizing_Boot_Sequence
 +
|metakeywords=carrier, carrier board, base board, SOM, System on Module, Boundary Devices, Nitrogen8M, Yocto, boot configuration, emmc boot, USB boot, advanced boot
 +
|title= i.MX8 - Nitrogen8M - Advanced Image Loading - RidgeRun
 +
|metadescription=The i.MX8 application media processor is the latest addition to the i.MX of SoC family! Learn more about this advanced image-loading technology now at RidgeRun.
 +
}}
 +
</noinclude>
  
 
__TOC__
 
__TOC__
Line 7: Line 13:
 
When you are developing or debugging on your kernel or a file system application, network boot can be handy to avoid multiple flashes and to load new application versions without having to reboot the board each time.   
 
When you are developing or debugging on your kernel or a file system application, network boot can be handy to avoid multiple flashes and to load new application versions without having to reboot the board each time.   
  
Network boot configuration will load the kernel and device tree from a TFTP server and the root file system will be shared from host PC over NFS.
+
Network boot configuration will load the kernel and device tree from a TFTP server and the root file system will be shared from the host PC over NFS.
  
 
=== Host Setup ===  
 
=== Host Setup ===  
Line 38: Line 44:
 
=== Target Setup ===
 
=== Target Setup ===
  
Finally you need to configure the Nitrogen8M u-boot to boot from network, as follows:
+
Finally, you need to configure the Nitrogen8M u-boot to boot from the network, as follows:
  
1. Power ON the Nitrogen8M board, and stop the boot up process on u-boot, (press a key during the boot up count down)
 
  
2. While in u-boot set the following environment variables
 
 
<syntaxhighlight lang=bash>
 
# You need to set <server_ip_address> and <nfs_server_path> to match your host setup
 
setenv tftpserverip <server_ip_address>
 
setenv nfsroot <nfs_server_path>
 
saveenv
 
</syntaxhighlight>
 
 
Example:
 
<syntaxhighlight lang=bash>
 
# Nitrogen8m rootfs is at NFS_ROOTFS=/srv/nfs/nitrogen8m
 
setenv tftpserverip 192.168.1.60
 
setenv nfsroot /srv/nfs/nitrogen8m
 
saveenv
 
</syntaxhighlight>
 
 
3. Boot the board from network (still in u-boot) with the following command
 
  
<syntaxhighlight lang=bash>
 
run netboot
 
</syntaxhighlight>
 
  
This command should be run each time you restart the board to boot from network.
 
  
 
<pre>
 
<pre>
Line 86: Line 69:
 
#################################################################
 
#################################################################
 
#################################################################
 
#################################################################
 +
 
#################################################################
 
#################################################################
 
#################################################################
 
#################################################################
Line 167: Line 151:
 
== Network File System (NFS) ==
 
== Network File System (NFS) ==
  
When you are development for the file system (don't need to modify the kernel), you may want a network file system to change your applications without having to flash and reboot the board each time, just change the files on your host PC. Following the next instructions you will have a root file system shared from host PC over NFS.
+
When you are developing for the file system (don't need to modify the kernel), you may want a network file system to change your applications without having to flash and reboot the board each time, just change the files on your host PC. Following the next instructions, you will have a root file system shared from the host PC over NFS.
  
 
=== Host Setup ===  
 
=== Host Setup ===  
Line 173: Line 157:
 
You will need a NFS server, you can use the following instruction to set them up if you don't have if already.
 
You will need a NFS server, you can use the following instruction to set them up if you don't have if already.
  
# [[Setting_Up_A_NFS_Service |Setup a NFS server]]
+
* [[Setting_Up_A_NFS_Service |Setup a NFS server]]
  
 
Also you will need mkimage from u-boot tools package
 
Also you will need mkimage from u-boot tools package
 
 
<syntaxhighlight lang=bash>
 
<syntaxhighlight lang=bash>
 
sudo apt-get install u-boot-tools
 
sudo apt-get install u-boot-tools
</syntaxhightlight>  
+
</syntaxhighlight>
 
 
  
 
=== Modifying Bootscript ===
 
=== Modifying Bootscript ===
  
Boundary U-Boot is made to look for and execute a boot script file named boot.scr. This script will load kernel, device tree, setup the bootargs and start the OS.  
+
Boundary U-Boot is made to look for and execute a boot script file named boot.scr. This script will load the kernel, device tree, setup the bootargs and start the OS.  
  
The boot.src doesn't contemplates an nfs filesystem and reset the bootargs variable before setting the values that seem appropriate. So U-Boot environment cannot be used to set the nfs filesystem. You will need to modify the boot.src file to have an nfs filesystem option, to do so follow the next steps:
+
The boot.src doesn't contemplate an NFS filesystem and reset the bootargs variable before setting the values that seem appropriate. So the U-Boot environment cannot be used to set the NFS filesystem. You will need to modify the boot.src file to have an NFS filesystem option, to do so follow the next steps:
  
 
   
 
   
1. Download the bootscript text file '''bootscript-yocto.txt''', found inside the [[IMX8/Nitrogen8M/Getting_Started/Software_Support#Source_Code|U-Boot source code]] under the bootscripts folder (board/boundary/bootscripts/). You can browse the github repository through the directory path until the bootscript-yocto.txt, get the raw version and save it.
+
1. Download the bootscript text file '''bootscript-yocto.txt''', found inside the [[IMX8/Nitrogen8M/Getting_Started/Software_Support#Source_Code|U-Boot source code]] under the bootscripts folder (board/boundary/bootscripts/). You can browse the GitHub repository through the directory path until the bootscript-yocto.txt, get the raw version and save it.
 +
 
 +
2. Modify bootscript-yocto.txt to include NFS option as follows:
 +
<syntaxhighlight lang=diff>
 +
@@ -103,7 +103,9 @@
 +
if itest.s "x" == "x${bpart}" ; then
 +
bpart=2
 +
fi
 +
-if test "sata" = "${devtype}" ; then
 +
+if test "nfs" = "$fstype" ; then
 +
+ setenv bootargs "${bootargs} root=/dev/nfs rw ip=dhcp nfsroot=${tftpserverip}:${nfsroot},v3,tcp" ;
 +
+elif test "sata" = "${devtype}" ; then
 +
setenv bootargs "${bootargs} root=/dev/sda${bpart}" ;
 +
elif test "usb" = "${devtype}" ; then
 +
setenv bootargs "${bootargs} root=/dev/sda${bpart}" ;
 +
</syntaxhighlight>
  
2.  
+
=== NFS Setup ===
 +
 
 +
On your host PC, copy the file system directory to a location exported by the NFS server.
 +
 
 +
<syntaxhighlight lang=bash>
 +
NFS_ROOTFS=/srv/nfs/nitrogen8m
 +
cp -r $YOCTO_BUILD_DIR/tmp/work/nitrogen8m/$IMAGE/1.0-r0/rootfs ~/$NFS_ROOTFS
 +
</syntaxhighlight>
 +
 
 +
On your target board, follow the next steps:
 +
 
 +
1. Power ON the Nitrogen8M board, and stop the bootup process on u-boot, (press a key during the bootup count down)
 +
 
 +
2. While in u-boot set the following environment variables
 +
 
 +
<syntaxhighlight lang=bash>
 +
# You need to set <server_ip_address> and <nfs_server_path> to match your host setup
 +
 
 +
setenv tftpserverip <server_ip_address>
 +
setenv nfsroot <nfs_server_path>
 +
setenv fstype nfs
 +
saveenv
 +
</syntaxhighlight>
 +
 
 +
Example:
 +
<syntaxhighlight lang=bash>
 +
# Nitrogen8m rootfs is at NFS_ROOTFS=/srv/nfs/nitrogen8m
 +
setenv tftpserverip 192.168.1.60
 +
setenv nfsroot /srv/nfs/nitrogen8m
 +
setenv fstype nfs
 +
saveenv
 +
</syntaxhighlight>
 +
 
 +
3. Boot the board with the following command
 +
 
 +
<syntaxhighlight lang=bash>
 +
boot
 +
</syntaxhighlight>
 +
 
 +
'''NOTE''':
 +
<syntaxhighlight lang=bash>
 +
# If you want to get back to your regular boot method you need to unset the fstype variable
 +
setenv fstype
 +
saveenv
 +
</syntaxhighlight>
  
<noinclude>{{IMX8/Foot|Nitrogen8M/Yocto/Installing_an_Image|Nitrogen8M/Android}}</noinclude>
+
<noinclude>{{IMX8/Foot|Nitrogen8M/Yocto/Installing_an_Image|Nitrogen8M/Yocto/Customizing_Boot_Sequence}}</noinclude>

Latest revision as of 05:36, 3 March 2023


NXP Partner Program Registered Vertical.jpg NXP Partner Program Horizontal.jpg
Previous: Nitrogen8M/Yocto/Installing_an_Image Index Next: Nitrogen8M/Yocto/Customizing_Boot_Sequence





Network Boot

When you are developing or debugging on your kernel or a file system application, network boot can be handy to avoid multiple flashes and to load new application versions without having to reboot the board each time.

Network boot configuration will load the kernel and device tree from a TFTP server and the root file system will be shared from the host PC over NFS.

Host Setup

You will need a TFTP server and a NFS server, you can use the following instruction to set them up if you don't have them already.

  1. Setup a TFTP server
  2. Setup a NFS server

TFTP and NFS Configuration

For the following steps you should have a complete Yocto build for the Nitrogen8M as described at Building Yocto

1. Copy the kernel image and the kernel device tree blob from your Yocto build into the TFTP directory.

# You need to change TFTP_SERVER variable to match your TFTP directory

TFTP_SERVER=/srv/tftp
cd $YOCTO_BUILD_DIR/build/tmp/deploy/images/nitrogen8m
cp Image $TFTP_SERVER
cp imx8mq-nitrogen8m.dtb $TFTP_SERVER

2. Copy the file system directory to a location exported by the NFS server.

cp -r $YOCTO_BUILD_DIR/tmp/work/nitrogen8m/$IMAGE/1.0-r0/rootfs ~/$NFS_ROOTFS

Target Setup

Finally, you need to configure the Nitrogen8M u-boot to boot from the network, as follows:



=> run netboot
BOOTP broadcast 1
BOOTP broadcast 2
BOOTP broadcast 3
DHCP client bound to address 192.168.1.78 (1067 ms)
Using ethernet@30be0000 device
TFTP from server 192.168.1.60; our IP address is 192.168.1.78
Filename 'Image'.
Load address: 0x40480000
Loading: #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################

	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 #################################################################
	 ######################
	 3.1 MiB/s
done
Bytes transferred = 21408256 (146aa00 hex)
BOOTP broadcast 1
DHCP client bound to address 192.168.1.78 (3 ms)
Using ethernet@30be0000 device
TFTP from server 192.168.1.60; our IP address is 192.168.1.78
Filename 'imx8mq-nitrogen8m.dtb'.
Load address: 0x43000000
Loading: ##########
	 2.9 MiB/s
done
Bytes transferred = 47956 (bb54 hex)
## Flattened Device Tree blob at 43000000
   Booting using the fdt blob at 0x43000000
   Using Device Tree in place at 0000000043000000, end 000000004300eb53

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0

Network File System (NFS)

When you are developing for the file system (don't need to modify the kernel), you may want a network file system to change your applications without having to flash and reboot the board each time, just change the files on your host PC. Following the next instructions, you will have a root file system shared from the host PC over NFS.

Host Setup

You will need a NFS server, you can use the following instruction to set them up if you don't have if already.

Also you will need mkimage from u-boot tools package

sudo apt-get install u-boot-tools

Modifying Bootscript

Boundary U-Boot is made to look for and execute a boot script file named boot.scr. This script will load the kernel, device tree, setup the bootargs and start the OS.

The boot.src doesn't contemplate an NFS filesystem and reset the bootargs variable before setting the values that seem appropriate. So the U-Boot environment cannot be used to set the NFS filesystem. You will need to modify the boot.src file to have an NFS filesystem option, to do so follow the next steps:


1. Download the bootscript text file bootscript-yocto.txt, found inside the U-Boot source code under the bootscripts folder (board/boundary/bootscripts/). You can browse the GitHub repository through the directory path until the bootscript-yocto.txt, get the raw version and save it.

2. Modify bootscript-yocto.txt to include NFS option as follows:

@@ -103,7 +103,9 @@
 if itest.s "x" == "x${bpart}" ; then
 	bpart=2
 fi
-if test "sata" = "${devtype}" ; then
+if test "nfs" = "$fstype" ; then
+	setenv bootargs "${bootargs} root=/dev/nfs rw ip=dhcp nfsroot=${tftpserverip}:${nfsroot},v3,tcp" ;
+elif test "sata" = "${devtype}" ; then
 	setenv bootargs "${bootargs} root=/dev/sda${bpart}" ;
 elif test "usb" = "${devtype}" ; then
 	setenv bootargs "${bootargs} root=/dev/sda${bpart}" ;

NFS Setup

On your host PC, copy the file system directory to a location exported by the NFS server.

NFS_ROOTFS=/srv/nfs/nitrogen8m
cp -r $YOCTO_BUILD_DIR/tmp/work/nitrogen8m/$IMAGE/1.0-r0/rootfs ~/$NFS_ROOTFS

On your target board, follow the next steps:

1. Power ON the Nitrogen8M board, and stop the bootup process on u-boot, (press a key during the bootup count down)

2. While in u-boot set the following environment variables

# You need to set <server_ip_address> and <nfs_server_path> to match your host setup

setenv tftpserverip <server_ip_address>
setenv nfsroot <nfs_server_path>
setenv fstype nfs
saveenv

Example:

# Nitrogen8m rootfs is at NFS_ROOTFS=/srv/nfs/nitrogen8m
setenv tftpserverip 192.168.1.60
setenv nfsroot /srv/nfs/nitrogen8m
setenv fstype nfs
saveenv

3. Boot the board with the following command

boot

NOTE:

# If you want to get back to your regular boot method you need to unset the fstype variable
setenv fstype
saveenv


Previous: Nitrogen8M/Yocto/Installing_an_Image Index Next: Nitrogen8M/Yocto/Customizing_Boot_Sequence