gen_ext_rand.c
808 Bytes
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
#include <stdlib.h>
#include <stdio.h>
/*
* Generate 64MB file to initialize flash with randoms
*
* Format has 512B 16B 512B 16B ...
*
*/
/* 64MB data file */
#define FLASH_SIZE 0x4000000
//#define FLASH_SIZE 0x800
int main(int argc,char *argv[])
{
int i,j;
FILE *fdata;
if(argc!=2){
printf("Need one argument for output filename\n");
exit(1);
}
if ((fdata=fopen(argv[1],"w"))==0) {
printf("cannot open %s\n",argv[1]);
exit(1);
}
for(i=0;i<FLASH_SIZE/512;i++){
fprintf(fdata,"// page %d\n",i);
for(j=0;j<528;j++){
fprintf(fdata,"%02x ",(unsigned char)rand());
if((j&0xf)==0xf)
fprintf(fdata,"\n");
}
fprintf(fdata,"\n");
}
fclose(fdata);
return 0;
}