From b3cf267705758a305a59b2d31e76e752d84a204c Mon Sep 17 00:00:00 2001
From: Nathaniel Graff <nathaniel.graff@sifive.com>
Date: Fri, 21 Jun 2019 14:42:20 -0700
Subject: Fix OpenOCD cfg and remove warnings

Fix OpenOCD config generator for hifive boards

Remove some warnings for FE310-compatible targets related to clocks and
the PRCI.

Signed-off-by: Nathaniel Graff <nathaniel.graff@sifive.com>
---
 bsp/freedom-e310-arty/metal-inline.h       |  2 +-
 bsp/freedom-e310-arty/metal.h              |  2 +-
 bsp/qemu-sifive-e31/metal-inline.h         |  2 +-
 bsp/qemu-sifive-e31/metal.h                |  2 +-
 bsp/qemu-sifive-s51/metal-inline.h         |  2 +-
 bsp/qemu-sifive-s51/metal.h                |  2 +-
 bsp/sifive-hifive-unleashed/metal-inline.h |  2 +-
 bsp/sifive-hifive-unleashed/metal.h        |  2 +-
 bsp/sifive-hifive-unleashed/openocd.cfg    | 10 +++++-----
 bsp/sifive-hifive1-revb/metal-inline.h     |  2 +-
 bsp/sifive-hifive1-revb/metal.h            |  2 +-
 bsp/sifive-hifive1/metal-inline.h          |  2 +-
 bsp/sifive-hifive1/metal.h                 |  2 +-
 bsp/sifive-hifive1/openocd.cfg             | 10 +++++-----
 bsp/update-targets.sh                      |  3 ++-
 15 files changed, 24 insertions(+), 23 deletions(-)

(limited to 'bsp')

diff --git a/bsp/freedom-e310-arty/metal-inline.h b/bsp/freedom-e310-arty/metal-inline.h
index 9210e60..2b02b7d 100644
--- a/bsp/freedom-e310-arty/metal-inline.h
+++ b/bsp/freedom-e310-arty/metal-inline.h
@@ -12,7 +12,7 @@
 
 
 /* --------------------- fixed_clock ------------ */
-extern inline unsigned long __metal_driver_fixed_clock_rate(struct metal_clock *clock);
+extern inline unsigned long __metal_driver_fixed_clock_rate(const struct metal_clock *clock);
 
 
 /* --------------------- fixed_factor_clock ------------ */
diff --git a/bsp/freedom-e310-arty/metal.h b/bsp/freedom-e310-arty/metal.h
index dbf2faf..753b3f5 100644
--- a/bsp/freedom-e310-arty/metal.h
+++ b/bsp/freedom-e310-arty/metal.h
@@ -116,7 +116,7 @@ struct __metal_driver_sifive_uart0 __metal_dt_serial_10013000;
 
 
 /* --------------------- fixed_clock ------------ */
