LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Embedded & Single-board computer (https://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/)
-   -   Cross-compiling a custom-kernel for Raspbian PI2; HowTo? (https://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/cross-compiling-a-custom-kernel-for-raspbian-pi2%3B-howto-4175717688/)

floppy_stuttgart 10-12-2022 12:01 PM

Cross-compiling a custom-kernel for Raspbian PI2; HowTo?
 
Hello,
according this https://www.raspberrypi.com/document...ux_kernel.html
I am trying to cross-compile a new custom-kernel for my pi2 (3G/1G instead of the standard 2G/2G).

sudo apt install git bc bison flex libssl-dev make libc6-dev libncurses5-dev
sudo apt install crossbuild-essential-armhf
git clone --depth=1 https://github.com/raspberrypi/linux
make bcm2709_defconfig

give the error..

Quote:

HOSTCC scripts/basic/fixdep
HOSTCC scripts/kconfig/conf.o
HOSTCC scripts/kconfig/confdata.o
HOSTCC scripts/kconfig/expr.o
LEX scripts/kconfig/lexer.lex.c
YACC scripts/kconfig/parser.tab.[ch]
HOSTCC scripts/kconfig/lexer.lex.o
HOSTCC scripts/kconfig/menu.o
HOSTCC scripts/kconfig/parser.tab.o
HOSTCC scripts/kconfig/preprocess.o
HOSTCC scripts/kconfig/symbol.o
HOSTCC scripts/kconfig/util.o
HOSTLD scripts/kconfig/conf
***
*** Can't find default configuration "arch/x86/configs/bcm2709_defconfig"!
***
make[1]: *** [scripts/kconfig/Makefile:94: bcm2709_defconfig] Fehler 1
make: *** [Makefile:619: bcm2709_defconfig] Fehler 2
I suppose I have to get the .config file from the raspberry pi2 and store it locally where I am in the cross-compiler. Correct ?

Or there is any other method to create that .config file for my pi2 locally on my cross-compiler (debian11 64bits desktop) ?
How?

Any hint and support is welcome.



UPDATE:

the command above was wrong. A new command seems ok. I will close in few hours if all fine.
Code:

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bcm2709_defconfig
Code:

#
# configuration written to .config
#


business_kid 10-12-2022 01:55 PM

did you use sudo? Error 1 is permissions, IIRC.

floppy_stuttgart 10-12-2022 02:32 PM

So far, it cross-compiled.

I identified a pi2 based on
cat /sys/firmware/devicetree/base/model
Quote:

Raspberry Pi Model B Rev 2
I moved the created cross-compiled ZImage to kernel7.img on the /boot/ directory of the pi2 SD card but, after a boot, by making dmesg I see
Quote:

Linux version 5.15.72+ (dom@buildbot) (arm-linux-gnueabihf-gcc-8 (Ubuntu/Linaro 8.4.0-3ubuntu1) 8.4.0, GNU ld (GNU Binutils for Ubuntu) 2.34) #1591 Wed Oct 5 12:01:13 BST 2022
In order for the pi2 to boot with correct kernel, I included in
sudo nano /boot/config.txt
...
[pi2]
kernel=kernel7.img
..

If anybody have an explanation why it is not Oct 12 which would be todays time (because the customized kernel7.img was created today oct 12).
Perhaps is the pi2 booting with another kernel?

floppy_stuttgart 10-12-2022 02:36 PM

Quote:

Originally Posted by business_kid (Post 6385996)
did you use sudo? Error 1 is permissions, IIRC.

No.
In fact, I used wrongly
Code:

make bcm2709_defconfig
instead of
Code:

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bcm2709_defconfig
(both local user compiling in an area /home/user/Downloads/linux..)

floppy_stuttgart 10-12-2022 02:48 PM

Or perhaps this is a PI1 ? I am confused..

cat /proc/cpuinfo
Quote:

processor : 0
model name : ARMv6-compatible processor rev 7 (v6l)
BogoMIPS : 697.95
Features : half thumb fastmult vfp edsp java tls
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xb76
CPU revision : 7

Hardware : BCM2835
Revision : 000e
Serial : 000000002a35d1af
Model : Raspberry Pi Model B Rev 2
according this
https://linuxhint.com/identify-raspberry-pi/
the BCM2835 is a PI1 with 2x USB. Which is the case.

I will have to review all my doing. Looks like my thinking of a PI2 was wrong.
Thats a PI1 and it was looking at boot at the kernel.img which was the old one.
Modifying config.txt
... with ...
[pi2]
kernel=kernel7.img
..
was then for sure useless.
Lets redo the whole thing.

business_kid 10-13-2022 04:03 AM

The change was that the folks at RazPi stopped using the BCM2836 in the Pi 2 in favour of the BCM2837 which had the A53 core. You can just google for specs.

You want at least the Pi 4 w/8G. If there's a little more cash about, there's an Arm A-72 16 core chip from NXP (runs @2 Ghz). It's built into a tiny server being sold fairly cheap by http://www.solid-run.com in Israel and you can get decent memory for that. Video is not really supplied, however, as it's a server.

floppy_stuttgart 10-15-2022 10:44 AM

Yes. Its working. Its a PI1 (I have another PI4 where my project is working but would like to make it working on that PI1) and the correct kernel is recognized at boot.

Linux version 5.15.73+ (xxxx) (arm-linux-gnueabihf-gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2) #2 Thu Oct 13 10:55:19 CEST 2022

Now its booting a bit weird and new errors are coming up.

systemd[1]: Failed to start Load Kernel Modules.
systemd[1]: Failed to mount Arbitrary Executable File Formats File System.


I missed something at the install recommend https://www.raspberrypi.com/document...ux_kernel.html
Quote:

sudo env PATH=$PATH make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=mnt/ext4 modules_install
I must see how to adapt it to my setup.

floppy_stuttgart 10-15-2022 11:08 AM

mkdir mnt
mkdir mnt/fat32
mkdir mnt/ext4
sudo mount /dev/sdd1 mnt/fat32
sudo mount /dev/sdd2 mnt/ext4
sudo env PATH=$PATH make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=mnt/ext4 modules_install

No errors anymore.
The correct cross-compiled kernel is in use.

End-summary:
- my original assumption was wrong: that was a pi1 instead of a pi2
- cross-compile a kernel for a pi1; after 2 days of compiling, I CTRL-C the local pi1 compilation (on a 6core 64bits linux PC that MUCH better; then I transfered all data onto the SD card)
- the link for cross-compiling had to be followed step by step; missing one step was creating errors


All times are GMT -5. The time now is 12:43 PM.