AVR32 Linux Development/Filesystem over NFS for AVR32 Linux

From AVRFreaks Wiki

Jump to: navigation, search

Contents

Introduction

Developing software for AVR32 Linux is often an iterating process. The program is compiled on a workstation, transfered to the target and executed.

This can be tedious if an SD memory card is used for the transfer. A more lean approach is to setup a NFS server holding the AVR32 Linux file system. This NFS server can be the development workstation and in this way the executable is directly available both on development and target system.


NFS server

If developing on Linux kernel drivers or other files that need to reside on the root file system, the NFS server must be capable of storing and exporting the Linux device files correctly. Currently no known Windows NFS server is capable of this. A Linux system is therefor required. This may be a virtual machine (eg. VMware) or at native system.

If, however, only user space programs are developed, AVR32 Linux may boot as normal (from on-board flash or SD-card) and the NFS server mounted at an arbitrary point. In this case any NFS server should do.

In the following a fully featured NFS server running on Linux is assumed and the complete AVR32 Linux file system is exported as NFS. The Linux distribution is Ubuntu-server.

Setting up nfsd, the NFS daemon

# sudo su -
# apt-get install nfs-kernel-server
# mkdir /nfs
# pico /etc/exports

add this line

 /nfs 10.0.0.0/255.0.0.0(rw,sync,no_root_squash)

save and exit (Ctrl-X), finally type

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

to reload the nfs daemon.

Note that you might have to adjust the ipaddress/ipmask above to match your network.


TFTP server

The U-Boot boot loader can retrieve the AVR32 Linux kernel over the network with the TFTP protocol.

Setting up in.tftpd, the TFTP daemon

# sudo su -
# apt-get install tftpd-hpa
# mkdir -p /nfs/tftp
# pico /etc/default/tftp-hpa

Change RUN_DAEMON to 'yes' and the path to /nfs/tftp

RUN_DAEMON="yes"
OPTIONS="-l -s /nfs/tftp"

Finally start the tftp server

# /etc/init.d/tftpd-hpa start

DHCP and IP addresses

Das U-Boot and AVR32 Linux can use manually configured ip addresses. However, many will find it more convenient to use dynamic ip assignment: DHCP.

DHCP is usually enabled if you are connecting the AVR32 device to an existing network. However, many IT-departments will deny hooking up non approved hardware (and especially development kits) to the business network. In such case you'll probably setup a small LAN or a direct link between the NFS server and AVR32 device. You will need to configure the network interface on the server for static IP address.

Note that in the following it is assumed that the AVR32 device is connected to the primary ethernet port (eth0) on the server.

Configuring server for static IP address

# pico /etc/network/interfaces

You will probably find a line like 'iface eth0 inet dhcp'

change this to:

iface eth0 inet static
  address 10.0.0.1 
  netmask 255.255.255.0


Restart network interfaces with

# ifdown eth0
# ifup eth0

Setting up DHCP server

WARNING do not install a DHCP server on your workstation if it is part of the business network as it will cause conflict with corporate DHCP servers.

# apt-get install dhcp3-server
# pico /etc/dhcp3/dhcpd.conf

Append the following section at the end:

subnet 10.0.0.0 netmask 255.255.255.0 {
  range 10.0.0.20 10.0.0.200;
  option routers 10.0.0.1;
  option broadcast-address 10.0.0.255;

Save and exit

 # pico /etc/default/dhcp3-server

Add 'eth0' to the interface (or eth1 if AVR32 device is connected to a secondary ethernet port)

INTERFACES="eth0"

Restart dhcp server

 # /etc/init.d/dhcp3-server restart


U-Boot parameters for TFTP and NFS with DHCP

It is assumed below that the NFS and TFTP server is the same machine and that this has IP address 10.0.0.1. The AVR32 devices receives a dynamic IP address from a DHCP server

# set serverip 10.0.0.1
# set tfpserver 10.0.0.1
# set bootcmd 'set bootfile uImage;dhcp;bootm'
# set bootargs 'root=/dev/nfs ip=dhcp nfsroot=10.0.0.1:/nfs console=ttyS0'
# saveenv
# boot

U-Boot parameters for TFTP and NFS without DHCP

It is assumed below that the NFS and TFTP server is the same machine and that this has IP address 10.0.0.1. The AVR32 device uses a static ip address 10.0.0.10

# set serverip 10.0.0.1
# set tfpserver 10.0.0.1
# set bootcmd 'set ipaddr 10.0.0.10;tftp 0x1200000 uImage;bootm'
# askenv bootargs 
>root=/dev/nfs nfsroot=10.0.0.1:/nfs ip=10.0.0.10::10.0.0.1:::eth0:off console=ttyS0
# saveenv
# boot

(we use askenv for the bootargs because it is too long for the U-Boot command line interpreter)

Working with the NFS server

When the nfs server is fully functional the /nfs folder will contain the file system for the AVR32 device and where you'll need to place the target application. If the NFS server is not your favorite MS Windows workstation, you are probably a little uncomfortable working your code in Linux.

Generally there is two ways to accomplish this: Learn windows to speak NFS or learn Linux to speak Windows' file sharing.

Setting up windows NFS client

Microsoft's services for unix (SFU) provides a NFS client and is free to download. Use the Services for UNIX Administration, User Name Mapping, and map your user name to unix 'root'.

Minimal passwd and group files are:

passwd:
root:x:0:0:root:/root:/bin/bash

group:
root:x:0:

Please note that NFS is not secure in a hostile (ie public) network environment

Setting up samba

An alternative is to setup samba, a windows file server for Linux which will let you mount the /nfs folder as a network drive in windows.


# sudo su -
# apt-get install samba
# pico /etc/samba/smb.conf

Append the following section at the end

[avr32nfs]
 comment = Target file system
 path = /nfs
 guest ok = yes
 browseable = yes
 writable = yes
 create mask = 0777
 directory mask = 0777
 admin users = avr
 force group = root
 force user = root

Add a samba user 'avr'

# smbpasswd avr

Restart samba server

# /etc/init.d/samba restart

Please note that this is usually not recomended setup for samba from a security point of view. Non the less, it is the easiest way to create files in the nfs folder with correct permissions. Do not use the admin users, force group, force user or guest ok in a hostile (ie public) network environment

Static version created: 2007-03-07
Copyright (c) 2007 Atmel Corporation