Using TFTP and NFS during software development
<uml> hide footbox box “liteboard” participant liteSOM as liteboard participant uSD as sd end box box “PC workstation” participant "TFTP\nserver" as tftp participant "NFS\nserver" as nfs end box →> liteboard : reset activate liteboard liteboard → sd : get bootloader activate sd sd –> liteboard : U-Boot deactivate sd liteboard → liteboard : run bootloader liteboard → tftp : get kernel image activate tftp tftp –> liteboard : zImage deactivate tftp liteboard → tftp : get device tree activate tftp tftp –> liteboard : liteboard.dtb deactivate tftp liteboard → liteboard : run kernel liteboard → nfs : mount rootfs activate nfs nfs –> liteboard loop operations on rootfs liteboard -> nfs nfs --> liteboard end loop </uml> |
To speedup software development process you can configure your liteboard to download firmware directly from your PC workstation via LAN network. This howto will guide you how to configure liteboard to:
With this configuration all steps required to deploy new firmware on liteboard are limited to the absolute minimum:
Because Buildroot can be configured to execute 2nd and 3rd steps as post-build action therefore in most cases deploy process will look like:
|
PC workstation configuration
If you are using non Debian based distribution please modify all apt-get …
commands accordingly to the package manager used on your system.
TFTP server
To install TFTP server please run following command
sudo apt-get install tftpd-hpa
sudo apt-get install tftpd-hpa Reading package lists... Done Building dependency tree Reading state information... Done Suggested packages: pxelinux The following NEW packages will be installed: tftpd-hpa 0 upgraded, 1 newly installed, 0 to remove and 12 not upgraded. Need to get 50.2 kB of archives. After this operation, 121 kB of additional disk space will be used. Get:1 http://ftp.pl.debian.org/debian stretch/main amd64 tftpd-hpa amd64 5.2+20150808-1+b1 [50.2 kB] Fetched 50.2 kB in 0s (236 kB/s) Preconfiguring packages ... Selecting previously unselected package tftpd-hpa. (Reading database ... 361203 files and directories currently installed.) Preparing to unpack .../tftpd-hpa_5.2+20150808-1+b1_amd64.deb ... Unpacking tftpd-hpa (5.2+20150808-1+b1) ... Setting up tftpd-hpa (5.2+20150808-1+b1) ... Processing triggers for systemd (232-25) ... Processing triggers for man-db (2.7.6.1-2) ..
On success on your PC workstation you should see new directory /srv/tftp
- this directory is shared via TFTP server.
NFS server
To install NFS server please run following command
sudo apt-get install nfs-kernel-server
sudo apt-get install nfs-kernel-server Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: nfs-kernel-server 0 upgraded, 1 newly installed, 0 to remove and 12 not upgraded. Need to get 124 kB of archives. After this operation, 334 kB of additional disk space will be used. Get:1 http://ftp.pl.debian.org/debian stretch/main amd64 nfs-kernel-server amd64 1:1.3.4-2.1 [124 kB] Fetched 124 kB in 0s (283 kB/s) Selecting previously unselected package nfs-kernel-server. (Reading database ... 361218 files and directories currently installed.) Preparing to unpack .../nfs-kernel-server_1%3a1.3.4-2.1_amd64.deb ... Unpacking nfs-kernel-server (1:1.3.4-2.1) ... Setting up nfs-kernel-server (1:1.3.4-2.1) ... Created symlink /etc/systemd/system/multi-user.target.wants/nfs-server.service → /lib/systemd/system/nfs-server.service. Job for nfs-server.service failed because the control process exited with error code. See "systemctl status nfs-server.service" and "journalctl -xe" for details. nfs-server.service couldn't start. Creating config file /etc/exports with new version Creating config file /etc/default/nfs-kernel-server with new version Processing triggers for systemd (232-25) ... Processing triggers for man-db (2.7.6.1-2) ...
On success new file /etc/exports
will be added. This file contains configuration for all directories exported via NFS.
To share your PC workstation directory via NFS you have to create it first.
sudo mkdir /srv/myproject
To share /nfs/myproject
directory via NFS server please edit /etc/exports
file and append following line
/srv/myproject 10.42.0.1/255.255.255.0(rw,no_subtree_check,no_root_squash)
10.42.0.1
) and netmask (here 255.255.255.0
) to your network configuration.
If your liteboard is connected directly to your PC workstation via (for example) eth0
interface you can check current configuration via ifconfig eth0
command, like presented below.
$ sudo ifconfig eth0 eth0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 inet 10.42.0.1 netmask 255.255.255.0 broadcast 10.42.0.255 inet6 fe80::d715:5cc:9b4d:d289 prefixlen 64 scopeid 0x20<link> ether d4:be:d9:1b:19:07 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 4 bytes 356 (356.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 device interrupt 20 memory 0xe6700000-e6720000
If you are using different LAN configuration please contact your network administrator for support.
After changes in /etc/exports
file you should trigger NFS server to apply configuration from this file.
sudo exportfs -a sudo exportfs -rv
Now your /srv/myproject
directory is shared via NFS server.
Buildroot
After successful build buildroot/output/images
directory contains following files:
boot.vfat
,imx6ul-liteboard.dtb
,rootfs.ext2
,rootfs.ext4
,rootfs.tar
,sdcard.img
,SPL
,u-boot.bin
,u-boot.img
,zImage
.
This directory contains everything what is needed to configure TFTP and NFS services.
U-Boot
U-Boot
is the only one application which must be loaded by liteSOM from uSD
card.
The easiest way to install U-Boot
on uSD
card is to copy complete sdcard.img
to it, like presented below.
sudo dd if=output/images/sdcard.img of=/dev/<SD card> bs=4M sync
By default sdcard.img
file contains complete configuration to boot liteboard directly from uSD
card, later on we will change U-Boot
configuration and the rest of the software (i.e. everything except U-Boot
) will be loaded directly from your PC workstation.
Kernel + Device tree
Kernel image
and device tree blob file
must be accessible by the liteboard via TFTP protocol, therefore both files must be copied to /srv/tftp
directory.
sudo cp output/images/zImage /srv/tftp/ sudo cp output/images/imx6ul-liteboard.dtb /srv/tftp/
ROOT filesystem
To allow liteboard to mount rootfs
via NFS we have to extract rootfs.tar
file to /srv/myproject
directory like presented below.
sudo tar -xavf output/images/rootfs.tar -C /srv/myproject/
Buildroot post compilation action
After each build you have to perform following steps to update firmware shared with your liteboard:
sudo cp output/images/zImage /srv/tftp/ sudo cp output/images/imx6ul-liteboard.dtb /srv/tftp/ sudo tar -xavf output/images/rootfs.tar -C /srv/myproject/
All those steps can be performed automatically by the Buildroot via script defined by BR2_ROOTFS_POST_IMAGE_SCRIPT
option.
For the liteboard BR2_ROOTFS_POST_IMAGE_SCRIPT
points to board/grinn/liteboard/post-image.sh
file which is responsible for sdcard.img
generation
#!/usr/bin/env bash BOARD_DIR="$(dirname $0)" GENIMAGE_CFG="${BOARD_DIR}/genimage.cfg" GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp" rm -rf "${GENIMAGE_TMP}" genimage \ --rootpath "${TARGET_DIR}" \ --tmppath "${GENIMAGE_TMP}" \ --inputpath "${BINARIES_DIR}" \ --outputpath "${BINARIES_DIR}" \ --config "${GENIMAGE_CFG}"
You can append to this file all TFTP/NFS related actions
sudo cp -f ${BINARIES_DIR}/zImage /srv/tftp/zImage sudo cp -f ${BINARIES_DIR}/imx6ul-liteboard.dtb /srv/tftp/imx6ul-liteboard.dtb sudo tar -xavf ${BINARIES_DIR}/rootfs.tar -C /srv/myproject
#!/usr/bin/env bash BOARD_DIR="$(dirname $0)" GENIMAGE_CFG="${BOARD_DIR}/genimage.cfg" GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp" TFTP_DIR=/srv/tftp NFS_DIR=/srv/myproject rm -rf "${GENIMAGE_TMP}" genimage \ --rootpath "${TARGET_DIR}" \ --tmppath "${GENIMAGE_TMP}" \ --inputpath "${BINARIES_DIR}" \ --outputpath "${BINARIES_DIR}" \ --config "${GENIMAGE_CFG}" sudo cp -f ${BINARIES_DIR}/zImage ${TFTP_DIR}/zImage sudo cp -f ${BINARIES_DIR}/imx6ul-liteboard.dtb ${TFTP_DIR}/imx6ul-liteboard.dtb sudo tar -xavf ${BINARIES_DIR}/rootfs.tar -C ${NFS_DIR}
With this configuration always after make all
all files used by the liteboard to boot & run will be updated.
Liteboard configuration
By default liteboard is configured to download and run all software from uSD
card. This configuration can be changed via U-Boot environment variables
.
Once liteboard is started you should see U-Boot
output.
U-Boot SPL 2017.01 (May 04 2017 - 18:54:17) Trying to boot from MMC1 U-Boot 2017.01 (May 04 2017 - 18:54:17 +0000), Build: jenkins-Buildroot-liteboard-release-9 CPU: Freescale i.MX6UL rev1.1 528 MHz (running at 396 MHz) CPU: Industrial temperature grade (-40C to 105C) at 42C Reset cause: POR Board: Grinn liteBoard DRAM: 256 MiB MMC: FSL_SDHC: 0, FSL_SDHC: 1 *** Warning - bad CRC, using default environment In: serial Out: serial Err: serial switch to partitions #0, OK mmc0 is current device Net: FEC [PRIME] Error: FEC address not set. Hit any key to stop autoboot: 1
As suggested by the last line default autoboot
procedure can be halted by any key.
Once it is terminated you will see U-Boot
prompt with enabled CLI.
Hit any key to stop autoboot: 0 =>
Network boot procedure is defined by two variables netargs
and netboot
:
=> printenv netargs netargs=setenv bootargs console=${console},${baudrate} root=/dev/nfs ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp
=> printenv netboot netboot=echo Booting from net ...; run netargs; if test ${ip_dyn} = yes; then setenv get_cmd dhcp; else setenv get_cmd tftp; fi; ${get_cmd} ${image}; if test ${boot_fdt} = yes || test ${boot_fdt} ;
To configure TFTP/NFS services at liteboard side we have to define few parameters:
serverip
- your PC workstation IP address,
setenv serverip 10.42.0.1
nfsroot
- rootfs
directory shared via NFS,
setenv nfsroot /srv/myproject
ethaddr
- liteboard MAC address (1A:4D:47:59:F6:24
is an example).
setenv ethaddr 1A:4D:47:59:F6:24
All variables configured like presented above are stored in RAM memory, i.e. after reset they are uninitialized. To save them permanently please use saveenv
command.
=> saveenv Saving Environment to MMC... Writing to MMC(0)... done
Booting liteboard via TFTP/NFS
To boot liteboard via TFTP and NFS you can use U-Boot
netboot
command
=> run netboot Booting from net ...
This command will:
1. download kernel image
via TFTP protocol
BOOTP broadcast 1 DHCP client bound to address 10.42.0.158 (9 ms) Using FEC device TFTP from server 10.42.0.1; our IP address is 10.42.0.158 Filename 'zImage'. Load address: 0x82000000 Loading: ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ############################### 2.3 MiB/s done Bytes transferred = 6176776 (5e4008 hex)
2. download device tree blob file
via TFTP protocol
BOOTP broadcast 1 DHCP client bound to address 10.42.0.158 (13 ms) Using FEC device TFTP from server 10.42.0.1; our IP address is 10.42.0.158 Filename 'imx6ul-liteboard.dtb'. Load address: 0x83000000 Loading: ## 1.8 MiB/s done Bytes transferred = 21230 (52ee hex)
3. boot kernel
with rootfs
mounted via NFS
## Flattened Device Tree blob at 83000000 Booting using the fdt blob at 0x83000000 Using Device Tree in place at 83000000, end 830082ed Starting kernel ... [ 0.000000] Booting Linux on physical CPU 0x0 [ 0.000000] Linux version 4.9.2 (jenkins@jenkins) (gcc version 5.4.0 (Buildroot 2017.02.2) ) #1 SMP Thu May 4 18:58:02 UTC 2017 [ 0.000000] CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c5387d [ 0.000000] CPU: div instructions available: patching division code [ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache [ 0.000000] OF: fdt:Machine model: Grinn i.MX6UL liteBoard [ 0.000000] cma: Reserved 16 MiB at 0x8f000000 [ 0.000000] Memory policy: Data cache writealloc [ 0.000000] percpu: Embedded 14 pages/cpu @cedd2000 s26728 r8192 d22424 u57344 [ 0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 65024 [ 0.000000] Kernel command line: console=ttymxc0,115200 root=/dev/nfs ip=dhcp nfsroot=10.42.0.1:/srv/myproject,v3,tcp [ 0.000000] PID hash table entries: 1024 (order: 0, 4096 bytes) [ 0.000000] Dentry cache hash table entries: 32768 (order: 5, 131072 bytes)
[ 0.000000] Inode-cache hash table entries: 16384 (order: 4, 65536 bytes) [ 0.000000] Memory: 221280K/262144K available (9216K kernel code, 460K rwdata, 2976K rodata, 1024K init, 8237K bss, 24480K reserved, 16384K cma-reserved, 0K highmem) [ 0.000000] Virtual kernel memory layout: [ 0.000000] vector : 0xffff0000 - 0xffff1000 ( 4 kB) [ 0.000000] fixmap : 0xffc00000 - 0xfff00000 (3072 kB) [ 0.000000] vmalloc : 0xd0800000 - 0xff800000 ( 752 MB) [ 0.000000] lowmem : 0xc0000000 - 0xd0000000 ( 256 MB) [ 0.000000] pkmap : 0xbfe00000 - 0xc0000000 ( 2 MB) [ 0.000000] modules : 0xbf000000 - 0xbfe00000 ( 14 MB) [ 0.000000] .text : 0xc0008000 - 0xc0a00000 (10208 kB) [ 0.000000] .init : 0xc0d00000 - 0xc0e00000 (1024 kB) [ 0.000000] .data : 0xc0e00000 - 0xc0e73140 ( 461 kB) [ 0.000000] .bss : 0xc0e75000 - 0xc1680454 (8238 kB) [ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1 [ 0.000000] Running RCU self tests [ 0.000000] Hierarchical RCU implementation. [ 0.000000] RCU lockdep checking is enabled. [ 0.000000] Build-time adjustment of leaf fanout to 32. [ 0.000000] RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=1. [ 0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=32, nr_cpu_ids=1 [ 0.000000] NR_IRQS:16 nr_irqs:16 16 [ 0.000000] Switching to timer-based delay loop, resolution 41ns [ 0.000017] sched_clock: 32 bits at 24MHz, resolution 41ns, wraps every 89478484971ns [ 0.000061] clocksource: mxc_timer1: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 79635851949 ns [ 0.002500] Console: colour dummy device 80x30 [ 0.002572] Lock dependency validator: Copyright (c) 2006 Red Hat, Inc., Ingo Molnar [ 0.002594] ... MAX_LOCKDEP_SUBCLASSES: 8 [ 0.002614] ... MAX_LOCK_DEPTH: 48 [ 0.002633] ... MAX_LOCKDEP_KEYS: 8191 [ 0.002652] ... CLASSHASH_SIZE: 4096 [ 0.002672] ... MAX_LOCKDEP_ENTRIES: 32768 [ 0.002691] ... MAX_LOCKDEP_CHAINS: 65536 [ 0.002710] ... CHAINHASH_SIZE: 32768 [ 0.002730] memory used by lock dependency info: 5167 kB [ 0.002750] per task-struct memory footprint: 1536 bytes [ 0.002834] Calibrating delay loop (skipped), value calculated using timer frequency.. 48.00 BogoMIPS (lpj=240000) [ 0.002881] pid_max: default: 32768 minimum: 301 [ 0.003623] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes) [ 0.003659] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes) [ 0.007977] CPU: Testing write buffer coherency: ok [ 0.009681] /cpus/cpu@0 missing clock-frequency property [ 0.009731] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000 [ 0.009803] Setting up static identity map for 0x80100000 - 0x80100070 [ 0.017521] Brought up 1 CPUs [ 0.017565] SMP: Total of 1 processors activated (48.00 BogoMIPS). [ 0.017588] CPU: All CPU(s) started in SVC mode. [ 0.021998] devtmpfs: initialized [ 0.064018] VFP support v0.3: implementor 41 architecture 2 part 30 variant 7 rev 5 [ 0.065934] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns [ 0.068052] pinctrl core: initialized pinctrl subsystem [ 0.076487] NET: Registered protocol family 16 [ 0.083369] DMA: preallocated 256 KiB pool for atomic coherent allocations [ 0.092715] cpuidle: using governor menu [ 0.161124] No ATAGs? [ 0.161225] hw-breakpoint: found 5 (+1 reserved) breakpoint and 4 watchpoint registers. [ 0.161259] hw-breakpoint: maximum watchpoint size is 8 bytes. [ 0.168408] imx6ul-pinctrl 20e0000.iomuxc: initialized IMX pinctrl driver [ 0.322252] mxs-dma 1804000.dma-apbh: initialized [ 0.330028] vgaarb: loaded [ 0.332247] SCSI subsystem initialized [ 0.335516] usbcore: registered new interface driver usbfs [ 0.335979] usbcore: registered new interface driver hub [ 0.336581] usbcore: registered new device driver usb [ 0.339022] Linux video capture interface: v2.00 [ 0.339590] pps_core: LinuxPPS API ver. 1 registered [ 0.339621] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it> [ 0.339743] PTP clock support registered [ 0.341836] Advanced Linux Sound Architecture Driver Initialized. [ 0.348220] Bluetooth: Core ver 2.22 [ 0.348471] NET: Registered protocol family 31 [ 0.348501] Bluetooth: HCI device and connection manager initialized [ 0.348655] Bluetooth: HCI socket layer initialized [ 0.348721] Bluetooth: L2CAP socket layer initialized [ 0.349182] Bluetooth: SCO socket layer initialized [ 0.356632] clocksource: Switched to clocksource mxc_timer1 [ 0.358009] VFS: Disk quotas dquot_6.6.0 [ 0.358346] VFS: Dquot-cache hash table entries: 1024 (order 0, 4096 bytes) [ 0.433874] NET: Registered protocol family 2 [ 0.437959] TCP established hash table entries: 2048 (order: 1, 8192 bytes) [ 0.438101] TCP bind hash table entries: 2048 (order: 4, 73728 bytes) [ 0.439905] TCP: Hash tables configured (established 2048 bind 2048) [ 0.440264] UDP hash table entries: 256 (order: 2, 20480 bytes) [ 0.440769] UDP-Lite hash table entries: 256 (order: 2, 20480 bytes) [ 0.442949] NET: Registered protocol family 1 [ 0.445709] RPC: Registered named UNIX socket transport module. [ 0.445759] RPC: Registered udp transport module. [ 0.445785] RPC: Registered tcp transport module. [ 0.445811] RPC: Registered tcp NFSv4.1 backchannel transport module. [ 0.455793] futex hash table entries: 256 (order: 2, 16384 bytes) [ 0.461155] workingset: timestamp_bits=30 max_order=16 bucket_order=0 [ 0.523263] NFS: Registering the id_resolver key type [ 0.523709] Key type id_resolver registered [ 0.523748] Key type id_legacy registered [ 0.524055] jffs2: version 2.2. (NAND) �© 2001-2006 Red Hat, Inc. [ 0.529180] fuse init (API version 7.26) [ 0.553604] io scheduler noop registered [ 0.553654] io scheduler deadline registered [ 0.554857] io scheduler cfq registered (default) [ 0.570817] imx-sdma 20ec000.sdma: Direct firmware load for imx/sdma/sdma-imx6q.bin failed with error -2 [ 0.570887] imx-sdma 20ec000.sdma: external firmware not found, using ROM firmware [ 0.596163] 2020000.serial: ttymxc0 at MMIO 0x2020000 (irq = 18, base_baud = 5000000) is a IMX [ 1.264609] console [ttymxc0] enabled [ 1.274943] [drm] Initialized [ 1.366894] brd: module loaded [ 1.417610] loop: module loaded [ 1.434067] libphy: Fixed MDIO Bus: probed [ 1.440929] CAN device driver interface [ 1.448820] 2188000.ethernet supply phy not found, using dummy regulator [ 1.460219] pps pps0: new PPS source ptp0 [ 1.467120] libphy: fec_enet_mii_bus: probed [ 1.481814] fec 2188000.ethernet eth0: registered PHC device 0 [ 1.491238] usbcore: registered new interface driver asix [ 1.497367] usbcore: registered new interface driver ax88179_178a [ 1.503817] usbcore: registered new interface driver cdc_ether [ 1.510338] usbcore: registered new interface driver net1080 [ 1.516365] usbcore: registered new interface driver cdc_subset [ 1.522920] usbcore: registered new interface driver zaurus [ 1.529256] usbcore: registered new interface driver cdc_ncm [ 1.534967] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver [ 1.541620] ehci-pci: EHCI PCI platform driver [ 1.546586] ehci-mxc: Freescale On-Chip EHCI Host driver [ 1.553499] usbcore: registered new inte
- litesom/buildroot/software_development_with_netboot.txt
- Last modified: 2017/06/09 11:36
- by filug