[原创]linux系统,ltib工具开发powerpc

来源:互联网 发布:苹果手机虚拟专用网络 编辑:程序博客网 时间:2024/06/07 23:37

工作目标:开发板上的文件系统通过nfs网络挂载,调试powerpc 8315或5121

PC机环境:(1)ubuntu 8.04 linux OS  或者 (2)虚拟机VMware(ubuntu 8.04) + Windows XP OS

开发板:Freescale的powerpc开发板8315或5121等等

 

PC机需要的串口调试工具:

(1)ubuntu linux OS : minicom

(2)Windows XP OS: 附件->通讯工具->超级终端

PC机串口属性典型值:

波特率-115200,数据位-8,奇偶校验-无,停止位-1,数据流控制-无

开发板启动,进入u-boot启动时的提示命令行,输入print,可以显示出baudrate=115200

(3)ubuntu虚拟机与windows XP互传文件,通常需要ssh服务 

linux@ubuntu:~/ltib$ sudo apt-get install openssh-server openssh-client
linux@ubuntu:~/ltib$ sudo /etc/init.d/ssh restart

 

ubuntu 8.04 linux主机开启nfs服务的步骤:

(1)安装tftp、 nfs-kernel-server、 xinetd

sudo apt-get install tftp-hpa

sudo apt-get install tftp

sudo apt-get install nfs-kernel-server

sudo apt-get install xinetd

(2)配置主机的nfs和tftp

    a)在/etc/exports文件中加入一行:

 /home/user-name/ltib/rootfs   192.168.0.*(rw,sync,no_root_squash,no_subtree_check)

    b)新建文件/etc/xinetd.d/tftp,输入如下内容:

service tftp
{
    protocol  = udp   
    port         = 69
    socket_type  = dgram
    wait         = yes
    user         = root
    server       = /usr/sbin/in.tftpd
    server_args  = -s /tftpboot -c
    disable      = no
    per_source  = 11
    cps = 100 2
 }

 

(3)重启nfs和tftp服务:

sudo  /etc/init.d/xinetd   restart

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

(4)测试tftp服务:

安装tftp、tftp-hpa后,输入命令:tftp 本机IP地址

(这里linux是我的ubuntu OS用户名)
linux@ubuntu:~/ltib$ tftp 192.168.0.129                       
tftp> get uImage                                              
tftp> get MPC8315erdb.dtb                                     
Error code 1: File not found                                  
tftp> get mpc8315erdb.dtb                                     
tftp> ls                                                       
?Invalid command                                              
tftp> help                                                    
tftp-hpa 0.48                                                 
Commands may be abbreviated.  Commands are:                   

connect         connect to remote tftp
mode            set file transfer mode
put             send file            
get             receive file         
quit            exit tftp            
verbose         toggle verbose mode  
trace           toggle packet tracing
literal         toggle literal mode, ignore ':' in file name
status          show current status                        
binary          set mode to octet                          
ascii           set mode to netascii                       
rexmt           set per-packet transmission timeout        
timeout         set total retransmission timeout           
?               print help information                     
help            print help information                     
tftp> quit                                                 
linux@ubuntu:~/ltib$                                       
linux@ubuntu:~/ltib$                     

 

测试get文件成功,即:配置的tftp服务已经启动。

 

LTIB配置、编译

在ubuntu系统上,假如ltib已经安装了,我们只需编译、重新配置ltib,

以非root用户登陆,进入ltib所在文件夹,依次输入以下两条命令:

./ltib clean

./ltib -c    

即可先后配置linux应用软件包、linux内核。

编译成功后,~/ltib/rootfs/boot目录下,有新编译的内核文件uImage、设备树mpc8315erdb_default.dtb,分别拷贝到/tftpboot目录下。

通过nfs服务,目标板挂载了PC机上的文件系统(~/ltib/rootfs/),所以只需要以上两个文件就够了。

 

开发板u-boot配置

插上开发板的网线、电源,将开发板与主机的串口互连。重启开发板、回车进入u-boot配置。

 

通常需要修改的几个选项

ipaddr=192.168.0.100
bootcmd=run nfsboot
serverip=192.168.0.193
rootpath=/home/user-name/ltib/rootfs

 

修改以上配置的示例(=>是提示符):

=>setenv serverip 192.168.0.193

