Installing Ubuntu 21.04 on the HiFive Unmatched

I wrote a guide to installing Ubuntu 21.04 on the Unmatched. It can be found at https://blogjawn.stufftoread.com/install-ubuntu-on-hifive-unmatched.html

It covers flashing the image to an SD, booting from an NVMe drive, and setting up a very basic desktop environment. I’ve also designed a case for it, though it’s untested so it isn’t included in the post yet. I will update the post once the case has been tested.

6 Likes

Thanks alot! That will (hopefully very soon) be quite helpful.

Hopefully, Haiku will support the Unmatched board once mine comes in :smiley:

Thank you @JawnSmith! This setup worked almost perfectly for me. The one thing I had to change: on the login screen, there’s a gear icon, I had to select “Ubuntu on Xorg”

My problem: using the default options I was able to log in, and the OS accepted keyboard input, but application windows would not. I found an article suggesting Wayland could be a problem, and switching back to Xorg seems to have worked around it.

Thanks for the feedback @x56 ! I can add a note to the post. May I ask what GPU you’re using? Wayland is known to be weird with nVidia graphics cards.

ah ok, I’m using a 1080Ti, so that’s probably it (understood that AMD is recommended, this is what I have on hand at least until prices come down…)

Yeah prices are ridiculous right now… Great to know that the nVidia cards work with xorg though! I didn’t have any extra nVidia cards on hand and honestly didn’t know if that would work. I’ll add a note to the blog post. Thanks for linking me in your DOOM post :laughing:

1 Like

I’ve already put some work into setting up my Ubuntu environment on an SD card (I’m using xfce for now as I wasn’t sure how gnome would run).

What do you think about getting the system quiet, doing a sync, and then using dd to copy the SD card to the SSD, rather than expanding a fresh copy?

Also, how do we experiment with changing the clock speed? At least to get the advertised 1.2 GHz, as it’s currently running at 1.0.

The cpupower frequency driver hasn’t been ported to unmatched yet. The clock frequency is set in the fsbl. The original fsbl (fusdk 2021.03) set the frequency to 1.0GHz. The current one (fusdk 2021.03.01 and later) sets the frequency to 1.2GHz. Maybe this image is using the older one? I believe that we are planning to publish a software guide that explains how to configure the clock. You would have to use that info to modify the fsbl if you want to try different frequencies. The same info in a less convenient form is probably also in the fu740 hardware docs.

I suspect that copying the SD card to the SSD may work, but there may be some headaches along the way, considering you’d be copying things from /proc, /dev on a booted system. If you try it can you post your results here along with any special steps you had to take to get it working?

How are you measuring the speed? Running perf stat /bin/ls says my Unmatched is running at 1.194 GHz.

The same way

ubuntu@ubuntu:~$ perf stat /bin/ls
Desktop                                                                                 hello.c
Documents                                                                               hello.hex
Downloads                                                                               mnt
Music                                                                                   primes.c
Pictures                                                                                stairway.mp3
Public                                                                                  test_memcpy
Templates                                                                               test_memcpy.c
Videos                                                                                  trv
hello

 Performance counter stats for '/bin/ls':

              5.83 msec task-clock                #    0.721 CPUs utilized          
                 2      context-switches          #    0.343 K/sec                  
                 0      cpu-migrations            #    0.000 K/sec                  
                90      page-faults               #    0.015 M/sec                  
           5829610      cycles                    #    1.000 GHz                    
           2434105      instructions              #    0.42  insn per cycle         
   <not supported>      branches                                                    
   <not supported>      branch-misses                                               

       0.008083000 seconds time elapsed

       0.000000000 seconds user
       0.007223000 seconds sys


ubuntu@ubuntu:~$

