skiffos / SkiffOS

Any Linux distribution, anywhere.
https://skiffos.com
MIT License
687 stars 51 forks source link

starfive/visionfive: add beaglev and visionfive support #212

Closed paralin closed 2 years ago

paralin commented 2 years ago

Adds support for the RISC-V StarFive VisionFive boards as well as BeagleV (Compatible).

paralin commented 2 years ago

requested & tested by @ clayauld on discord

clayauld commented 2 years ago

I put some info on the Discord server, but the build is stopping when it tries to pull the ddrinit tar.gz from the SkiffOS mirror repo. I believe it should be pulling the latest released ddrinit file from here: https://github.com/starfive-tech/JH7100_ddrinit/releases

The relevant info is on the StarFive VisionFive Quick Start Guide in Appendix A and B: https://wiki.rvspace.org/en/Product/VisionFive/Technical_Documents/VisionFive_Single_Board_Computer_Quick_Start_Guide

paralin commented 2 years ago

@clayauld it fails the hash check. See your logs you sent. The download hash changed from GitHub since it was added in the buildroot tree.

After the hash check failed it will try to download from the mirror repo as a fallback.

I've updated the hash in the buildroot tree. Please pull this branch and then "git submodule update" and try again

clayauld commented 2 years ago

The hash in buildroot/boot/beaglev-secondboot/beaglev-secondboot.hash for beaglev-secondboot-2d20047960044308126117ad56bc08a1164e82b2.tar.gz needs to be updated to:

683f017c11d7955b6108c2538313ad3bb546a792fccc6cf01dee62c082516965

Changing this manually allowed the build to continue after downloading the beaglev-secondboot tar.gz file.

paralin commented 2 years ago

@clayauld Fixed both 👍🏽

paralin commented 2 years ago

Hey @clayauld did you have a chance to test this yet?

clayauld commented 2 years ago

Building this works. Still gotta test it on the board. Waiting for my UART to USB converter to arrive from Amazon.

clayauld commented 2 years ago

I did get uboot, ddrinit, and second bootloader updated on the board. However, SkiffOS does not seem to boot from the SD card. U-boot seems to start the autoboot process and initialize the sd card appropriately, but nothing happens. The terminal just appears to drop to the U-boot shell.

clayauld commented 2 years ago

I'm able to see the files in on the sd card inside the uboot shell, and I tried to run the following commands... I got them from the boot-scripts directory for the visionfive.

setenv bootargs 'root=PARTUUID=${uuid} rootwait rw init=/boot/skiff-init/skiff-init-squashfs console=ttyS0,115200 earlyprintk fsck.repair=yes net.ifnames=0'
load mmc 0:1 $kernel_addr_r /boot/Image
load mmc 0:1 $fdt_addr_r /boot/jh7100-starfive-visionfive-v1.dtb
bootm $kernel_addr_r - $fdt_addr_r

However, it does not appear to be able to boot the kernel image. Here is the output

BeagleV # setenv bootargs 'root=PARTUUID=${uuid} rootwait rw init=/boot/skiff-init/skiff-init-squashfs console=ttyS0,115200 earlyprintk fsck.repair=yes net.ifnames=0'
BeagleV # load mmc 0:1 $kernel_addr_r /boot/Image
19746816 bytes read in 4090 ms (4.6 MiB/s)
BeagleV # load mmc 0:1 $fdt_addr_r /boot/jh7100-starfive-visionfive-v1.dtb
21860 bytes read in 13 ms (1.6 MiB/s)
BeagleV # bootm $kernel_addr_r - $fdt_addr_r
Wrong Image Format for bootm command
ERROR: can't get kernel image!
paralin commented 2 years ago

@clayauld the boot scripts dir just has extlinux.conf - are you sure you're on the latest visionfive branch version from GitHub? Or do you mean that you've written those uboot commands based on extlinux?

It's supposed to scan the drives and find one with extlinux, then load that. Could you possibly paste the uboot logs where it's not finding the extlinux.conf?

As for the commands you tried: perhaps try using "booti" instead of "bootm" to check if that maybe works

Also - if you could printenv kernel_addr_r and printenv fdt_addr_r so we can check those addresses and see if maybe the kernel is overlapping the FDT in memory or vise-versa with the default addresses.

paralin commented 2 years ago

@clayauld I just noticed a typo in the install_sd script which was using -d instead of -f to look for extlinux.conf, which would have returned false since it's a file and not a dir.

Please update to the latest version of this branch & run "install" again so extlinux is copied. Please also confirm there's "extlinux.conf" on the persist partition at /boot/extlinux/extlinux.conf

It should work then, I think. Your script may also have worked if you used "booti"

git fetch
git reset --hard origin/visionfive
clayauld commented 2 years ago

Looks like it now starts the boot, then ends in a kernel panic. See attached log file. boot_error.log

