BPI-R4:Beginner questions for kernel building

Would it be an option to use 1 fixed branch name, that always has the latest patches? Me too I’m always searching which branch.

That’s why I stick with dangowrt’s mt7988-for-next branch for R4, which holds most latest patches and is always rebased. Then I don’t need to search and just build this one, even using a script.

No it’s no option as i need to look when a problem starts or till which it works…and there are lts kernels for productive use.

Ok, i did this:

git clone --depth 1  -b  6.12-main https://github.com/frank-w/BPI-Router-Linux.git
git stash
cd BPI-Router-Linux/
git config --global --add safe.directory $PWD
git stash


./build.sh  updatesrc
# error:
Update kernel source
fatal: 'stable' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.


# So i ran it again:
./build.sh  updatesrc
Update kernel source
remote: Enumerating objects: 13545655, done.
# ***  SNIP ***

 * [new tag]                   v6.9.7               -> v6.9.7
 * [new tag]                   v6.9.8               -> v6.9.8
 * [new tag]                   v6.9.9               -> v6.9.9
newkernver:6.12.31 (max:6.12.32)
fatal: refusing to merge unrelated histories


./build.sh importconfig

grep 6.12 ../build/.config
# Linux/arm64 6.12.30 Kernel Configuration

So, no 6.12.32, any other alternative Frank?

So actually running 6.15.0, which came from your branch 6.16-mt7988 branch, the problems with the mt7922 seem to be been fixed, but again, the fiber ports don’t work. So, hopefully 6.12.32 has the fixes for this card.

build.sh should add it on this error (seems it did in your case because error-message changed)…

but the new error (refusing to merge unrelated histories) is strange…are you on 6.12-main (i see you cloned only this branch which should be ok - calculation of newkernver is right so far)?

i had done the last merges with another laptop, so my current sync also contains already merged tags, but basicly works

$ ./build.sh updatesrc
Update kernel source
remote: Enumerating objects: 862356, done.
remote: Counting objects: 100% (109197/109197), done.
remote: Compressing objects: 100% (3222/3222), done.
remote: Total 862356 (delta 106563), reused 106960 (delta 105975), pack-reused 753159
Receiving objects: 100% (862356/862356), 633.08 MiB | 3.02 MiB/s, done.
Resolving deltas: 100% (633397/633397), completed with 41345 local objects.
From https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable
...
 * [new tag]                   v6.12.24             -> v6.12.24
 * [new tag]                   v6.12.25             -> v6.12.25
 * [new tag]                   v6.12.26             -> v6.12.26
 * [new tag]                   v6.12.27             -> v6.12.27
 * [new tag]                   v6.12.28             -> v6.12.28
 * [new tag]                   v6.12.29             -> v6.12.29
 * [new tag]                   v6.12.30             -> v6.12.30
 * [new tag]                   v6.12.32             -> v6.12.32
....
newkernver:6.12.31 (max:6.12.32)
...

and similar for 6.12.32 without errors, maybe issue with shallow clone…maybe you need the --single-branch too, but manpage says that depth implies single-branch?

pushed the updated tree

I don’t i know Frank, but i cloned the tree again and yes, 6.12.32 came. Running it now. Fiber working again, thanks for the update Frank. Nex time, i try without --depth 1.

@frank-w I’m writing a complete tutorial for installing your debian in emmc. However i’m having this error:

compilador@debian /home/compilador $ git clone --depth 1 https://github.com/frank-w/BPI-Router-Images
cd BPI-Router-Images/
Cloning into 'BPI-Router-Images'...
remote: Enumerating objects: 88, done.
remote: Counting objects: 100% (88/88), done.
remote: Compressing objects: 100% (55/55), done.
remote: Total 88 (delta 13), reused 65 (delta 4), pack-reused 0 (from 0)
Receiving objects: 100% (88/88), 21.06 KiB | 7.02 MiB/s, done.
Resolving deltas: 100% (13/13), done.

