-boot版本: v2009.08

在调试其他功能时增加了u-boot.bin容量到1M,使用fastboot download时提示:


 

 
 
1. sending 'bootloader' (1191 KB)...  
2. OKAY [  1.062s]  
3. writing 'bootloader'...  
4. FAILED (remote: image too large for partition)  
5. finished. total time: 1.098s


但是分区的时候是预留蛮大空间的:


 

 
 
1. # partition size in MB  
2. BOOTLOAD_RESERVE=8

只能先查找出现error log的地方, uboot-imx/common/cmd_fastboot.c

1. static int rx_handler (const unsigned char *buffer, unsigned int buffer_size)  
2. {  
3. ......  
4. else if ((download_bytes >  
5.                        (ptn->length * MMC_SATA_BLOCK_SIZE)) &&  
6.                         !(ptn->flags & FASTBOOT_PTENTRY_FLAGS_WRITE_ENV)) {  
7. "Image too large for the partition\n");  
8. "FAILimage too large for partition");  
9. else if (ptn->flags & FASTBOOT_PTENTRY_FLAGS_WRITE_ENV) {  
10. ......  
11. }

download_bytes是要download的size, 


ptn->length应该就是u-boot分区的大小了,以MMC_SATA_BLOCK_SIZE为单位。

那么ptn->length是什么时候得到的,看fastboot_init():

fastboot_init -> fastboot_init_mmc_sata_ptable

uboot-imx/drivers/fastboot/fastboot.c

 

 
 
1. static int fastboot_init_mmc_sata_ptable(void)  
2. {  
3. ......  
4. /*以下操作是保存分区表信息到ptable中*/  
5. char *)ptable, 0,  
6. sizeof(fastboot_ptentry) * (PTN_RECOVERY_INDEX + 1));  
7. /* MBR */  
8. /*头一个分区放MBR*/  
9. "mbr");  
10.     ptable[PTN_MBR_INDEX].start = ANDROID_MBR_OFFSET / dev_desc->blksz;  
11.     ptable[PTN_MBR_INDEX].length = ANDROID_MBR_SIZE / dev_desc->blksz;  
12.     ptable[PTN_MBR_INDEX].partition_id = user_partition;  
13. /* Bootloader */  
14. /*保存bootloader信息,也就是u-boot信息*/  
15. "bootloader");  
16.     ptable[PTN_BOOTLOADER_INDEX].start =  
17.                 ANDROID_BOOTLOADER_OFFSET / dev_desc->blksz;  
18.     ptable[PTN_BOOTLOADER_INDEX].length =  
19.                  ANDROID_BOOTLOADER_SIZE / dev_desc->blksz;  
20.     ptable[PTN_BOOTLOADER_INDEX].partition_id = boot_partition;  
21. /*从MBR中读取boot, recovery, system分区的信息并保存*/  
22.     setup_ptable_mmc_partition(PTN_KERNEL_INDEX,  
23.                    CONFIG_ANDROID_BOOT_PARTITION_MMC,  
24. "boot", dev_desc, ptable);  
25.     setup_ptable_mmc_partition(PTN_RECOVERY_INDEX,  
26.                    CONFIG_ANDROID_RECOVERY_PARTITION_MMC,  
27.                    user_partition,  
28. "recovery", dev_desc, ptable);  
29.     setup_ptable_mmc_partition(PTN_SYSTEM_INDEX,  
30.                    CONFIG_ANDROID_SYSTEM_PARTITION_MMC,  
31.                    user_partition,  
32. "system", dev_desc, ptable);  
33. /*全部添加到ptable中*/  
34. for (i = 0; i <= PTN_RECOVERY_INDEX; i++)  
35.         fastboot_flash_add_ptn(&ptable[i]);  
36.   
37. return 0;  
38. }

ANDROID_BOOTLOADER_OFFSET:

1. #define ANDROID_BOOTLOADER_SIZE     0xFFC00

所以原因就在于u-boot.bin的size是在u-boot写死了,而不是从MBR中读取的,只要修改此值就可以了。

为什么不能按照读取boot分区那样操作呢?

因为在分区表里并没有保存bootloader的信息,所以MBR和u-boot只能在u-boot中写死了。