Uploaded Code is Not Being Implemented to HiFive Rev B Controller Properly

To whom it may concern,

I am using the HiFive Rev B Controller as a main component in a Lab Course, so I have been trying to solve this issue day in and day out. I am running projects in PlatformIO with JLink and my programs are in C. My first two projects worked nice, but while I was working on my next project, I accidentally got the board into “bootloader mode” or a specific mode by accidentally pressing a series of RESET and WAKE buttons, believing that I was resetting the board. However, I should have known that this was not a good idea. I uploaded my project code into the board during this time, and it seems that the board is reading locations wrongly and my JLink won’t even recognize the FE310. I have pasted below the readings of the upload. So far, no matter what, I cannot get my controller to recognize my GPIO assignments for this project and only remembers the last pin’s settings. I also realized that if I upload my code (which is supposed to simulate a simple red, yellow, and green LED annunciator), and then unplug my HiFive Board, it will reset for about 1-2 seconds and illuminate my LED’s, but then they turn off and the board refuses to do anything. My previous projects will not work now.

I wish to reset my HiFive Rev B Board to it’s factory default state. Is this possible and can anyone assist me with this. I would need decently detailed steps, since this is my first experience with programming and controllers. I am using Windows 10, Visual Studio Code, PlatformIO, with a HiFive Rev B (FE310) Board.

Terminal After Upload

Executing task in folder Lab3 Redo: C:\Users\Kyle.platformio\penv\Scripts\platformio.exe run --target upload --environment hifive1-revb

Processing hifive1-revb (platform: sifive; board: hifive1-revb; framework: freedom-e-sdk)

Verbose mode can be enabled via -v, --verbose option
CONFIGURATION: https://docs.platformio.org/page/boards/sifive/hifive1-revb.html
PLATFORM: SiFive (4.0.0) > HiFive1 Rev B
HARDWARE: FE310 320MHz, 16KB RAM, 16MB Flash
DEBUG: Current (jlink) On-board (jlink, renode)

  • framework-freedom-e-sdk 2.20050003.200818 (2005.0.3)
  • tool-jlink 1.68801.0 (6.88.1)
  • tool-openocd-riscv 2.1000.20190927 (10.0)
  • toolchain-riscv 1.80300.190927 (8.3.0)
    LDF: Library Dependency Finder → http://bit.ly/configure-pio-ldf
    LDF Modes: Finder ~ chain, Compatibility ~ soft
    Found 0 compatible libraries
    Scanning dependencies…
    No dependencies
    Building in release mode
    Checking size .pio\build\hifive1-revb\firmware.elf
    Advanced Memory Usage is available via “PlatformIO Home > Project Inspect”
    RAM: [=== ] 27.2% (used 4460 bytes from 16384 bytes)
    Flash: [ ] 0.1% (used 11150 bytes from 16777216 bytes)
    Configuring upload protocol…
    AVAILABLE: jlink
    CURRENT: upload_protocol = jlink
    Uploading .pio\build\hifive1-revb\firmware.hex
    SEGGER J-Link Commander V6.88b (Compiled Nov 27 2020 15:45:43)
    DLL version V6.88b, compiled Nov 27 2020 15:44:11

J-Link Command File read successfully.
Processing script file…

J-Link connection not established yet but required for command.
Connecting to J-Link via USB…O.K.
Firmware: J-Link OB-K22-SiFive compiled Mar 3 2021 14:13:05
Hardware version: V1.00
S/N: 979014988
Target connection not established yet but required for command.
Device “FE310” selected.

Connecting to target via JTAG
ConfigTargetSettings() start
ConfigTargetSettings() end
TotalIRLen = 5, IRPrint = 0x01
JTAG chain detection found 1 devices:
#0 Id: 0x20000913, IRLen: 05, Unknown device
Debug architecture:
RISC-V debug: 0.13
AddrBits: 7
DataBits: 32
IdleClks: 5
Memory access:
Via system bus: No
Via ProgBuf: Yes (16 ProgBuf entries)
DataBuf: 1 entries
autoexec[0] implemented: Yes
Detected: RV32 core
CSR access via abs. commands: No
Temp. halted CPU for NumHWBP detection
HW instruction/data BPs: 8
Support set/clr BPs while running: No
HW data BPs trigger before execution of inst
RISC-V identified.
pc = 20010D46 sp = 80000940 ra = 20010D24
gp = 80000C88 tp = 800004D0 fp = 00000800
t0 = 0200BFF8 t1 = 05ADFECC t2 = 05AE0849
t3 = 00000000 t4 = 00000000 t5 = 00000000 t6 = 00000000
a0 = 000000C8 a1 = 00000001 a2 = 20010314 a3 = FFFFFFFF
a4 = 00200000 a5 = 00000000 a6 = 0000001F a7 = 00000000
s1 = 02000080 s2 = 02000080 s3 = 00000000 s4 = 00000000
s5 = 00000000 s6 = 00000000 s7 = 00000000 s8 = 00000000
s9 = 00000000 s10 = 00000000 s11 = 00000000

Downloading file [.pio\build\hifive1-revb\firmware.hex]…
Comparing flash [100%] Done.
J-Link: Flash download: Bank 0 @ 0x20000000: Skipped. Contents already match

Reset delay: 0 ms
Reset type Normal: Resets core & peripherals using bit in debug register.
RISC-V: Performing reset via

Script processing completed.

==================================================================== [SUCCESS] Took 5.63 seconds ====================================================================

Terminal will be reused by tasks, press any key to close it.

Hi Kyle,

There is a recovery procedure described in Section 9.1 of the Getting Started Guide:

From what you describe, we think if you program a working hex file to the board this should make your board operational again.

Please let us know if it resolves the problem.


Thank you for your time and assistance! I understand everything up to when I am in boot mode. I am not really quite sure what you mean by “program a working hex file to the board”, are you able to provide some details on how I may do this or what I need to learn to be able to do this?

Hi Kyle,

Sorry - we just meant to program it with the “drag and drop” capability. With the LED blinking red, do you see the board mounted in Windows as a drive? If so, you can just copy a working hex file (a previously built program that you know works) to the drive and it will program to the board.

Unfortunately I can’t attach a hex file in the forums. I see you aren’t using FreedomStudio, but if you were, a canned example like SiFiveWelcome should work. This prints a welcome message to the serial port and will rotate colors on the LED.