Skip to content
Snippets Groups Projects
cmd_nand.c 26.7 KiB
Newer Older
  • Learn to ignore specific revisions
  • 	printf ("\nLoading from device %d: %s at 0x%lx (offset 0x%lx)\n",
    
    		dev, nand_dev_desc[dev].name, nand_dev_desc[dev].IO_ADDR,
    		offset);
    
    
    	if (nand_legacy_rw (nand_dev_desc + dev, NANDRW_READ, offset,
    			SECTORSIZE, NULL, (u_char *)addr)) {
    
    		printf ("** Read error on %d\n", dev);
    
    		show_boot_progress (-56);
    
    	show_boot_progress (56);
    
    	switch (genimg_get_format ((void *)addr)) {
    
    	case IMAGE_FORMAT_LEGACY:
    		hdr = (image_header_t *)addr;
    
    		cnt = image_get_image_size (hdr);
    		cnt -= SECTORSIZE;
    
    		break;
    #if defined(CONFIG_FIT)
    	case IMAGE_FORMAT_FIT:
    
    		fit_hdr = (const void *)addr;
    		if (!fit_check_format (fit_hdr)) {
    
    		puts ("Fit image detected...\n");
    
    		cnt = fit_get_size (fit_hdr);
    		break;
    
    		puts ("** Unknown image type\n");
    
    	show_boot_progress (57);
    
    	if (nand_legacy_rw (nand_dev_desc + dev, NANDRW_READ,
    			offset + SECTORSIZE, cnt, NULL,
    			(u_char *)(addr+SECTORSIZE))) {
    
    		printf ("** Read error on %d\n", dev);
    
    		show_boot_progress (-58);
    
    	show_boot_progress (58);
    
    #if defined(CONFIG_FIT)
    	/* This cannot be done earlier, we need complete FIT image in RAM first */
    	if (genimg_get_format ((void *)addr) == IMAGE_FORMAT_FIT)
    		fit_print_contents ((const void *)addr);
    #endif
    
    
    	/* Loading ok, update default load address */
    
    	load_addr = addr;
    
    	/* Check if we should attempt an auto-start */
    	if (((ep = getenv("autostart")) != NULL) && (strcmp(ep,"yes") == 0)) {
    		char *local_args[2];
    		extern int do_bootm (cmd_tbl_t *, int, int, char *[]);
    
    		local_args[0] = argv[0];
    		local_args[1] = NULL;
    
    
    		printf ("Automatic boot of image at addr 0x%08lx ...\n", addr);
    
    
    		do_bootm (cmdtp, 0, 1, local_args);
    		rcode = 1;
    	}
    	return rcode;
    }
    
    
    U_BOOT_CMD(
    	nboot,	4,	1,	do_nandboot,
    
    	"nboot   - boot from NAND device\n",
    	"loadAddr dev\n"
    );