Esempio n. 1
0
/*
************************************************************************************************************
*
*                                             function
*
*    name          :
*
*    parmeters     :
*
*    return        :
*
*    note          :
*
*
************************************************************************************************************
*/
int sunxi_sprite_download_uboot(void *buffer, int production_media, int mode)
{
	if(!gd->securemode)
    {
    	struct spare_boot_head_t    *uboot  = (struct spare_boot_head_t *)buffer;

		//校验特征字符是否正确
		debug("%s\n", uboot->boot_head.magic);
		if(strncmp((const char *)uboot->boot_head.magic, UBOOT_MAGIC, MAGIC_SIZE))
		{
			printf("sunxi sprite: uboot magic is error\n");

			return -1;
		}
		//校验数据是否正确
		if(!mode)
		{
			if(sunxi_sprite_verify_checksum(buffer, uboot->boot_head.length, uboot->boot_head.check_sum))
			{
				printf("sunxi sprite: uboot checksum is error\n");

				return -1;
			}
		}
		/* regenerate check sum */
		uboot->boot_head.check_sum = sunxi_sprite_generate_checksum(buffer, uboot->boot_head.length, uboot->boot_head.check_sum);
		//校验数据是否正确
		if(sunxi_sprite_verify_checksum(buffer, uboot->boot_head.length, uboot->boot_head.check_sum))
		{
			printf("sunxi sprite: uboot checksum is error\n");

			return -1;
		}

		printf("uboot size = 0x%x\n", uboot->boot_head.length);

		return card_download_uboot(uboot->boot_head.length, buffer);
	}
	else
	{
		sbrom_toc1_head_info_t *toc1 = (sbrom_toc1_head_info_t *)buffer;

		printf("mmc down uboot\n");
		return card_download_uboot(toc1->valid_len, buffer);
	}
}
Esempio n. 2
0
/*
************************************************************************************************************
*
*                                             function
*
*    name          :
*
*    parmeters     :
*
*    return        :
*
*    note          :
*
*
************************************************************************************************************
*/
int sunxi_sprite_download_uboot(void *buffer, int production_media, int mode)
{
    struct spare_boot_head_t    *uboot  = (struct spare_boot_head_t *)buffer;

	//校验特征字符是否正确
	debug("%s\n", uboot->boot_head.magic);
	if(strncmp((const char *)uboot->boot_head.magic, UBOOT_MAGIC, MAGIC_SIZE))
	{
		printf("sunxi sprite: uboot magic is error\n");

		return -1;
	}
	//校验数据是否正确
	if(!mode)
	{
		if(sunxi_sprite_verify_checksum(buffer, uboot->boot_head.length, uboot->boot_head.check_sum))
		{
			printf("sunxi sprite: uboot checksum is error\n");

			return -1;
		}
		//读出dram参数
		//填充FLASH信息
		if(!production_media)
		{
			nand_uboot_get_flash_info((void *)uboot->boot_data.nand_spare_data, STORAGE_BUFFER_SIZE);
		}
	}
	/* regenerate check sum */
	uboot->boot_head.check_sum = sunxi_sprite_generate_checksum(buffer, uboot->boot_head.length, uboot->boot_head.check_sum);
	//校验数据是否正确
	if(sunxi_sprite_verify_checksum(buffer, uboot->boot_head.length, uboot->boot_head.check_sum))
	{
		printf("sunxi sprite: uboot checksum is error\n");

		return -1;
	}

	printf("uboot size = 0x%x\n", uboot->boot_head.length);
	printf("storage type = %d\n", production_media);
	if(!production_media)
	{
		debug("nand down uboot\n");
		return nand_download_uboot(uboot->boot_head.length, buffer);
	}
	else
	{
		printf("mmc down uboot\n");
		return card_download_uboot(uboot->boot_head.length, buffer);
	}
}