TQE9开发板QNX系统下载graphic镜像

问题描述:TQE9开发板下载带有图形界面的qnx-ifs系统镜像后总是无法启动,卡在Load QNX image from SDMMC...

分析问题之前,先分析一下sabreARD-graphics.build的启动脚本,镜像文件说明如下:

[image=0x10800000]
# For u-boot, IFS image should be uncompressed
[virtual=armle-v7,raw] .bootstrap = {
# For IPL, IFS image should be compressed
#[virtual=armle-v7,raw +compress] .bootstrap = {

    # Startup parameters:
    # '-b' -> enable BT (conflicts with SPI NOR and PCIe)
    # '-m' -> enable d-cache/MMU (improves boot time)
    # '-W' -> enable watchdog (wdtkick should be uncommented when using this option)
    # Note:only ONE of below option may be selected for NOR flash
    # '-n0' -> no NOR Flash (I2C3 enabled)
    # '-n1' -> parallel NOR Flash (I2C3 disabled)
    # '-n2' -> SPI NOR Flash (I2C3 disabled)
    #
    # '-c' -> CAN startup option (conflicts with Ethernet)
    # '-s' -> Use SDMA to load IFS
    # '-r' -> to reserve the top 256M of RAM (0x80000000 -- 0x8FFFFFFF) so that
    # screen will work properly. There is an issue with the graphics processor
    # on the i.MX6 Quad Plus  where the code will not run if allocated in this
    # block of memory. This is an interm fix until the problem is resolved by
    # NXP.
    # startup-imx6x-sabreARD -n0 -m -r 0x80000000,256M

    # Otherwise use the following version of startup to access the full range of RAM
    startup-imx6x-sabreARD -n1 -m -W -s
    PATH=/proc/boot:/bin:/usr/bin:/opt/bin/sbin:/usr/sbin LD_LIBRARY_PATH=/proc/boot:/lib:/usr/lib:/lib/dll:/lib/dll/pci:/opt/lib procnto-smp-instr
}
image表示镜像需要加载到的地址,也就是系统会从该地址启动。查看手册virtual属性的配置格式为:virtual=[cpu_name ,]bootfile_name [filter_args ]。

armle-v7:CPU type

raw:Create a binary image with an instruction sequence at its beginning to jump
that when you download a raw image to memory using a bootloader, you can
then instruct it to run right at the beginning of the image, rather than having
to figure out what the actual startup_vaddr is each time you modify the
startup code.

+compress: compress flag.

compress参数会指明要不要对镜像进行压缩。对于u-boot来讲,镜像是不可以被压缩的,否则设备无法启动。默认加载的镜像image地址是0x10800000,如果代码中加载镜像的地址与build中image值不一致,则需要使用-s参数,使用SDMA加载IFS。

分析我单板的问题:无论是否进行压缩,单板始终都无法正常启动,但同样生成的不带graphic的镜像却可以正常启动,经过层层定位分析:问题出现在接口fat_copy_file上,该接口的逻辑实现:如果当前存储数据的块是连续的,则会一次性把连续块上的内容全部读取出来;如果不连续,则只读当前块的内容。问题就是一次性把连续块上的内容都读取出来的时候存在异常,这个也不知道是emmc的问题还是bsp版本实现的问题。当我们强制让emmc分多次将连续块上的内容分多次读取出来的时候,大包便可以启动了。代码如下:

/*  copy a file from to a memory location */
static int
fat_copy_file(unsigned cluster, unsigned size, unsigned char *buf)
{
  #if 1
    int        result, txf;
    unsigned   prev_c, next_c, curr_c;
    int     sz  = (int)size;
    int     cbytes = fs_info.cluster_size*SECTOR_SIZE;
    int actual_len = 0;

    if(sdmmc_debug > 1)
    {
		 ser_putstr((char *)"fat_copy_file: cs 0x");
		 ser_puthex(fs_info.cluster_size);
		 ser_putstr((char *)" size 0x");
		 ser_puthex(sz);
		 ser_putstr((char *)"type 0x");
		 ser_puthex(fs_info.fat_type );
		 ser_putstr((char *)"\n");
    }

#if 1
	cache_valid = 1;
#endif
	g_fat_sector = -1;
	
    /*
    *Note that this impl assume the following:
    * 1) The max DMA transfer size is bigger than the max consolidate transfer size
    * Otherwise, we need to break down into smaller transfer.
    * 2) we always do at least one whole cluster transfer. This might overwrite the client buffer, but
    * since this is purely used for IPL, we don't care about that now.
    */
    curr_c = cluster;
    while(sz>0){
        txf = cbytes;
        prev_c = curr_c;
        while(sz>txf){
           //try consolidate contigus entry;
            next_c = fat_get_fat_entry(curr_c);
            if(next_c == (curr_c+1)  && txf > 20*SECTOR_SIZE){
                txf +=cbytes;
                curr_c = next_c;
            }else{
                curr_c = next_c;
                break;
            }
        }
        if(sdmmc_debug > 4)
        {
			ser_putstr((char *)"blkcnt 0x");
			ser_puthex(txf/SECTOR_SIZE);
			ser_putstr((char *)" p 0x");
			ser_puthex(prev_c);
			ser_putstr((char *)" n 0x");
			ser_puthex(curr_c);
			ser_putstr((char *)"\n");
        }
        //read the contig cluster out
        result= read_fsector(cluster2fsector(prev_c), buf, txf/SECTOR_SIZE) ;
        if (result != SDMMC_OK)
           return result;
        sz     -= txf;
        buf  += txf;
        actual_len += txf;
    }
#else

  int     sz  = (int)size;

    while(!end_of_file(cluster) && (sz > 0)) {
        int txf = MIN(sz, fs_info.cluster_size * SECTOR_SIZE);

        if (SDMMC_OK != read_cluster(cluster, buf, txf)) {
        	ser_putstr("      Error - read_clust(): clust buf txf = ");
        	ser_puthex((unsigned int)clust); ser_putstr(" ");
        	ser_puthex((unsigned int)buf); ser_putstr(" ");
        	ser_puthex((unsigned int)txf); ser_putstr("\n");
            return SDMMC_ERROR;
        }
        ser_putstr((char *)"cluster %x");
        ser_puthex(cluster);
        ser_putstr((char *)"\n");

        sz   -= txf;
        buf  += txf;
        cluster = fat_get_fat_entry(cluster);
    }
#endif

    if(sdmmc_debug > 0)
    {
    	ser_putstr("Actual read fs size = 0x");
    	ser_puthex(actual_len);
    	ser_putstr("\n");
    }
    return SDMMC_OK;
}

上述代码的修改地方是将if(next_c == (curr_c+1))改为if(next_c == (curr_c+1) && txf >20*SECTOR_SIZE),即将连续块上超过10M的数据的分多次读写。这样修改完成之后,镜像可以正常启动。

经过试验后得出以下两条结论:
1、压缩情况下,只要地址不同(build文件中的image值和ipl文件main函数中的QNX_LOAD_ADDR值不同),启动参数无论是否包含-s,镜像均可以正常启动。(由于需要解压缩,所以大包加载的地址必须不能和build中的image地址不同,否则无法解压缩)
2、不压缩情况下,地址若相同,无论是否加-s,都可以正常启动;但若地址不同,只有不加-s的时候才可以正常启动。




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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值