Skip to content

Not working scripts for native compiling kernel modules #4125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pmelikov opened this issue Feb 6, 2021 · 4 comments
Closed

Not working scripts for native compiling kernel modules #4125

pmelikov opened this issue Feb 6, 2021 · 4 comments

Comments

@pmelikov
Copy link

pmelikov commented Feb 6, 2021

Describe the bug
The fixdep command as provided in the armhf header file is a x86-64 version which cannot run on armhf and arm64. This break native compilation of kernel modules. I am compiled my own kernel end headers with preemt-rt patch. Used

root@raspberrypi:/home/pi/Desktop/LEDG0_timer# file /usr/src/$(uname -r)/scripts/basic/fixdep
/usr/src/5.10.13-rt26-preemt_rt-v7+/scripts/basic/fixdep: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=fc5b93fa068bb02ca6fa1f1e2eeb99fa74a19c84, for GNU/Linux 3.2.0, not stripped

CROSS COMPILE HOST: Linux VirtualBox 5.8.0-41-generic #46~20.04.1-Ubuntu SMP Mon Jan 18 17:52:23 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
DEVICE: Pi3B+

I tryed to compile end test 4 different options :

  • kernel 5.4 and 5.10 with this parameters + rt_preemt patch:
export KERNEL=kernel8
export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-gnu-
export BIT_32=false
make -j$((`nproc`*2)) bcmrpi3_defconfig
make -j$((`nproc`*2))
  • kernel 5.4 and 5.10 with this parameters + rt_preemt patch:
export KERNEL=kernel7
export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabihf-
export BIT_32=true
make -j$((`nproc`*2)) bcm2709_defconfig
make -j$((`nproc`*2))

Two of 4 tested configs:
kernel 5.10.13-rt26-v7+ with rt-preemt patch 5.10.12-rt26
kernel 5.4.83-v8+ with rt-preemt patch 5.4.84-rt47

As base SD image i used this and just put my headers, modules, dts and kernel into it:

  • 2021-01-11-raspios-buster-armhf.zip
  • 2020-08-20-raspios-buster-arm64.zip
env PATH=$PATH make -j$((`nproc`*2)) INSTALL_MOD_PATH=../mnt/ext4 modules_install
env PATH=$PATH make -j$((`nproc`*2)) INSTALL_HDR_PATH=../mnt/ext4 headers_instal
#for armhf 
mv ../mnt/fat32/kernel.img ../mnt/fat32/kernel-backup.img
cp arch/arm/boot/zImage ../mnt/fat32/kernel.img
cp arch/arm/boot/dts/*.dtb ../mnt/fat32/
cp arch/arm/boot/dts/overlays/*.dtb* ../mnt/fat32/overlays/
cp arch/arm/boot/dts/overlays/README ../mnt/fat32/overlays/

release="$(cat ./include/config/kernel.release)" #in linux dir
cp -R linux ./mnt/ext4/usr/src/
mv -R ./mnt/ext4/usr/src/linux ./mnt/ext4/usr/src/"$release" #rename sources
cd ./mnt/ext4/
ln -sr ./usr/src/"$release" ./lib/modules/"$release"/build

Error when trying to compile "hello world" kernel module:

root@raspberrypi:/home/pi/Desktop/LEDG0_timer# make
make -C /lib/modules/5.10.13-rt26-preemt_rt-v7+/build M=/home/pi/Desktop/LEDG0_timer modules
make[1]: Entering directory '/usr/src/5.10.13-rt26-preemt_rt-v7+'
  CC [M]  /home/pi/Desktop/LEDG0_timer/LEDG0_timer.o
/bin/sh: 1: scripts/basic/fixdep: Exec format error
make[2]: *** [scripts/Makefile.build:279: /home/pi/Desktop/LEDG0_timer/LEDG0_timer.o] Error 2
make[2]: *** Deleting file '/home/pi/Desktop/LEDG0_timer/LEDG0_timer.o'
make[1]: *** [Makefile:1808: /home/pi/Desktop/LEDG0_timer] Error 2
make[1]: Leaving directory '/usr/src/5.10.13-rt26-preemt_rt-v7+'
make: *** [Makefile:4: all] Error 2
@pmelikov
Copy link
Author

pmelikov commented Feb 6, 2021

@pyavitz
Copy link

pyavitz commented Feb 7, 2021

Cross Compiling
Simply applying the byteshift patch and running make scripts doesn't always work, I recommend trying the following.

make M=scripts clean
patch -p1 < headers-byteshift.patch
echo 'y' | make -s scripts
echo 'y' | make -s M=scripts/mod/

@pyavitz
Copy link

pyavitz commented Feb 8, 2021 via email

@pmelikov
Copy link
Author

Cross Compiling

Simply applying the byteshift patch and running make scripts doesn't always work, I recommend trying the following.

make M=scripts clean

patch -p1 < headers-byteshift.patch

echo 'y' | make -s scripts

echo 'y' | make -s M=scripts/mod/

Thanks a lot, my friend. Armbian patch and making of "scripts" and "scripts/mod" solved the problem. All the best to you🙋‍♂️. Ok, later I will research your repo🤓.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants