Linux 内核 - 尝试在 ubuntu 上交叉编译(针对 rpi zero)

Linux 内核 - 尝试在 ubuntu 上交叉编译(针对 rpi zero)

[全新的 Virtual Box VM,使用 Ubuntu 20.04,所有更新均在安装过程中完成]

我只是试着跑制作bcmrpi_defconfig在 Linux 内核 git 存储库上

已针对 RT 进行修补

wget https://mirrors.edge.kernel.org/pub/linux/kernel/projects/rt/4.19/patch-4.19.127-rt55.patch.gz
zcat patch-4.19.127-rt55.patch.gz | patch -p1

但它说了找不到 arm 编译器...

phil@rt-linux-pi:~/linux$ /home/phil/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc
bash: /home/phil/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian
/bin/arm-linux-gnueabihf-gcc: No such file or directory

phil@rt-linux-pi:~/linux$ ls /home/phil/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc -lha
lrwxrwxrwx 1 phil phil 29 Jun 25 22:58 /home/phil/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc -> arm-linux-gnueabihf-gcc-4.8.3

我现在意识到系统上找不到 arm-linux-gnueabihf-gcc

我收到这个错误

make bcmrpi_defconfig
/bin/sh: 1: /home/phil/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc: not found
/bin/sh: 1: /home/phil/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc: not found
./scripts/gcc-version.sh: 26: /home/phil/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc: not found
./scripts/gcc-version.sh: 27: /home/phil/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc: not found
./scripts/gcc-version.sh: 29: /home/phil/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc: not found
./scripts/gcc-version.sh: 26: /home/phil/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc: not found
./scripts/gcc-version.sh: 27: /home/phil/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc: not found
./scripts/gcc-version.sh: 29: /home/phil/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc: not found
init/Kconfig:17: syntax error
init/Kconfig:16: invalid option
./scripts/clang-version.sh: 15: /home/phil/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc: not found
./scripts/gcc-plugin.sh: 11: /home/phil/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc: not found
make[1]: *** [scripts/kconfig/Makefile:104: bcmrpi_defconfig] Error 1
make: *** [Makefile:534: bcmrpi_defconfig] Error 2

我试过

  • 安装构建必需品

  • 我安装了这些软件包:libncurses-dev flex bison openssl libssl-dev dkms libelf-dev libudev-dev libpci-dev libiberty-dev autoconf

  • 我修改了 PATH 变量:

echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/phil/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/

感谢你花时间回答这个问题

问候

我遵循本教程:http://www.frank-durr.de/?p=203

答案1

官方文档对事情的解释更清楚一些,并且采用了更“新的方式”

https://www.raspberrypi.org/documentation/linux/kernel/building.md

首先 mod 和源 .bashrc 文件并在末尾添加:

if [ -d "$HOME/tools/arm-bcm2708/arm-linux-gnueabihf/bin" ] ; then
    PATH="$PATH:$HOME/tools/arm-bcm2708/arm-linux-gnueabihf/bin"
fi

要构建内核,请执行以下操作:

sudo apt install git bc bison flex libssl-dev make libc6-dev libncurses5-dev

git clone --depth=1 --branch rpi-4.19.y https://github.com/raspberrypi/linux

cd linux
export KERNEL=kernel
make bcmrpi_defconfig

cd ..
git clone https://github.com/raspberrypi/tools ~/tools

cd linux

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bcmrpi_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage modules dtbs

希望这也能帮助别人

相关内容