summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile7
-rw-r--r--bsp/env/coreplexip-arty.h2
-rw-r--r--bsp/env/coreplexip-e31-arty/link.lds16
-rw-r--r--bsp/env/freedom-e300-hifive1/link.lds16
-rw-r--r--bsp/env/hifive1.h2
-rw-r--r--bsp/env/start.S10
-rw-r--r--bsp/libwrap/misc/write_hex.c4
m---------openocd0
-rwxr-xr-xregression.bash71
m---------riscv-gnu-toolchain0
-rw-r--r--software/coremark/.unsupported-boards6
-rw-r--r--software/coreplexip_welcome/.unsupported-boards2
-rw-r--r--software/double_tap_dontboot/.unsupported-boards3
-rw-r--r--software/global_interrupts/.unsupported-boards2
-rw-r--r--software/led_fade/.unsupported-boards3
-rw-r--r--software/local_interrupts/.unsupported-boards2
-rw-r--r--software/performance_counters/performance_counters.c24
17 files changed, 137 insertions, 33 deletions
diff --git a/Makefile b/Makefile
index 0c36f36..eedb007 100644
--- a/Makefile
+++ b/Makefile
@@ -14,6 +14,7 @@ endif
# Default target
BOARD ?= freedom-e300-hifive1
PROGRAM ?= demo_gpio
+GDB_PORT ?= 3333
# Variables the user probably shouldn't override.
builddir := work/build
@@ -190,7 +191,7 @@ PROGRAM_ELF = software/$(PROGRAM)/$(PROGRAM)
.PHONY: software_clean
software_clean:
- $(MAKE) -C $(PROGRAM_DIR) clean
+ $(MAKE) -C $(PROGRAM_DIR) BSP_BASE=$(abspath bsp) BOARD=$(BOARD) clean
.PHONY: software
software: software_clean
@@ -208,7 +209,7 @@ OPENOCDARGS += -f $(OPENOCDCFG)
GDB_UPLOAD_ARGS ?= --batch
GDB_UPLOAD_CMDS += -ex "set remotetimeout 240"
-GDB_UPLOAD_CMDS += -ex "target extended-remote localhost:3333"
+GDB_UPLOAD_CMDS += -ex "target extended-remote localhost:$(GDB_PORT)"
GDB_UPLOAD_CMDS += -ex "monitor reset halt"
GDB_UPLOAD_CMDS += -ex "monitor flash protect 0 64 last off"
GDB_UPLOAD_CMDS += -ex "load"
@@ -229,7 +230,7 @@ run_openocd:
$(RISCV_OPENOCD) $(OPENOCDARGS)
GDBCMDS += -ex "set remotetimeout 240"
-GDBCMDS += -ex "target extended-remote localhost:3333"
+GDBCMDS += -ex "target extended-remote localhost:$(GDB_PORT)"
run_gdb:
$(RISCV_GDB) $(PROGRAM_DIR)/$(PROGRAM) $(GDBARGS) $(GDBCMDS)
diff --git a/bsp/env/coreplexip-arty.h b/bsp/env/coreplexip-arty.h
index 161da7c..eedcaa5 100644
--- a/bsp/env/coreplexip-arty.h
+++ b/bsp/env/coreplexip-arty.h
@@ -97,6 +97,6 @@
#define RTC_FREQ 32768
-void write_hex(int fd, long int hex);
+void write_hex(int fd, unsigned long int hex);
#endif /* _SIFIVE_COREPLEXIP_ARTY_H */
diff --git a/bsp/env/coreplexip-e31-arty/link.lds b/bsp/env/coreplexip-e31-arty/link.lds
index 45a82d7..590c5b6 100644
--- a/bsp/env/coreplexip-e31-arty/link.lds
+++ b/bsp/env/coreplexip-e31-arty/link.lds
@@ -120,11 +120,11 @@ SECTIONS
{
*(.data .data.*)
*(.gnu.linkonce.d.*)
- } >ram AT>flash :ram_init
-
- .srodata :
- {
- PROVIDE( _gp = . + 0x800 );
+ . = ALIGN(8);
+ PROVIDE( __global_pointer$ = . + 0x800 );
+ *(.sdata .sdata.*)
+ *(.gnu.linkonce.s.*)
+ . = ALIGN(8);
*(.srodata.cst16)
*(.srodata.cst8)
*(.srodata.cst4)
@@ -132,12 +132,6 @@ SECTIONS
*(.srodata .srodata.*)
} >ram AT>flash :ram_init
- .sdata :
- {
- *(.sdata .sdata.*)
- *(.gnu.linkonce.s.*)
- } >ram AT>flash :ram_init
-
. = ALIGN(4);
PROVIDE( _edata = . );
PROVIDE( edata = . );
diff --git a/bsp/env/freedom-e300-hifive1/link.lds b/bsp/env/freedom-e300-hifive1/link.lds
index 90e5c8f..6b37141 100644
--- a/bsp/env/freedom-e300-hifive1/link.lds
+++ b/bsp/env/freedom-e300-hifive1/link.lds
@@ -120,11 +120,11 @@ SECTIONS
{
*(.data .data.*)
*(.gnu.linkonce.d.*)
- } >ram AT>flash :ram_init
-
- .srodata :
- {
- PROVIDE( _gp = . + 0x800 );
+ . = ALIGN(8);
+ PROVIDE( __global_pointer$ = . + 0x800 );
+ *(.sdata .sdata.*)
+ *(.gnu.linkonce.s.*)
+ . = ALIGN(8);
*(.srodata.cst16)
*(.srodata.cst8)
*(.srodata.cst4)
@@ -132,12 +132,6 @@ SECTIONS
*(.srodata .srodata.*)
} >ram AT>flash :ram_init
- .sdata :
- {
- *(.sdata .sdata.*)
- *(.gnu.linkonce.s.*)
- } >ram AT>flash :ram_init
-
. = ALIGN(4);
PROVIDE( _edata = . );
PROVIDE( edata = . );
diff --git a/bsp/env/hifive1.h b/bsp/env/hifive1.h
index b987847..0db2f0f 100644
--- a/bsp/env/hifive1.h
+++ b/bsp/env/hifive1.h
@@ -76,6 +76,6 @@
#define RTC_FREQ 32768
-void write_hex(int fd, long int hex);
+void write_hex(int fd, unsigned long int hex);
#endif /* _SIFIVE_HIFIVE1_H */
diff --git a/bsp/env/start.S b/bsp/env/start.S
index 9ec6c1c..e86105b 100644
--- a/bsp/env/start.S
+++ b/bsp/env/start.S
@@ -7,7 +7,10 @@
.type _start,@function
_start:
- la gp, _gp
+.option push
+.option norelax
+ la gp, __global_pointer$
+.option pop
la sp, _sp
/* Load data section */
@@ -52,7 +55,8 @@ _start:
/* argc = argv = 0 */
li a0, 0
li a1, 0
- call _init
call main
- call _fini
tail exit
+
+1:
+ j 1b
diff --git a/bsp/libwrap/misc/write_hex.c b/bsp/libwrap/misc/write_hex.c
index 96f832d..a35ad7a 100644
--- a/bsp/libwrap/misc/write_hex.c
+++ b/bsp/libwrap/misc/write_hex.c
@@ -4,13 +4,13 @@
#include <unistd.h>
#include "platform.h"
-void write_hex(int fd, long int hex)
+void write_hex(int fd, unsigned long int hex)
{
uint8_t ii;
uint8_t jj;
char towrite;
write(fd , "0x", 2);
- for (ii = sizeof(long int) * 2 ; ii > 0; ii--) {
+ for (ii = sizeof(unsigned long int) * 2 ; ii > 0; ii--) {
jj = ii - 1;
uint8_t digit = ((hex & (0xF << (jj*4))) >> (jj*4));
towrite = digit < 0xA ? ('0' + digit) : ('A' + (digit - 0xA));
diff --git a/openocd b/openocd
-Subproject 51ab5a0c8b1513e0bf2581173c569ec4505dde5
+Subproject 459b39ec67bbbe2ea0a192344c5236518da79c6
diff --git a/regression.bash b/regression.bash
new file mode 100755
index 0000000..da8bf10
--- /dev/null
+++ b/regression.bash
@@ -0,0 +1,71 @@
+#!/bin/bash
+
+unset board
+unset manual
+while [[ "$1" != "" ]]
+do
+ case "$1" in
+ "--board")
+ board="$2"
+ shift
+ shift
+ ;;
+ "--manual")
+ manual="true"
+ shift
+ ;;
+ esac
+done
+
+if [[ "$board" == "" ]]
+then
+ echo "Specify a --board to test" >&2
+ exit 1
+fi
+
+if [[ "$manual" == "true" ]]
+then
+ echo "You're running in manual test mode. Please connect a $board to continue..."
+ read -p "Press ENTER to continue"
+fi
+
+set -e
+
+find software -mindepth 1 -maxdepth 2 -type d | cut -d/ -f2 | while read program
+do
+ # Allow examples to specify the boards on which they won't run.
+ if test -f software/$program/.unsupported-boards
+ then
+ if grep -q $board software/$program/.unsupported-boards
+ then
+ continue
+ fi
+ fi
+
+ # Build the example.
+ make BOARD=$board PROGRAM=$program software
+
+ # We require user interaction in order to verify the tests succeed. If the
+ # user hasn't specified the manual flag then don't bother running the tests.
+ if [[ "$manual" == "true" ]]
+ then
+ echo "We're about to run $program on $board, waiting 10 seconds"
+ sleep 1s
+
+ echo "flashing $program"
+ make BOARD=$board PROGRAM=$program upload
+
+ echo "$program has been flashed to your $board, please test it. GDB will open in 2 seconds"
+ urxvt -hold -e make BOARD=$board PROGRAM=$program run_openocd &
+ sleep 2s
+ urxvt -hold -e make BOARD=$board PROGRAM=$program run_gdb
+
+ echo "Close the running OpenOCD"
+ wait
+ fi
+done
+
+if [[ "$manual" != "true" ]]
+then
+ echo "You haven't actually verified the tests run, please don't release!" >&2
+fi
diff --git a/riscv-gnu-toolchain b/riscv-gnu-toolchain
-Subproject 19ddd4d6f42bddaa29a76f926fea9ee5be17776
+Subproject f5fae1c27b2365da773816ddcd92f533867f28e
diff --git a/software/coremark/.unsupported-boards b/software/coremark/.unsupported-boards
new file mode 100644
index 0000000..9221334
--- /dev/null
+++ b/software/coremark/.unsupported-boards
@@ -0,0 +1,6 @@
+# We don't deliver the full coremark sources for license reasons, so this can't
+# run in regression.
+freedom-e300-hifive1
+freedom-e300-arty
+coreplexip-e31-arty
+coreplexip-e51-arty
diff --git a/software/coreplexip_welcome/.unsupported-boards b/software/coreplexip_welcome/.unsupported-boards
new file mode 100644
index 0000000..33cea3a
--- /dev/null
+++ b/software/coreplexip_welcome/.unsupported-boards
@@ -0,0 +1,2 @@
+freedom-e300-arty
+freedom-e300-hifive1
diff --git a/software/double_tap_dontboot/.unsupported-boards b/software/double_tap_dontboot/.unsupported-boards
new file mode 100644
index 0000000..4e93148
--- /dev/null
+++ b/software/double_tap_dontboot/.unsupported-boards
@@ -0,0 +1,3 @@
+coreplexip-e31-arty
+coreplexip-e51-arty
+
diff --git a/software/global_interrupts/.unsupported-boards b/software/global_interrupts/.unsupported-boards
new file mode 100644
index 0000000..33cea3a
--- /dev/null
+++ b/software/global_interrupts/.unsupported-boards
@@ -0,0 +1,2 @@
+freedom-e300-arty
+freedom-e300-hifive1
diff --git a/software/led_fade/.unsupported-boards b/software/led_fade/.unsupported-boards
new file mode 100644
index 0000000..4e93148
--- /dev/null
+++ b/software/led_fade/.unsupported-boards
@@ -0,0 +1,3 @@
+coreplexip-e31-arty
+coreplexip-e51-arty
+
diff --git a/software/local_interrupts/.unsupported-boards b/software/local_interrupts/.unsupported-boards
new file mode 100644
index 0000000..33cea3a
--- /dev/null
+++ b/software/local_interrupts/.unsupported-boards
@@ -0,0 +1,2 @@
+freedom-e300-arty
+freedom-e300-hifive1
diff --git a/software/performance_counters/performance_counters.c b/software/performance_counters/performance_counters.c
index e7c12a3..8094128 100644
--- a/software/performance_counters/performance_counters.c
+++ b/software/performance_counters/performance_counters.c
@@ -18,6 +18,15 @@
// rollover with this routine as suggested by the
// RISC-V Priviledged Architecture Specification.
+#if __riscv_xlen == 64
+#define rdmcycle(x) { \
+ uint64_t hi; \
+ __asm__ __volatile__ ("1:\n\t" \
+ "csrr %0, mcycle\n\t" \
+ : "=r" (hi)) ; \
+ *(x) = hi; \
+ }
+#else
#define rdmcycle(x) { \
uint32_t lo, hi, hi2; \
__asm__ __volatile__ ("1:\n\t" \
@@ -28,12 +37,22 @@
: "=r" (hi), "=r" (lo), "=r" (hi2)) ; \
*(x) = lo | ((uint64_t) hi << 32); \
}
+#endif
// The minstret counter is 64-bit counter, but
// Freedom E platforms use RV32, we must access it as
// 2 32-bit registers, same as for mcycle.
+#if __riscv_xlen == 64
+#define rdminstret(x) { \
+ uint64_t hi; \
+ __asm__ __volatile__ ("1:\n\t" \
+ "csrr %0, minstret\n\t" \
+ : "=r" (hi)) ; \
+ *(x) = hi; \
+ }
+#else
#define rdminstret(x) { \
uint32_t lo, hi, hi2; \
__asm__ __volatile__ ("1:\n\t" \
@@ -44,6 +63,7 @@
: "=r" (hi), "=r" (lo), "=r" (hi2)) ; \
*(x) = lo | ((uint64_t) hi << 32); \
}
+#endif
// Simple program to measure the performance of.
@@ -90,9 +110,11 @@ int main()
for (int ii = 0; ii < 3; ii++){
write_csr(mcycle, 0);
- write_csr(mcycleh, 0);
write_csr(minstret, 0);
+#if __riscv_xlen == 32
+ write_csr(mcycleh, 0);
write_csr(minstreth, 0);
+#endif
volatile int result = factorial (100);