Chinaunix首页 | 论坛 | 博客
  • 博客访问: 549099
  • 博文数量: 105
  • 博客积分: 3274
  • 博客等级: 中校
  • 技术积分: 1161
  • 用 户 组: 普通用户
  • 注册时间: 2010-02-21 12:14
文章分类

全部博文(105)

文章存档

2011年(1)

2010年(104)

分类: LINUX

2010-03-28 12:43:14

上文中说到构建ubifs文件系统时,没有使用交叉编译器,今天就制作一下交叉编译的ubifs
 
编译环境:fedora 10
1,按照链接,下了zlib-1.2.3.tar.gz,lzo-2.03.tar.gz,mtd-utils-1.2.0.tar.gz
   注释:zlib是一种压缩算法,目标机也就是开发板使用MTD工具的时候,需要zlib库的支持。
        lzo是致力于解压速度的一种数据压缩算法,LZO 是 Lempel-Ziv-Oberhumer 的缩写。
        mtd-utils_20080508.orig.tar.gz比较老了,还需要打补丁,
        就使用了相对新的mtd-utils-1.2.0.tar.gz
2,编译安装zlib
               tar xzvf zlib-1.2.3.tar.gz
               cd zlib-1.2.3
               CC=arm-none-linux-gnueabi-gcc ./configure --shared --prefix=/opt/arm-2007q3/arm-none-linux-gnueabi
               make
               make install
3,编译安装lzo
               tar xzvf lzo-2.03.tar.gz
               cd lzo-2.03
               CC=arm-none-linux-gnueabi-gcc ./configure --host=arm-linux --prefix=/opt/arm-2007q3/arm-none-linux-gnueabi
             make
             make install
4,编译mtd-utils-1.2.0
  进去后
  vi ./Makefile
  发现如下几行
  #CROSS=arm-linux-
  CC := $(CROSS)gcc
 
  于是改成了
  CROSS=arm-none-linux-gnueabi-
  CC := $(CROSS)gcc
 
  然后编译
  make WITHOUT_XATTR=1
 
  出现错误,提示找不到相关文件之类。
 
  重新打开Makefile
  有如下几行
  ifeq ($(origin CROSS),undefined)
  BUILDDIR := .
  else
  BUILDDIR := $(CROSS:-=)
  endif
  怪不得,于是直接都注释掉了,写上
  BUILDDIR := .
  然后重新编译
  make WITHOUT_XATTR=1
 
  编译成功。
  当前目录下生成flash_erase等,ubi-utils子目录生成ubiattach、ubimkvol,查看以下他们的属性
  $:file ./flash_erase
  ./flash_erase:ELF 32-bit LSB executable,ARM,version 1(SYSV),dynamically linked(uses shared libs),for GNU/linux 2.6.14,not stripped
  没问题。
 再查看下ubi-utils目录下的
 $:file ./ubiattach
 ./ubiattach:ELF 32-bit LSB executable,Intel 80386,version 1(SYSV),dynamically linked(uses shared libs),for GNU/linux 2.6.9,not stripped
 
 是在Intel 80386,晕,还有点问题,
于是修改ubi-utils/Makefile文件:
添加    CROSS=arm-none-linux-gnueabi-

修改    ubi-utils/new-utils/Makefile文件:
添加    CROSS=arm-none-linux-gnueabi-
 
返回到mtd-utils-1.2.0目录
执行
make clean
make WITHOUT_XATTR=1
然后再用file查看,一切OK
 
不过仍然没有生成mkfs.ubifs,
实际上我为这个头痛了一个上午了,比较新版本的mtd-utils_20090606.orig.tar.gz
可以生成mkfs.ubifs,我试验了好久一直没有成功,幸好天漠的光盘中已经有编译好了的mkfs.ubifs(小小鄙视下,也不把源代码贡献出来),为了赶下进度,先放一边,待出了比较正式的版本后试验。
 
下面开始正式进入烧写程序部分,先看看x-loader-1.4.1
第一件事当然是读下README了,
Directory Hierarchy:    // 下面的目录
====================
 
