demo: build BRAM initialization files

parent cd65f5f7
...@@ -4,7 +4,19 @@ include $(MMDIR)/software/include.mak ...@@ -4,7 +4,19 @@ include $(MMDIR)/software/include.mak
OBJECTS=crt0.o main.o boot.o OBJECTS=crt0.o main.o boot.o
SEGMENTS=-j .text -j .data -j .rodata SEGMENTS=-j .text -j .data -j .rodata
all: bios.bin all: bios.bin bios.h1 bios.h2 bios.h3 bios.h4
bios.h1: bios.bin
$(MMDIR)/tools/bin2hex $< $@ 4096 1
bios.h2: bios.bin
$(MMDIR)/tools/bin2hex $< $@ 4096 2
bios.h3: bios.bin
$(MMDIR)/tools/bin2hex $< $@ 4096 3
bios.h4: bios.bin
$(MMDIR)/tools/bin2hex $< $@ 4096 4
%.bin: %.elf %.bin: %.elf
$(OBJCOPY) $(SEGMENTS) -O binary $< $@ $(OBJCOPY) $(SEGMENTS) -O binary $< $@
...@@ -21,7 +33,7 @@ depend: ...@@ -21,7 +33,7 @@ depend:
makedepend -Y -- $(CFLAGS) -- *.c makedepend -Y -- $(CFLAGS) -- *.c
clean: clean:
rm -f *.o bios.elf bios.bin .*~ *~ Makefile.bak rm -f *.o bios.elf bios.bin bios.h1 bios.h2 bios.h3 bios.h4 .*~ *~ Makefile.bak
# DO NOT DELETE # DO NOT DELETE
......
/* /*
* Milkymist SoC * Milkymist SoC
* Copyright (C) 2007, 2008, 2009 Sebastien Bourdeauducq * Copyright (C) 2007, 2008, 2009 Sebastien Bourdeauducq
* Copyright (C) 2011 CERN
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -22,18 +23,25 @@ int main(int argc, char *argv[]) ...@@ -22,18 +23,25 @@ int main(int argc, char *argv[])
{ {
int i; int i;
int pad; int pad;
int pos;
FILE *fdi, *fdo; FILE *fdi, *fdo;
unsigned char w[4]; unsigned char w[4];
if(argc != 4) { if(argc != 5) {
fprintf(stderr, "Usage: bin2hex <infile> <outfile> <size>"); fprintf(stderr, "Usage: bin2hex <infile> <outfile> <size> <pos>\n");
return 1; return 1;
} }
pad = atoi(argv[3]); pad = atoi(argv[3]);
if(pad <= 0) { if(pad <= 0) {
fprintf(stderr, "Incorrect size"); fprintf(stderr, "Incorrect size\n");
return 1; return 1;
} }
pos = atoi(argv[4]);
if((pos <= 0)||(pos > 4)) {
fprintf(stderr, "Incorrect position\n");
return 1;
}
pos--;
fdi = fopen(argv[1], "rb"); fdi = fopen(argv[1], "rb");
if(!fdi) { if(!fdi) {
perror("Unable to open input file"); perror("Unable to open input file");
...@@ -47,14 +55,14 @@ int main(int argc, char *argv[]) ...@@ -47,14 +55,14 @@ int main(int argc, char *argv[])
} }
while(1) { while(1) {
if(fread(w, 4, 1, fdi) <= 0) break; if(fread(w, 4, 1, fdi) <= 0) break;
fprintf(fdo, "%02hhx%02hhx%02hhx%02hhx\n", w[0], w[1], w[2], w[3]); fprintf(fdo, "%02hhx\n", w[pos]);
pad--; pad--;
} }
fclose(fdi); fclose(fdi);
if(pad<0) if(pad < 0)
fprintf(stderr, "Warning: Input binary is larger than specified size"); fprintf(stderr, "Warning: Input binary is larger than specified size\n");
for(i=0;i<pad;i++) for(i=0;i<pad;i++)
fprintf(fdo, "00000000\n"); fprintf(fdo, "00\n");
if(fclose(fdo) != 0) { if(fclose(fdo) != 0) {
perror("Unable to close output file"); perror("Unable to close output file");
return 1; return 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment