Friday 29 November 2013

Running embedded linux on mpc8572ds using NFS and TFTP servers

    In this post I will mention the steps that should be performed to run embedded linux on powerpc board mpc8572ds using NFS and TFTP servers. I have used mentor embedded linux for this purpose. In order to boot the target with linux we need to perform following steps.

  • Setting up NFS Server
  • Setting up TFTP Server
  • Running embedded linux on target


Setting up NFS Server
I installed NFS Server on Ubuntu 12.04 64 bit machine using following command.
sudo apt-get install nfs-kernel-server
    In order to configure the directories to be exported edit /etc/exports file. I exported /nfsboot directory by adding following line in /etc/exports.
/nfsboot *(ro,sync,no_root_squash)
   In above command I specified all host formats to be valid by specifying *, as this is a network machine in my case which can only be accessed by network machine and expected to be accessed by all systems in the network network, so this format is fine in my case. If you want to restrict unwanted access to NFS server make it specific one.  

Start the NFS server by executing following command
sudo /etc/init.d/nfs-kernel-server start

Setting up TFTP Server

    Install TFTP server by executing following command'
sudo apt-get install tftpd-hpa openbsd-inetd
I want directory /tftpboot to be the root of tftp server. So create it and give rights to everyone using following commands.
cd /
mdir tftpboot
sudo chmod -R 777 /tftpboot

Now, in order to configure tftp server open tftpd-hpa file using following commands
cd /etc/default

sudo vi tftpd-hpa
Insert following code in file.
# /etc/default/tftpd-hpa

RUN_DAEMON="yes"

TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/tftpboot"
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="--secure"
Now restart tftp server using following commands.
sudo service openbsd-inetd restart

sudo service tftpd-hpa restart

Running embedded linux on target

Now transfer filesystem and boot images on nfsboot and tftboot servers. Create a directory mpc8572ds in tftpboot and copy following files.

mpc8572ds/uimage.bin
mpc8572ds/uimage.dtb

Similarly create a folder mpc8572ds in nfsboot and copy file system in it.

Now connect target serial port with computer and monitor the output using a suitable tool like putty, minicom etc.

Here I am assuming that uboot is already installed on the target. Starting up the target will show similar uboot console output.
U-Boot 2009.11-rc1 (Nov 05 2010 - 01:19:31)
CPU0:  8572E, Version: 2.1, (0x80e80021)
Core:  E500, Version: 3.0, (0x80210030)
Clock Configuration:
       CPU0:1499.985 MHz, CPU1:1499.985 MHz,
       CCB:599.994 MHz,
       DDR:399.996 MHz (799.992 MT/s data rate) (Asynchronous), LBC:37.500 MHz
L1:    D-cache 32 kB enabled
       I-cache 32 kB enabled
Board: MPC8572DS Sys ID: 0x14, Sys Ver: 0x20, FPGA Ver: 0x01, vBank: 0
I2C:   ready
DRAM:  Initializing....    DDR:  1 GB (DDR2, 64-bit, CL=6, ECC off)
       DDR Controller Interleaving Mode: bank
Now running in RAM - U-Boot at: 3ff70000
FLASH: 128 MB
L2:    1024 KB enabled
NAND:  4096 MiB
EEPROM: Invalid ID (ff ff ff ff)
    PCIE3 connected to ULI as Root Complex (base addr ffe08000)
               Scanning PCI bus 01
        02  1c  10b9  5237  0c03  00
        02  1c  10b9  5237  0c03  00
        02  1c  10b9  5237  0c03  00
        02  1c  10b9  5239  0c03  00
        02  1d  10b9  5455  0401  00
        02  1d  10b9  5457  0703  00
        02  1e  10b9  1575  0601  00
        02  1e  10b9  7101  0680  00
        02  1f  10b9  5229  0101  00
        02  1f  10b9  5288  0101  00
        01  00  10b9  5249  0604  00
    PCIE3 on bus 00 - 02
    PCIE2 connected to Slot 1 as Root Complex (base addr ffe09000)
    PCIE2 on bus 03 - 03
    PCIE1 connected to Slot 2 as Root Complex (base addr ffe0a000)
    PCIE1 on bus 04 - 04