compilador@debian /home/compilador/BPI-Router-Images $ ./buildimg.sh bpi-r4 bookworm 6.12 emmc
needed: python3 python3-requests parted qemu-user-static debootstrap binfmt-support
create image for bpi-r4 (arm64) bookworm 6.12 emmc
board  : bpi-r4
kernel : 6.12
device : emmc
bpi-r3mini_emmc_bl2.img
bpi-r3mini_spim-nand_bl2.img
bpi-r3mini_spim-nand_ubi_bl2.img
bpi-r3_emmc_bl2.img
bpi-r3_nor_bl2.img
bpi-r3_nor_ubi_bl2.img
bpi-r3_sdmmc_bl2.img
bpi-r3_spim-nand_bl2.img
bpi-r3_spim-nand_ubi_bl2.img
bpi-r4_emmc_8GB_bl2.img
bpi-r4_emmc_bl2.img
bpi-r4_sdmmc_8GB_bl2.img
bpi-r4_sdmmc_bl2.img
bpi-r4_spim-nand_8GB_bl2.img
bpi-r4_spim-nand_bl2.img
bpi-r4_spim-nand_ubi_8GB_bl2.img
bpi-r4_spim-nand_ubi_bl2.img
bpi-r64_emmc_bl2.img
bpi-r64_sdmmc_bl2.img
files: {
  "bpi-r2pro": {
    "sdmmc": {
      "name": "bpi-r2pro_sdmmc.img.gz",
      "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r2pro_sdmmc.img.gz"
    }
  },
  "bpi-r2": {
    "sdmmc": {
      "name": "bpi-r2_sdmmc.img.gz",
      "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r2_sdmmc.img.gz"
    }
  },
  "bpi-r3mini": {
    "emmc": {
      "name": "bpi-r3mini_emmc.img.gz",
      "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r3mini_emmc.img.gz",
      "bl2": {
        "name": "bpi-r3mini_emmc_bl2.img",
        "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r3mini_emmc_bl2.img"
      },
      "fip": {
        "name": "bpi-r3mini_emmc_fip.bin",
        "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r3mini_emmc_fip.bin"
      }
    },
    "ram": {
      "bl2": {
        "name": "bpi-r3mini_ram_bl2.bin",
        "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r3mini_ram_bl2.bin"
      },
      "fip": {
        "name": "bpi-r3mini_ram_fip.bin",
        "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r3mini_ram_fip.bin"
      }
    },
    "spim-nand": {
      "bl2": {
        "name": "bpi-r3mini_spim-nand_bl2.img",
        "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r3mini_spim-nand_bl2.img",
        "UBI": {
          "name": "bpi-r3mini_spim-nand_ubi_bl2.img",
          "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r3mini_spim-nand_ubi_bl2.img"
        }
      },
      "fip": {
        "name": "bpi-r3mini_spim-nand_ubi_fip.bin",
        "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r3mini_spim-nand_ubi_fip.bin"
      }
    }
  },
  "bpi-r3": {
    "emmc": {
      "name": "bpi-r3_emmc.img.gz",
      "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r3_emmc.img.gz",
      "bl2": {
        "name": "bpi-r3_emmc_bl2.img",
        "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r3_emmc_bl2.img"
      },
      "fip": {
        "name": "bpi-r3_emmc_fip.bin",
        "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r3_emmc_fip.bin"
      }
    },
    "nor": {
      "bl2": {
        "name": "bpi-r3_nor_bl2.img",
        "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r3_nor_bl2.img",
        "UBI": {
          "name": "bpi-r3_nor_ubi_bl2.img",
          "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r3_nor_ubi_bl2.img"
        }
      },
      "fip": {
        "name": "bpi-r3_nor_ubi_fip.bin",
        "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r3_nor_ubi_fip.bin"
      }
    },
    "ram": {
      "bl2": {
        "name": "bpi-r3_ram_bl2.bin",
        "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r3_ram_bl2.bin"
      },
      "fip": {
        "name": "bpi-r3_ram_fip.bin",
        "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r3_ram_fip.bin"
      }
    },
    "sdmmc": {
      "name": "bpi-r3_sdmmc.img.gz",
      "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r3_sdmmc.img.gz",
      "bl2": {
        "name": "bpi-r3_sdmmc_bl2.img",
        "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r3_sdmmc_bl2.img"
      },
      "fip": {
        "name": "bpi-r3_sdmmc_fip.bin",
        "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r3_sdmmc_fip.bin"
      }
    },
    "spim-nand": {
      "bl2": {
        "name": "bpi-r3_spim-nand_bl2.img",
        "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r3_spim-nand_bl2.img",
        "UBI": {
          "name": "bpi-r3_spim-nand_ubi_bl2.img",
          "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r3_spim-nand_ubi_bl2.img"
        }
      },
      "fip": {
        "name": "bpi-r3_spim-nand_ubi_fip.bin",
        "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r3_spim-nand_ubi_fip.bin"
      }
    }
  },
  "bpi-r4": {
    "emmc": {
      "name": "bpi-r4_emmc.img.gz",
      "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r4_emmc.img.gz",
      "bl2": {
        "8G": {
          "name": "bpi-r4_emmc_8GB_bl2.img",
          "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r4_emmc_8GB_bl2.img"
        },
        "name": "bpi-r4_emmc_bl2.img",
        "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r4_emmc_bl2.img"
      },
      "fip": {
        "name": "bpi-r4_emmc_fip.bin",
        "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r4_emmc_fip.bin"
      }
    },
    "ram": {
      "bl2": {
        "name": "bpi-r4_ram_bl2.bin",
        "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r4_ram_bl2.bin"
      },
      "fip": {
        "name": "bpi-r4_ram_fip.bin",
        "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r4_ram_fip.bin"
      }
    },
    "sdmmc": {
      "name": "bpi-r4_sdmmc.img.gz",
      "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r4_sdmmc.img.gz",
      "bl2": {
        "8G": {
          "name": "bpi-r4_sdmmc_8GB_bl2.img",
          "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r4_sdmmc_8GB_bl2.img"
        },
        "name": "bpi-r4_sdmmc_bl2.img",
        "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r4_sdmmc_bl2.img"
      },
      "fip": {
        "name": "bpi-r4_sdmmc_fip.bin",
        "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r4_sdmmc_fip.bin"
      }
    },
    "spim-nand": {
      "bl2": {
        "8G": {
          "name": "bpi-r4_spim-nand_8GB_bl2.img",
          "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r4_spim-nand_8GB_bl2.img",
          "UBI": {
            "name": "bpi-r4_spim-nand_ubi_8GB_bl2.img",
            "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r4_spim-nand_ubi_8GB_bl2.img"
          }
        },
        "name": "bpi-r4_spim-nand_bl2.img",
        "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r4_spim-nand_bl2.img",
        "UBI": {
          "name": "bpi-r4_spim-nand_ubi_bl2.img",
          "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r4_spim-nand_ubi_bl2.img"
        }
      },
      "fip": {
        "name": "bpi-r4_spim-nand_ubi_fip.bin",
        "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r4_spim-nand_ubi_fip.bin"
      }
    }
  },
  "bpi-r64": {
    "emmc": {
      "name": "bpi-r64_emmc.img.gz",
      "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r64_emmc.img.gz",
      "bl2": {
        "name": "bpi-r64_emmc_bl2.img",
        "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r64_emmc_bl2.img"
      },
      "fip": {
        "name": "bpi-r64_emmc_fip.bin",
        "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r64_emmc_fip.bin"
      }
    },
    "sdmmc": {
      "name": "bpi-r64_sdmmc.img.gz",
      "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r64_sdmmc.img.gz",
      "bl2": {
        "name": "bpi-r64_sdmmc_bl2.img",
        "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r64_sdmmc_bl2.img"
      },
      "fip": {
        "name": "bpi-r64_sdmmc_fip.bin",
        "url": "https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r64_sdmmc_fip.bin"
      }
    }
  }
}
initfiles: {'rootfs_armhf.cpio.zst': 'https://github.com/frank-w/buildroot/releases/download/CI-BUILD-2025.05-bpi-armhf-2025-07-16_1747/rootfs_armhf.cpio.zst', 'rootfs_arm64.cpio.zst': 'https://github.com/frank-w/buildroot/releases/download/CI-BUILD-2025.05-bpi-arm64-2025-07-16_1747/rootfs_arm64.cpio.zst'}
board:bpi-r4 ubootfile: {'name': 'bpi-r4_emmc.img.gz', 'url': 'https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r4_emmc.img.gz', 'bl2': {'8G': {'name': 'bpi-r4_emmc_8GB_bl2.img', 'url': 'https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r4_emmc_8GB_bl2.img'}, 'name': 'bpi-r4_emmc_bl2.img', 'url': 'https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r4_emmc_bl2.img'}, 'fip': {'name': 'bpi-r4_emmc_fip.bin', 'url': 'https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r4_emmc_fip.bin'}}
board:bpi-r4 kernelfile: https://github.com/frank-w/BPI-Router-Linux/releases/download/CI-BUILD-6.12-main-6.12.39-2025-07-19_1110/bpi-r4_6.12.39-main.tar.gz
ubootfile: {'name': 'bpi-r4_emmc.img.gz', 'url': 'https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r4_emmc.img.gz', 'bl2': {'8G': {'name': 'bpi-r4_emmc_8GB_bl2.img', 'url': 'https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r4_emmc_8GB_bl2.img'}, 'name': 'bpi-r4_emmc_bl2.img', 'url': 'https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r4_emmc_bl2.img'}, 'fip': {'name': 'bpi-r4_emmc_fip.bin', 'url': 'https://github.com/frank-w/u-boot/releases/download/CI-BUILD-2025-07-bpi-2025.07-2025-07-22_1719/bpi-r4_emmc_fip.bin'}} filename: bpi-r4_emmc.img.gz
kernelfile: https://github.com/frank-w/BPI-Router-Linux/releases/download/CI-BUILD-6.12-main-6.12.39-2025-07-19_1110/bpi-r4_6.12.39-main.tar.gz filename: bpi-r4_6.12.39-main.tar.gz
-rw-r--r-- 1 compilador compilador 65 Aug  9 14:27 sourcefiles_bpi-r4.conf
image-file: bpi-r4_emmc.img.gz
kernel-file: bpi-r4_6.12.39-main.tar.gz
checking for needed packages...
debootstrap missing
-rw-r--r-- 1 compilador compilador 7.6M Aug  9 14:27 bpi-r4_emmc.img.gz
ls: cannot access 'bookworm_arm64.tar.gz': No such file or directory
rootfs file missing