On the SiFive HiFive Unmatched web page
https://www.sifive.com/boards/hifive-unmatched
see the link at the bottom for the “HiFive Unmatched SW Reference Manual” document dated May 17, 2021. On page 39 (pdf page 41) it explains how to read the clock info with devmem2 and decode the value. Then looking at the FU740 manual I see that the final frequency is ((26MHz / (R+1)) * 2 * (F+1)) / (1<<Q).

Anyways, as I mentioned before, I think this image has the wrong version of the bootloader, as the old one did set the clock to 1GHz.

1 Like

I still need a decoder ring:

# devmem2 0x10000004 w 0x820544C2
/dev/mem opened.
Memory mapped at address 0x3fe3560000.
Read at address  0x10000004 (0x3fe3560004): 0x820544C2
Write at address 0x10000004 (0x3fe3560004): 0x820544C2, readback 0x820544C2

# devmem2 0x1000000c w 0x820D1180
/dev/mem opened.
Memory mapped at address 0x3ff4985000.
Read at address  0x1000000C (0x3ff498500c): 0x820D1180
Write at address 0x1000000C (0x3ff498500c): 0x820D1180, readback 0x820D1180
# perf_5.10 stat /bin/ls
bin  boot  dev	etc  home  lib	lost+found  media  mnt	proc  run  sbin  share	srv  sys  tmp  usr  var

 Performance counter stats for '/bin/ls':

              2.43 msec task-clock                #    0.731 CPUs utilized          
                 0      context-switches          #    0.000 K/sec                  
                 0      cpu-migrations            #    0.000 K/sec                  
                64      page-faults               #    0.026 M/sec                  
           2900803      cycles                    #    1.194 GHz                    
            993730      instructions              #    0.34  insn per cycle         
   <not supported>      branches                                                    
   <not supported>      branch-misses                                               

       0.003322999 seconds time elapsed

       0.003561000 seconds user
       0.000000000 seconds sys

The SW Reference Manual shows which bits are R, F, and Q. The hardware manual probably does also. The low 6 bits are R. The next 9 bits are F. Then the next 3 bits are Q. So for the value 0x820544C2, R=2, F=275, Q=2 and we get 26MHz / 3 * 2 * 276 / 4 which is 1.196GHz.

3 Likes

I don’t think that’s any great problem, as those are procedural file systems, not actual things on the disk. dd would not see them, but only the directories they are mounted on.

But anyway, copying from the SD card is soooo slow it turned out to be far quicker to use ssh to stream the .img from another computer and dd the stream directly onto the SSD without touching SD.

I installed gnome and it’s definitely a lot more sluggish than xfce, though things such as dragging a window under the transparent launcher work just fine on my old R5 230 card (radeon driver not amdgpu).

vlc plays video files very well but unfortunately locks up the entire UI in the process and I have to kill not only VLC but also the desktop manager to recover. This may or may not be because I’m using DVI and don’t have a sound device.

I received today the 40mm Noctua fan and installed it. It’s certainly far far quieter, and temperatures are about the same. The screw holes are larger than the ones in the original fan and the head of the long screws pass right through. I used a plastic washer from the M.2 mounting kit included with the board and that works well.

2 Likes

Glad you got it working! I’m working on printing a case with a slot for a 120mm fan so I can also replace the stock fan. I can make a note about older graphics cards not playing very well with gnome.

I think it’s the CPU struggling, not the graphics card. The graphics are fine.

Also, either the Noctua fan has failed or else the 3 pin connector. I’ve gone back to the original fan.

It was working fine until I rebooted, and then no spin.

I just used an NFS mount back to my Linux box.

sudo dd if=/media/xfer/ubuntu-21.04-preinstalled-server-riscv64+unmatched.img of=/dev/nvme0n1 bs=1M status=progress
3731881984 bytes (3.7 GB, 3.5 GiB) copied, 96 s, 38.9 MB/s
3584+0 records in
3584+0 records out
3758096384 bytes (3.8 GB, 3.5 GiB) copied, 101.308 s, 37.1 MB/s

Forgot to mention, Western Digital Black SN750.

1 Like