summaryrefslogtreecommitdiffstatsabout
path: root/nandCreator.c
blob: 6ac115178831259858857608191d1cdd7733c6fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

#include <stdio.h>
#include <string.h>

int main(int argc, char* argv[])
{
	FILE *fp;
	long i;
	unsigned char buf[4096];
	long size;
	int write_size;
	int oob_size;
	char name[128];
	int ret;

	strcpy(name, "nand.bin");

	size = 128; /* MB */

	write_size = 2048; /* Byte */

	oob_size = 64; /* Byte */

	size = size * 1024 * 1024 / write_size * (write_size + oob_size);

	fp = fopen(name, "wb");
	if (fp) {
		for (i = 0; i < sizeof(buf); i++) {
			buf[i] = 0xFF;
		}

		for (i = 0; i < size/sizeof(buf); i++) {
			fwrite(buf, sizeof(buf), 1, fp);
		}

		fwrite(buf, size%sizeof(buf), 1, fp);

		fclose(fp);

		printf("create %s success\n", name);

	} else {
		printf("failed to create %s\n", name);
	}
	return 0;
}