gen_ext_rand.c 808 Bytes
#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;
}