Пример #1
0
static int tryload(char *filename, unsigned int address)
{
	int devsize, realsize;

	devsize = fatfs_load(filename, (char *)address, 16*1024*1024, &realsize);
	if(devsize <= 0)
		return -1;
	if(realsize > devsize) {
		printf("E: File size larger than the blocks read (corrupted FS or IO error ?)\n");
		return -1;
	}
	printf("I: Read a %d byte image from %s\n", realsize, filename);

	return realsize;
}
Пример #2
0
static void load(char *filename, char *addr, char *dev)
{
	char *c;
	unsigned int *addr2;

	if((*filename == 0) || (*addr == 0)) {
		printf("load <filename> <address>\n");
		return;
	}
	addr2 = (unsigned *)strtoul(addr, &c, 0);
	if(*c != 0) {
		printf("incorrect address\n");
		return;
	}
	if(!fatfs_init(BLOCKDEV_MEMORY_CARD)) return;
	fatfs_load(filename, (char *)addr2, 16*1024*1024, NULL);
	fatfs_done();
}