HiFive Unleased stuck in ROM1


#1

Hello,

I can’t seem to boot Linux on my HiFive Unleashed board. It is stuck in a loop in ROM1 (somewhere in 0x1_0000 address range) when I connect to the board with openocd. I tried recusing image from SD card (MSEL = 1011) but no luck. Any thoughts ?

regards,
-tf


(Jim Wilson) #2

If you are trying to boot the normal way, then with the power switch on the left, all switches need to be in the left position. It isn’t clear why you are trying MSEL = 1011 as that isn’t a standard way to boot. The position of the MSEL switches needed for normal operation is mentioned in the HiFive Unleashed Getting Started guide in the documentation section of our web site.

By “recusing image” do you perhaps mean “rescue image”. Where did you get the rescue image? The board should ship with a bootable image on the SDcard. I don’t think we provide any rescue image.

You can build your own bootable images using github.com/sifive/freedom-u-sdk or github.com/riscv/meta-riscv (Open Embedded). The latter one is probably better supported, and requires setting MACHINE=“freedom-u540” in the setup.sh file. The former one has a v1_0 branch that was used to build the original image shipped with the board, and the master branch has u-boot support which requires different MSEL switch positions, see the README file.


#3

Well, I started with MSEL = 1111 (default) to boot Linux initially. That worked until I tried to flash bare-metal hello world into SPI flash (@ 0x20000000) using openocd.

The bare metal did not run, so as Linux since then. The “rescue image” was an attempt to recovery original state of the board. The SD card came with the board still has default boot images but I don’t seem to boot from SD card.


(Jim Wilson) #4

I believe that the board ships with a ZSBL in rom and a FSBL in flash. If you overwrote flash, then you probably lost the FSBL. The image on the original SDcard won’t boot without the FSBL in flash.

You should be able to download the FSBL from our web site and rewrite it to flash, but I’ve never done that and don’t know the details of how that works. Maybe this is what you mean by rescue image?

There is an alternative solution. If you download and build freedom-u-sdk you can get an image that has the FSBL linked into u-boot, and that can boot without using flash. So that should still work on your board.


#5

Using freedom-u-sdk, I build the bootable images successfully, but failed while creating SD card with error “recipe for target ‘format-boot-loader’ failed”. See below logs. Is this normal or am I missing something ?

$ make


xxd -c1 -p /home/user/freedom-u-sdk/work/bbl.bin > /home/user/freedom-u-sdk/work/bbl.hex

This image has been generated for an ISA of rv64imafdc and an ABI of lp64d
Find the image in work/bbl.bin, which should be written to a boot partition

To completely erase, reformat, and program a disk sdX, run:
sudo make DISK=/dev/sdX format-boot-loader
… you will need gdisk and e2fsprogs installed

$ sudo make DISK=/dev/sdb format-boot-loader
sgdisk --clear
–new=1:2048:67583 --change-name=1:bootloader --typecode=1:2E54B353-1271-4842-806F-E436D6AF6985
–new=2:264192: --change-name=2:root --typecode=2:0FC63DAF-8483-4772-8E79-3D69D8477DE4
/dev/sdb
Setting name!
partNum is 0
REALLY setting name!
Setting name!
partNum is 1
REALLY setting name!
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot or after you
run partprobe(8) or kpartx(8)
The operation has completed successfully.
dd if=/home/user/freedom-u-sdk/work/bbl.bin of=/dev/sdb1 bs=4096
4086+1 records in
4086+1 records out
16738804 bytes (17 MB, 16 MiB) copied, 2.25932 s, 7.4 MB/s
mke2fs -t ext3 /dev/sdb2
mke2fs 1.42.13 (17-May-2015)
/dev/sdb2 contains a ext3 file system
last mounted on Sun Sep 29 11:14:09 2019
Proceed anyway? (y,n) y

Makefile:229: recipe for target ‘format-boot-loader’ failed
make: *** [format-boot-loader] Error 1


(Jim Wilson) #6

This is the v1_0 branch? I think this is a quirk of mkfs that it returns an error even when it worked correctly, if it was asked to overwrite an existing filesystem. Adding a -F option might fix that. Or clobbering the file system first. But anyways what you have is probably a correctly written sdcard, you can just try mounting it to check. The second partition is just an empty filesystem, so even if it wasn’t created correctly you can still boot. Or you can just rerun the mke2fs command manually to create the filesystem again.


#7

Yes, this is v1_0 branch.

I also used the SD card to boot the board, but nothing is showing up on the serial console (/dev/ttyUSB1).

Also, the partitions created on the SD card are as following:

$ sudo gdisk /dev/sdb
[sudo] password for user:
GPT fdisk (gdisk) version 1.0.1

Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present

Found valid GPT with protective MBR; using GPT.

Command (? for help): p
Disk /dev/sdb: 15523840 sectors, 7.4 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 52F94D57-ABC1-44C0-9EF0-629E2F00FFC7
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 15523806
Partitions will be aligned on 2048-sector boundaries
Total free space is 198622 sectors (97.0 MiB)

Number Start (sector) End (sector) Size Code Name
1 2048 67583 32.0 MiB FFFF bootloader
2 264192 15523806 7.3 GiB 8300 root


(Jim Wilson) #8

Make sure the boot select switches are in the right position, all 1. If /dev/USB1 doesn’t work, try /dev/USB2. Which one is the serial console depends on the software driver the board is talking to. Try turning off hardware/software flow control, and make sure the baud rate is set right.

The v1_0 branch only writes to one partition on the card, the first one, and it only writes bbl+kernel+initramfs. It should give you a sdcard similar to your original one. But this boot flow requires the FSBL in flash, and if you accidentally overwrote that, you can’t boot this way anymore unless you restore the flash contents.

You could also try the master branch, which has FSBL linked into u-boot, and should work even if the original flash contents aren’t there anymore. This requires different boot select settings.

Or you could also try restoring the original flash contents. There is a firmware image on our web site but I’ve never used it. There are instructions in the Getting Started Guide that talk about it.