I also tried manually downloading the u-boot file, build with skipubootdownload=1 and skipkerneldownload=1 with just ./buildimg.sh bpi-r4 bookworm, same error. But yesterday it ran fine. Am i missing something or something changed in the repo?

EDIT: Alright, here’s the thing, yesterday i compiled as root, today as a normal user. Error is debootstrap missing, because /usr/sbin/debootstrap is not the $PATH for normal user. @frank-w am i screwing something up on my bashrc file or some sudo missing on the build scripts? This is why i always do stuff as root :slight_smile:

This script makes sudo where needed. Please do not run as root…but you have to install some packages like debootstrap and qemu-static. /usr/sbin should be in path for root after run with sudo

But it is possible that files are created as root which cannot be overwritten with normal user.

Frank, the necessary packages are installed. That error still happens if run as a normal user. So what is the solution?

  • A normal user should have /usr/sbin in $PATH.
  • Run sudo ./buildimg.sh
  • Adding some missing sudo somewhere

Here on debian 12, a normal user does not have /usr/sbin in $PATH. And that makes sense. sbin is for super users.

That is clear that normal user does not have it in path,but debootstrap is called with sudo and should find debootstrap. But i have tested it only on ubuntu where script works.

Maybe you can disable the check as this is not called with sudo

Possibly in ubuntu this command is in /usr/bin

edit in ubuntu $PATH contains the /usr/sbin and /usr/local/sbin where debootstrap is located…so i need a different way for checking if command is there

Frank, here it works fine with sudo ./buildimg.sh. No permissions issues that i can see. Not during building, nor later in the emmc system. So, i guess it’s better to keep simple.