示例#1
0
文件: mtd.c 项目: nickarsov/Firmware
int mtd_main(int argc, char *argv[])
{
	if (argc >= 2) {
		if (!strcmp(argv[1], "start")) {

			/* start mapping according to user request */
			if (argc >= 3) {
				mtd_start(argv + 2, argc - 2);
			} else {
				mtd_start(partition_names_default, n_partitions_default);
			}
		}

		if (!strcmp(argv[1], "test"))
			mtd_test();

		if (!strcmp(argv[1], "readtest")) {
			if (argc >= 3) {
				mtd_readtest(argv + 2, argc - 2);
			} else {
				mtd_readtest(partition_names_default, n_partitions_default);
			}
                }

		if (!strcmp(argv[1], "rwtest")) {
			if (argc >= 3) {
				mtd_rwtest(argv + 2, argc - 2);
			} else {
				mtd_rwtest(partition_names_default, n_partitions_default);
			}
                }

		if (!strcmp(argv[1], "status"))
			mtd_status();

		if (!strcmp(argv[1], "erase")) {
			if (argc >= 3) {
				mtd_erase(argv + 2, argc - 2);
			} else {
				mtd_erase(partition_names_default, n_partitions_default);
			}
                }
	}

	errx(1, "expected a command, try 'start', 'erase', 'status', 'readtest', 'rwtest' or 'test'");
}
示例#2
0
int mtd_main(int argc, char *argv[])
{
	uint8_t test_value = 100;

	if (argc >= 2) {
		if (!strcmp(argv[1], "start")) {

			/* start mapping according to user request */
			if (argc >= 3) {
				mtd_start(argv + 2, argc - 2);
			} else {
				mtd_start(partition_names_default, n_partitions_default);
			}
		}

		if (!strcmp(argv[1], "test"))
			if (argc >= 5) {
				if (argc >= 6) {
					// grab the desired value to write/check
					test_value = atoi(argv[5]);
				}
				if (!strcmp(argv[3], "w")) {
					mtd_test_custom(argv[2], true, atoi(argv[4]), test_value);
				}
				else {
					mtd_test_custom(argv[2], false, atoi(argv[4]), test_value);
				}
			
			}
			else {
				mtd_test();
			}

		if (!strcmp(argv[1], "readtest")) {
			if (argc >= 3) {
				mtd_readtest(argv + 2, argc - 2);
			} else {
				mtd_readtest(partition_names_default, n_partitions_default);
			}
                }

		if (!strcmp(argv[1], "rwtest")) {
			if (argc >= 3) {
				mtd_rwtest(argv + 2, argc - 2);
			} else {
				mtd_rwtest(partition_names_default, n_partitions_default);
			}
                }

		if (!strcmp(argv[1], "status"))
			mtd_status();

		if (!strcmp(argv[1], "erase")) {
			if (argc >= 3) {
				mtd_erase(argv + 2, argc - 2);
			} else {
				mtd_erase(partition_names_default, n_partitions_default);
			}
                }
	}

	errx(1, "expected a command, try 'start', 'erase', 'status', 'readtest', 'rwtest' or 'test'");
}