diff --git a/util/mkflashimg/Makefile b/util/mkflashimg/Makefile new file mode 100644 index 0000000000..b07ce9affe --- /dev/null +++ b/util/mkflashimg/Makefile @@ -0,0 +1,29 @@ +PROG = mkflashimg +OBJS = mkflashimg.o + +INCLUDES= + +BIN = ../bin + +CC = gcc +STRIP = strip +CHMOD = chmod +RM = rm -f +CP = cp -fp + +all: $(PROG) + +$(PROG): $(OBJS) + $(CC) -o $(PROG) $(OBJS) + $(STRIP) $(PROG) + +install: $(PROG) + $(CP) $(PROG) $(BIN) + $(CHMOD) 775 $(BIN)/$(PROG) + +clean: + $(RM) $(BIN)/$(PROG) $(PROG) *.o *~ + +.c.o: + $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -c -o $*.o $< + diff --git a/util/mkflashimg/mkflashimg.c b/util/mkflashimg/mkflashimg.c new file mode 100644 index 0000000000..514ae9cfa7 --- /dev/null +++ b/util/mkflashimg/mkflashimg.c @@ -0,0 +1,60 @@ +#include + + +unsigned char buffer[65536]; + + +int main(int argc, char *argv[]) +{ + FILE *lb; + FILE *ipl; + FILE *out; + int i; + int blocks, size; + + if(argc<4) { + printf("%s []\n",argv[0]); + printf("Where docipl is the output from ipl.S\n"); + printf("linuxbios.strip is a linuxbios stripped but not run through mkrom\n"); + printf("target is the result. It should be flashed to the rom.\n"); + return(-1); + } + + if(!(ipl = fopen(argv[1],"rb"))) { + fprintf(stderr,"Cannot open %s for reading\n",argv[1]); + return(-2); + } + + if(!(lb = fopen(argv[2],"rb"))) { + fprintf(stderr,"Cannot open %s for reading\n",argv[2]); + return(-2); + } + + if(!(out = fopen(argv[3],"wb"))) { + fprintf(stderr,"Cannot open %s for write\n",argv[3]); + return(-3); + } + + if(argc == 5) + size = atoi(argv[4]); + else + size = 256; + + blocks = ((size + 64)/64)-1; + + blocks -=1; // We always write the payload block! + + for(i=0; i