diff options
| -rw-r--r-- | Makefile | 21 | ||||
| -rw-r--r-- | bsp/sifive-hifive1-revb/design.dts | 4 | ||||
| -rw-r--r-- | bsp/sifive-hifive1-revb/metal.lds | 2 | ||||
| -rw-r--r-- | bsp/sifive-hifive1-revb/settings.mk | 2 | ||||
| -rw-r--r-- | doc/sphinx/userguide/installing.rst | 9 | ||||
| -rwxr-xr-x | scripts/debug | 13 | ||||
| -rw-r--r-- | scripts/standalone.mk | 16 | ||||
| -rwxr-xr-x | scripts/upload | 17 | 
8 files changed, 72 insertions, 12 deletions
@@ -216,20 +216,21 @@ endif  endif  ############################################################# -# MEE Software Compilation +# CoreIP RTL Simulation Hex File Creation  ############################################################# -# Generation of $(PROGRAM_ELF) is handled by scripts/standalone.mk -# In this top level Makefile, just describe how to turn the elf into -# $(PROGRAM_HEX) -  ifeq ($(BSP),metal) + +# Use elf2hex if we're not using Segger J-Link OB (i.e. for coreip-rtl targets) +ifeq ($(SEGGER_JLINK_OB),)  $(PROGRAM_HEX): \  		scripts/elf2hex/install/bin/$(CROSS_COMPILE)-elf2hex \  		$(PROGRAM_ELF)  	$< --output $@ --input $(PROGRAM_ELF) --bit-width $(COREIP_MEM_WIDTH)  endif +endif +  #############################################################  # Legacy Software Compilation  ############################################################# @@ -263,11 +264,21 @@ endif  ifeq ($(BSP),metal) +ifneq ($(SEGGER_JLINK_OB),) +upload: $(PROGRAM_HEX) +	scripts/upload --hex $(PROGRAM_HEX) --jlink $(SEGGER_JLINK_EXE) +else  upload: $(PROGRAM_ELF)  	scripts/upload --elf $(PROGRAM_ELF) --openocd $(RISCV_OPENOCD) --gdb $(RISCV_GDB) --openocd-config bsp/$(TARGET)/openocd.cfg +endif +ifneq ($(SEGGER_JLINK_OB),) +debug: $(PROGRAM_ELF) +	scripts/debug --elf $(PROGRAM_ELF) --jlink $(SEGGER_JLINK_GDB_SERVER) --gdb $(RISCV_GDB) +else  debug: $(PROGRAM_ELF)  	scripts/debug --elf $(PROGRAM_ELF) --openocd $(RISCV_OPENOCD) --gdb $(RISCV_GDB) --openocd-config bsp/$(TARGET)/openocd.cfg +endif  else # BSP != metal diff --git a/bsp/sifive-hifive1-revb/design.dts b/bsp/sifive-hifive1-revb/design.dts index 5f1797d..6c7da04 100644 --- a/bsp/sifive-hifive1-revb/design.dts +++ b/bsp/sifive-hifive1-revb/design.dts @@ -8,7 +8,7 @@          chosen {                  stdout-path = "/soc/serial@10013000:115200"; -                metal,entry = <&spi0 0x100000>; +                metal,entry = <&spi0 0x10000>;          };          cpus { @@ -180,7 +180,7 @@                          compatible = "sifive,spi0";                          interrupt-parent = <&plic>;                          interrupts = <6>; -                        reg = <0x10014000 0x1000 0x20000000 0x20000000>; +                        reg = <0x10014000 0x1000 0x20000000 0x7A120>;                          reg-names = "control", "mem";                          clocks = <&hfclk>;                          pinmux = <&gpio0 0x0003C 0x0003C>; diff --git a/bsp/sifive-hifive1-revb/metal.lds b/bsp/sifive-hifive1-revb/metal.lds index fdd23c7..f7050c4 100644 --- a/bsp/sifive-hifive1-revb/metal.lds +++ b/bsp/sifive-hifive1-revb/metal.lds @@ -5,7 +5,7 @@ ENTRY(_enter)  MEMORY  {  	ram (wxa!ri) : ORIGIN = 0x80000000, LENGTH = 0x4000 -	flash (rxai!w) : ORIGIN = 0x20400000, LENGTH = 0x20000000 +	flash (rxai!w) : ORIGIN = 0x20010000, LENGTH = 0x6a120  }  PHDRS diff --git a/bsp/sifive-hifive1-revb/settings.mk b/bsp/sifive-hifive1-revb/settings.mk index d84238b..61e2b02 100644 --- a/bsp/sifive-hifive1-revb/settings.mk +++ b/bsp/sifive-hifive1-revb/settings.mk @@ -1,4 +1,4 @@  RISCV_ARCH = rv32imac  RISCV_ABI  = ilp32  RISCV_CMODEL = medlow -COREIP_MEM_WIDTH = 32 +SEGGER_JLINK_OB = 1 diff --git a/doc/sphinx/userguide/installing.rst b/doc/sphinx/userguide/installing.rst index 6e57425..b6f3a49 100644 --- a/doc/sphinx/userguide/installing.rst +++ b/doc/sphinx/userguide/installing.rst @@ -48,6 +48,15 @@ and unpack it to your desired location. Then, set the ``RISCV_PATH`` and     export RISCV_OPENOCD_PATH=/my/desired/location/openocd     export RISCV_PATH=/my/desired/location/riscv64-unknown-elf-gcc-<date>-<version> +Install Segger J-Link Software +------------------------------ + +Some targets supported by Freedom E SDK (like the SiFive HiFive1 Rev B) use Segger J-Link OB +for programming and debugging. If you intend to use these targets, install the Segger J-Link +Software and Documentation Pack for your machine: + +`Segger J-Link Software Downloads <https://www.segger.com/downloads/jlink#J-LinkSoftwareAndDocumentationPack>`_ +  Cloning the Repository  ---------------------- diff --git a/scripts/debug b/scripts/debug index d02c42c..87068c5 100755 --- a/scripts/debug +++ b/scripts/debug @@ -5,6 +5,7 @@ set -o pipefail  unset elf  unset cfg +unset jlink  unset openocd  unset gdb  while [[ "$1" != "" ]] @@ -13,13 +14,14 @@ do      in      --elf)                 elf="$2";     shift 2;;      --openocd)             openocd="$2"; shift 2;; +    --jlink)               jlink="$2";   shift 2;;      --openocd-config)      cfg="$2";     shift 2;;      --gdb)                 gdb="$2";     shift 2;;      *) echo "$0: Unknown argument $1";   exit 1;;      esac  done -if [[ "$elf" == "" ]] +if [ "$elf" == "" ]  then      echo "$0: --elf is required" >&2      exit 1 @@ -27,8 +29,17 @@ fi  export GDB_PORT=3333 +if [ "$jlink" != "" ] +then + +$jlink -device RISC-V -port $GDB_PORT & + +else +  $openocd -f $cfg & +fi +  $gdb $elf -ex "set remotetimeout 240" -ex "target extended-remote localhost:${GDB_PORT}"  kill %1 diff --git a/scripts/standalone.mk b/scripts/standalone.mk index e80e0c1..921d6a1 100644 --- a/scripts/standalone.mk +++ b/scripts/standalone.mk @@ -54,6 +54,7 @@ ifeq ($(RISCV_PATH),)  RISCV_GCC     := $(CROSS_COMPILE)-gcc  RISCV_GXX     := $(CROSS_COMPILE)-g++  RISCV_OBJDUMP := $(CROSS_COMPILE)-objdump +RISCV_OBJCOPY := $(CROSS_COMPILE)-objcopy  RISCV_GDB     := $(CROSS_COMPILE)-gdb  RISCV_AR      := $(CROSS_COMPILE)-ar  RISCV_SIZE    := $(CROSS_COMPILE)-size @@ -61,12 +62,16 @@ else  RISCV_GCC     := $(abspath $(RISCV_PATH)/bin/$(CROSS_COMPILE)-gcc)  RISCV_GXX     := $(abspath $(RISCV_PATH)/bin/$(CROSS_COMPILE)-g++)  RISCV_OBJDUMP := $(abspath $(RISCV_PATH)/bin/$(CROSS_COMPILE)-objdump) +RISCV_OBJCOPY := $(abspath $(RISCV_PATH)/bin/$(CROSS_COMPILE)-objcopy)  RISCV_GDB     := $(abspath $(RISCV_PATH)/bin/$(CROSS_COMPILE)-gdb)  RISCV_AR      := $(abspath $(RISCV_PATH)/bin/$(CROSS_COMPILE)-ar)  RISCV_SIZE    := $(abspath $(RISCV_PATH)/bin/$(CROSS_COMPILE)-size)  PATH          := $(abspath $(RISCV_PATH)/bin):$(PATH)  endif +SEGGER_JLINK_EXE := JLinkExe +SEGGER_JLINK_GDB_SERVER := JLinkGDBServer +  #############################################################  # Software  ############################################################# @@ -84,6 +89,9 @@ software: $(PROGRAM_ELF)  ifneq ($(COREIP_MEM_WIDTH),)  software: $(PROGRAM_HEX)  endif +ifneq ($(SEGGER_JLINK_OB),) +software: $(PROGRAM_HEX) +endif  PROGRAM_SRCS = $(wildcard $(SRC_DIR)/*.c) $(wildcard $(SRC_DIR)/*.h) $(wildcard $(SRC_DIR)/*.S) @@ -104,6 +112,14 @@ $(PROGRAM_ELF): \  	$(RISCV_SIZE) $@ +ifneq ($(SEGGER_JLINK_OB),) +# If we're using Segger J-Link OB, use objcopy to create an Intel hex file for programming +$(PROGRAM_HEX): \ +		$(RISCV_OBJCOPY) \ +		$(PROGRAM_ELF) +	$< -O ihex $(PROGRAM_ELF) $@ +endif +  .PHONY: clean-software  clean-software:  	$(MAKE) -C $(SRC_DIR) clean diff --git a/scripts/upload b/scripts/upload index 66e9ed8..a52fc0a 100755 --- a/scripts/upload +++ b/scripts/upload @@ -4,31 +4,44 @@ set -e  set -o pipefail  unset elf +unset hex  unset cfg  unset openocd +unset jlink  unset gdb  while [[ "$1" != "" ]]  do      case "$1"      in      --elf)                 elf="$2";     shift 2;; +    --hex)                 hex="$2";     shift 2;;      --openocd)             openocd="$2"; shift 2;;      --openocd-config)      cfg="$2";     shift 2;; +    --jlink)               jlink="$2";   shift 2;;      --gdb)                 gdb="$2";     shift 2;;      *) echo "$0: Unknown argument $1";   exit 1;;      esac  done -if [[ "$elf" == "" ]] +if [ "$elf" == "" -a "$hex" == "" ]  then -    echo "$0: --elf is required" >&2 +    echo "$0: --elf or --hex is required" >&2      exit 1  fi  export GDB_PORT=3333 +if [ "$jlink" != "" ] +then + +echo -e "loadfile $hex\nrnh\nexit" | $jlink -device FE310 -if JTAG -speed 4000 -jtagconf -1,-1 -autoconnect 1 + +else +  $openocd -f $cfg &  $gdb $elf --batch -ex "set remotetimeout 240" -ex "target extended-remote localhost:${GDB_PORT}" -ex "monitor reset halt" -ex "monitor flash protect 0 64 last off" -ex "load" -ex "monitor resume" -ex "monitor shutdown" -ex "quit"  kill %1 + +fi  | 
