Chinaunix首页 | 论坛 | 博客
  • 博客访问: 855223
  • 博文数量: 286
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1980
  • 用 户 组: 普通用户
  • 注册时间: 2014-05-04 16:41
文章分类

全部博文(286)

文章存档

2020年(2)

2018年(5)

2017年(95)

2016年(69)

2015年(15)

2014年(100)

我的朋友

分类: 嵌入式

2014-08-27 19:51:41

Linux移植开发指南学习笔记(三) uboot移植--环境搭建(ubuntu)

按照mini2440手册下载uboot到开发板
Fedora9中usb转串口驱动没法用,换ubuntu了


1、开发环境搭建

      1.Git安装   

            参考:http://www.cnblogs.com/perseus/archive/2012/01/06/2314069.html
         

       编译之前,我们必须首先安装以下软件,否则会编译不通过。

     sudo apt-get install libcurl4-openssl-dev  libexpat1-dev


安装完后我们边可以编译、安装
出现错误,提示“/bin/sh: msgfmt: not found”

执行以下命令安装gettext

$ sudo aptitude install gettext



             A、 arm-linux-gcc4.3.2安装 
    Step1:将光盘目录 linux\ 中的arm-linux-gcc-4.3.2.tgz 复制到某个目录下如 tmp\ ,然后
    进入到该目录,执行解压命令: 
    #cd \tmp 
    #tar xvzf arm-linux-gcc-4.3.2.tgz    –C /     
    注意:C 后面有个空格,并且 C 是大写的,它是英文单词“Change”的第一个字母,
    在此是改变目录的意思。 
    执行该命令,将把arm-linux-gcc 安装到/usr/loca/arm/4.3.2目录

    Step2:把编译器路径加入系统环境变量,运行命令 
    #gedit /root/.bashrc 
    编辑/root/.bashrc 文件,在最后一行  export PATH=$PATH:/usr/local/arm/4.3.2/bin 

    B、虚拟机网络连接
   虚拟机的连接方式为桥接
   路由(网关)ip:192.168.1.2
    windows      ip :192.168.1.100
    ubuntu        ip:192.168.1.101
   mini2440      ip:192.168.1.230
  
    查看网络环境  ifconfig
    设置ip    ifconfig etho 192.168.1.101    netmask  255.255.255.0
     设置网关 route add default gw 192.168.1.2
     重启网路服务  /etc/init.d/networking  restart

   C、shell脚本安装tftp
       
        ubuntu的vi不完整,按上下左右键时会变为A、B需要安装完整包
         sudo apt-get install vim-gtk
安装配置TFTP 服务的大致步骤如下: 
(1)安装tftp-hpa 、tftpd-hpa 和openbsd-inetd程序; 
(2)修改配置文件/etc/inetd.conf; 
(3)根据配置文件的路径,建立tftp 目录,并修改目录权限; 
(4)重启tftp 服务; 
(5)本地传输测试。

#!/bin/sh
TFTPDIR=/tftp

echo install tftp server ...

sudo apt-get install tftp-hpa tftpd-hpa


if [ "$?" = "0" ]     注意:每一个元素之间都需要空格 。 [ ] 代表test比较特别
then
echo "install tftp-hpa and tftpd-hpa OK!!"
else
echo "install tftp-hpa and tftpd-hpa error!!!"
# exit 1
fi

sudo apt-get install openbsd-inetd
if [ "$?" = "0" ]
then
echo "install openbsd-inetd OK!!"
else
echo "install openbsd-inetd error!!!"
# exit 1
fi

echo modify /etc/inetd.conf
#tftp dgram udp wait root /usr/sbin/in.tftpd /usr/sbin/in.tffpd -c -s /tftp
sudo vi /etc/inetd.conf

#build tftp dictory and modify mode
mkdir -p $TFTPDIR
if [ "$?" = "0" ]
then
echo "make tftp dir $TFTPDIR OK!!"
else
echo "make tftp dir $TFTPDIR error!!!"
# exit 1
fi
sudo chmod 777 $TFTPDIR

#restart tftp server
sudo /etc/init.d/openbsd-inetd restart

  
  
D、安装配置NFS 服务


    启动NFS的方法和启动其他服务器的方法类似。首先需要启动portmap和nfs这两个服务,并且portmap服务一定要先于nfs服务启动,具体命令
        先:service  portmap restart   不可用/etc/init.d/portmap start,会产生冲突
        再:/etc/init.d/nfs restart

了使NFS服务器能正常工作,需要启动portmap和nfs两个服务,并且portmap一定要先于nfs启动

通过dpkg-reconfigure portmap  选N来启动portmap
不要关闭一些启动项,会影响NFS下载


安装配置NFS 服务的大致步骤如下: 
(1)安装NFS 内核服务; 
(2)重新配置portmap 服务,修改/etc/hosts.deny 和/etc/hosts.allow 配置文件,重启
portmap 服务; 
(3)修改NFS 服务的配置文件/etc/exports,添加服务目录和配置,重新导入配置; 
(4)重启NFS 服务,并检查可挂载的目录; 
(5)在本地挂载测试。
 
#!/bin/sh 
  echo install tftp server ... 
    sudo apt-get install nfs-kernel-server 
    if [ "$?" = "0" ] 
  then 
   echo "install nfs-kernel-server  OK!!" 
  else 
   echo "install nfs-kernel-server error !!!" 
