Network

The phyCORE-AM62x Development Kit can be operated as a disk-less system by hosting its bootloader, kernel, device tree and root filesystem on a remote server and then loading/mounting these artifacts over a Local Area Network. This approach is very convenient throughout development because you can quickly build and test changes to your kernel and root filesystem without having to update a physical boot device (such as the bootable SD Card). Furthermore, it makes file transfers between your Host Machine and phyCORE-AM62x Development Kit easy since they will effectively have shared access to the same directories.

These steps were verified using the same Host Machine outlined in the Host Requirements section of the Build the BSP guide, go check out that guide first if you still haven’t setup an Ubuntu 20.04 Host Machine.

Note

  • BSP-Yocto-Ampliphy-AM62x-PD24.1.0 only supports 1x ethernet port in the U-Boot bootloader by default. You MUST use ETH0 (reference designator X7) for these steps to work.

  • Link info Bootmode pin needs to be ON along with RGMII boot mode selection Bootmode pins.

Additional Hardware

  • USB to Ethernet Adapter - This provides an isolated network for us to serve our files to the phyCORE-AM62x.

Load The Bootloader

The TI boot ROM has the ability to make BOOTP requests to retrieve a bootloader over the network. This requires configuring a DHCP and TFTP server on our host machine.

Host Setup

First, run the following commands to satisfy some Host dependencies required for network boot:

host:~$ sudo apt update
host:~$ sudo apt install isc-dhcp-server tftpd-hpa

Note

firewalld can be installed to configure iptables if you have an active firewall on your system. Ubuntu ships with UFW (The default firewall manager) disabled.

# To install firewalld
host:~$ sudo apt install firewalld
# To configure the TFTP port
host:~$ sudo firewall-cmd --add-port=69/udp
# To configure the NFS port
host:~$ sudo firewall-cmd --add-port=2049/tcp

We will need our Host Machine’s IPv4 address. Use the following command to check your Host’s IP address:

host:~$ ip addr
Example Output
host:~$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
    valid_lft forever preferred_lft forever
2: enp11s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 6c:24:08:cf:12:4b brd ff:ff:ff:ff:ff:ff
    inet 172.22.10.32/24 brd 172.22.10.255 scope global dynamic noprefixroute enp11s0
    valid_lft 405645sec preferred_lft 405645sec
    inet6 fe80::d4b:2f18:2975:a5c9/64 scope link noprefixroute
    valid_lft forever preferred_lft forever
3: enx047bcb62cb4a: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
    link/ether 04:7b:cb:62:cb:4a brd ff:ff:ff:ff:ff:ff

In the above example output, it can be seen that this Host Machine’s USB to Ethernet adapter has a network interface named enx047bcb62cb4a.

Bring up the interface first:

host:~$ sudo ip link set enx047bcb62cb4a up

Once the interface is up, we can assign an address as follows:

host:~$ sudo ip addr add 192.168.100.1/24 dev enx047bcb62cb4a

Note

Depending on your LAN, IT department’s routing rules, and/or your specific Host Machine installation (virtual versus native) there may be additional consideration when establishing a valid network connection between your Host Machine and Target hardware.

In general, you usually need your Target device and Host Machine on the same subnet (ie the Host Machine and Target device should be assigned similar IPv4 addresses where all numbers match, such as 192.168.100.X where only the X is different for the two devices). This usually isn’t a issue if both the Host and Target device are connected to the same network switch.

In the case that your Ubuntu Host Machine is setup as a virtual machine (VM), you may need to modify the VM’s Networking settings:

  • Network Address Translation (NAT) mode is often times the default networking configuration for VMs and causes the underlying Host to route traffic between the VM and the network (the VM is essentially hidden behind the underlying Host from the perspective of the network). While NAT mode is great for anonymously connecting your VM to a network, it makes it invisible to other devices such as the phyCORE-AM62x Development Kit and thus prevents Network Boot from working properly.

  • Bridged mode allows your VM to connect directly to the network, replicating a physical device connection. You’ll generally want your VM in Bridged mode whenever it runs network services, which would allow devices such as the phyCORE-AM62x to access it.

Setup DHCP Server

phyCORE-AM62x supports loading SPL and U-Boot over the network using DHCP/BOOTP protocol. The DHCP server replying to DHCP/BOOTP requests from the SoC must provide filename to be fetched over TFTP for each stage depending on the Vendor-Class-Identifier (VCI) DHCP field specified in the request. VCI DHCP field is filled out by the ROM and subsequent stages and corresponding binaries files to be sent over TFTP are listed in the table below.

Host (Ubuntu) - Configure DHCP Server

  • First we need to configure which interface the DHCP server should use:

