Setting up a Debian server for network booting the i.MX6 sabre sd platform

Document created by Vincent Stehle Employee on Jun 28, 2013Last modified by Vincent Stehle Employee on Jun 28, 2013
Version 1Show Document
  • View in full screen mode

In this post we see how to setup a Debian server, to allow booting the i.MX6 sabre sd platform (mostly) from the network.

 

Booting from the network instead of e.g. the SD card is very handy for day to day development and testing, as it eliminates almost all physical interactions with the board and saves much time.

 

Also, fortunately for us, both u-boot and Linux for i.MX6 support network booting out of the box.

 

Boot sequence principles

Before we setup the server, here are some more details on the boot sequence we will obtain in the end:

 

  1. i.MX6 boots, loads u-boot from SD card.
  2. u-boot starts, loads its environment (boot commands) from SD card.
  3. u-boot obtains its network address by DHCP, loads a Linux kernel uImage and a dtb by TFTP.
  4. Linux boots; obtains its network address by DHCP (again), mounts its root filesystem on NFS.

 

Setting up DHCP and TFTP

One can easily setup a Debian server to act as DHCP and TFTP server with Dnsmasq; just install the dnsmasq package. The default configuration is mostly empty; so we need to enhance it a bit.

 

For the following we will assume that your Debian server has IP address 192.168.111.1 on the network where it sees the i.MX6 sabre sd platform.

 

You can add some options to a dnsmasq config file such as e.g. /etc/dnsmasq.d/my-custom-config-file:

 

  dhcp-range=192.168.111.50,192.168.111.150,12h

  enable-tftp

  tftp-root=/var/ftpd


This informs dnsmasq to act as a DHCP server for addresses range 192.168.111.50-150 and act as TFTP server, which serves files under /var/ftpd.

 

That means you will need to copy a Linux uImage and an imx6q-sabresd.dtb under /var/ftpd/. See this post for more details about compiling Linux to obtain those two files.

 

Setting up NFS

If we want the root filesystem to be mounted on the network we will need to export some folders with NFS from the Debian server.

 

We need to install the nfs-kernel-server package and setup /etc/exports with a line such as:

 

  /tftpboot       192.168.111.*(rw,no_root_squash,subtree_check)

 

This allows clients on the 192.168.111.0 network to access filesystems under the /tftpboot folder.

 

So you will need to create a /tftpboot folder on the server, and install some "filesystem" under there. For this example we assume you will have a busybox installed under a /tftpboot/busybox/ folder. That means we want to have under there all folders such as bin, dev, etc... See this post for details on how to compile busybox to populate this folder.

 

Do not forget to restart the NFS server after configuration, with:

 

  # /etc/init.d/nfs-kernel-server restart

 

We are now setup on the server side.

 

Setting up u-boot

At the time of this writing we need to help u-boot a bit when booting the i.MX6 sabre sd platform from the network. Stop at u-boot prompt and configure a few things:

 

  env default -a

  setenv netargs $netargs rw

  setenv serverip 192.168.111.1

  setenv nfsroot /tftpboot/busybox

  setenv bootcmd run netboot

  saveenv


Reset your board; it should now boot from the network:

 

  U-Boot 2013.07-rc1-00210-gc623eb0 (Jun 27 2013 - 21:10:47)

  (..)

  Hit any key to stop autoboot:  0

  Booting from net ...

  BOOTP broadcast 1

  DHCP client bound to address 192.168.111.121

  Using FEC device

  TFTP from server 192.168.111.1; our IP address is 192.168.111.121

  Filename 'uImage'.

  Load address: 0x12000000

  Loading: #################################################################

           #################################################################

           #################################################################

           #################################################################

           ##########################

           4 MiB/s

  done

  Bytes transferred = 4185600 (3fde00 hex)

  BOOTP broadcast 1

  DHCP client bound to address 192.168.111.121

  Using FEC device

  TFTP from server 192.168.111.1; our IP address is 192.168.111.121

  Filename 'imx6q-sabresd.dtb'.

  Load address: 0x11000000

  Loading: ##

           2.7 MiB/s

  done

  Bytes transferred = 22818 (5922 hex)

  ## Booting kernel from Legacy Image at 12000000 ...

     Image Name:   Linux-3.10.0-rc7

  (..)

  Starting kernel ...

 

 

  Booting Linux on physical CPU 0x0

  Linux version 3.10.0-rc7 (jenkins@debian) (gcc version 4.7.2 (Debian 4.7.2-5) ) #1 SMP Tue Jun 25 08:28:31 CEST 2013

  (..)

  Kernel command line: console=ttymxc0,115200 root=/dev/nfs ip=dhcp nfsroot=192.168.111.1:/tftpboot/busybox,v3,tcp rw

  (..)

  fec 2188000.ethernet eth0: Freescale FEC PHY driver [Generic PHY] (mii_bus:phy_addr=2188000.ethernet:01, irq=-1)

  IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready

  libphy: 2188000.ethernet:01 - Link is Up - 1000/Full

  IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready

  Sending DHCP requests ., OK

  IP-Config: Got DHCP answer from 192.168.111.1, my address is 192.168.111.121

  IP-Config: Complete:

       device=eth0, hwaddr=00:04:9f:02:b7:fd, ipaddr=192.168.111.121, mask=255.255.255.0, gw=192.168.111.1

       host=192.168.111.121, domain=, nis-domain=(none)

       bootserver=192.168.111.1, rootserver=192.168.111.1, rootpath=

       nameserver0=192.168.111.1

  ALSA device list:

    No soundcards found.

  VFS: Mounted root (nfs filesystem) on device 0:11.

  devtmpfs: mounted

  Freeing unused kernel memory: 292K (806d5000 - 8071e000)

 

 

  Please press Enter to activate this console.

 

Enjoy!

 

Bonus: updating u-boot by the network

One last piece remains on the SD card: u-boot. If you do not want to move your SD card out of its slot any more, here is a method for you to update even u-boot from the network. You will need to copy u-boot.imx under /var/ftpd. See this post for details on how to compile u-boot and obtain u-boot.imx.

 

Then, at u-boot prompt, do:

 

  dhcp $loadaddr u-boot.imx

  mmc dev 1

  mmc write $loadaddr 2 600

 

This will download a new u-boot.imx from the network and flash it to your SD card; reboot your board and you are done.

 

Note that we give 600 as the number of SD card blocks to write; this is a rough estimate of ~300KB, which should work in most of the cases as writing a bit "too much" blocks does not harm. If you are very picky, you can compute the exact number of blocks by dividing your u-boot.imx size by 512 and rounding it up.

 

See also...

Did you know that dnsmasq primary role is to be used to "relay" the DNS queries? A feature that come very handy when you want to let your i.MX6 platform "see" the internet.

Attachments

    Outcomes