#   exit 1  
  fi 
 
  sudo dpkg-reconfigure portmap 
 #对Should portmap be bound to the loopback address? 选N. 
 
  sudo vi /etc/hosts.deny 
#portmap:ALL 
#lockd:ALL 
#mountd:ALL 
#rquotad:ALL 
#statd:ALL 
 
  sudo vi /etc/hosts.allow 
#portmap: 192.168.1. 
#lockd: 192.168.1. 
#rquotad: 192.168.1. 
#mountd: 192.168.1. 
#statd: 192.168.1. 
 
  sudo service portmap restart 
 
  sudo vi /etc/exports 
 #/home/pjz/development/share  
192.168.1.0/24 (rw,nohide,insecure,no_wdelay,no_ro ot_squash,no_subtree_check,sync) 
 #特别要注意上面的IP 的形式,以前是形如 192.168.1.*,现在是IP/掩码为数的形式。用旧的格式可能会
出问题 
 #具体的说明,建议看man 手册 : man exports 
  sudo exportfs -r 
 
 sudo /etc/init.d/nfs-kernel-server restart 
  showmount -e 127.0.0.1 


    E、C-kermit的安装配置 (推荐)

在Linux 下是通过串口传输文件到开发板,就属C-kermit 比较好用。 
(1)安装ckermit程序; 
(2)编写ckermit的配置文件~/.kermrc。
#!/bin/sh 
  echo install C-kermit ... 
  sudo apt-get install ckermit 
    if [ "$?" = "0" ] 
  then 
   echo "install ckermit  OK!!" 
  else 
   echo "install ckermit error !!!" 
#   exit 1  
  fi 
 
# 如果是USB转串口,就是类似/dev/ttyUSB0 的设备,如果是原生的硬件串口,就是类似/dev/ttyS0 的设备节
点。 
# 根据你使用的串口,设备节点编号可能有变,你可以ls /dev/tty* 看看你用的到底有什么设备节点。 
  cat > ~/.kermrc  <在root下执行时,kermrc在/root/.kermrc下,.代表隐藏文件
                                            在~/.kermrc不存在时,启用/etc/kermit/kermrc
set line /dev/ttyS1   (同下面minicom的串口)一般ttyS0对应com1,ttyS1对应com2,当然也不一定是必然的
set speed 115200 
set carrier-watch off 
set handshake none 
set flow-control none 
robust 
set file type bin 
set file name u-boot.bin 
set rec pack 1000 
set send pack 1000 
set window 5 

 
EOF 

顺利配置好kermit后,在 terminal上输入kermit命令,进入到kermit程序,连到串口,开发板在uboot下启动,按任意键进入uboot模式



C-kermit通过串口下载,速度较慢
    u-boot@MINI2440]# loadb 
    ## Ready for binary (kermit) download to 0x30008000 at 115200 bps... 
 
    (Back at MAGI-Linux) 
    ---------------------------------------------------- 
    C-Kermit 8.0.211, 10 Apr 2004, for Linux 
    Copyright (C) 1985, 2004, 
   Trustees of Columbia University in the City of New York. 
    Type ? or HELP for help. 
    (/home/pjz) C-Kermit> send /home/pjz/Desktop/zImage



c-kermit利用nfs下载uboot到SRAM,速度很快    
    
    命令的格式:指令   [目的 SDRAM 地址] [[主机 IP:] 文件名] 
    注意: 

        要使用dhcp、rarpboot 或 bootp 要路由器或Host支持的这些协议和服务。 
        如果没有输入[ 目的SDRAM 地址] ,系统就是用编译时定义的CONFIG_SYS_LOAD_ADDR 
        在使用如果tftpboot 和nfs 命令没有定义[ 主机IP:] ,则使用ENV中的serverip 
        其它命令必需定义[ 主机IP:] ,否则使用提供动态IP 服务的主机IP 。




    F、minicom 的安装配置(采用的是minicom)

minicom 是在Linux 系统下比较常用的串口终端工具,简单的安装配置步骤如下: 
(1)安装minicom 程序; 
(2)使用minicom -s 命令生成配置文件~/.minirc.dfl。
#!/bin/sh 
  echo install minicom ... 
    sudo apt-get install minicom 
    if [ "$?" = "0" ] 
  then 
   echo "install minicom  OK!!" 
  else 
   echo "install minicom error !!!" 
#   exit 1  
  fi 
 
 minicom -s 

配置串口


回车退到“ 配置” 菜单后再进入 “ 设置保存为dfl”,就会保存配置到~/.minirc.dfl。

ESC键开启了minicom界面

在ubuntu关闭状态下,VM setting-->HardWare  add  serial port 后面按默认 添加串口

参考:

linux下查看串口信息

查看串口名称使用 ls -l /dev/ttyS*一般情况下串口的名称全部在dev下面,如果你没有外插串口卡的话默认是dev下的ttyS*
一般ttyS0对应com1,ttyS1对应com2,当然也不一定是必然的

USB连接到虚拟机--设置
1.在Windows下点击开始->运行,在对话框中输入"services.msc",确定,打开windows服务管理器。
2.在服务列表中选中"VMware USB Arbitration Service",双击打开属性对话框,再选择"启动",就能启动VMware USB Arbitration Service服务
3.关闭VMware软件,并重新打开,启动一个虚拟机,进入系统之后VMware就会提示发现USB设备

阅读(2616) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~