- board         Board dependent files
- cpu           CPU specific files
- drivers       Commonly used device drivers
- lib           Libraries
 
- cpu/arm926ejs Files specific to ARM 926 CPUs
- cpu/arm1136 Files specific to ARM 1136 CPUs
- cpu/omap3 Files specific to ARM CortexA8 CPU
 
 
- board/omap1710h3
                Files specific to OMAP 1710 H3 boards
- board/omap2420h4
                Files specific to OMAP 2420 H4 boards
- board/omap2430sdp
                Files specific to OMAP 2430 2430sdp boards
- board/omap3430sdp
                Files specific to OMAP 3420sdp boards
Software Configuration:
=======================
 
Configuration is usually done using C preprocessor defines. Configuration
depends on the combination of board and CPU type; all such information is
kept in a configuration file "include/configs/.h".
 
Example: For a H3 module, all configuration settings are in
"include/configs/omap1710h3.h".
 
For all supported boards there are ready-to-use default
configurations available; just type "make _config".
 
Example: For a H3 module type:
 
        cd x-load
        make omap1710h3_config
 
After a board has been configured, type "make" to build it supposing the
needed cross tools are in your path.
Image Format:
=============
 
X-Loader expects OS boot loader (e.g. U-Boot) in Nand flash using
JFFS2 style ECC.
 
 
Prepare Booting Nand Flash:
===========================
 
After you have built x-load.bin for your board, you need to do the
followings to get it into Nand flash:
 
1. Use Texas Instruments IFT to sign x-load.bin. This results in a
signed image called x-load.bin.ift.
2. Use Texas Instruments FlashPrep to generate a .out file using
FlashWriterNand and specifying 0 as nand target address.
3. Use Texas instrumnets Code Composer Studio to run the .out file
which flashes x-load.bin.ift to Nand flash.
 
Next you need to get your OS boot loader to Nand at the address your
X-Loader expects. For the H3 example, you can use U-Boot to flash U-Boot.
You can't use FlashWriterNand because it uses ROM code ECC style.
从上面可以得知:
(1)我们第一步需要配置板子的参数,板子的参数放在include/configs/.h,
#ls ./include/configs/
omap1510.h         omap2430sdp.h      omap3devkit8000.h 
omap1710h3.h       omap3430sdp.h      omap3devkit9000.h 
omap2420h4.h       omap3530beagle.h   sbc8100.h
很显然我使用板子是omap3devkit8000.h,
继续看看,挺长的就不贴出来了,我的目的是跑beagle的资源,不妨看下二者在x-loader的配置
区别,
#diff ./omap3530beagle.h ./omap3devkit8000.h
41c41
< #define CONFIG_OMAP3_BEAGLE      1    /* working with BEAGLE */
---
> #define CONFIG_OMAP3_DevKit8000  1    /* working with DevKit8000 */
46,51d45
< /* Uncomment this for Rev 1 boards*/
< //#define CONFIG_BEAGLE_REV1   1
<
< /* Uncomment this for Rev 2 boards */
< #define CONFIG_BEAGLE_REV2     1
<
66d59
< #ifdef CONFIG_OMAP3_BEAGLE
68,70d60
< #else
< #define V_OSCK                   19200000  /* Clock output from T2 */
< #endif
92,94d81
< #ifdef CONFIG_BEAGLE_REV1
< #define CFG_ONENAND           1
< #else
96d82
< #endif
117,119d102
< #ifdef CONFIG_BEAGLE_REV1
< #define CFG_NS16550_COM1         OMAP34XX_UART1
< #else
121d103
< #endif
127,131d108
< #ifdef CONFIG_BEAGLE_REV1
< #define CONFIG_SERIAL1           1    /* UART1 on BEAGLE */
< #define CONFIG_CONS_INDEX        1
< #else
< #define CONFIG_SERIAL1           3    /* UART3 on BEAGLE */
133d109
< #endif
162c138
< //#define NAND_16BIT
---
> #define NAND_16BIT
172c148
< #define NAND_UBOOT_END           0x0160000 /* Giving a space of 2 blocks = 256KB */
---
> #define NAND_UBOOT_END           0x01E0000 /* Giving a space of 2 blocks = 256KB */
从中可以看出基本没有差别,就是改了下板子的名字而已。
接下来按照devkit8000步骤:
#make distclean
find . -type f \
                \( -name 'core' -o -name '*.bak' -o -name '*~' \
                -o -name '*.o'  -o -name '*.a'  \) -print \
                | xargs rm -f
