static int check_update_file(void) { int ret, dev; block_dev_desc_t *dev_desc; char *sdev = getenv("mmcdev"); dev = (int)((char)sdev[0] - '0'); dev_desc = get_dev("mmc", dev); if (dev_desc == NULL) { printf("Failed to find %s:%d\n", "mmc", dev); return -1; } ret = fat_register_device(dev_desc, 0); if (ret) { printf("Failed to register %s: 0:0\n","mmc"); ret = fat_register_device(dev_desc, 1); if (ret) { printf("Failed to register %s: 0:1\n","mmc"); return -1; } } ret = fat_exists("update.zip"); if(ret == 0) { printf("not find update.zip, ret=%d\n", ret); return -1; } printf("is card update, ret=%d\n", ret); return 0; }
int mmc_read_bootloader(int dev) { unsigned char ret = 0; unsigned long offset = ( CFG_LOADADDR - 0x120 ); ret = mmc_init(dev); if (ret != 0){ printf("\n MMC init failed \n"); return -1; } #ifdef CFG_CMD_FAT long size; block_dev_desc_t *dev_desc = NULL; if (fat_boot()) { dev_desc = mmc_get_dev(dev); fat_register_device(dev_desc, 1); size = file_fat_read("u-boot.bin", (unsigned char *)offset, 0); if (size == -1) return -1; } else { /* FIXME: OMAP4 specific */ mmc_read(dev, 0x200, (unsigned char *)( CFG_LOADADDR - 0x120 ), 0x00060000); } #endif return 0; }
int mmc_init(int verbose) { unsigned char ret; ret = configure_mmc(&cur_card_data); if (ret == 1) { mmc_blk_dev.if_type = IF_TYPE_MMC; mmc_blk_dev.part_type = PART_TYPE_DOS; mmc_blk_dev.dev = 0; mmc_blk_dev.lun = 0; mmc_blk_dev.type = 0; /* FIXME fill in the correct size (is set to 32MByte) */ mmc_blk_dev.blksz = MMCSD_SECTOR_SIZE; mmc_blk_dev.lba = 0x10000; mmc_blk_dev.removable = 0; mmc_blk_dev.block_read = mmc_bread; fat_register_device(&mmc_blk_dev, 1); return 1; } else return 0; }
int do_fat_fsinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { int dev=0; int part=1; char *ep; block_dev_desc_t *dev_desc=NULL; if (argc < 2) { printf ("usage: fatinfo <interface> <dev[:part]>\n"); return (0); } dev = (int)simple_strtoul (argv[2], &ep, 16); dev_desc=get_dev(argv[1],dev); if (dev_desc==NULL) { puts ("\n** Invalid boot device **\n"); return 1; } if (*ep) { if (*ep != ':') { puts ("\n** Invalid boot device, use `dev[:part]' **\n"); return 1; } part = (int)simple_strtoul(++ep, NULL, 16); } if (fat_register_device(dev_desc,part)!=0) { printf ("\n** Unable to use %s %d:%d for fatinfo **\n",argv[1],dev,part); return 1; } return (file_fat_detectfs ()); }
static void mmc_load_image_fat(struct mmc *mmc) { int err; struct image_header *header; header = (struct image_header *)(CONFIG_SYS_TEXT_BASE - sizeof(struct image_header)); err = fat_register_device(&mmc->block_dev, CONFIG_SYS_MMC_SD_FAT_BOOT_PARTITION); if (err) { printf("spl: fat register err - %d\n", err); hang(); } err = file_fat_read(CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME, header, sizeof(struct image_header)); if (err <= 0) goto end; spl_parse_image_header(header); err = file_fat_read(CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME, (u8 *)spl_image.load_addr, 0); end: if (err <= 0) { printf("spl: error reading image %s, err - %d\n", CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME, err); hang(); } }
int do_fat_ls (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { char *filename = "/"; int ret, dev, part; block_dev_desc_t *dev_desc=NULL; disk_partition_t info; if (argc < 2) { printf("usage: fatls <interface> [<dev[:part]>] [directory]\n"); return 0; } part = get_device_and_partition(argv[1], argv[2], &dev_desc, &info, 1); if (part < 0) return 1; dev = dev_desc->dev; if (fat_register_device(dev_desc,part)!=0) { printf("\n** Unable to use %s %d:%d for fatls **\n", argv[1], dev, part); return 1; } if (argc == 4) ret = file_fat_ls(argv[3]); else ret = file_fat_ls(filename); if(ret!=0) printf("No Fat FS detected\n"); return ret; }
int fat_fsload_file (char * file_name,unsigned int ddr_addr) { long size; unsigned long count; block_dev_desc_t *dev_desc=NULL; int dev=0; int part=1; dev_desc = get_dev("sunxi_flash",dev); if (dev_desc == NULL) { puts("\n** Invalid boot device **\n"); return -1; } if (fat_register_device(dev_desc,part)!=0) { printf("\n** Unable to use %s %d:%d for fatload **\n", "sunxi_flash", dev, part); return -1; } count = 0; size = file_fat_read(file_name, (unsigned char *)ddr_addr, count); if(size==-1) { printf("\n** Unable to read \"%s\" from %s %d:%d **\n", file_name, "sunxi_flash", dev, part); return -1; } return size; }
/* * Dump crash to file (typically FAT file on SD/MMC). */ static int crashdump(Elf32_Ehdr *elfhdr_addr) { int rc; block_dev_desc_t *dev_desc=NULL; rc = wait_for_mmc(); if (rc == 0) { dev_desc = get_dev("mmc", CONFIG_SD_FAT_DEV_NUM); /* mmc 1 */ rc = fat_register_device(dev_desc, CONFIG_SD_FAT_PART_NUM); /* part 1 */ if (rc != 0) { printf("crashdump: fat_register_device failed %d\n", rc); return -1; } if(find_dump_file_name() < MAX_PREFIX) rc = dump_elf(elfhdr_addr, crash_filename); else printf("Number of dumps have reached maximum on SD card: %d\n", MAX_PREFIX); } if (rc != 0) printf("crashdump: error writing dump to %s\n", crash_filename); return rc; }
void fs_init(void) { #ifdef HTCLEO_SUPPORT_VFAT fat_register_device(&mmc_dev, 1); file_fat_detectfs(); #endif }
void spl_mmc_load_image(void) { struct mmc *mmc; int err; u32 boot_mode; mmc_initialize(gd->bd); /* We register only one device. So, the dev id is always 0 */ mmc = find_mmc_device(0); if (!mmc) { #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT puts("spl: mmc device not found!!\n"); #endif hang(); } err = mmc_init(mmc); if (err) { #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT printf("spl: mmc init failed: err - %d\n", err); #endif hang(); } boot_mode = spl_boot_mode(); if (boot_mode == MMCSD_MODE_RAW) { debug("boot mode - RAW\n"); #ifdef CONFIG_SPL_OS_BOOT if (spl_start_uboot() || mmc_load_image_raw_os(mmc)) #endif err = mmc_load_image_raw(mmc, CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR); #ifdef CONFIG_SPL_FAT_SUPPORT } else if (boot_mode == MMCSD_MODE_FAT) { debug("boot mode - FAT\n"); err = fat_register_device(&mmc->block_dev, CONFIG_SYS_MMC_SD_FAT_BOOT_PARTITION); if (err) { #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT printf("spl: fat register err - %d\n", err); #endif hang(); } #ifdef CONFIG_SPL_OS_BOOT if (spl_start_uboot() || mmc_load_image_fat_os(mmc)) #endif err = mmc_load_image_fat(mmc, CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME); #endif } else { #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT puts("spl: wrong MMC boot mode\n"); #endif hang(); } if (err) hang(); }
static int initFatFileSystem(void) { if (fat_register_device(stor_dev, 0) != 0) { debug ("Unable to use %d:%d for fat \n", current_usb_storage_device, 0); if (fat_register_device(stor_dev, 1) != 0) { debug ("Unable to use %d:%d for fat \n", current_usb_storage_device, 1); return FALSE; } } if (file_fat_detectfs() != 0) { debug ("file_fat_detectfs failed\n"); return FALSE; } return TRUE; }
int do_fat_fsload (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { long size; unsigned long offset; unsigned long count; char buf [12]; block_dev_desc_t *dev_desc=NULL; int dev=0; int part=1; char *ep; if (argc < 5) { printf( "usage: fatload <interface> <dev[:part]> " "<addr> <filename> [bytes]\n"); return 1; } dev = (int)simple_strtoul(argv[2], &ep, 16); dev_desc = get_dev(argv[1],dev); if (dev_desc == NULL) { puts("\n** Invalid boot device **\n"); return 1; } if (*ep) { if (*ep != ':') { puts("\n** Invalid boot device, use `dev[:part]' **\n"); return 1; } part = (int)simple_strtoul(++ep, NULL, 16); } if (fat_register_device(dev_desc,part)!=0) { printf("\n** Unable to use %s %d:%d for fatload **\n", argv[1], dev, part); return 1; } offset = simple_strtoul(argv[3], NULL, 16); if (argc == 6) count = simple_strtoul(argv[5], NULL, 16); else count = 0; #ifdef DEBUG printf("offset = %x\n", (int)offset); #endif size = file_fat_read(argv[4], (unsigned char *)offset, count); if(size==-1) { printf("\n** Unable to read \"%s\" from %s %d:%d **\n", argv[4], argv[1], dev, part); return 1; } debug("\n%ld bytes read\n", size); sprintf(buf, "%lX", size); setenv("filesize", buf); return 0; }
int mmc_init(int slot) { int result = -1; switch (slot) { case 0: configure_controller(&cur_controller_data[slot], slot); configure_mmc(&cur_card_data[slot], &cur_controller_data[slot]); mmc_blk_dev[slot].if_type = IF_TYPE_MMC; mmc_blk_dev[slot].part_type = PART_TYPE_DOS; mmc_blk_dev[slot].dev = cur_controller_data[slot].slot; mmc_blk_dev[slot].lun = 0; mmc_blk_dev[slot].type = 0; /* FIXME fill in the correct size (is set to 32MByte) */ mmc_blk_dev[slot].blksz = MMCSD_SECTOR_SIZE; mmc_blk_dev[slot].lba = 0x10000; mmc_blk_dev[slot].removable = 0; mmc_blk_dev[slot].block_read = mmc_bread; result = fat_register_device(&mmc_blk_dev[slot], 1); break; case 1: configure_controller(&cur_controller_data[slot], slot); configure_mmc(&cur_card_data[slot], &cur_controller_data[slot]); mmc_blk_dev[slot].if_type = IF_TYPE_MMC; mmc_blk_dev[slot].part_type = PART_TYPE_DOS; mmc_blk_dev[slot].dev = cur_controller_data[slot].slot; mmc_blk_dev[slot].lun = 0; mmc_blk_dev[slot].type = 0; /* FIXME fill in the correct size (is set to 32MByte) */ mmc_blk_dev[slot].blksz = MMCSD_SECTOR_SIZE; mmc_blk_dev[slot].lba = 0x10000; mmc_blk_dev[slot].removable = 0; mmc_blk_dev[slot].block_read = mmc_bread; fat_register_device(&mmc_blk_dev[slot], 1); result = 0; break; default: printf("mmc_init:mmc slot is not supported%d\n", slot); } return result; }
int do_fat_fswrite (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { long size; unsigned long offset; unsigned long count; char buf[12]; block_dev_desc_t *dev_desc=NULL; int dev=0; int part=1; char *ep; if (argc < 6) { printf ("usage: fatwrite <interface> <dev[:part]> " "<addr> <filename> <bytes>\n"); return 1; } dev = (int)simple_strtoul (argv[2], &ep, 16); dev_desc=get_dev(argv[1],dev); if (dev_desc==NULL) { puts ("\n** Invalid device **\n"); return 1; } if (*ep) { if (*ep != ':') { puts ("\n** Invalid device, use `dev[:part]' **\n"); return 1; } part = (int)simple_strtoul(++ep, NULL, 16); } if (fat_register_device(dev_desc,part)!=0) { printf ("\n** Unable to use %s %d:%d for fatwrite **\n", argv[1],dev,part); return 1; } offset = simple_strtoul (argv[3], NULL, 16); count = simple_strtoul (argv[5], NULL, 16); size = file_fat_write(argv[4], (unsigned char *)offset, count); if (size <= 0) { printf("\n** Unable to write\"%s\" to %s %d:%d **\n", argv[4],argv[1],dev,part); return 1; } printf ("\n%ld bytes written\n", size); sprintf(buf, "%lX", size); setenv("filesize", buf); return 0; }
int saveenv(void) { env_t env_new; ssize_t len; char *res; block_dev_desc_t *dev_desc = NULL; int dev = FAT_ENV_DEVICE; int part = FAT_ENV_PART; res = (char *)&env_new.data; len = hexport_r(&env_htab, '\0', &res, ENV_SIZE, 0, NULL); if (len < 0) { error("Cannot export environment: errno = %d\n", errno); return 1; } #ifdef CONFIG_MMC if (strcmp (FAT_ENV_INTERFACE, "mmc") == 0) { struct mmc *mmc = find_mmc_device(dev); if (!mmc) { printf("no mmc device at slot %x\n", dev); return 1; } mmc->has_init = 0; mmc_init(mmc); } #endif /* CONFIG_MMC */ dev_desc = get_dev(FAT_ENV_INTERFACE, dev); if (dev_desc == NULL) { printf("Failed to find %s%d\n", FAT_ENV_INTERFACE, dev); return 1; } if (fat_register_device(dev_desc, part) != 0) { printf("Failed to register %s%d:%d\n", FAT_ENV_INTERFACE, dev, part); return 1; } env_new.crc = crc32(0, env_new.data, ENV_SIZE); if (file_fat_write(FAT_ENV_FILE, (void *)&env_new, sizeof(env_t)) == -1) { printf("\n** Unable to write \"%s\" from %s%d:%d **\n", FAT_ENV_FILE, FAT_ENV_INTERFACE, dev, part); return 1; } puts("done\n"); return 0; }
int do_update_image_name(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { long size; char linebuf[1024]; char kernel[256]; char rootfs[256]; int i; block_dev_desc_t *dev_desc=NULL; dev_desc = get_dev("mmc", 0); if (dev_desc==NULL) { puts ("\n** Invalid boot device **\n"); return 1; } if (fat_register_device(dev_desc, 1)!=0) { printf ("\n** Unable to use mmc %d:%d for fatload **\n",0,0); return 1; } if (dev_desc==NULL) { puts ("\n** Invalid boot device **\n"); return 1; } size = file_fat_read ("/images/uEnv.txt", (unsigned char *) linebuf, 0); if(size==-1) { printf("\n** Unable to read /images/uEnv.txt\n"); return 1; } printf("file size = %ld bytes\n", size); char *p = strchr(linebuf, '=') + 1; for(i=0; i<size && *p != '\r' && *p != '\n'; i++) { kernel[i] = *p++; } kernel[i]='\0'; p = strrchr(linebuf, '=') + 1; int len = size - (p-linebuf); for(i=0; i<len && *p != '\r' && *p != '\n'; i++) { rootfs[i]=*p++; } rootfs[i]='\0'; printf("kernel:%s\n", kernel); printf("rootfs:%s\n", rootfs); //设置环境变量 setenv("kernel", kernel); setenv("rootfs", rootfs); return 0; }
int do_fat_fsload (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { long size; unsigned long offset; unsigned long count = 0; unsigned long pos = 0; char buf [12]; block_dev_desc_t *dev_desc=NULL; disk_partition_t info; int part, dev; if (argc < 5) { printf("usage: fatload <interface> [<dev[:part]>] " "<addr> <filename> [bytes [pos]]\n"); return 1; } part = get_device_and_partition(argv[1], argv[2], &dev_desc, &info, 1); if (part < 0) return 1; dev = dev_desc->dev; if (fat_register_device(dev_desc,part)!=0) { printf("\n** Unable to use %s %d:%d for fatload **\n", argv[1], dev, part); return 1; } offset = simple_strtoul(argv[3], NULL, 16); if (argc >= 6) count = simple_strtoul(argv[5], NULL, 16); if (argc >= 7) pos = simple_strtoul(argv[6], NULL, 16); size = file_fat_read_at(argv[4], pos, (unsigned char *)offset, count); if(size==-1) { printf("\n** Unable to read \"%s\" from %s %d:%d **\n", argv[4], argv[1], dev, part); return 1; } printf("\n%ld bytes read\n", size); sprintf(buf, "%lX", size); setenv("filesize", buf); return 0; }
static int do_fat_fswrite(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { long size; unsigned long addr; unsigned long count; block_dev_desc_t *dev_desc = NULL; int dev = 0; int part = 1; char *ep; if (argc < 5) return cmd_usage(cmdtp); dev = (int)simple_strtoul(argv[2], &ep, 16); dev_desc = get_dev(argv[1], dev); if (dev_desc == NULL) { puts("\n** Invalid boot device **\n"); return 1; } if (*ep) { if (*ep != ':') { puts("\n** Invalid boot device, use `dev[:part]' **\n"); return 1; } part = (int)simple_strtoul(++ep, NULL, 16); } if (fat_register_device(dev_desc, part) != 0) { printf("\n** Unable to use %s %d:%d for fatwrite **\n", argv[1], dev, part); return 1; } addr = simple_strtoul(argv[3], NULL, 16); count = simple_strtoul(argv[5], NULL, 16); size = file_fat_write(argv[4], (void *)addr, count); if (size == -1) { printf("\n** Unable to write \"%s\" from %s %d:%d **\n", argv[4], argv[1], dev, part); return 1; } printf("%ld bytes written\n", size); return 0; }
void env_relocate_spec(void) { char buf[CONFIG_ENV_SIZE]; block_dev_desc_t *dev_desc = NULL; int dev = FAT_ENV_DEVICE; int part = FAT_ENV_PART; #ifdef CONFIG_MMC if (strcmp (FAT_ENV_INTERFACE, "mmc") == 0) { struct mmc *mmc = find_mmc_device(dev); if (!mmc) { printf("no mmc device at slot %x\n", dev); set_default_env(NULL); return; } mmc->has_init = 0; mmc_init(mmc); } #endif /* CONFIG_MMC */ dev_desc = get_dev(FAT_ENV_INTERFACE, dev); if (dev_desc == NULL) { printf("Failed to find %s%d\n", FAT_ENV_INTERFACE, dev); set_default_env(NULL); return; } if (fat_register_device(dev_desc, part) != 0) { printf("Failed to register %s%d:%d\n", FAT_ENV_INTERFACE, dev, part); set_default_env(NULL); return; } if (file_fat_read(FAT_ENV_FILE, (unsigned char *)&buf, CONFIG_ENV_SIZE) == -1) { printf("\n** Unable to read \"%s\" from %s%d:%d **\n", FAT_ENV_FILE, FAT_ENV_INTERFACE, dev, part); set_default_env(NULL); return; } env_import(buf, 1); }
int do_fat_fsmv (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { char buf[256]; block_dev_desc_t *dev_desc=NULL; int dev=0; int part=1; char *ep; if (argc < 5) { printf ("usage: fatmv <interface> <dev[:part]> <oldname> <newname>\n"); return 1; } dev = (int)simple_strtoul (argv[2], &ep, 16); dev_desc=get_dev(argv[1],dev); if (dev_desc==NULL) { puts ("\n** Invalid device **\n"); return 1; } if (*ep) { if (*ep != ':') { puts ("\n** Invalid device, use `dev[:part]' **\n"); return 1; } part = (int)simple_strtoul(++ep, NULL, 16); } if (fat_register_device(dev_desc,part)!=0) { printf ("\n** Unable to use %s %d:%d for fatmv **\n", argv[1],dev,part); return 1; } if (file_fat_mv(argv[3], argv[4]) < 0) { printf("\n** Unable to change \"%s\" to \"%s\" **\n", argv[3], argv[4]); return 1; } strncpy(buf, argv[3], sizeof(buf)); setenv("filename", buf); return 0; }
int detect_program_bin(void) { int ret, size, count; u32 *buf; buf = (u32 *)0xe00000; fat_register_device(&mmc_blk_dev,1); //buzzer_off(); size = file_fat_read ("program.bin", buf, 128 * 1024); if (size > 1 && (buf[0] == 0xea000012 || buf[0] == 0x120000ea)) { buzzer_on(0); run_command("go e00000", 0); buzzer_off(); } //buzzer_off(); return 0; }
static int spl_register_fat_device(struct blk_desc *block_dev, int partition) { int err = 0; if (fat_registered) return err; err = fat_register_device(block_dev, partition); if (err) { #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT printf("%s: fat register err - %d\n", __func__, err); #endif return err; } fat_registered = 1; return err; }
void spl_usb_load_image(void) { struct usb_device *usb_dev; int err; block_dev_desc_t *stor_dev; usb_stop(); err = usb_init(); if (err) { #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT printf("spl: usb init failed: err - %d\n", err); #endif hang(); } else { #ifdef CONFIG_USB_STORAGE /* try to recognize storage devices immediately */ usb_stor_curr_dev = usb_stor_scan(1); stor_dev = usb_stor_get_dev(usb_stor_curr_dev); #endif } debug("boot mode - FAT\n"); err = fat_register_device(stor_dev, CONFIG_SYS_USB_FAT_BOOT_PARTITION); if (err) { #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT printf("spl: fat register err - %d\n", err); #endif hang(); } #ifdef CONFIG_SPL_OS_BOOT if (spl_start_uboot() || usb_load_image_fat_os(usb_dev)) #endif err = usb_load_image_fat(CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME); if (err) { puts("Error loading USB device\n"); hang(); } }
static void mmc_load_image_fat(struct mmc *mmc) { s32 err; struct image_header *header; char *payloadname; header = (struct image_header *)(CONFIG_SYS_TEXT_BASE - sizeof(struct image_header)); err = fat_register_device(&mmc->block_dev, CONFIG_SYS_MMC_SD_FAT_BOOT_PARTITION); if (err) { printf("spl: fat register err - %d\n", err); hang(); } payloadname = CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME; err = file_fat_read(payloadname, (u8 *)header, sizeof(struct image_header)); if (err <= 0) { payloadname = "u-boot.bin"; err = file_fat_read(payloadname, (u8 *)header, sizeof(struct image_header)); if (err <= 0) { goto end; } } spl_parse_image_header(header); err = file_fat_read(payloadname, (u8 *)spl_image.load_addr, 0); end: if (err <= 0) { printf("spl: error reading image %s, err - %d\n", payloadname, err); hang(); } }
int do_fat_ls (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { char *filename = "/"; int ret; int dev=0; int part=1; char *ep; block_dev_desc_t *dev_desc=NULL; if (argc < 3) { printf("usage: fatls <interface> <dev[:part]> [directory]\n"); return 0; } dev = (int)simple_strtoul(argv[2], &ep, 16); dev_desc = get_dev(argv[1],dev); if (dev_desc == NULL) { puts("\n** Invalid boot device **\n"); return 1; } if (*ep) { if (*ep != ':') { puts("\n** Invalid boot device, use `dev[:part]' **\n"); return 1; } part = (int)simple_strtoul(++ep, NULL, 16); } if (fat_register_device(dev_desc,part)!=0) { printf("\n** Unable to use %s %d:%d for fatls **\n", argv[1], dev, part); return 1; } if (argc == 4) ret = file_fat_ls(argv[3]); else ret = file_fat_ls(filename); if(ret!=0) printf("No Fat FS detected\n"); return ret; }
int mmc_init(int slot) { configure_controller(&cur_controller_data, slot); configure_mmc(&cur_card_data, &cur_controller_data); #ifdef CFG_CMD_FAT mmc_blk_dev.if_type = IF_TYPE_MMC; mmc_blk_dev.part_type = PART_TYPE_DOS; mmc_blk_dev.dev = slot; mmc_blk_dev.lun = 0; mmc_blk_dev.type = 0; /* FIXME fill in the correct size (is set to 32MByte) */ mmc_blk_dev.blksz = MMCSD_SECTOR_SIZE; mmc_blk_dev.lba = 0x10000; mmc_blk_dev.removable = 0; mmc_blk_dev.block_read = mmc_bread; fat_register_device(&mmc_blk_dev, 1); #endif return 0; }
static int do_fat_fswrite(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { long size; unsigned long addr; unsigned long count; block_dev_desc_t *dev_desc = NULL; disk_partition_t info; int dev = 0; int part = 1; if (argc < 5) return cmd_usage(cmdtp); part = get_device_and_partition(argv[1], argv[2], &dev_desc, &info, 1); if (part < 0) return 1; dev = dev_desc->dev; if (fat_register_device(dev_desc, part) != 0) { printf("\n** Unable to use %s %d:%d for fatwrite **\n", argv[1], dev, part); return 1; } addr = simple_strtoul(argv[3], NULL, 16); count = simple_strtoul(argv[5], NULL, 16); size = file_fat_write(argv[4], (void *)addr, count); if (size == -1) { printf("\n** Unable to write \"%s\" from %s %d:%d **\n", argv[4], argv[1], dev, part); return 1; } printf("%ld bytes written\n", size); return 0; }
int mmc_legacy_init(int dev) { if (mmc_set_dev(dev) != 0) return 1; if (configure_mmc(&cur_card_data) != 1) return 1; mmc_blk_dev.if_type = IF_TYPE_MMC; mmc_blk_dev.part_type = PART_TYPE_DOS; mmc_blk_dev.dev = 0; mmc_blk_dev.lun = 0; mmc_blk_dev.type = 0; /* FIXME fill in the correct size (is set to 32MByte) */ mmc_blk_dev.blksz = MMCSD_SECTOR_SIZE; mmc_blk_dev.lba = 0x10000; mmc_blk_dev.removable = 0; mmc_blk_dev.block_read = mmc_bread; fat_register_device(&mmc_blk_dev, 1); return 0; }
int do_fat_fsinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { int dev, part; block_dev_desc_t *dev_desc; disk_partition_t info; if (argc < 2) { printf("usage: fatinfo <interface> [<dev[:part]>]\n"); return 0; } part = get_device_and_partition(argv[1], argv[2], &dev_desc, &info, 1); if (part < 0) return 1; dev = dev_desc->dev; if (fat_register_device(dev_desc,part)!=0) { printf("\n** Unable to use %s %d:%d for fatinfo **\n", argv[1], dev, part); return 1; } return file_fat_detectfs(); }
int mmc_legacy_init(int verbose) { //test_switch_register(); printf("MMC Init Card ...\n"); InitCardReader(); ReInitCard(); mmc_blk_dev.if_type = IF_TYPE_MMC; mmc_blk_dev.part_type = PART_TYPE_DOS; mmc_blk_dev.dev = 0; mmc_blk_dev.lun = 0; mmc_blk_dev.type = 0; /* FIXME fill in the correct size (is set to 32MByte) */ mmc_blk_dev.blksz = 512; mmc_blk_dev.lba = 0x100000; mmc_blk_dev.removable = 0; mmc_blk_dev.block_read = mmc_bread; if (fat_register_device(&mmc_blk_dev, 1)) { printf("Could not register MMC fat device\n"); init_part(&mmc_blk_dev); } if (mmc_inited == 0) { mmc_inited = 1; //detect_program_bin(); //detect_test_bin(); } mmc_inited = 1; return 0; }