/*
************************************************************************************************************
*
*                                             function
*
*    name          :
*
*    parmeters     :
*
*    return        :
*
*    note          :
*
*
************************************************************************************************************
*/
int load_boot1_from_spinor(void)
{
	__u32 length;
	struct spare_boot_head_t  *bfh;

	if(spinor_init(0))
	{
		printf("spinor init fail\n");

		return -1;
	}
	/* 载入当前块最前面512字节的数据到SRAM中,目的是获取文件头 */
	if(spinor_read(UBOOT_START_SECTOR_IN_SPINOR, 1, (void *)CONFIG_SYS_TEXT_BASE ) )
	{
		printf("the first data is error\n");

		goto __load_boot1_from_spinor_fail;
	}
	printf("Succeed in reading Boot1 file head.\n");

	/* 察看是否是文件头 */
	if( check_magic( (__u32 *)CONFIG_SYS_TEXT_BASE, UBOOT_MAGIC ) != 0 )
	{
		printf("ERROR! Add %u doesn't store head of Boot1 copy.\n", UBOOT_START_SECTOR_IN_SPINOR );

		goto __load_boot1_from_spinor_fail;
	}

	bfh = (struct spare_boot_head_t *)CONFIG_SYS_TEXT_BASE;
	length =  bfh->boot_head.length;
	printf("The size of uboot is %x.\n", length );
	if( ( length & ( 512 - 1 ) ) != 0 ) 	// length必须是NF_SECTOR_SIZE对齐的
	{
		printf("the boot1 is not aligned by %x\n", bfh->boot_head.align_size);

		goto __load_boot1_from_spinor_fail;
	}

	if(spinor_read(UBOOT_START_SECTOR_IN_SPINOR, length/512, (void *)CONFIG_SYS_TEXT_BASE ))
	{
		printf("spinor read data	error\n");

		goto __load_boot1_from_spinor_fail;
	}
	bfh->boot_data.storage_type = 3;

	return 0;

__load_boot1_from_spinor_fail:

	return -1;
}
Exemple #2
0
static int
sunxi_flash_spinor_read(unsigned int start_block, unsigned int nblock, void *buffer)
{
	debug("spinor read: start 0x%x, sector 0x%x\n", start_block, nblock);

    return spinor_read(start_block + CONFIG_SPINOR_LOGICAL_OFFSET, nblock, buffer);
}