Merge remote-tracking branch 'origin/newprogram' into debug-0.13
authorMegan Wachs <megan@sifive.com>
Mon, 17 Apr 2017 18:34:33 +0000 (11:34 -0700)
committerMegan Wachs <megan@sifive.com>
Mon, 17 Apr 2017 18:34:33 +0000 (11:34 -0700)
debug/programs/entry.S
debug/programs/mprv.S
debug/targets.py
debug/targets/HiFive1/openocd.cfg
debug/targets/freedom-e300-sim/openocd.cfg
debug/targets/freedom-e300/openocd.cfg
debug/targets/freedom-u500-sim/openocd.cfg
debug/targets/freedom-u500/openocd.cfg
debug/testlib.py

index e021860f58c38b85b703e6992aa6488f01e7aaed..c9e319ccc0549b31d4ef148bfc2ca8c62e15556d 100755 (executable)
@@ -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
index 574f32e62a562a69732dd74af4903f6bf6baa841..cc1ca54b5da24216ea2137f3831a2ef942c0a3d4 100644 (file)
@@ -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
index 5ac62a83de518f934f89aca4ef7733d38ad53861..f2728d1aed30db7ff7cdecf1f100e026f06d1577 100644 (file)
@@ -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
index d2c2879358598def797d7766d3c581c655796f3c..72a54469d8664b936337d62c8b9eb9ff642d84ab 100644 (file)
@@ -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
index 0b808858a410a53f876d02fec4a5fc42c52e42e2..fcb8451daa505982eab588e9196b2cc118aecb26 100644 (file)
@@ -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"
index 0596b15cb5f31cefb2d2857493cfaa3a731150c2..5824b7724a995c180d0f156d3bf92ee00be686a8 100644 (file)
@@ -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
 
index 0b808858a410a53f876d02fec4a5fc42c52e42e2..0ce11d80eb4f96323b9237e99ade74a9ee223a27 100644 (file)
@@ -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"
index d448989243ecc7d893ed4eca399eb2d62b737c76..3e3bcad62a9a342cbc75174a4444e1b387a6fac4 100644 (file)
@@ -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
 
index 392772291f2ffa633b38b9d462dcec1005a59941..71bd60966abdab6cb5ab8298de91e49db3b67418 100644 (file)
@@ -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