In:    serial
Out:   serial
Err:   serial
SCSI:  AHCI 0001.0000 32 slots 4 ports 3 Gbps 0xf impl IDE mode
flags: ncq ilck pm led clo pmp pio slum part
scanning bus for devices...
Net:   eTSEC1, eTSEC2, eTSEC3, eTSEC4
Hit any key to stop autoboot:  10

Press enter when you see above message. Now execute printenv command to see the settings of the machine. In my case I see following settings. You need to make the correct settings for your specific case.
=> printenv
ramboot=setenv bootargs root=/dev/ram rw console=$consoledev,$baudrate
$othbootargs;tftp $ramdiskaddr $ramdiskfile;tftp $loadaddr $bootfile;tftp $fdtaddr $fdtfile;bootm $loadaddr $ramdiskaddr $fdtaddr
baudrate=115200
loads_echo=1
ethaddr=00:E0:0C:02:00:FD
eth1addr=00:E0:0C:02:01:FD
eth2addr=00:E0:0C:02:02:FD
eth3addr=00:E0:0C:02:03:FD
rootpath=/opt/nfsroot
hostname=unknown
loadaddr=1000000
memctl_intlv_ctl=2
netdev=eth0
uboot=u-boot.bin
tftpflash=tftpboot $loadaddr $uboot; protect off 0xeff80000 +$filesize;
erase 0xeff80000 +$filesize; cp.b $loadaddr 0xeff80000 $filesize;
protect on 0xeff80000 +$filesize; cmp.b $loadaddr 0xeff80000 $filesize
consoledev=ttyS0
ramdiskaddr=2000000
ramdiskfile=8572ds/ramdisk.uboot
bdev=sda3
bootdelay=3
bootcmd=run nfsboot
bootfilele=/tftpboot/abbasr/mpc8572/uImage-2.6.31-r14-mpc8572ds.bin
fdtaddr=c00000
dtbfile=MEL4_cycle1_rc4/mpc8572ds-nonsmp/uImage-mpc8572ds.dtb
nfsboot=tftp 1000000 $bootfile;tftp c00000 $fdtfile;bootm 1000000 - c00000
bootfile=uImage-mpc8572ds.bin
fdtfile=uImage-mpc8572ds.dtb
filesize=3AAC
fileaddr=C00000
gatewayip=137.202.157.254
netmask=255.255.254.0
ipaddr=137.202.156.100
bootargs=root=/dev/nfs rw nfsroot=137.202.157.115:/nfsboot/8572ds ip=dhcp console=ttyS0,115200
ethact=eTSEC1
serverip=137.202.157.94
stdin=serial
stdout=serial
stderr=serial
Now execute below command to set serverip, which will be used to get boot images from tftpserver
setenv serverip 137.202.156.63

Now execute following commands to specify the location of bin and dtb files. It can be seen that I don't specify tftpboot folder path while specifying any file, using tftpboot in the path will be wrong here.
setenv fdtfile mpc8572ds/uimage.dtb
setenv bootfile mpc8572ds/uimage.bin

Now set the bootargs as shown below.
setenv bootargs root=/dev/nfs rw nfsroot=137.202.156.63:/nfsboot/mpc8572ds/ ip=dhcp console=ttyS0,115200 

If I need to use a static ip address instead of using dhcp I can use following command as shown below.
setenv bootargs root=/dev/nfs rw nfsroot=137.202.156.63:/nfsboot/mpc8572ds/
ip=137.202.156.114:137.202.156.63:137.202.157.255:255.255.254.0:MPC8572DS:eth0:on console=ttyS0,115200

Now load the bin and dtb files using tftp command as shown below.


tftp 1000000 $bootfile;tftp c00000 $fdtfile;

Now start the linux using following boot command.
bootm 1000000 - c00000

If images are fine and properly placed on servers, executing above command will successfully boot embedded linux on mpc8572ds

No comments:

Post a Comment