aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMegan Wachs <megan@sifive.com>2017-04-17 11:34:33 -0700
committerMegan Wachs <megan@sifive.com>2017-04-17 11:34:33 -0700
commiteca66b135bbbc4fb804ac49a93fb2bf70f6e739f (patch)
tree9e5b8001bccf0a85a1792ab3479734aadc5f0e57
parentd76b30df333659baf81b8411c7144378b735062a (diff)
parent3429eb68637ff9e25d678d7e2b5f636ab409543c (diff)
downloadriscv-tests-eca66b135bbbc4fb804ac49a93fb2bf70f6e739f.zip
riscv-tests-eca66b135bbbc4fb804ac49a93fb2bf70f6e739f.tar.gz
riscv-tests-eca66b135bbbc4fb804ac49a93fb2bf70f6e739f.tar.bz2
Merge remote-tracking branch 'origin/newprogram' into debug-0.13
-rwxr-xr-xdebug/programs/entry.S15
-rw-r--r--debug/programs/mprv.S4
-rw-r--r--debug/targets.py4
-rw-r--r--debug/targets/HiFive1/openocd.cfg2
-rw-r--r--debug/targets/freedom-e300-sim/openocd.cfg5
-rw-r--r--debug/targets/freedom-e300/openocd.cfg2
-rw-r--r--debug/targets/freedom-u500-sim/openocd.cfg6
-rw-r--r--debug/targets/freedom-u500/openocd.cfg2
-rw-r--r--debug/testlib.py20
9 files changed, 42 insertions, 18 deletions
diff --git a/debug/programs/entry.S b/debug/programs/entry.S
index e021860..c9e319c 100755
--- a/debug/programs/entry.S
+++ b/debug/programs/entry.S
@@ -30,8 +30,23 @@ handle_reset:
la t0, trap_entry
csrw mtvec, t0
csrwi mstatus, 0
+
+ // make sure these registers exist by seeing if either S or U bits
+ // are set before attempting to zero them out.
+ csrr t1, misa
+ addi t2, x0, 1
+ slli t2, t2, 20 // U_EXTENSION
+ and t2, t1, t2
+ bne x0, t2, 1f
+ addi t2, x0, 1
+ slli t2, t2, 18 // S_EXTENSION
+ and t2, t1, t2
+ bne x0, t2, 1f
+ j 2f
+1:
csrwi mideleg, 0
csrwi medeleg, 0
+2:
csrwi mie, 0
# initialize global pointer
diff --git a/debug/programs/mprv.S b/debug/programs/mprv.S
index 574f32e..cc1ca54 100644
--- a/debug/programs/mprv.S
+++ b/debug/programs/mprv.S
@@ -13,9 +13,9 @@ main:
# update mstatus
csrr t1, CSR_MSTATUS
#if XLEN == 32
- li t0, (MSTATUS_MPRV | (VM_SV32 << 24))
+ li t0, (MSTATUS_MPRV | (SPTBR_MODE_SV32 << 24))
#else
- li t0, (MSTATUS_MPRV | (VM_SV39 << 24))
+ li t0, (MSTATUS_MPRV | (SPTBR_MODE_SV39 << 24))
#endif
#li t0, ((VM_SV39 << 24))
or t1, t0, t1
diff --git a/debug/targets.py b/debug/targets.py
index 5ac62a8..f2728d1 100644
--- a/debug/targets.py
+++ b/debug/targets.py
@@ -100,7 +100,7 @@ class HiFive1Target(FreedomE300Target):
class FreedomE300SimTarget(Target):
name = "freedom-e300-sim"
xlen = 32
- timeout_sec = 240
+ timeout_sec = 6000
ram = 0x80000000
ram_size = 256 * 1024 * 1024
instruction_hardware_breakpoint_count = 2
@@ -120,7 +120,7 @@ class FreedomU500Target(Target):
class FreedomU500SimTarget(Target):
name = "freedom-u500-sim"
xlen = 64
- timeout_sec = 240
+ timeout_sec = 6000
ram = 0x80000000
ram_size = 256 * 1024 * 1024
instruction_hardware_breakpoint_count = 2
diff --git a/debug/targets/HiFive1/openocd.cfg b/debug/targets/HiFive1/openocd.cfg
index d2c2879..72a5446 100644
--- a/debug/targets/HiFive1/openocd.cfg
+++ b/debug/targets/HiFive1/openocd.cfg
@@ -14,7 +14,7 @@ jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x10e31913
set _TARGETNAME $_CHIPNAME.cpu
target create $_TARGETNAME riscv -chain-position $_TARGETNAME
-$_TARGETNAME configure -work-area-phys 0x80000000 -work-area-size 8096 -work-area-backup 1
+$_TARGETNAME configure -work-area-phys 0x80000000 -work-area-size 8096 -work-area-backup 1 -rtos riscv
flash bank my_first_flash fespi 0x20000000 0 0 0 $_TARGETNAME
init
diff --git a/debug/targets/freedom-e300-sim/openocd.cfg b/debug/targets/freedom-e300-sim/openocd.cfg
index 0b80885..fcb8451 100644
--- a/debug/targets/freedom-e300-sim/openocd.cfg
+++ b/debug/targets/freedom-e300-sim/openocd.cfg
@@ -2,13 +2,14 @@ adapter_khz 10000
source [find interface/jtag_vpi.cfg]
jtag_vpi_set_port $::env(JTAG_VPI_PORT)
+#jtag_vpi_set_port 34448
set _CHIPNAME riscv
jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x10e31913
set _TARGETNAME $_CHIPNAME.cpu
-target create $_TARGETNAME riscv -chain-position $_TARGETNAME
+target create $_TARGETNAME riscv -chain-position $_TARGETNAME -rtos riscv
init
-
halt
+echo "OK GO NOW"
diff --git a/debug/targets/freedom-e300/openocd.cfg b/debug/targets/freedom-e300/openocd.cfg
index 0596b15..5824b77 100644
--- a/debug/targets/freedom-e300/openocd.cfg
+++ b/debug/targets/freedom-e300/openocd.cfg
@@ -6,7 +6,7 @@ set _CHIPNAME riscv
jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x10e31913
set _TARGETNAME $_CHIPNAME.cpu
-target create $_TARGETNAME riscv -chain-position $_TARGETNAME
+target create $_TARGETNAME riscv -chain-position $_TARGETNAME -rtos riscv
gdb_report_data_abort enable
diff --git a/debug/targets/freedom-u500-sim/openocd.cfg b/debug/targets/freedom-u500-sim/openocd.cfg
index 0b80885..0ce11d8 100644
--- a/debug/targets/freedom-u500-sim/openocd.cfg
+++ b/debug/targets/freedom-u500-sim/openocd.cfg
@@ -1,14 +1,16 @@
adapter_khz 10000
source [find interface/jtag_vpi.cfg]
-jtag_vpi_set_port $::env(JTAG_VPI_PORT)
+#jtag_vpi_set_port $::env(JTAG_VPI_PORT)
+jtag_vpi_set_port 46401
set _CHIPNAME riscv
jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x10e31913
set _TARGETNAME $_CHIPNAME.cpu
-target create $_TARGETNAME riscv -chain-position $_TARGETNAME
+target create $_TARGETNAME riscv -chain-position $_TARGETNAME -rtos riscv
init
halt
+echo "OK GO NOW"
diff --git a/debug/targets/freedom-u500/openocd.cfg b/debug/targets/freedom-u500/openocd.cfg
index d448989..3e3bcad 100644
--- a/debug/targets/freedom-u500/openocd.cfg
+++ b/debug/targets/freedom-u500/openocd.cfg
@@ -6,7 +6,7 @@ set _CHIPNAME riscv
jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x10e31913
set _TARGETNAME $_CHIPNAME.cpu
-target create $_TARGETNAME riscv -chain-position $_TARGETNAME
+target create $_TARGETNAME riscv -chain-position $_TARGETNAME -rtos riscv
init
diff --git a/debug/testlib.py b/debug/testlib.py
index 3927722..71bd609 100644
--- a/debug/testlib.py
+++ b/debug/testlib.py
@@ -19,8 +19,14 @@ def find_file(path):
return None
def compile(args, xlen=32): # pylint: disable=redefined-builtin
- cc = os.path.expandvars("$RISCV/bin/riscv%d-unknown-elf-gcc" % xlen)
+ cc = os.path.expandvars("$RISCV/bin/riscv64-unknown-elf-gcc")
cmd = [cc, "-g"]
+ if (xlen == 32):
+ cmd.append("-march=rv32imac")
+ cmd.append("-mabi=ilp32")
+ else:
+ cmd.append("-march=rv64imac")
+ cmd.append("-mabi=lp64")
for arg in args:
found = find_file(arg)
if found:
@@ -28,7 +34,7 @@ def compile(args, xlen=32): # pylint: disable=redefined-builtin
else:
cmd.append(arg)
process = subprocess.Popen(cmd, stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
+ stderr=subprocess.PIPE)
stdout, stderr = process.communicate()
if process.returncode:
print
@@ -185,7 +191,7 @@ class Openocd(object):
messaged = False
while True:
log = open(Openocd.logname).read()
- if "Examined RISCV core" in log:
+ if "OK GO NOW" in log:
break
if not self.process.poll() is None:
raise Exception(
@@ -222,7 +228,7 @@ class Openocd(object):
elif matches:
[match] = matches
return int(match.group('port'))
- time.sleep(0.1)
+ time.sleep(1)
raise Exception("Timed out waiting for gdb server to obtain port.")
def __del__(self):
@@ -280,7 +286,7 @@ class Gdb(object):
"""Wait for prompt."""
self.child.expect(r"\(gdb\)")
- def command(self, command, timeout=-1):
+ def command(self, command, timeout=6000):
self.child.sendline(command)
self.child.expect("\n", timeout=timeout)
self.child.expect(r"\(gdb\)", timeout=timeout)
@@ -297,7 +303,7 @@ class Gdb(object):
def interrupt(self):
self.child.send("\003")
- self.child.expect(r"\(gdb\)", timeout=60)
+ self.child.expect(r"\(gdb\)", timeout=6000)
return self.child.before.strip()
def x(self, address, size='w'):
@@ -330,7 +336,7 @@ class Gdb(object):
return output
def load(self):
- output = self.command("load", timeout=60)
+ output = self.command("load", timeout=6000)
assert "failed" not in output
assert "Transfer rate" in output