Mpc8306开发环境的搭建

Mpc8306开发环境的搭建

Ltib工具

LTIB项目是用于在不同目标平台下,开发和部署BSP的简单工具。使用该工具,用户能够为其目标平台开发符合GNU/Linux标准的映像。

 

官网:

http://www.ltib.org/documentation-LtibFaq

Ltib安装

1. 启动虚拟机

   基于CentOS-6.7-i386-bin-DVD1.iso 最小化安装

2. 登陆系统,用户名:root,密码:123456

 

3. 最小化安装,系统的网络可能是禁用状态,修改配置使其启用

  #cd /etc/sysconfig/network-scripts

  #vi ifcfg-eth0

   修改 ONBOOT=yes即可

 

4. 复制以下文件到虚拟机(可使用WinSCP工具通过网络直接传输)

  MPC8306som_pre-release-20110131.tar.gz

  patch.tar.gz

  yum_package_20160308.tar.gz

  rootinstall.sh

  userinstall.sh

  ltib-mpc8308erdb-20100413.iso ==>  此文件可复制,也可以不复制

 

5. 如果上一步未复制ltib-mpc8308erdb-20100413.iso 文件,则应将此 iso 文件加入虚拟机设备

 

  mount -o loop /mnt/wind/xxx.iso /mnt/

 

6. 运行安装脚本

  chmod +x rootinstall.sh userinstall.sh

   执行rootinstall.sh 脚本

   再执行userinstall.sh 脚本

  

  (A) Ramdisk Image -> rootfs.ext2.gz.uboot

  (B) Kernel Image  ->rootfs/boot/uImage

  (C) DTB Image     ->rootfs/boot/mpc8306som.dtb

  (D) U-Boot Image  ->rootfs/boot/u-boot.bin

 

 

**安装过程到 ltib.iso 时,会提示输入,可依次输入y, q, yes, 回车键即可

 

**编译内核前的配置,基本按默认配置即可,注意在最后面开启支持 TDM 的编译,具体可以参考《Note_on_LTIB_Build_mpc830x.doc

 

 

1:比较重要的是,虚拟机系统尽量选择 32 Linux 系统,否则后续编译内核时,会出现动态库异常的故障

2:以下是手动安装的全过程记录:

安装流程(virtual box 虚拟机平台)

  1.最小化安装 Centos6,注意使用32位光盘安装(CentOS-6.7-i386-bin-DVD1.iso)

   #ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

  2.安装额外的软件

   yum install -C -y perl glibc-headers glibc-devel libstdc++ gcc gcc-c++zlib-devel rpm-build wget ncurses-devel bison patch gettext tclperl-ExtUtils-MakeMaker lrzsz vim

  3.为虚拟机分配ltib-mpc8308erdb-20100413.iso 作为光驱设备,然后挂载

   #mount -t iso9660 /dev/sr0 /mnt

  4.添加用户

   #useradd mpc8306

  5.添加软件目录,并设定权限

   #chmod ugo+w /opt

   #mkdir -m 777 /opt/freescale

   #mkdir -m 777 /home/mpc8306/som

  6.设定 sudo 权限

   #visudo

    添加:mpc8306  ALL=NOPASSWD: /bin/rpm, /usr/bin/rpm,/opt/freescale/ltib/usr/bin/rpm

  7.切换到 mpc8306 用户

   #su - mpc8306

  8.安装光盘内容

   $/mnt/install

  9.修正错误(注意:centos6 可以跳过本步骤)

    复制patch.tar.gz 到主目录

   $tar zxvf patch.tar.gz

   $cd patch

   $cp sparse.spec /home/mpc8306/ltib-mpc8308erdb-20100413/dist/lfs-5.1/sparse/

   $cp sparse-0.4-fixlabel.patch sparse-0.4-fixlabel.patch.md5/home/mpc8306/ltib-mpc8308erdb-20100413/pkgs/

   $cp pme_tools.spec.in/home/mpc8306/ltib-mpc8308erdb-20100413/dist/lfs-5.1/pme_tools/

   $cp pme_tools-1.0.0-a6-pm_defs_priv.h-double-unused.patch/home/mpc8306/ltib-mpc8308erdb-20100413/pkgs/

   $cp pme_tools-1.0.0-a6-pm_defs_priv.h-double-unused.patch.md5/home/mpc8306/ltib-mpc8308erdb-20100413/pkgs/

  10.开始安装Ltib

   $./ltib

  11.复制MPC8306som_pre-release-20110131.tar.gz /home/mpc8306/som/ 目录

  12.解压文件

   $cd /home/mpc8306/som

   $tar zxf MPC8306som_pre-release-20110131.tar.gz

   $tar zxf MPC830xsom-pkg2.tar.gz -C /opt/freescale/pkgs

   $tar zxf ltib-mpc8306som-pkg-prerel-0131.tar.gz -C /opt/freescale/pkgs

    $tar xzfltib-mpc8306som-src-prerel-0131.tar.gz

   $cd ltib-mpc8306som-prerel-0131

   $./ltib

    注意配置支持 TDM ,生成的文件如下:

   (A) Ramdisk Image -> rootfs.ext2.gz.uboot          4.7M

   (B) Kernel Image  ->rootfs/boot/uImage            1.6M

   (C) DTB Image     ->rootfs/boot/mpc8306som.dtb    8K

   (D) U-Boot Image  ->rootfs/boot/u-boot.bin        323K

 

