I would like to learn how to build a custom kernel package for Debian on Excito B3. However I need some help with that.
I'm a developer by trade and quite comfortable managing Debian systems. Howerver C is not my home turf and I suppose the kernel needs to be cross compiled on a X86_64 to avoid a compile cycle measured in days.
I have found https://github.com/Excito/kernel-5.10 and I suppose a good start is to check out that repository on my laptop. Then what? Merge it with a more recent upstream repo? How? And then?
Help!
New user's registration have been closed due to high spamming and low trafic on this forum. Please contact forum admins directly if you need an account. Thanks !
How to build a kernel for Debian on Excito B3
Re: How to build a kernel for Debian on Excito B3
My primary goal is to be able to build the most recent kernel version of Debian, 5.10.162.
An awesome but perhaps less likely stretch goal for me is to attempt the most recent Debian testing kernel. Right now 6.1.12.
https://tracker.debian.org/pkg/linux
An awesome but perhaps less likely stretch goal for me is to attempt the most recent Debian testing kernel. Right now 6.1.12.
https://tracker.debian.org/pkg/linux
Re: How to build a kernel for Debian on Excito B3
I have not built a uImage kernel for quite some time now. Too much of a hassle. The last one I built I configured with an initrd to serve as a secondary 'BIOS' that enables me to boot a regular zImage. This idea originally came from Sakaki and I refined it to be more transparent towards the final running system. I have the methods as well as the preboot kernel available on my GitHub account (https://github.com/gordonb3/bubba-b3-kernel). To build your own kernel you also need the buildkernel-b3 script from Sakaki (https://github.com/sakaki-/buildkernel-b3).
You can simply build a new kernel on the B3 itself. Make sure that you have screen installed and started so that you will not have to keep the SSH connection open. Yes building on the B3 will take quite some time and so if sources allow I do use a x86 virtual machine for cross compiling because I found that x86_64 crossdev creates paths that are typical for the host operating system and you end up with items ending up in e.g. /usr/lib64 and it doesn't work on the B3.
You can simply build a new kernel on the B3 itself. Make sure that you have screen installed and started so that you will not have to keep the SSH connection open. Yes building on the B3 will take quite some time and so if sources allow I do use a x86 virtual machine for cross compiling because I found that x86_64 crossdev creates paths that are typical for the host operating system and you end up with items ending up in e.g. /usr/lib64 and it doesn't work on the B3.
Re: How to build a kernel for Debian on Excito B3
Oh, to create a kernel:
- install the kernel source package
- copy `.config` from your current running kernel (or that from that GitHub page) into the main source directory (where Makefile is)
- run `make menuconfig` (also do this if you do not intend to make changes to the config)
- if you do want to add functions or modules you can select them here
- exit menuconfig
- if using the method I linked above run `build-zImage-b3`
- to create a uImage: run `make zImage && make kirkwood-b3.dtb && make modules_install`, then follow up with the following commands
Code: Select all
pushd arch/arm/boot # per https://lists.debian.org/debian-boot/2012/08/msg00804.html echo -n -e \\x11\\x3f\\x3f\\xee > cache_head_patch echo -n -e \\x01\\x35\\xc3\\xe3 >> cache_head_patch echo -n -e \\x11\\x3f\\x2f\\xee >> cache_head_patch echo -n -e \\x00\\x30\\xa0\\xe3 >> cache_head_patch echo -n -e \\x17\\x3f\\x07\\xee >> cache_head_patch cat cache_head_patch zImage dts/kirkwood-b3.dtb > zImage-dts-appended rm cache_head_patch mkimage -A arm -O linux -T kernel -C none -a 0x00008000 -e 0x00008000 \ -n "Bubba B3 kernel" -d zImage-dts-appended ../../../uImage rm zImage-dts-appended popd
Re: How to build a kernel for Debian on Excito B3
Building custom kernel for the b3's debian system is one area where documentation is ... well absent. It's not overly complicated but I admit I never took the time to write it. Note that the goal is to create a kernel deb package.
You can either build this package directly on the b3 (at least 8 hours) or cross-compile it on another system (~20-30 minutes on a reasonably modern computer). To cross compile, you need to install cross compilation tools and dependencies with the following commands on a debian system or chroot :
If you compile directly on a b3, you just need to install build dependencies :
After that, you can clone the repository (as a regular user of course):
I use quilt to manage the patches, you should configure it following this guide.
Now everything is in place. You could compile a binary-only package with these commands:
Then apply the configuration (remove ARCH=arm if you run this directly on the b3) :
You can then edit the configuration with the usual tools :
Once you're happy with your configuration, generate the new configuration file and refresh the configuration patch:
After that you can recompile the binary package with the above dpkg-buildpackage command, upload and test it on the b3.
In order to compile a newer version, you need first to port the patches in debian/patches for this version. This is a different beast as sometimes kernel changes between the versions break things and you need to update the patches. Quilt makes this easy though as long as you're careful.
Note that as bookworm is in soft freeze, it seems that the included kernel will be 6.1 series. I will soon start working on creating a 6.1 package for the b3.
You can either build this package directly on the b3 (at least 8 hours) or cross-compile it on another system (~20-30 minutes on a reasonably modern computer). To cross compile, you need to install cross compilation tools and dependencies with the following commands on a debian system or chroot :
Code: Select all
dpkg --add-architecture armel
apt update
apt install crossbuild-essential-armel device-tree-compiler u-boot-tools bc gawk bison flex libncurses-dev libssl-dev devscripts git git-buildpackage
Code: Select all
apt update
apt install build-essential device-tree-compiler u-boot-tools bc gawk bison flex libncurses-dev libssl-dev devscripts git git-buildpackage
Code: Select all
git clone https://github.com/Excito/kernel-5.10.git
Now everything is in place. You could compile a binary-only package with these commands:
- Cross-compiling :
Code: Select all
dpkg-buildpackage -aarmel -us -uc -b
- Directly on the b3 :
Code: Select all
dpkg-buildpackage -us -uc -b
Code: Select all
quilt push -a
Code: Select all
make ARCH=arm bubba3_defconfig
Code: Select all
make ARCH=arm menuconfig
Code: Select all
make ARCH=arm savedefconfig
mv defconfig arch/arm/bubba3_defconfig
quilt refresh
In order to compile a newer version, you need first to port the patches in debian/patches for this version. This is a different beast as sometimes kernel changes between the versions break things and you need to update the patches. Quilt makes this easy though as long as you're careful.
Note that as bookworm is in soft freeze, it seems that the included kernel will be 6.1 series. I will soon start working on creating a 6.1 package for the b3.
Re: How to build a kernel for Debian on Excito B3
Thanks Mouette and Gordon for your help!
Now I have something to do the next rainy weekend here. And the south of Sweden is quite rainy this time of the year, so sooner rather than later i believe.
I'll be back with a followup on my progress.
Thanks again, this has been on my TODO-list for quite some time!
Now I have something to do the next rainy weekend here. And the south of Sweden is quite rainy this time of the year, so sooner rather than later i believe.
I'll be back with a followup on my progress.
Thanks again, this has been on my TODO-list for quite some time!
Re: How to build a kernel for Debian on Excito B3
FYI I created a 6.1 repository and ported the patchset and configuration. It compiles fine but I did not test it yet.