Fishwaldo / sophgo-sg200x-debian

Debian Image for SG200x based boards such as Milk Duo256/DuoS and Sipeed LicheeRVNano
99 stars 24 forks source link

fsbl repo moved? #27

Open KevinMX opened 4 months ago

KevinMX commented 4 months ago

Seems the original milkv-duo/fsbl repo has moved/gone.

$ podman run --privileged -it --rm -v ./configs/:/configs -v ./image:/output ghcr.io/fishwaldo/sophgo-sg200x-debian:master make BOARD=duos fsbl

Board: duos
Storage: sd
Image Addons: "usb-gadget" "aic8800-firmware" "ethernet-leds" "usb-switch" "hciattach-service"
Packages: ca-certificates debian-archive-keyring dosfstools binutils file tree sudo bash-completion u-boot-menu openssh-server network-manager dnsmasq-base libpam-systemd ppp libengine-pkcs11-openssl iptables systemd-timesyncd vim usbutils parted exfatprogs systemd-sysv i2c-tools net-tools ethtool avahi-utils sudo gnupg rsync gpiod u-boot-tools libubootenv-tool duo-pinmux wireless-regdb wpasupplicant cvi-pinmux-cv181x bluez

Checking out FSBL for duos

Cloning into '/build//fsbl'...
Username for 'https://github.com':

There is an fsbl repo at https://github.com/milkv-duo/duo-buildroot-sdk/tree/develop/fsbl though. I guess some changes might be needed?

Fishwaldo commented 4 months ago

Sigh. The MilkV people removed the repo for unknown reasons. I’ll have to rebase against the Sophgo repo instead. But I’m swamped with real life at the moment so might take me a while.

(Checking out the full buildroot at MilkV just for fsbl is a bit heavy!)

carbonfix commented 4 months ago

The reason is that many users have been complaining that the SDK is not fully open source, so Sophgo has gradually opened up some source codes, including fsbl. Sophgo changed fsbl to source code compilation, and we also synchronized Sophgo's source code.

KevinMX commented 4 months ago

Sigh. The MilkV people removed the repo for unknown reasons. I’ll have to rebase against the Sophgo repo instead. But I’m swamped with real life at the moment so might take me a while.

(Checking out the full buildroot at MilkV just for fsbl is a bit heavy!)

You can do something like a sparse clone to avoid cloning the whole repo, but only the specific folder inside the repo.

Since GitHub already deprecated svn so for now it's a bit more complicated:

# Clone a sub-directory of a git repository. Probably replaces "svn co" which is deprecated by GitHub.
# Usage: git_sparse_clone $repo_url $repo_branch $sub_directory $target_location

function git_sparse_clone() {
    git clone --filter=blob:none --no-checkout --depth=1 -b $2 $1 upstream && cd upstream
    git sparse-checkout init --cone
    git sparse-checkout set $3
    git checkout
    mv $3 ../$4
    cd ../ && rm -rf upstream
}

And BTW, your Docker image is failing to build ATM. You'l probably want to change from Debian sid to bookworm. The latter works for me.

asyncmeow commented 3 months ago

Any fixes for this yet, or is there anything I can contribute here to fix it? Not entirely sure how the repo/scripts are set up, or where the FSBL we need actually is 😅

Yefori-Go commented 3 months ago

same problem

skarstein commented 1 month ago

Hey guys I've been trying to get this to build for a day or so. I solved this particular fsbl repo being moved like so

First clone the milk-v SDK inside of your sophgo-sg200x-debian directory: git clone git@github.com:milkv-duo/duo-buildroot-sdk.git

Then make these changes to the Makefile. They just switch from cloning these dead repos to using your local copy:

diff --git a/scripts/Makefile b/scripts/Makefile
index 24a59c7..23cb217 100644
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -79,8 +79,8 @@ linux-clean:
 $(BUILDDIR)/uboot-prepare-checkout-stamp:
        @echo "$(COLOUR_GREEN)Checking out U-Boot for $(BOARD)$(END_COLOUR)"
        @mkdir -p $(BUILDDIR)
-       @git clone --depth 1 https://github.com/milkv-duo/u-boot-2021.10.git $(BUILDDIR)/u-boot
-       @cd $(BUILDDIR)/u-boot && git checkout a57aa1f
+       @cp -r ./sdk/u-boot-2021.10 $(BUILDDIR)/u-boot
+       @cd $(BUILDDIR)/u-boot
        @touch $@

 $(BUILDDIR)/uboot-prepare-patch-stamp: $(BUILDDIR)/uboot-prepare-checkout-stamp
@@ -151,8 +151,8 @@ opensbi-clean:
 $(BUILDDIR)/fsbl-prepare-checkout-stamp:
        @echo "$(COLOUR_GREEN)Checking out FSBL for $(BOARD)$(END_COLOUR)"
        @mkdir -p $(BUILDDIR)
-       @git clone -b milkv --depth 1 https://github.com/milkv-duo/fsbl.git $(BUILDDIR)/fsbl
-       @cd $(BUILDDIR)/fsbl && git checkout beb1483
+       @cp -r ./sdk/fsbl $(BUILDDIR)/fsbl
+       @cd $(BUILDDIR)/fsbl
        @touch $@

Then modify the build_image script to include the sdk inside of the docker container

diff --git a/build_image.sh b/build_image.sh
index 2262526..9aef6f0 100755
--- a/build_image.sh
+++ b/build_image.sh
@@ -1,2 +1,6 @@
 #!/bin/sh
-docker run --privileged -it --rm -v ./configs/:/configs -v ./image:/output builder make BOARD=licheervnano image
+docker run --privileged -it --rm \
+    -v ./configs/:/configs \
+    -v ./image:/output \
+    -v $(pwd)/duo-buildroot-sdk:/builder/sdk \
+    builder make BOARD=duos image

Then build like so: ./build_docker.sh ./build_image.sh

This fixes the original issue but the build still fails for me. There is an error complaining about GPG keys. I tried skipping those steps by commenting out those parts of the Makefile but we eventually run into more issues related to the patches here in configs/common/patches.

I think the issue is that the repos that were originally cloned in this build script (fsbl, uboot, etc) differ pretty significantly from the current versions in the duo-buildroot-sdk repo.

If anyone has managed to build this Debian image please let me know how you managed to do it. Thanks!

KevinMX commented 1 month ago

If anyone has managed to build this Debian image please let me know how you managed to do it. Thanks!

Would require many changes. As Fishwaldo said and AFAIK many patches need to be rebased against the sophgo repo. You can't just apply those patches to the upstream sophgo repo for now. You'll need to changes some.

I some how managed to build an image for Duo S, however it's not booting up properly. Will investigate further.

skarstein commented 1 month ago

Got it building for Duo-s. Also got the TPU working with the old buildroot-sdk libs. Check it out: https://github.com/nuha-inc/sophgo-sg200x-debian/

It's working well for me. Anyone using this give it a shot and let me know any comments/concerns. Thanks!