1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
===================================================
Raspberry Pi (RPI): How to Install a New Kernel
===================================================
.. _rpi-deploy-kernel:
.. contents::
:depth: 1
:local:
:backlinks: none
.. highlight:: console
Tutorial Assumptions
--------------------
For simplicity's sake, this tutorial will assume that you already read
:ref:`How to cross-compile your kernel with kw<cross-compilation>` and
:ref:`How to Install a New Kernel<deploy-kernel>`. If not, get back here later;
we will wait for you :)
Anyway, we also assume the following tasks are completed:
* You already compiled your kernel
* You have a working `.config` file
* You will use remote deploy. Remember, to deploy remotely, you need to
have root access to the target machine via ssh.
* All commands in this tutorial must be executed inside a kernel tree. If you want to work with Raspberry Pi, use this `repository <https://github.com/raspberrypi/linux>`.
We also assume that you have a Raspberry Pi (RPI) with Rasbian (it could be 32
or 64 bits), but keep in mind that the steps described here are generic, and we
just decided to focus on this device to have a way to provide some practical
examples.
DTB file and kworkflow.config
-----------------------------
Some architectures require Device Tree Binary (dtb) and Device Tree Binary
Overlay (dtbo) files, and Raspberry Pi falls into this category. We usually
need to add these files in a specific location for a functional boot. For
example, in the case of RPI 4 32 bits, it should be under the ``/boot`` folder,
and for RPI 4 64 bits, it is ``/boot/broadcom``. However, these locations may
vary, so we need to tell kw how to handle these files, but don't worry, this is
a trivial task. Open your ``.kw/deploy.config`` and search for::
dtb_copy_pattern=
Use this parameter to configure how kw will handle the dtb files. You have
three different options:
1. Empty: It will assume ``*.dtb``, which means that kw will copy all dtb files
to the target ``/boot`` folder. For example, RPI 4 32 bits requires this
option.
2. Folder pattern: You can specify something like
``dtb_copy_pattern=broadcom/*``, which means kw will copy all dtb files inside
the broadcom folder. This is the required option for RPI 4 64 bits.
3. Multiple folder copy: Finally, you can tell kw that you want to copy
multiple folders by using a pattern like this
``dtb_copy_pattern=broadcom,rockchip,arm``.
As you can see, kw is really flexible about handling the dtb files.
Use a default kw config template for RPI
----------------------------------------
For RPI developers, kw provides some useful templates that already setup your
config in a convenient way. If you want to deploy your kernel for an RPI 32
bits, you can use the following template::
kw init --template=rpi4-raspbian-32-cross-x86-arm
Or if you want to deploy your kernel to an RPI 4 64 bits, you can use::
kw init --template=rpi4-raspbian-64-cross-x86-arm
Build and deploy
----------------
.. note::
The RPI needs to keep the modules after they are installed, so to have a
proper deploy on the RPI is ideal to set ``strip_modules_debug_option=no``
on ``.kw/deploy.config``.
At this point, we suppose that you already compiled your kernel and added a
very cool suffix name to your image. Additionally, we presume that your target
is a machine that you have ssh access as root. For now, you can run the
glorious build and deploy::
kw bd
Other kw deploy features
------------------------
Remember that kw deploy provides many other features to handle your custom
kernel. For example, if you want to list all custom kernels that you installed
in your system, just use::
kw deploy --list
Or if you want to remove some specific kernel::
kw deploy --uninstall KERNEL_NAME
Keep in Mind
------------
In this tutorial, we used RPI 4 as a use case in order to make some of the new
concepts more practical. Nevertheless, you should be able to setup kw to handle
dtb files that need to be deployed in various ways. Finally, if this step does
not work in your custom system, consider improving kw to support your target
system workflow; patches are always welcome.
|