2

Followed guide here: https://source.android.com/setup/build/building-kernels

mkdir android-kernel && cd android-kernel
repo init -u https://android.googlesource.com/kernel/manifest -b android-msm-bonito-4.9-android11-qpr2
repo sync
build/build.sh

It runs for ~7min then fails @

Creating initramfs: build/build.sh: line 967: mkbootfs: command not found

I found the mkbootfs binary, in many locations actually, and all of them, when executed, say "command not found"!

  • I tried chmod 777 & chmod +x, but same issue.
  • Tried sudo as well.
  • I tried adding $HOME/android/aosp-kernel/build/build-tools/path/linux-x86 to my PATH but same results.

build\build.sh Line 967 is not where the mkbootfs cmd is, but it does appear on line 980:

mkbootfs "${INITRAMFS_STAGING_DIR}" >"${MODULES_STAGING_DIR}/initramfs.cpio"

What is the expected result when mkbootfs is run without parameters??

I'd think this would be easy. For some reason, I can't find anything helpful on the net.

Please help.

4
  • What about the system you are building AOSP on? Is it a regular x86_64 Linux PC or something different?
    – Robert
    Jul 8, 2021 at 7:11
  • It is WSL2 running Ubuntu 20.x. I've successfully compiled several ROMs & kernels, LineageOS, without issue, so didn't think much of that. But I did try the mkbootfs binary on a raspberry pi 4 (debian) & still got "command not found". Is that expected when executed with no parameters? I wouldn't think so.
    – Kevin
    Jul 8, 2021 at 14:22
  • You can't transfer a binary from an x86 platform to an ARM[64] platform, that will never work. You should execute file mkbootfs on the binary to see for what platform it has been compiled.
    – Robert
    Jul 8, 2021 at 14:39
  • Thank you Robert - you sent me down the right path. At first I was simply trying to determine HOW to validate the mkbootfs file - in the end, executing it should issue the error: "error: no directories to process?!". I have no idea why my binaries in my AOSP directory, that compile just fine, dont work. You actually taught me a few things as well about how to troubleshoot - and in the end, my continued search to find these binaries is what helped me fix it. Now...how to report this bug to Google!?!
    – Kevin
    Jul 8, 2021 at 18:00

1 Answer 1

2

Issue: Cloning the repo doesn't include these folders:

  • /aosp-kernel/prebuilts/build-tools/path/linux-x86/
  • /aosp-kernel/prebuilts/build-tools/path/linux-x86/bin
  • /aosp-kernel/prebuilts/kernel-build-tools/linux-x86/bin/[mkbootfs] (& more)
  • (maybe a few more)

Note: kernel-build-tools URL/Repo is on https://android.googlesource.com/kernel/prebuilts/build-tools/+/refs/heads/master/linux-x86/bin/

Band-aid Fix: (x86 Linux)

cd ~/
mkdir kernel-build-tools
git clone https://android.googlesource.com/kernel/prebuilts/build-tools
ls -l kernel-build-tools

Add build tools you just downloaded to the path: (this will work as the current user, NOT SUDO!)

nano ~/.profile

Paste the following lines at the end of your ~/.profile file.

# add Kernel tools to path
if [ -d "$HOME/kernel-build-tools/build-tools/linux-x86/bin" ] ; then
    PATH="$HOME/kernel-build-tools/build-tools/linux-x86/bin:$PATH"
fi

Refresh your shell environment: source ~/.profile

VALIDATE: mkbootfs -> "error: no directories to process?!" (This is good!)

I was able to compile it after this. FYI, ~/aosp-kernel/ is where I synced the Android kernel to.

1
  • The procedure above also works for the following error: "build/build.sh: line 885: soong_zip: command not found" πŸ˜πŸ‘πŸ»
    – thau0x01
    Jan 17, 2023 at 13:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .