Example #1
0
int do_insnand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
{
	size_t total = CFG_ENV_OFFSET;
	ulong addr = PHYS_SDRAM_1;

	movi_read((uint) addr, ofsinfo.bl2, MOVI_BL2_BLKCNT);
	nand_erase(&nand_info[0], 0x0, CFG_ENV_OFFSET + CFG_ENV_SIZE);
	nand_write(&nand_info[0], 0x0, &total, (u_char *) addr);

	printf("Done\n");

	return 1;
}
Example #2
0
void movi_read_env(ulong addr)
{
	movi_read(raw_area_control.image[2].start_blk,
		  raw_area_control.image[2].used_blk, addr);
}
Example #3
0
int do_movi(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
{
	char *cmd;
	unsigned int addr, blk, blocks;
	uint last_blkpos, bytes;

	cmd = argv[1];

	if (strcmp(cmd, "init") == 0) {
		if (argc < 4)
			goto usage;
		
		last_blkpos = (uint) simple_strtoul(argv[2], NULL, 10);
		movi_hc = (uint) simple_strtoul(argv[3], NULL, 10);

		if (movi_set_ofs(last_blkpos))
			movi_init();
	} else {
		if (argc == 4 || (strcmp(argv[2], "rootfs") == 0))
			addr = (ulong) simple_strtoul(argv[3], NULL, 16);
		else if (argc == 5)
			addr = (ulong) simple_strtoul(argv[4], NULL, 16);
		else
			goto usage;

		if (addr >= 0xc0000000)
			addr = virt_to_phys(addr);

		if (ofsinfo.last == 0) {
			printf("### Execute 'movi init' command first!\n");
			return -1;
		}
		
		if (strcmp(cmd, "read") == 0) {
			if (argc == 4 || (strcmp(argv[2], "rootfs") == 0)) {
				if (strcmp(argv[2], "u-boot") == 0) {
					printf("Reading bootloader.. ");
					movi_read((uint) addr, ofsinfo.bl2, MOVI_BL2_BLKCNT);
					printf("completed\n");

				} else if (strcmp(argv[2], "kernel") == 0) {
					printf("Reading kernel from sector %d (%d sectors).. ", ofsinfo.kernel, MOVI_ZIMAGE_BLKCNT);
					movi_read((uint) addr, ofsinfo.kernel, MOVI_ZIMAGE_BLKCNT);
					printf("completed\n");

				} else if (strcmp(argv[2], "rootfs") == 0) {
					bytes = simple_strtoul(argv[4], NULL, 16);
					
					if (argc == 5)
						blocks = (ulong) (bytes / MOVI_BLKSIZE);
					else
						blocks = MOVI_ROOTFS_BLKCNT;

					if (bytes % MOVI_BLKSIZE > 0)
						blocks++;

					blk = ofsinfo.rootfs;

					printf("Reading rootfs from sector %d (%d sectors).. ", blk, blocks);

					while (blocks > 0) {
						if (blocks < MOVI_RW_MAXBLKS) {
							movi_read((uint) addr, blk, blocks);
							blocks = 0;
						} else {
							movi_read((uint) addr, blk, MOVI_RW_MAXBLKS);
							addr += (MOVI_RW_MAXBLKS * MOVI_BLKSIZE);
							blk += MOVI_RW_MAXBLKS;
							blocks -= MOVI_RW_MAXBLKS;
						}
					}
					printf("completed\n");
				} else
					goto usage;
			} else {
				blk = (uint) simple_strtoul(argv[2], NULL, 10);
				bytes = (uint) simple_strtoul(argv[3], NULL, 16);

				if (blk >= 0 && blk <= ofsinfo.last) {
					blocks = (int) (bytes / MOVI_BLKSIZE);

					if (bytes % MOVI_BLKSIZE > 0)
						blocks++;

					printf("Reading data from sector %d (%d sectors).. ", blk, blocks);

					while (blocks > 0) {
						if (blocks < MOVI_RW_MAXBLKS) {
							movi_read((uint) addr, blk, blocks);
							blocks = 0;
						} else {
							movi_read((uint) addr, blk, MOVI_RW_MAXBLKS);
							addr += (MOVI_RW_MAXBLKS * MOVI_BLKSIZE);
							blk += MOVI_RW_MAXBLKS;
							blocks -= MOVI_RW_MAXBLKS;
						}
					}
					printf("completed\n");
				} else
					goto usage;
			}
		} else if (strcmp(cmd, "write") == 0) {
			if (argc == 4 || (strcmp(argv[2], "rootfs") == 0)) {
				if (strcmp(argv[2], "u-boot") == 0) {
					printf("Writing 1st bootloader to sector %d (%d sectors).. ", ofsinfo.bl1, MOVI_BL1_BLKCNT);
					movi_write((uint) addr, ofsinfo.bl1, MOVI_BL1_BLKCNT);
					printf("completed\nWriting 2nd bootloader to sector %d (%d sectors).. ", ofsinfo.bl2, MOVI_BL2_BLKCNT);
					movi_write((uint) addr, ofsinfo.bl2, MOVI_BL2_BLKCNT);
					printf("completed\n");

				} else if (strcmp(argv[2], "kernel") == 0) {
					printf("Writing kernel to sector %d (%d sectors).. ", ofsinfo.kernel, MOVI_ZIMAGE_BLKCNT);
					movi_write((uint) addr, ofsinfo.kernel, MOVI_ZIMAGE_BLKCNT);
					printf("completed\n");

				} else if (strcmp(argv[2], "env") == 0) {
					printf("Writing env to sector %d (%d sectors).. ", ofsinfo.env, MOVI_ENV_BLKCNT);
					movi_write((uint) addr, ofsinfo.env, MOVI_ENV_BLKCNT);
					printf("completed\n");

				} else if (strcmp(argv[2], "rootfs") == 0) {
					blk = ofsinfo.rootfs;
					bytes = simple_strtoul(argv[4], NULL, 16);
					
					if (argc == 5)
						blocks = (ulong) (bytes / MOVI_BLKSIZE);
					else
						blocks = MOVI_ROOTFS_BLKCNT;

					if (bytes % MOVI_BLKSIZE > 0)
						blocks++;

					printf("Writing rootfs to sector %d (%d sectors).. ", blk, blocks);

					while (blocks > 0) {
						if (blocks < MOVI_RW_MAXBLKS) {
							movi_write((uint) addr, blk, blocks);
							blocks = 0;
						} else {
							movi_write((uint) addr, blk, MOVI_RW_MAXBLKS);
							addr += (MOVI_RW_MAXBLKS * MOVI_BLKSIZE);
							blk += MOVI_RW_MAXBLKS;
							blocks -= MOVI_RW_MAXBLKS;
						}
					}
					printf("completed\n");
				} else
					goto usage;
			} else {
				blk = (uint) simple_strtoul(argv[2], NULL, 10);
				bytes = (uint) simple_strtoul(argv[3], NULL, 16);

				if (blk >= 0 && blk <= ofsinfo.last) {
					blocks = (int) (bytes / MOVI_BLKSIZE);

					if (bytes % MOVI_BLKSIZE > 0)
						blocks++;

					printf("Writing data to sector %d (%d sectors).. ", blk, blocks);

					while (blocks > 0) {
						if (blocks < MOVI_RW_MAXBLKS) {
							movi_write((uint) addr, blk, blocks);
							blocks = 0;
						} else {
							movi_write((uint) addr, blk, MOVI_RW_MAXBLKS);
							addr += (MOVI_RW_MAXBLKS * MOVI_BLKSIZE);
							blk += MOVI_RW_MAXBLKS;
							blocks -= MOVI_RW_MAXBLKS;
						}
					}
					printf("completed\n");
				} else
					goto usage;
			}
		} else {
			goto usage;
		}
	}

	return 1;

usage:
	printf("Usage:\n%s\n", cmdtp->usage);
	return -1;
}
Example #4
0
void movi_read_env(ulong addr)
{
	movi_read((uint)addr, ofsinfo.env, MOVI_ENV_BLKCNT);
}