OpenCores
URL https://opencores.org/ocsvn/potato/potato/trunk

Subversion Repositories potato

[/] [potato/] [trunk/] [scripts/] [extract_hex.sh] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 skordal
#!/bin/bash
2
# The Potato Processor - A simple processor for FPGAs
3
# (c) Kristian Klomsten Skordal 2014 - 2015 <kristian.skordal@wafflemail.net>
4 3 skordal
# Report bugs and issues on <http://opencores.org/project,potato,bugtracker>
5 2 skordal
 
6
# This script extracts the code and data sections from executables and
7
# produces hex files that can be used to initialize the instruction and
8
# data memories in the testbench.
9
 
10
if [ -z "$1" -o -z "$2" -o -z "$3" ]; then
11
        echo "exctract_hex <input elf file> <imem hex file> <dmem hex file>"
12
        exit 1
13
fi
14
 
15
if [ -z "$TOOLCHAIN_PREFIX" ]; then
16
        TOOLCHAIN_PREFIX=riscv64-unknown-elf
17
fi;
18
 
19
$TOOLCHAIN_PREFIX-objdump -d -w $1 | sed '1,5d' | awk '!/:$/ { print $2; }' | sed '/^$/d' > $2; \
20
test -z "$($TOOLCHAIN_PREFIX-readelf -l $1 | grep .data)" || \
21
        $TOOLCHAIN_PREFIX-objdump -s -j .data $1 | sed '1,4d' | \
22
        awk '!/:$/ { for (i = 2; i < 6; i++) print $i; }' | sed '/^$/d' > $3;
23
 
24
exit 0
25
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.