CPU did not reset


#1

I’m trying to run the example programs on my new HiFive 1 rev B board but neither freedom studio nor the freedom-e-sdk methods work. Compilation is always successful but it seems the board fails somehow…

This is what the sdk gives me:

$ make PROGRAM=sifive-welcome TARGET=sifive-hifive1-revb upload
scripts/upload --hex /redacted/sifive-welcome.hex --jlink JLinkExe
SEGGER J-Link Commander V6.44h (Compiled May  3 2019 17:40:41)
DLL version V6.44h, compiled May  3 2019 17:40:32

Connecting to J-Link via USB...O.K.
Firmware: J-Link OB-K22-SiFive compiled Mar 15 2019 12:47:14
Hardware version: V1.00
S/N: 979000164
VTref=3.300V
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
  Stat: 0
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 BPs: 8
Support set/clr HW BPs while running: No
RISC-V identified.
Downloading file [redacted/sifive-welcome.hex]...
J-Link: Flash download: Flash download: No dirty areas found in flash cache
O.K.
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
  Stat: 0
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
HW BPs: 8
Support set/clr HW BPs while running: No

****** Error: Timeout while waiting for core to halt after reset and halt request

****** Error: CPU is not halted

I also tried the same using the studio which also fails. One difference is that with the studio my board blinks the red LED once a second after the upload. I suspect this means some sort of error.

Is the board faulty?


(Bruce Hoult) #2

Looks like it worked to me.

Try in one terminal window:

sudo stty -F /dev/ttyACM0 115200 igncr
sudo cat /dev/ttyACM0

And in another window:

make PROGRAM=hello TARGET=sifive-hifive1-revb software
make PROGRAM=hello TARGET=sifive-hifive1-revb upload

You should see the “cat” window output something like:

Bench Clock Reset Complete

ATE0--> Send Flag error: #0 #0 #0 #0 AT+BLEINIT=0-->AT+BLEINIT=0
OK
AT+CWMODE=0-->AT+CWMODE=0
OK

Hello, World!

If you temporarily modify software/hello/hello.c to say …

#include <stdio.h>

int main() {
    printf("Hello, World!\n");
    for (int i=0; i<10; ++i) printf("Line %d\n", i);
}

… and then repeat the build and upload commands then you should see instead …

Bench Clock Reset Complete

ATE0--> Send Flag error: #0 #0 #0 #0 AT+BLEINIT=0-->AT+BLEINIT=0
OK
AT+CWMODE=0-->AT+CWMODE=0
OK

Hello, World!
Line 0
Line 1
Line 2
Line 3
Line 4
Line 5
Line 6
Line 7
Line 8
Line 9

#3

Hmm so the hello world program worked ok. I then tried the sifive-welcome one expecting the LED to blink and it didn’t and printed:

At least one of LEDs is null.

Is it just some LED mapping issue in the source code?


(Bruce Hoult) #4

Yes, that definitely looks like a bug in either the sifive-welcome program or the metal library or RevB BSP. I’ll get someone to look at it.

The version preloaded on my board worked fine.

Also, the Getting Started doc shows a question being printed “Are the LEDs Changing [y/n]” and waits for a “y” response. This didn’t happen in the preloaded program and I see that feature is not present in the sifive-welcome source code. It was in the led_fade program in the v1_0 freedom-e-sdk. Unfortunate that got out of sync.


(Màrius Montón) #5

I can confirm the same problem with all other examples and rev B.

Hope you fix the issue quickly.


(Bruce Hoult) #6

I’m not sure what you mean by “all other examples”. As far as I can see only “local-interrupt” could be affected by this. It’s not going to do much anyway, as it’s designed to run on FPGA evaluation boards which have a number of push-buttons.

Not all the programs distributed in freedom-e-sdk are applicable to the HiFive1 RevB.

At least the following work for me:

dhrystone (after commenting out the scanf() in dhry_1.c)
empty
example-itim
example-pmp
example-spi
hello
return-fail
return-pass

Note 1: I don’t think there is any way to get or respond to a return value from main() on the HiFive1 RevB, so those examples are a bit useless.

Note 2: example-pmp and example-spi leave the board in a state where J-Link is unable to download a new program. To recover, press the reset button, wait for the LED to flash green, press reset again, and watch for the LED to repeatedly flash red. You can then download a new program. This procedure doesn’t seem to be documented in the Getting Started. It was in the original HiFive1 Getting Started document.


(Màrius Montón) #7

Sorry, I should have specified better what examples I tried.
For me “sifive-welcome” is not working and all other examples are showing the error mentioned in the first post when programming.


(Bruce Hoult) #8

That doesn’t seem to be an actual error, or at least it’s not important. The program is successfully downloaded to the board.

Look at a Linux kernel’s boot messages sometime – errors and errors and errors. Most of them just mean one thing didn’t work (maybe that PC doesn’t have some particular hardware) so then it tries something else, or disables one feature.