find . -type f \
                \( -name .depend -o -name '*.srec' -o -name '*.bin' \) \
                -print \
                | xargs rm -f
rm -f  *.bak tags TAGS
rm -fr *.*~
rm -f x-load x-load.map 
rm -f include/asm/proc include/asm/arch
rm -f x-load.bin.ift
rm -f include/config.h include/config.mk
#sudo make omap3devkit8000_config
rm -f include/config.h include/config.mk
Configuring for omap3devkit8000 board...
然后make生成x-load.bin
然后再依据下列步骤:
1. Use Texas Instruments IFT to sign x-load.bin. This results in a
signed image called x-load.bin.ift.
2. Use Texas Instruments FlashPrep to generate a .out file using
FlashWriterNand and specifying 0 as nand target address.
3. Use Texas instrumnets Code Composer Studio to run the .out file
which flashes x-load.bin.ift to Nand flash.
第一个步骤可使用signGP,signGP.c如下:
#include
#include
#include
#include
#include
#include
 
 
main(int argc, char *argv[])
{
        int     i;
        char    ifname[FILENAME_MAX], ofname[FILENAME_MAX], ch;
        FILE    *ifile, *ofile;
        unsigned long   loadaddr, len;
        struct stat     sinfo;
 
 
        // Default to x-load.bin and 0x40200800.
        strcpy(ifname, "x-load.bin");
        loadaddr = 0x40200800;
 
        if ((argc == 2) || (argc == 3))
                strcpy(ifname, argv[1]);
 
        if (argc == 3)
                loadaddr = strtol(argv[2], NULL, 16);
 
        // Form the output file name.
        strcpy(ofname, ifname);
        strcat(ofname, ".ift");
 
        // Open the input file.
        ifile = fopen(ifname, "rb");
        if (ifile == NULL) {
                printf("Cannot open %s\n", ifname);
                exit(0);
        }
 
        // Get file length.
        stat(ifname, &sinfo);
        len = sinfo.st_size;
 
        // Open the output file and write it.
        ofile = fopen(ofname, "wb");
        if (ofile == NULL) {
                printf("Cannot open %s\n", ofname);
                fclose(ifile);
                exit(0);
        }
 
        // Pad 1 sector of zeroes.
        //ch = 0x00;
        //for (i=0; i<0x200; i++)
        //      fwrite(&ch, 1, 1, ofile);
 
        fwrite(&len, 1, 4, ofile);
        fwrite(&loadaddr, 1, 4, ofile);
        for (i=0; i                fread(&ch, 1, 1, ifile);
                fwrite(&ch, 1, 1, ofile);
        }
 
        fclose(ifile);
        fclose(ofile);
}
                                                       
把这个文件编译下,生成signGP
 gcc -o ./signGP ./signGP.c
然后
./signGP ./x-load.bin
就会由x-load.bin转化生成x-load.bin.ift,
由于我打算用MMC卡试验,所以该需要重新命名x-load.bin.ift
mv ./x-load.bin.ift ./MLO
然后把MLO拷贝到MMC卡,
启动时按住用户键,如下:
Texas Instruments X-Loader 1.41
Starting on with MMC
Reading boot sector
1086232 Bytes Read from MMC
Starting OS Bootloader from MMC...
U-Boot 1.3.3-svn333 (Sep 10 2009 - 16:47:29)
----
证明这个MLO是没问题的。
 
 
 

 
 
            
 
 

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