Linux 4.20 on HiFive Unleashed

Hi,

does anyone managed to get Linux 4.20 to boot and run on HiFive Unleashed? I managed to get half-way through but now I’m little stuck.

It is my understanding that all drivers needed to run on Unleashed did not make it into 4.20. So I took vanilla 4.20 (8fe28cb58bcb2) and apply patches I found at (https://github.com/riscv/meta-riscv/tree/master/recipes-kernel/linux/files/freedom-u540 - not all of them just those mentioned in config file for 4.20).

The kernel compiles and run fine under QEMU. On Unleashed is starts booting and then sort of hangs - following is printend on console:

[    0.000000] OF: fdt: Ignoring memory range 0x80000000 - 0x80200000
[    0.000000] Linux version 4.20.0-00010-g004a58746358 (jv@jenkins-debian) (gcc version 7.2.0 (GCC)) #4 SMP Wed Jan 9 10:21:56 UTC 2019
[    0.000000] printk: bootconsole [early0] enabled
[    0.000000] Zone ranges:
[    0.000000]   DMA32    [mem 0x0000000080200000-0x00000000ffffffff]
[    0.000000]   Normal   [mem 0x0000000100000000-0x000027ffffffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000080200000-0x000000027fffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000080200000-0x000000027fffffff]
[    0.000000] software IO TLB: mapped [mem 0xfbfff000-0xfffff000] (64MB)
[    0.000000] CPU with hartid=0 has a non-okay status of "masked"
[    0.000000] CPU with hartid=0 has a non-okay status of "masked"
[    0.000000] elf_hwcap is 0x112d
[    0.000000] percpu: Embedded 15 pages/cpu @(____ptrval____) s28696 r0 d32744 u61440
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 2067975
[    0.000000] Kernel command line: earlyprintk root=/dev/mmcblk0p2 rootwait
[    0.000000] Dentry cache hash table entries: 1048576 (order: 11, 8388608 bytes)
[    0.000000] Inode-cache hash table entries: 524288 (order: 10, 4194304 bytes)
[    0.000000] Sorting __ex_table...
[    0.000000] Memory: 8184876K/8386560K available (5584K kernel code, 352K rwdata, 1492K rodata, 212K init, 819K bss, 201684K reserved, 0K cma-reserved)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
[    0.000000] rcu: Hierarchical RCU implementation.
[    0.000000] rcu:     RCU event tracing is enabled.
[    0.000000] rcu:     RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=4.
[    0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 10 jiffies.
[    0.000000] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=4
[    0.000000] NR_IRQS: 0, nr_irqs: 0, preallocated irqs: 0
[    0.000000] plic: mapped 53 interrupts to 4 (out of 9) handlers.
[    0.000000] clocksource: riscv_clocksource: mask: 0xffffffffffffffff max_cycles: 0x1d854df40, max_idle_ns: 3526361616960 ns
[    0.000000] Console: colour dummy device 80x25
[    0.000000] printk: console [tty0] enabled
[    0.000000] printk: bootconsole [early0] disabled

This is all. Interestingly, heartbeat LED is flashing like should. I can provide kernel .config and reference to the exact kernel source I’m using if anyone wants to have a look.

Do I miss some patch or config? Any idea what to check? Does anyone managed to get 4.20 running?

This page


has info on how to get 4.19-rc2 working on a HiFive Unleashed plus the expansion board, and lists all of the drivers you need to add to get it to work. You can ignore the PCIe driver for the expansion board if you don’t have it, and the rest of them you need if you don’t already have them. You can also ignore the config file which only works if you have the expansion board and a PCI video card.

Make sure that you have the SiFive serial console driver enabled. If you have the wrong serial console driver enabled, or if you have a video console driver enabled, you can see a boot failure like this, in which case it might have booted OK, you just don’t have any console you can see.

The default linux kernel configs in freedom-u-sdk should work, updated for the 4.20 kernel. The default ones use a serial console, and then there are alternative ones that use a video console driver that won’t work without the expansion card.

1 Like

Thanks! I went through that page and got it working.

OK, one more issue. Kernel boots just fine but now the ethernet is fairly unstable and slow. Ping shows ~20% packet loss when Unleashed is connected directly to my laptop ethernet port. With 4.15 kernel I have no issues:. Also RTT time several orders of magnitude higher than when runnin 4.15.

Following is ping output for 4.20:

PING 10.42.0.136 (10.42.0.136) 56(84) bytes of data.
64 bytes from 10.42.0.136: icmp_seq=3 ttl=64 time=1740 ms
64 bytes from 10.42.0.136: icmp_seq=4 ttl=64 time=961 ms
64 bytes from 10.42.0.136: icmp_seq=5 ttl=64 time=2283 ms
64 bytes from 10.42.0.136: icmp_seq=6 ttl=64 time=1308 ms
64 bytes from 10.42.0.136: icmp_seq=7 ttl=64 time=1001 ms
64 bytes from 10.42.0.136: icmp_seq=8 ttl=64 time=2292 ms
64 bytes from 10.42.0.136: icmp_seq=9 ttl=64 time=1293 ms
64 bytes from 10.42.0.136: icmp_seq=10 ttl=64 time=944 ms
64 bytes from 10.42.0.136: icmp_seq=11 ttl=64 time=287 ms
64 bytes from 10.42.0.136: icmp_seq=12 ttl=64 time=991 ms
64 bytes from 10.42.0.136: icmp_seq=13 ttl=64 time=1005 ms
64 bytes from 10.42.0.136: icmp_seq=14 ttl=64 time=733 ms
64 bytes from 10.42.0.136: icmp_seq=15 ttl=64 time=986 ms
64 bytes from 10.42.0.136: icmp_seq=16 ttl=64 time=1920 ms
64 bytes from 10.42.0.136: icmp_seq=17 ttl=64 time=1000 ms
^C
--- 10.42.0.136 ping statistics ---
18 packets transmitted, 15 received, 16.6667% packet loss, time 165ms
rtt min/avg/max/mdev = 287.276/1249.659/2292.006/550.116 ms, pipe 3

For comparison, following is taken when running 4.15:

PING 10.42.0.136 (10.42.0.136) 56(84) bytes of data.
64 bytes from 10.42.0.136: icmp_seq=1 ttl=64 time=0.167 ms
64 bytes from 10.42.0.136: icmp_seq=2 ttl=64 time=0.172 ms
64 bytes from 10.42.0.136: icmp_seq=3 ttl=64 time=0.115 ms
64 bytes from 10.42.0.136: icmp_seq=4 ttl=64 time=0.108 ms
64 bytes from 10.42.0.136: icmp_seq=5 ttl=64 time=0.111 ms
64 bytes from 10.42.0.136: icmp_seq=6 ttl=64 time=0.122 ms
64 bytes from 10.42.0.136: icmp_seq=7 ttl=64 time=0.145 ms
64 bytes from 10.42.0.136: icmp_seq=8 ttl=64 time=0.171 ms
64 bytes from 10.42.0.136: icmp_seq=9 ttl=64 time=0.155 ms
^C
--- 10.42.0.136 ping statistics ---
9 packets transmitted, 9 received, 0% packet loss, time 202ms
rtt min/avg/max/mdev = 0.108/0.140/0.172/0.028 ms

I would appreciate any hint how to fix this issue.

Maybe ask on the linux-riscv linux kernel mailing list? I’m still using a patched 4.15 myself.

For the record, I think I found the problem. The issue was that RX/TX rings were for some reason too small:

root@unleashed:~# ethtool -g eth0
Ring parameters for eth0:
Pre-set maximums:
RX:             8192
RX Mini:        0
RX Jumbo:       0
TX:             4096
Current hardware settings:
RX:             512
RX Mini:        0
RX Jumbo:       0
TX:             512

Setting them to max before bringing the interface up
seem to solve the problem:

ethtool -G eth0 rx 8192
ethtool -G eth0 tx 4096

Thanks for your help!

1 Like

hello jim,

i suppose to write my own driver module and build image, in riscv-linux , but i came to know that if i want to insert any module that need to be configured in auto.config file but that file is generated one ,so how can i build a image with my own driver need help

This doesn’t appear to have any relationship to the original question. New threads for new questions please. I’m not a linux kernel developer, so I don’t know anything about adding modules. The linux kernel newbies mailing list is probably a better place to ask a question like this.

Hi,

  I also got same issue with the board.my image booted up to boot console disabled. i used yocto build system risc -v .then i cleaned my build directory. again i was build then its working fine.