锋影
e-mail 174176320@qq.com
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; }
即将连续块上超过10M的数据的分多次读写。这样修改完成之后,镜像可以正常启动。