:

    对于 QUICCEngine microcode,应烧录 iram_mpc8306_r1.bin 档案,它来自于 MPC8306-KIT_LinuxBSP.iso,可从官网下载。

 

Ltib命令参数

1.       ./ltib              on the very first run for a CVSinstance  首次运行时,自动进入配置界面

2 ./ltib -mconfig      configure only                            只执行配置

3 ./ltib--configure     configure and build                       执行配置和编译

4.   显示帮助信息

      ./ltib --help

 

5.  编译安装指定软件包

      ./ltib -p pkg

 

6.  解压指定源码包

      -p pkg -m prep

      The sources will be found in rpm/BUILD/xxx

 

7.  编译指定源码包(源码已解压缩)

      -p pkg -m scinstall

 

8.  安装指定源码包

      -p pkg -m scdeploy

 

9.  合并源码

      -p pkg -m patchmerge

      分析修改后的源码与修改前的源码包的差异,并生成 patch 补丁

 

10.  显示当前编译安装的软件包

      ./ltib -m listpkgs

      ./ltib -m listpkgs | grep ' y '

Ltib重新配置内核

1.      Select the option: [ ]Configure the kernel

 

2.      run:

       ./ltib -p kernel-2.6.11-pq3 -m prep

3.      build:

       ./ltib -p kernel-2.6.11-pq3 -m scbuild

 

4.      To copy the built kernel to therootfs/boot directory (optional)

       ./ltib -p kernel-2.6.11-pq3 -m scdeploy

 

5.      If you change any source codein 'rpm/BUILD/linux-xxx/' you can capture your changes at the end by running:

       ./ltib -p kernel-2.6.11-pq3 -m patchmerge

     This will generate a patch of your changes and update the spec file.

 

Ltib添加新软件到根文件系统