-static inline unsigned long __metal_driver_fixed_clock_rate(struct metal_clock *clock)
+static inline unsigned long __metal_driver_fixed_clock_rate(const struct metal_clock *clock)
 {
 	if ((uintptr_t)clock == (uintptr_t)&__metal_dt_clock_0) {
 		return METAL_FIXED_CLOCK_0_CLOCK_FREQUENCY;
diff --git a/bsp/qemu-sifive-e31/metal-inline.h b/bsp/qemu-sifive-e31/metal-inline.h
index 61601c7..bf8dec5 100644
--- a/bsp/qemu-sifive-e31/metal-inline.h
+++ b/bsp/qemu-sifive-e31/metal-inline.h
@@ -12,7 +12,7 @@
 
 
 /* --------------------- fixed_clock ------------ */
-extern inline unsigned long __metal_driver_fixed_clock_rate(struct metal_clock *clock);
+extern inline unsigned long __metal_driver_fixed_clock_rate(const struct metal_clock *clock);
 
 
 /* --------------------- fixed_factor_clock ------------ */
diff --git a/bsp/qemu-sifive-e31/metal.h b/bsp/qemu-sifive-e31/metal.h
index 1ec4b0b..56c2ea8 100644
--- a/bsp/qemu-sifive-e31/metal.h
+++ b/bsp/qemu-sifive-e31/metal.h
@@ -146,7 +146,7 @@ struct __metal_driver_sifive_fe310_g000_prci __metal_dt_prci_10008000;
 
 
 /* --------------------- fixed_clock ------------ */
-static inline unsigned long __metal_driver_fixed_clock_rate(struct metal_clock *clock)
+static inline unsigned long __metal_driver_fixed_clock_rate(const struct metal_clock *clock)
 {
 	if ((uintptr_t)clock == (uintptr_t)&__metal_dt_clock_0) {
 		return METAL_FIXED_CLOCK_0_CLOCK_FREQUENCY;
diff --git a/bsp/qemu-sifive-s51/metal-inline.h b/bsp/qemu-sifive-s51/metal-inline.h
index 6ef4db2..3a23702 100644
--- a/bsp/qemu-sifive-s51/metal-inline.h
+++ b/bsp/qemu-sifive-s51/metal-inline.h
@@ -12,7 +12,7 @@
 
 
 /* --------------------- fixed_clock ------------ */
-extern inline unsigned long __metal_driver_fixed_clock_rate(struct metal_clock *clock);
+extern inline unsigned long __metal_driver_fixed_clock_rate(const struct metal_clock *clock);
 
 
 /* --------------------- fixed_factor_clock ------------ */
diff --git a/bsp/qemu-sifive-s51/metal.h b/bsp/qemu-sifive-s51/metal.h
index e61ca6e..8022370 100644
--- a/bsp/qemu-sifive-s51/metal.h
+++ b/bsp/qemu-sifive-s51/metal.h
@@ -146,7 +146,7 @@ struct __metal_driver_sifive_fe310_g000_prci __metal_dt_prci_10008000;
 
 
 /* --------------------- fixed_clock ------------ */
-static inline unsigned long __metal_driver_fixed_clock_rate(struct metal_clock *clock)
+static inline unsigned long __metal_driver_fixed_clock_rate(const struct metal_clock *clock)
 {
 	if ((uintptr_t)clock == (uintptr_t)&__metal_dt_clock_0) {
 		return METAL_FIXED_CLOCK_0_CLOCK_FREQUENCY;
diff --git a/bsp/sifive-hifive-unleashed/metal-inline.h b/bsp/sifive-hifive-unleashed/metal-inline.h
index 5911a7d..5a1c380 100644
--- a/bsp/sifive-hifive-unleashed/metal-inline.h
+++ b/bsp/sifive-hifive-unleashed/metal-inline.h
@@ -12,7 +12,7 @@
 
 
 /* --------------------- fixed_clock ------------ */
-extern inline unsigned long __metal_driver_fixed_clock_rate(struct metal_clock *clock);
+extern inline unsigned long __metal_driver_fixed_clock_rate(const struct metal_clock *clock);
 
 
 /* --------------------- fixed_factor_clock ------------ */
diff --git a/bsp/sifive-hifive-unleashed/metal.h b/bsp/sifive-hifive-unleashed/metal.h
index 8d63c92..f9e87d8 100644
--- a/bsp/sifive-hifive-unleashed/metal.h
+++ b/bsp/sifive-hifive-unleashed/metal.h
@@ -169,7 +169,7 @@ struct __metal_driver_sifive_fu540_c000_l2 __metal_dt_cache_controller_2010000;
 
 
 /* --------------------- fixed_clock ------------ */
-static inline unsigned long __metal_driver_fixed_clock_rate(struct metal_clock *clock)
+static inline unsigned long __metal_driver_fixed_clock_rate(const struct metal_clock *clock)
 {
 	if ((uintptr_t)clock == (uintptr_t)&__metal_dt_refclk) {
 		return METAL_FIXED_CLOCK__CLOCK_FREQUENCY;
diff --git a/bsp/sifive-hifive-unleashed/openocd.cfg b/bsp/sifive-hifive-unleashed/openocd.cfg
index cfebf1c..bddaaa8 100644
--- a/bsp/sifive-hifive-unleashed/openocd.cfg
+++ b/bsp/sifive-hifive-unleashed/openocd.cfg
@@ -3,12 +3,12 @@
 adapter_khz     10000
 
 interface ftdi
-ftdi_device_desc "Olimex OpenOCD JTAG ARM-USB-TINY-H"
-ftdi_vid_pid 0x15ba 0x002a
+ftdi_device_desc "Dual RS232-HS"
+ftdi_vid_pid 0x0403 0x6010
 
-ftdi_layout_init 0x0808 0x0a1b
-ftdi_layout_signal nSRST -oe 0x0200
-ftdi_layout_signal LED -data 0x0800
+ftdi_layout_init 0x0008 0x001b
+ftdi_layout_signal nSRST -oe 0x0020
+ftdi_layout_signal LED -data 0x0020
 
 set _CHIPNAME riscv
 jtag newtap $_CHIPNAME cpu -irlen 5
diff --git a/bsp/sifive-hifive1-revb/metal-inline.h b/bsp/sifive-hifive1-revb/metal-inline.h
index f8f03d0..8c0cd04 100644
--- a/bsp/sifive-hifive1-revb/metal-inline.h
+++ b/bsp/sifive-hifive1-revb/metal-inline.h
@@ -12,7 +12,7 @@
 
 
 /* --------------------- fixed_clock ------------ */
-extern inline unsigned long __metal_driver_fixed_clock_rate(struct metal_clock *clock);
+extern inline unsigned long __metal_driver_fixed_clock_rate(const struct metal_clock *clock);
 
 
 /* --------------------- fixed_factor_clock ------------ */
diff --git a/bsp/sifive-hifive1-revb/metal.h b/bsp/sifive-hifive1-revb/metal.h
index de9f454..f76dbd6 100644
--- a/bsp/sifive-hifive1-revb/metal.h
+++ b/bsp/sifive-hifive1-revb/metal.h
@@ -148,7 +148,7 @@ struct __metal_driver_sifive_fe310_g000_prci __metal_dt_prci_10008000;
 
 
 /* --------------------- fixed_clock ------------ */
-static inline unsigned long __metal_driver_fixed_clock_rate(struct metal_clock *clock)
+static inline unsigned long __metal_driver_fixed_clock_rate(const struct metal_clock *clock)
 {
 	if ((uintptr_t)clock == (uintptr_t)&__metal_dt_clock_0) {
 		return METAL_FIXED_CLOCK_0_CLOCK_FREQUENCY;
diff --git a/bsp/sifive-hifive1/metal-inline.h b/bsp/sifive-hifive1/metal-inline.h
index 0deb10b..f3d83c7 100644
--- a/bsp/sifive-hifive1/metal-inline.h
+++ b/bsp/sifive-hifive1/metal-inline.h
@@ -12,7 +12,7 @@
 
 
 /* --------------------- fixed_clock ------------ */
-extern inline unsigned long __metal_driver_fixed_clock_rate(struct metal_clock *clock);
+extern inline unsigned long __metal_driver_fixed_clock_rate(const struct metal_clock *clock);
 
 
 /* --------------------- fixed_factor_clock ------------ */
diff --git a/bsp/sifive-hifive1/metal.h b/bsp/sifive-hifive1/metal.h
index 792a88a..9589eba 100644
--- a/bsp/sifive-hifive1/metal.h
+++ b/bsp/sifive-hifive1/metal.h
@@ -146,7 +146,7 @@ struct __metal_driver_sifive_fe310_g000_prci __metal_dt_prci_10008000;
 
 
 /* --------------------- fixed_clock ------------ */
-static inline unsigned long __metal_driver_fixed_clock_rate(struct metal_clock *clock)
+static inline unsigned long __metal_driver_fixed_clock_rate(const struct metal_clock *clock)
 {
 	if ((uintptr_t)clock == (uintptr_t)&__metal_dt_clock_0) {
 		return METAL_FIXED_CLOCK_0_CLOCK_FREQUENCY;
diff --git a/bsp/sifive-hifive1/openocd.cfg b/bsp/sifive-hifive1/openocd.cfg
index 0a20b89..5835934 100644
--- a/bsp/sifive-hifive1/openocd.cfg
+++ b/bsp/sifive-hifive1/openocd.cfg
@@ -3,12 +3,12 @@
 adapter_khz     10000
 
 interface ftdi
-ftdi_device_desc "Olimex OpenOCD JTAG ARM-USB-TINY-H"
-ftdi_vid_pid 0x15ba 0x002a
+ftdi_device_desc "Dual RS232-HS"
+ftdi_vid_pid 0x0403 0x6010
 
-ftdi_layout_init 0x0808 0x0a1b
-ftdi_layout_signal nSRST -oe 0x0200
-ftdi_layout_signal LED -data 0x0800
+ftdi_layout_init 0x0008 0x001b
+ftdi_layout_signal nSRST -oe 0x0020
+ftdi_layout_signal LED -data 0x0020
 
 set _CHIPNAME riscv
 jtag newtap $_CHIPNAME cpu -irlen 5
diff --git a/bsp/update-targets.sh b/bsp/update-targets.sh
index 81b48a3..70c1a67 100755
--- a/bsp/update-targets.sh
+++ b/bsp/update-targets.sh
@@ -116,7 +116,8 @@ update_target() {
 
     if [[ "$TARGET_TYPE" =~ "arty" || "$TARGET_TYPE" =~ "hifive" ]] ; then
         if [ `grep -c "jlink" $TARGET/$SETTINGS_FILENAME` -ne 1 ] ; then
-            $OPENOCDCFG_GENERATOR -d $TARGET/$DTB_FILENAME -o $TARGET/$OPENOCDCFG_FILENAME || warn "Failed to produce $TARGET/$OPENOCDCFG_FILENAME"
+            echo "generating openocd.cfg"
+            $OPENOCDCFG_GENERATOR -d $TARGET/$DTB_FILENAME -b $TARGET_TYPE -o $TARGET/$OPENOCDCFG_FILENAME || warn "Failed to produce $TARGET/$OPENOCDCFG_FILENAME"
         fi
     fi
 
-- 
cgit v1.2.3