=>setenv bootcmd run nfsboot
=>saveenv

 

//u-boot命令行 示例

=> print
ramboot=setenv bootargs root=/dev/ram rw console=$consoledev,$baudrate $othbootargs;tftp $ramdiskaddr $ramdiskfile;tftp $loadaddr $bootfile;tftp $fdtaddr $fdtfile;bootm $loadaddr $ramdiskaddr $fdtaddr
nfsboot=setenv bootargs root=/dev/nfs rw nfsroot=$serverip:$rootpath ip=$ipaddr:$serverip:$gatewayip:$netmask:$hostname:$netdev:off console=$consoledev,$baudrate $othbootargs;tftp $loadaddr $bootfile;tftp $fdtaddr $fdtfile;bootm $loadaddr - $fdtaddr
bootdelay=6
baudrate=115200
loads_echo=1
ethaddr=04:00:00:00:00:0A
eth1addr=04:00:00:00:00:0B
loadaddr=200000
netdev=eth0
consoledev=ttyS0
ramdiskaddr=1000000
ramdiskfile=ramfs.83xx
fdtaddr=400000
fdtfile=mpc8315erdb.dtb
ethact=eTSEC0
bootargs=root=/dev/nfs rw nfsroot=: ip=:::::eth0:off console=ttyS0,115200
bootfile=uImage
mtdids=nor0=nor,nand0=nand
ipaddr=192.168.0.100
bootcmd=run nfsboot
serverip=192.168.0.193
rootpath=/home/user-name/ltib/rootfs
stdin=serial
stdout=serial
stderr=serial

Environment size: 940/8188 bytes
=> help
?       - alias for 'help'
autoscr - run script from memory
base    - print or set address offset
bdinfo  - print Board Info structure
boot    - boot default, i.e., run 'bootcmd'
bootd   - boot default, i.e., run 'bootcmd'
bootm   - boot application image from memory
bootp - boot image via network using BootP/TFTP protocol
chpart - change active partition
clocks  - print clock configuration
cmp     - memory compare
coninfo - print console devices and information
cp      - memory copy
crc32   - checksum calculation
date    - get/set/reset date & time
echo    - echo args to console
erase   - erase FLASH memory
exit    - exit script
fdt     - flattened device tree utility commands
flinfo  - print FLASH memory information
fsinfo - print information about filesystems
fsload - load binary file from a filesystem image
go      - start application at address 'addr'
help    - print online help
icrc32  - checksum calculation
iloop   - infinite loop on address range
imd     - i2c memory display
iminfo  - print header information for application image
imls    - list all images found in flash
imm     - i2c memory modify (auto-incrementing)
imw     - memory write (fill)
inm     - memory modify (constant address)
iprobe  - probe to discover valid I2C chip addresses
itest - return true/false on integer compare
loadb   - load binary file over serial line (kermit mode)
loads   - load S-Record file over serial line
loady   - load binary file over serial line (ymodem mode)
loop    - infinite loop on address range
ls - list files in a directory (default /)
md      - memory display
mii     - MII utility commands
mm      - memory modify (auto-incrementing)
mtdparts- define flash/nand partitions
mtest   - simple RAM test
mw      - memory write (fill)
nand    - NAND sub-system
nboot   - boot from NAND device
nfs - boot image via network using NFS protocol
nm      - memory modify (constant address)
pci     - list and access PCI Configuration Space
ping - send ICMP ECHO_REQUEST to network host
printenv- print environment variables
protect - enable or disable FLASH write protection
rarpboot- boot image via network using RARP/TFTP protocol
reset   - Perform RESET of the CPU
run     - run commands in an environment variable
saveenv - save environment variables to persistent storage
setenv  - set environment variables
sleep   - delay execution for some time
test    - minimal test like /bin/sh
tftpboot- boot image via network using TFTP protocol
version - print monitor version

 

=>ping 192.168.0.193    ////试试开发板与PC的网络是否互通

........
=> reset
Resetting the board.

 

通过PC机上的串口工具,如超级终端,可以看到一大堆提示信息。最后显示linux console提示符。

输入ls、pwd、cd 等命令,可以看出,板子上的根目录就是PC机上的~/ltib/rootfs/目录。

呵呵,开发的准备工作已经完成。开工吧。