1. First clean your sources (remove any .o, .a, .so generated files)and then make a 'tarball'

      $make clean

      $tar zcvf xxx.tar.gz xxx

 

    2.Move this tarball to the LPP so ltib can find it.

      $mv xxx.tar.gz /opt/freescale/pkgs/

        

         然后要生成该文件的md5,不然步骤e会出错(解压包失败)

 

    3.Create a specfile using the existing template.

      $mkdir dist/lfs-5.1/xxx

      $cp dist/lfs-5.1/template/template.spec dist/lfs-5.1/xxx/xxx.spec

 

    4.Edit and fixup the template to reflect your package.

      Summary     put in a summary ofwhat the package is/does

      Name        put in the name of thepackge (usually from the tarball name)

      Version     put in the version(usually from the tarball/directory

      Release     start at 1 and reveach time you change the spec file

      License     e.g GPL/LGPL/BSD, lookthis up in the package's files

      Group       If this exists on anrpm based machine, copy from rpm -qi

                   If not, choose somethingfrom /usr/share/doc/rpm-/GROUPS

      %Build      often you'll need toadd --host=$CFGHOST --build=%{_build} to the configure clause

 

         注:要把新包安装到根文件系统,必须修改xxx.spec文件

         %Install

         rm-rf $RPM_BUILD_ROOT

         makeinstall prefix=%{_prefix} DESTDIR=$RPM_BUILD_ROOT/%{pfx}

        

    5.Unpack the new package sources

      $./ltib -m prep -p xxx

    6.Make any changes you need to the sources to get them to cross compile

    7.Build the new package with your changes

       $./ltib -m scbuild -p xxx

    8.Once the new package builds okay, check the install phase:

       $./ltib -m scinstall -p xxx

    9.Install the test package in the NFS root filesystem area (rootfs) and test

       $./ltib -m scdeploy -p xxx

    10.Once you're happy the package is running correctly, capture your changes.

      $./ltib -m patchmerge xxx

 

     当有任何改动时,会自动创建 patch 补丁文件并复制到 /opt/freescale/pkgs 目录下,相应的 spec 文件也会更新

 

遇到问题:

问题1./ltib -m prep -p hello

Try hello-1.1.tar.bz2.md5 from the GPP

http://bitshrine.org/gpp/hello-1.1.tar.bz2.md5:

23:49:10 ERROR 404: Not Found.

Try hello-1.1.tar.bz2 from the GPP

http://bitshrine.org/gpp/hello-1.1.tar.bz2:

23:49:10 ERROR 404: Not Found.

Can't get: hello-1.1.tar.bz2 at ./ltib line790.

解决:生成新包的md5

 

问题2:选中加入编译新包,运行./ltib

./configure --prefix=/usr--host=powerpc-linux --build=i686-pc-linux-gnu

/home/mpc8306/som/ltib-mpc8306som-prerel-0131/tmp/rpm-tmp.55956:line 22: ./configure: No such file or directory

解决:新包的xxx.spec文件修改为

%Build

make prefix=%{_prefix}

 

问题3:没有添加到根文件系统

解决:新包的xxx.spec文件修改为

%Install

rm -rf $RPM_BUILD_ROOT

make install prefix=%{_prefix}DESTDIR=$RPM_BUILD_ROOT/%{pfx}

Ltib添加软件到配置界面

1. Edit config/userspace/packages.lkc, thisis in alphabetic order. Just after the 'PKG_SKELL' entry add:

      config PKG_STRACE

      bool "strace"

 

2. Edit config/userspace/pkg_map. This isin build order. Put your package where it should go in the build order, and addan entry that ties the config key, to the directory containing the spec filefor the package. For strace, I put this after gdb as shown:

      PKG_GDB             =   gdb

      PKG_STRACE          =   strace

 

ltib启动服务

1. 添加软件包(遵照以上两步)

 

   2. 编写启动脚本,可仿照已有的脚本进行修改。例如 etc/rc.d/init.d/named

 

   3. config/userspace/sysconfig.lkc 添加配置入口

      config SYSCFG_START_NAMED

          depends PKG_NAMED

          bool "start named (nameserver)"

          default y

 

   4. dist/lfs-5.1/sysconfig/sysconfig.spec 添加服务的入口

      if [ "$SYSCFG_START_NAMED" = "y" ]

      then

          named=named

      fi

 

   5. dist/lfs-5.1/sysconfig/sysconfig.spec 文件的all_services 行添加服务的名字

 

   6. dist/lfs-5.1/sysconfig/sysconfig.spec 文件的all_services_r 行添加服务的名字

 

   7. dist/lfs-5.1/sysconfig/sysconfig.spec 文件的cfg_services 行添加服务的名字

 

8. dist/lfs-5.1/sysconfig/sysconfig.spec 文件的 cfg_services_r 行添加服务的名字

 

Ltib添加文件到根文件系统

1.      将文件放入 config/platform/mpc830xsom/merge 目录              

 

注:只针对 mpc830xsom 平台

 

   2. 将文件放入 merge 目录

 

       注:针对全平台

 

Mpc8306烧写

tftp 0x2000000 uImage

tftp 0x3000000 rootfs.ext2.gz.uboot

tftp 0x4000000 mpc8306som.dtb

erase 0xfe000000 0xfeffffff

cp.b 0x2000000 0xfe000000 0x190000

cp.b 0x3000000 0xfe200000 0x4f0000

cp.b 0x4000000 0xfe800000 0x2000

 

bootm 0x2000000 0x3000000 0x4000000

 

遇到问题

问题1erase 0xff000000 0xffffffff      

出错:Error: start and/or end address not on sector boundary

解决:根据Bank[2] = fe000000: 16 MiB提示,得知nonflash的地址为0xfe000000,改为:erase0xfe000000 0xfeffffff

 

问题2

#setenv bootcmd bootm 0xfe000000 0xfe2000000xfe800000

#saveenv

#Saving Environment to Flash...

#Error: start and/or end address not onsector boundary

解决:修改uboot源码

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值