paralin commented 2 years ago

@clayauld It should work if you change the extlinux.conf

LABEL SkiffOS
  KERNEL /boot/Image
  FDT /boot/jh7100-starfive-visionfive-v1.dtb
  APPEND root=/dev/mmcblk0p1 rootwait rw init=/boot/skiff-init/skiff-init-squashfs console=ttyS0,115200 earlyprintk fsck.repair=yes net.ifnames=0
clayauld commented 2 years ago

We're making progress. Here's the boot log. Its getting locked up further along in the process now...

BUG: workqueue lockup - pool cpus=1 node=0 flags=0x0 nice=0 stuck for 353s!

See log attached visionfive-boot.log .

paralin commented 2 years ago

@clayauld

Unable to handle kernel paging request at virtual address 0000007f0139dac0
Oops [#1]
Modules linked in: brcmfmac brcmutil zstd zstd_decompress zstd_compress snd_soc_simple_card snd_soc_simple_card_utils zram snd_soc_starfive_pwmdac snd_soc_starfive_pwmdac_transmitter zsmalloc snd_soc_core snd_pcm_dmaengine snd_pcm cfg80211 snd_timer snd fuse
CPU: 1 PID: 45 Comm: kworker/1:1 Not tainted 5.19.0-rc1-visionfive #1
Hardware name: StarFive VisionFive V1 (DT)
Workqueue: events request_firmware_work_func
epc : brcmf_sdio_bus_txctl+0xc4/0x118 [brcmfmac]
 ra : brcmf_sdio_bus_txctl+0xc4/0x118 [brcmfmac]
epc : ffffffff0139dac0 ra : ffffffff0139dac0 sp : ffffffc80419b8d0
 gp : ffffffff812d48f0 tp : ffffffd88016eb80 t0 : 0000000000046000
 t1 : 0000000000000000 t2 : 00000000000003ff s0 : ffffffc80419b930
 s1 : ffffffd888930000 a0 : 0000000000000271 a1 : 0000000000000002
 a2 : ffffffd9f7dc6e10 a3 : 14c0800000000000 a4 : 0000000000000000
 a5 : ffffffffffffffff a6 : ffffffff812122f8 a7 : 0000000000000001
 s2 : 0000000000000271 s3 : ffffffd8889302f8 s4 : ffffffd88abf07c0
 s5 : ffffffd88abf0960 s6 : 0000000000000000 s7 : 0000000000000106
 s8 : ffffffd88abf4054 s9 : ffffffd88abf0960 s10: ffffffd88abf07c0
 s11: ffffffd88893182c t3 : 0000000000000000 t4 : ffffffff80da7e30
 t5 : d8a722f2be0e6c50 t6 : 0000000000001970
status: 0000000200000120 badaddr: 0000007f0139dac0 cause: 000000000000000c
[<ffffffff01399106>] brcmf_proto_bcdc_msg+0xa8/0xc0 [brcmfmac]
[<ffffffff0139934e>] brcmf_proto_bcdc_query_dcmd+0x40/0x17c [brcmfmac]
[<ffffffff0138fb14>] brcmf_fil_cmd_data+0x4e/0xb0 [brcmfmac]
[<ffffffff01390308>] brcmf_fil_bsscfg_data_get+0x5e/0xc6 [brcmfmac]
[<ffffffff013903b4>] brcmf_fil_bsscfg_int_get+0x20/0x32 [brcmfmac]
[<ffffffff013855aa>] brcmf_construct_chaninfo+0x26e/0x324 [brcmfmac]
[<ffffffff01385734>] brcmf_setup_wiphybands+0xd4/0x462 [brcmfmac]
[<ffffffff0138d9dc>] brcmf_cfg80211_attach+0x29a/0x76a [brcmfmac]
[<ffffffff013960c4>] brcmf_bus_started+0xde/0x31a [brcmfmac]
[<ffffffff01396380>] brcmf_attach+0x80/0x106 [brcmfmac]
[<ffffffff0139f576>] brcmf_sdio_firmware_callback+0x426/0x4c6 [brcmfmac]
[<ffffffff01397060>] brcmf_fw_request_done+0xc2/0x14a [brcmfmac]
[<ffffffff803e0400>] request_firmware_work_func+0x2c/0x50
[<ffffffff80024376>] process_one_work+0x192/0x2c6
[<ffffffff800245bc>] worker_thread+0x112/0x3f4
[<ffffffff8002ac92>] kthread+0x96/0xa8
[<ffffffff80002fba>] ret_from_exception+0x0/0xc
---[ end trace 0000000000000000 ]---
[  OK  ] Reached target Sound Card.

seems to have crashed at brcmf_sdio_bus_txctl

... or the firmware loading step

Probably because of:

# CONFIG_PREVENT_FIRMWARE_BUILD is not set
CONFIG_EXTRA_FIRMWARE="regulatory.db regulatory.db.p7s brcm/brcmfmac43430-sdio.bin brcm/brcmfmac43430-sdio.clm_blob brcm/brcmfmac43430-sdio.txt"
CONFIG_EXTRA_FIRMWARE_DIR="firmware"

I'm preparing a couple patches and will ping you in a few mins when it's ready

paralin commented 2 years ago

@clayauld Okay I:

Please git pull, git submodule update, delete workspaces/default/build/ dirs linux-custom, linux-headers-custom, glibc*, and delete workspaces/default/extra_images, then run "make configure compile" again.

clayauld commented 2 years ago

Here is the latest boot log. Still seems to be locking up. I performed a full clean of the workspace and rebuild. visionfive_boot.log

paralin commented 2 years ago

@clayauld seems to be a lockup in either addrconf_verify_work or ipv6_addrconf. I suspect it's because extra features (Probably BPF) are enabled in Skiff that aren't enabled in the visionfive_defconfig, so these bugs haven't been found yet by the kernel developers.

I'm pushing a patch which disables a lot of extra features to bring it closer to the stock visionfive_defconfig.

paralin commented 2 years ago

@clayauld pushed the change. Looking forward to hearing how it goes, when you are next able to test.

git fetch
git reset --hard origin/visionfive
git submodule update

Not needed to fully rebuild, you can delete extra_images and build/linux-custom only and it should be fine.

https://github.com/skiffos/SkiffOS/pull/212/commits/eedddef2bd1d375249855be90bd6e48629045260#diff-d7647ccb6055645d25cde2c20c59879128673608a89d7c807a1af2d57adc7dbeR1

clayauld commented 2 years ago

After the latest changes the system successfully booted.

image

clayauld commented 2 years ago

However, after connecting to core it seems there's an issue as its setting up the core docker container. I'm not sure if Chromium has been built for RISC-V yet, but it seems that's keeping it from completing.

Removing intermediate container e054f156fbf6                                                                                                                                                                         
Image setup failed with error:                                                                                                                                                                                       
The command '/bin/sh -c apt-get dist-upgrade -y &&     apt-get install -y      --no-install-recommends     -o "Dpkg::Options::=--force-confdef"      -o "Dpkg::Options::=--force-confnew"      autotools-dev     buil
d-essential     chromium     cups     curl     git     htop     less     lightdm     locales     lsb-release     mesa-utils     nano     ncurses-term     net-tools     openssh-client     rsync     software-propert
ies-common     sudo     systemd     task-xfce-desktop     unzip     usbutils     vim     wget     x11vnc' returned a non-zero code: 100                                                                              
2022/06/27 16:50:18 Re-opening truncated file /home/core/.skiff-core-setup.log ...                                                                                                                                   
2022/06/27 16:50:18 Successfully reopened truncated /home/core/.skiff-core-setup.log                                                                                                                                 
latest: Pulling from skiffos/skiff-core-debian                                                                                                                                                                       
Step 1/15 : ARG DISTRO                                                                                                                                                                                               
Step 2/15 : FROM ${DISTRO:-debian:sid} as stage1                                                                                                                                                                     
 ---> faf6a9a03d5b                                                                                                                                                                                                   
Step 3/15 : ENV LANG=C.UTF-8     LC_ALL=en_US.UTF-8     DEBIAN_FRONTEND=noninteractive     container=docker                                                                                                          
 ---> Using cache                                                                                                                                                                                                    
 ---> 5c4737f6bdc5                                                                                                                                                                                                   
Step 4/15 : RUN rm -rf /var/lib/apt/lists/* &&     apt-get update                                                                                                                                                    
 ---> Using cache                                                                                                                                                                                                    
 ---> 381b2401225a                                                                                                                                                                                                   
Step 5/15 : RUN     apt-get dist-upgrade -y &&     apt-get install -y      --no-install-recommends     -o "Dpkg::Options::=--force-confdef"      -o "Dpkg::Options::=--force-confnew"      autotools-dev     build-es
sential     chromium     cups     curl     git     htop     less     lightdm     locales     lsb-release     mesa-utils     nano     ncurses-term     net-tools     openssh-client     rsync     software-properties-
common     sudo     systemd     task-xfce-desktop     unzip     usbutils     vim     wget     x11vnc                                                                                                                 
 ---> Running in 0e99714c9dce                                                                                                                                                                                        
Reading package lists...                                                                                                                                                                                             
Building dependency tree...                                                                                                                                                                                          
Reading state information...                                                                                                                                                                                         
Calculating upgrade...                                                                                                                                                                                               
The following packages will be upgraded:                                                                                                                                                                             
  libcap-ng0                                                                                                                                                                                                         
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.                                                                                                                                                       
Need to get 17.5 kB of archives.                                                                                                                                                                                     
After this operation, 7168 B of additional disk space will be used.                                                                                                                                                  
Get:1 http://deb.debian.org/debian-ports sid/main riscv64 libcap-ng0 riscv64 0.8.3-1 [17.5 kB]                                                                                                                       
perl: warning: Setting locale failed.                                                                                                                                                                                
perl: warning: Please check that your locale settings:                                                                                                                                                               
        LANGUAGE = (unset),                                                                                                                                                                                          
        LC_ALL = "en_US.UTF-8",                                                                                                                                                                                      
        LANG = "C.UTF-8"                                                                                                                                                                                             
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("C.UTF-8").
debconf: delaying package configuration, since apt-utils is not installed
Fetched 17.5 kB in 0s (63.9 kB/s)
(Reading database ... 6614 files and directories currently installed.)
Preparing to unpack .../libcap-ng0_0.8.3-1_riscv64.deb ...
Unpacking libcap-ng0:riscv64 (0.8.3-1) over (0.7.9-4) ...
Setting up libcap-ng0:riscv64 (0.8.3-1) ...
Processing triggers for libc-bin (2.33-7) ...
Reading package lists...
Building dependency tree...
Reading state information...
Package chromium is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  chromium-bsu

E: Package 'chromium' has no installation candidate
Removing intermediate container 0e99714c9dce
Image setup failed with error:
The command '/bin/sh -c apt-get dist-upgrade -y &&     apt-get install -y      --no-install-recommends     -o "Dpkg::Options::=--force-confdef"      -o "Dpkg::Options::=--force-confnew"      autotools-dev     buil
d-essential     chromium     cups     curl     git     htop     less     lightdm     locales     lsb-release     mesa-utils     nano     ncurses-term     net-tools     openssh-client     rsync     software-propert
ies-common     sudo     systemd     task-xfce-desktop     unzip     usbutils     vim     wget     x11vnc' returned a non-zero code: 100
2022/06/27 16:51:15 Re-opening truncated file /home/core/.skiff-core-setup.log ...
2022/06/27 16:51:15 Successfully reopened truncated /home/core/.skiff-core-setup.log
latest: Pulling from skiffos/skiff-core-debian
Step 1/15 : ARG DISTRO
Step 2/15 : FROM ${DISTRO:-debian:sid} as stage1
 ---> faf6a9a03d5b
Step 3/15 : ENV LANG=C.UTF-8     LC_ALL=en_US.UTF-8     DEBIAN_FRONTEND=noninteractive     container=docker
 ---> Using cache
 ---> 5c4737f6bdc5
Step 4/15 : RUN rm -rf /var/lib/apt/lists/* &&     apt-get update
 ---> Using cache
 ---> 381b2401225a
Step 5/15 : RUN     apt-get dist-upgrade -y &&     apt-get install -y      --no-install-recommends     -o "Dpkg::Options::=--force-confdef"      -o "Dpkg::Options::=--force-confnew"      autotools-dev     build-es
sential     chromium     cups     curl     git     htop     less     lightdm     locales     lsb-release     mesa-utils     nano     ncurses-term     net-tools     openssh-client     rsync     software-properties-
common     sudo     systemd     task-xfce-desktop     unzip     usbutils     vim     wget     x11vnc
 ---> Running in 3ff13a2eb234
Reading package lists...
Building dependency tree...
Reading state information...
Calculating upgrade...
The following packages will be upgraded:
  libcap-ng0
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 17.5 kB of archives.
After this operation, 7168 B of additional disk space will be used.
Get:1 http://deb.debian.org/debian-ports sid/main riscv64 libcap-ng0 riscv64 0.8.3-1 [17.5 kB]
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = "en_US.UTF-8",
        LANG = "C.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("C.UTF-8").
debconf: delaying package configuration, since apt-utils is not installed
Fetched 17.5 kB in 0s (79.2 kB/s)
(Reading database ... 6614 files and directories currently installed.)
Preparing to unpack .../libcap-ng0_0.8.3-1_riscv64.deb ...
Unpacking libcap-ng0:riscv64 (0.8.3-1) over (0.7.9-4) ...
Setting up libcap-ng0:riscv64 (0.8.3-1) ...
Processing triggers for libc-bin (2.33-7) ...
Reading package lists...
Building dependency tree...
Reading state information...
Package chromium is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  chromium-bsu
paralin commented 2 years ago

@clayauld could you please try with core/gentoo or edit the dockerfile in /opt/skiff/core (somewhere in there) and remove the chromium lines?

paralin commented 2 years ago

@clayauld thanks again for testing. I've added --ignore-missing to the core defconfig which should have it skip the missing packages (chromium) in future. I'm also updating the debian image to have riscv as well.

Merging this, please open new issues if you run into any more problems! Thanks again!

clayauld commented 2 years ago

Excellent! I'll definitely update you on any other issues that may come up.