Added read binary targets

This commit is contained in:
lcbcFoo 2018-03-11 13:22:03 -03:00
parent 6f2a907580
commit 0adc8f6131
3 changed files with 5093 additions and 1 deletions

View file

@ -51,6 +51,22 @@ reonv_crt0.o : reonv_crt0.S
%.bin : %.hex
${CROSS}$(OBJCOPY) $(OBJCPFLAGS) $< $@
%.x86 : %.c
gcc $< -o $@
# Make binaries readable
%.read : %.* ./tools/to_text.x86
./tools/to_text.x86 $< $@
# Copy grmon-dump.bin from design directory
copy_dump : ../designs/$(DESIGN)/grmon-dump.bin
cp ../designs/$(DESIGN)/grmon-dump.bin .
# Read dump from grmon
read_dump : copy_dump ./tools/to_text.x86
./tools/to_text.x86 grmon-dump.bin grmon-dump.read
rm grmon-dump.bin ./tools/*.x86 -f
################################################################################
#
# Boot Code
@ -67,4 +83,4 @@ ahbrom : ../bin/ahbrom.c
gcc ../bin/ahbrom.c -o ahbrom
clean:
rm -rf ahbrom* *.hex *.inv *.bin *.o *.log *.jou *.str acstone/*.out *.out *.read
rm -rf ahbrom* tools/*.x86 *.hex *.inv *.convert *.bin *.o *log *.jou *.str acstone/*.out *.out *.read

5010
riscv/tools/iu3.original.vhd Normal file

File diff suppressed because it is too large Load diff

66
riscv/tools/to_text.c Normal file
View file

@ -0,0 +1,66 @@
/*
* This file is part of the ReonV distribution (https://github.com/lcbcFoo/ReonV).
* Copyright (c) 2018 to Lucas C. B. Castro.
*
* 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
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* Author: Lucas C. B. Castro
* Description: Reads a binary file and converts its content to readable
* hexadecimal
*/
#include <stdio.h>
#include <stdint.h>
int main(int argc, char** argv){
char word;
char res[8];
uint8_t i = 0;
FILE* input;
FILE* output;
if(argc != 3){
printf("Usage: ./<program name> <input bin file> <output readable hex file>\n");
return 1;
}
input = fopen(argv[1], "rb");
output = fopen(argv[2], "w");
if(input == NULL){
printf("Error opening input!\n");
return 1;
}
if(output == NULL){
fclose(input);
printf("Error opening output!\n");
return 1;
}
while(fread(&word, sizeof(unsigned char), 1, input)){
sprintf(res, "%02X", (unsigned char) word & 0xff);
fwrite(&res, sizeof(unsigned char), 2, output);
i++;
if(i == 4){
fwrite("\n", sizeof(char), 1, output);
i = 0;
}
}
fclose(input);
fclose(output);
return 0;
}