host:~$ sudo vim /etc/default/isc-dhcp-server

Update the file with your usb-to-eth device interface. The interface must be properly defined or the isc-dhcp-server will fail to start.

# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
#   Separate multiple interfaces with spaces, e.g. "eth0 eth1".
INTERFACESv4="enx047bcb62cb4a"
INTERFACESv6=""
  • Second we can configure our DHCP server by editing our dhcpd.conf.

host:~$ sudo vim /etc/dhcp/dhcpd.conf

Adapt the subnet range depending on your network card! In our case, subnet is 192.168.100.0/24

default-lease-time 600;
max-lease-time 7200;

option subnet-mask 255.255.255.0;
option domain-name-servers 192.168.100.1;
option routers 192.168.100.254;
option broadcast-address 192.168.100.255;

# Define the subnet and netmask
subnet 192.168.100.0 netmask 255.255.255.0
{
    # Specify a range of IP addresses for BOOTP
    range dynamic-bootp 192.168.100.10 192.168.100.20;

    # Conditional filename assignments based on the vendor-class-identifier
    if substring (option vendor-class-identifier, 0, 16) = "TI K3 Bootp Boot"
    {
        filename "tiboot3.bin-ethboot";
    } elsif substring (option vendor-class-identifier, 0, 20) = "AM62X U-Boot R5 SPL"
    {
        filename "tispl.bin";
    } elsif substring (option vendor-class-identifier, 0, 21) = "AM62X U-Boot A53 SPL"
    {
        filename "u-boot.img";
    }

    range 192.168.100.21 192.168.100.31;

    # Lease times
    default-lease-time 6000;
    max-lease-time 72000;

    # The IP address of the TFTP server (this could be the DHCP server itself)
    next-server 192.168.100.1;
}

We can now start our DHCP server:

host:~$ systemctl start isc-dhcp-server

To check the status of our server we can run the following:

Example Output
host:~$ systemctl status isc-dhcp-server
● isc-dhcp-server.service - ISC DHCP IPv4 server
        Loaded: loaded (/lib/systemd/system/isc-dhcp-server.service; enabled; vendor preset: enabled)
        Active: active (running) since Wed 2024-07-31 15:43:35 PDT; 4s ago
        Docs: man:dhcpd(8)
    Main PID: 173833 (dhcpd)
        Tasks: 4 (limit: 115431)
        Memory: 4.5M
            CPU: 15ms
        CGroup: /system.slice/isc-dhcp-server.service
                └─173833 dhcpd -user dhcpd -group dhcpd -f -4 -pf /run/dhcp-server/dhcpd.pid -cf /etc/dhcp/dhcpd.conf enx047bcb62cb4a

Setup TFTP Server

TFTP (which stands for “trivial file transfer protocol”) is supported in PHYTEC’s phyCORE-AM62x Boot ROM and BSP-Yocto-Ampliphy-AM62x-PD24.1.0 U-Boot by default, so we will setup a TFTP server on our Ubuntu Host Machine to make our Bootloader and Linux kernel binaries available.

First create a directory to host the TFTP server:

host:~$ sudo mkdir /tftpboot
host:~$ sudo chmod 777 /tftpboot
host:~$ sudo chown nobody /tftpboot

Now we can setup our TFTP server configuration:

host:~$ sudo vim /etc/default/tftpd-hpa

Edit the contents of the TFTP config file such that it reflects the following before saving and closing the file (note that we are basically pointing our TFTP daemon to open up the /tftpboot directory we just created on port 69):

# /etc/default/tftpd-hpa

TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/tftpboot"
TFTP_ADDRESS=":69"
TFTP_OPTIONS="--secure --create"

Start the TFTP daemon:

host:~$ sudo systemctl restart tftpd-hpa

Now that the TFTP server is up, we need to copy our desired u-boot and kernel binaries to it. Checkout the Build the BSP guide to give you a basis for customizing your software for your application requirements. For now, we’ll just populate our TFTP server with pre-built binaries:

host:~$ cd /tftpboot

host:~$ wget https://download.phytec.de/Software/Linux/BSP-Yocto-AM62x/BSP-Yocto-Ampliphy-AM62x-PD24.1.0/images/ampliphy-xwayland/phyboard-lyra-am62xx-3/tiboot3.bin-ethboot
host:~$ wget https://download.phytec.de/Software/Linux/BSP-Yocto-AM62x/BSP-Yocto-Ampliphy-AM62x-PD24.1.0/images/ampliphy-xwayland/phyboard-lyra-am62xx-3/tispl.bin
host:~$ wget https://download.phytec.de/Software/Linux/BSP-Yocto-AM62x/BSP-Yocto-Ampliphy-AM62x-PD24.1.0/images/ampliphy-xwayland/phyboard-lyra-am62xx-3/u-boot.img

At this point we are ready to load our bootloader from the network!

Target Setup (phyCORE-AM62x)

Ensure one end of your Ethernet cable is plugged into ETH0 of the dev kit, the other end should be connected to your dhcp server. Simply power on the board. If everything is configured correctly, the boot rom will reach out to the DHCP server to download the boot binaries.

Note

BOOTP requests and replies are mapped via VCI strings → vendor class identification strings.

Boot Flow: ROM -> DHCP/BOOTP -> tiboot3 -> DHCP/BOOTP -> tispl.bin -> DHCP/BOOTP -> u-boot.img


Load The Kernel

We can configure our phyCORE-AM62x‘s bootloader to grab the kernel and device trees over the network and use them for boot. This can be done by modifying the bootloader environment directly on the running phyCORE-AM62x.

Refer to the Quickstart guide for the basic steps required to boot your phyCORE-AM62x. When prompted, halt autoboot and stop in the U-Boot bootloader.

Connect your phyCORE-AM62x Development Kit’s ETH0 port to your Local Area Network using a CAT-5e cable.

Host Setup

First, run the following commands to satisfy some Host dependencies required for network boot:

host:~$ sudo apt update
host:~$ sudo apt install nfs-kernel-server

This chapter also requires to have a DHCP and TFTP service installed on the host system. Please see the previous chapter Boot The Bootloader how to install both services.

Setup NFS

A Network Filesystem Server (NFS) gives other systems the ability to mount a filesystem over a network. Once U-Boot loads our kernel via TFTP and boots it, the Linux kernel will eventually need a Root Filesystem to mount in order to boot all the way into Linux userspace.

Create a directory to host the NFS:

host:~$ sudo mkdir /nfsroot
host:~$ sudo chmod 777 /nfsroot
host:~$ sudo chown nobody /nfsroot

Now modify the NFS export table:

host:~$ sudo vim /etc/exports

Add the following to the end of exports before saving and closing:

/nfsroot    192.168.100.0/24(rw,insecure,no_subtree_check,async,no_root_squash)

Start the NFS daemon:

host:~$ sudo systemctl restart nfs-kernel-server

Now that the NFS is up, we just need to populate it with our desired root filesystem. Checkout the Build the BSP guide to give you a basis for customizing your software for your application requirements. For now, we’ll just populate our NFS with a pre-built root filesystem:

host:~$ wget phytec-qt6demo-image-phyboard-lyra-am62xx-3.rootfs.tar.gz
host:~$ sudo tar -xvf phytec-qt6demo-image-phyboard-lyra-am62xx-3.rootfs.tar.gz -C /nfsroot
host:~$ rm phytec-qt6demo-image-phyboard-lyra-am62xx-3.rootfs.tar.gz

The NFS should now be ready for network booting the kernel from the bootloader!

Setup TFTP Server

In addition to all bootloader files, the Linux kernel image and Device-Tree blob are required. Fetch both pre-build files and store them in the tftpboot directory:

host:~$ cd /tftpboot

host:~$ wget https://download.phytec.de/Software/Linux/BSP-Yocto-AM62x/BSP-Yocto-Ampliphy-AM62x-PD24.1.0/images/ampliphy-xwayland/phyboard-lyra-am62xx-3/Image
host:~$ wget https://download.phytec.de/Software/Linux/BSP-Yocto-AM62x/BSP-Yocto-Ampliphy-AM62x-PD24.1.0/images/ampliphy-xwayland/phyboard-lyra-am62xx-3/k3-am625-phyboard-lyra-rdk--6.6.32-10.00.08-phy2-r0.0-phyboard-lyra-am62xx-3-20240927110047.dtb -O oftree

Target Setup (phyCORE-AM62x)

By default, our BSPs boot with the server IP set to 192.168.3.10 and nfsroot to /nfsroot. Enter the following commands to modify the bootloader environment and save it to non-volatile memory.

uboot:~# setenv nfsroot /nfsroot
uboot:~# setenv serverip 192.168.100.1

Now we can proceed with boot:

uboot:~# boot

Once fully booted into Linux, you can double check that your root filesystem is mounted over a network (as opposed to the 2nd, unused rootfs partition of the SD Card) with the following command:

phyboard-lyra-am62xx-3:~# mount | grep nfs
Example Output
phyboard-lyra-am62xx-3:~# mount | grep nfs
172.22.10.18:/nfsroot on / type nfs4 (rw,relatime,vers=4.0,rsize=4096,wsize=4096,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=172.22.30.129,local_lock=none,addr=172.22.10.18)