-
Notifications
You must be signed in to change notification settings - Fork 1
Build a B2 Kernel on your crossdev PC
Build a kernel for your B2 in minutes, using your crossdev
PC!
This guide assumes that you have already set up crossdev
and the gentoo-b2 overlay on your PC, per these instructions. So, if you haven't yet, please do this first, before proceeding.
First, we need to download some kernel sources, that have been appropriately patched for the B2. You can of course set this up yourself (the necessary patches are here), but for simplicity, in this guide we'll use gentoo-b2-sources package, which will take care of everything for us.
So, let's say you wanted 4.1.3, the version used in the current live USB image. You should issue the following to pull down the sources (note we use --nodeps
here; we don't actually want to cross-emerge the perl
etc. tools that'll be used to patch the sources, as you already have them in your native architecture (amd64
or whatever) and they'll be called from there):
gentoo_pc ~ # PORTDIR_OVERLAY="/usr/local/portage-crossdev" ARCH="ppc" powerpc-e300c3-linux-gnu-emerge --ask --verbose --nodeps ~sys-kernel/gentoo-b2-sources-4.1.3
This may take some time to complete, depending on the speed of your network connection.
Note also that while this particular kernel version's ebuild (4.1.3) was in the
gentoo-b2-sources
repository at the time of writing, it may have been replaced by the time you read this. In that case, simply use a more modern version. You can use a tool likeeix
to show all the currently available ebuild versions for a given package (such asgentoo-b2-sources
).
Incidentally, the prefix use of
PORTDIR_OVERLAY
here is to avoid polluting the/etc/portage/make.conf
file (since setting this variable is now deprecated, but is currently required forcrossdev
).
Now, go into the source directory (crossdev
automatically keeps things separate from your normal sysroot, to avoid pollution):
gentoo_pc ~ # cd /usr/powerpc-e300c3-linux-gnu/usr/src/linux-4.1.3-gentoo
Grab a suitable starter config from somewhere, such as the one used in this project ^-^, save it to .config
, and then run the buildkernel-b2
script to build the kernel (see its manpage for options; in particular, add --usb
, if you want to build a kernel that is bootable from USB, rather than the B2's hard drive, and --menuconfig
if you'd like to change the configuration using the editor, at the start of the build):
gentoo_pc linux-4.1.3-gentoo # cp <your config file> .config
gentoo_pc linux-4.1.3-gentoo # buildkernel-b2
This does a parallel make
, so on a modern PC, it shoudn't take long (5-15 mins).
When done, you'll have a deploy_root
directory, which will contain:
- a
lib
directory, with the modules and firmware for the kernel; and - a
boot
directory, which will contain either:- the
uImage
,System.map
,config
,bubba.dtb
and8313E21.dtb
files, if compiling for an HDD deployment (the default, where you did not specify the--usb
flag tobuildkernel-b2
, above); or - an
install
subdirectory, containing theinstall.itb
,8313E21.itb
,System.map
andconfig
files, if compiling for a USB deployment (where you did specify the--usb
flag tobuildkernel-b2
).
- the
You can now simply copy these files over to the real root (on the B2's hard drive, or the live-USB, as appropriate), and you can try booting with your new kernel!
The next time you invoke
buildkernel-b2
in the same directory (perhaps with a slightly altered configuration) it should be significantly faster, since most of the required components will be already compiled.
Now that you have a functioning cross-compilation environment on your PC, why not hook it up to distcc
? This will allow your B2 to leverage the power of your PC when performing local builds (for C and C++ compilation and header pre-processing), and makes it possible to use a source-based distribution like Gentoo without huge update times. See these instructions for details on how to proceed.
Wiki content license: Creative Commons Attribution-ShareAlike 4.0 International License