diff --git a/boards/hifive1b/Makefile.include b/boards/hifive1b/Makefile.include index bf2e7c485a..5a385e615f 100644 --- a/boards/hifive1b/Makefile.include +++ b/boards/hifive1b/Makefile.include @@ -5,12 +5,23 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*))) # setup serial terminal include $(RIOTMAKE)/tools/serial.inc.mk -# setup JLink for flashing -# export JLINK := JLink -JLINK_DEVICE = FE310 -JLINK_IF = JTAG -FLASH_ADDR = 0x20010000 -include $(RIOTMAKE)/tools/jlink.inc.mk +# Set default programmer as jlink +PROGRAMMER ?= jlink + +ifeq (openocd,$(PROGRAMMER)) + DEBUG_ADAPTER = jlink + OPENOCD_TRANSPORT = jtag + OPENOCD_PRE_FLASH_CMDS += "-c flash protect 0 1 last off" + include $(RIOTMAKE)/tools/openocd.inc.mk +else ifeq (jlink,$(PROGRAMMER)) + # setup JLink for flashing + JLINK_DEVICE = FE310 + JLINK_IF = JTAG + FLASH_ADDR = 0x20010000 + include $(RIOTMAKE)/tools/jlink.inc.mk +else + $(error Programmer '$(PROGRAMMER)' not supported for board '$(BOARD)') +endif TESTRUNNER_RESET_DELAY = 1 $(call target-export-variables,test,TESTRUNNER_RESET_DELAY) diff --git a/boards/hifive1b/dist/openocd.cfg b/boards/hifive1b/dist/openocd.cfg new file mode 100644 index 0000000000..9a569fbbcc --- /dev/null +++ b/boards/hifive1b/dist/openocd.cfg @@ -0,0 +1,10 @@ +adapter speed 4000 + +set _CHIPNAME riscv +jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x20000913 + +set _TARGETNAME $_CHIPNAME.cpu +target create $_TARGETNAME.0 riscv -chain-position $_TARGETNAME +$_TARGETNAME.0 configure -work-area-phys 0x80000000 -work-area-size 0x4000 -work-area-backup 0 + +flash bank onboard_spi_flash fespi 0x20000000 0 0 0 $_TARGETNAME.0