KernelBuild » History » Version 11
Denis 'GNUtoo' Carikli, 02/03/2016 05:27 PM
1 | 1 | Denis 'GNUtoo' Carikli | h1. KernelBuild |
---|---|---|---|
2 | |||
3 | 2 | Denis 'GNUtoo' Carikli | h2. Use case |
4 | |||
5 | Building a kernel aside Replicant, is faster to setup and faster to build since you need to fetch and use the huge Android build system. |
||
6 | |||
7 | Users wanting to add a driver to their kernel, or developers that want to work on kernel related areas can do that to speed up the development process, however if the changes are integrated back into Replicant, they will automatically be built by the Android build system, when building images. |
||
8 | |||
9 | 4 | Denis 'GNUtoo' Carikli | h2. Dependencies |
10 | 1 | Denis 'GNUtoo' Carikli | |
11 | 4 | Denis 'GNUtoo' Carikli | Since you are not compiling any userspace applications, you don't need the Android build system. The Linux Kenrel, and Bootloaders such as uboot can be built without the Android build system. |
12 | |||
13 | The Trisquel ARM version of gcc seem to work well. |
||
14 | |||
15 | 1 | Denis 'GNUtoo' Carikli | If you use distributions such as Parabola, this will probably not work because the arm-none-eabi-gcc is too recent for many devices kernels. |
16 | |||
17 | 4 | Denis 'GNUtoo' Carikli | To workaround that you can install Trisquel in a container. |
18 | This way it will have very few CPU and memory overhead compared to a virtual machine. |
||
19 | It will also save disk space since you can just store the Trisquel rootfs in any directory. |
||
20 | |||
21 | 10 | Denis 'GNUtoo' Carikli | h2. Example with crespo under Trisquel |
22 | 1 | Denis 'GNUtoo' Carikli | |
23 | 10 | Denis 'GNUtoo' Carikli | h3. Getting the right parameters |
24 | |||
25 | 6 | Denis 'GNUtoo' Carikli | First download the following example image and its signatures: |
26 | * http://ftp-osl.osuosl.org/pub/replicant/images/replicant-4.2/0004/security/4A80EB23.asc |
||
27 | 5 | Denis 'GNUtoo' Carikli | * http://ftp-osl.osuosl.org/pub/replicant/images/replicant-4.2/0004/images/crespo/replicant-4.2-crespo.zip.asc |
28 | * http://ftp-osl.osuosl.org/pub/replicant/images/replicant-4.2/0004/images/crespo/replicant-4.2-crespo.zip |
||
29 | 1 | Denis 'GNUtoo' Carikli | |
30 | As usual, verify the signature: |
||
31 | 6 | Denis 'GNUtoo' Carikli | <pre> |
32 | 8 | Denis 'GNUtoo' Carikli | $ gpg --import 4A80EB23.asc |
33 | $ gpg --verify replicant-4.2-crespo.zip.asc |
||
34 | 6 | Denis 'GNUtoo' Carikli | </pre> |
35 | It should then say something like: |
||
36 | <pre> |
||
37 | $ gpg --verify replicant-4.2-crespo.zip.asc |
||
38 | gpg: assuming signed data in 'replicant-4.2-crespo.zip' |
||
39 | gpg: Signature made Tue 01 Sep 2015 01:31:47 PM CEST using RSA key ID 4A80EB23 |
||
40 | gpg: Good signature from "Replicant project release key <contact@replicant.us>" [unknown] |
||
41 | gpg: WARNING: This key is not certified with a trusted signature! |
||
42 | gpg: There is no indication that the signature belongs to the owner. |
||
43 | Primary key fingerprint: E776 092B 052A DC91 FDD1 FD80 16D1 FEEE 4A80 EB23 |
||
44 | </pre> |
||
45 | 5 | Denis 'GNUtoo' Carikli | |
46 | 7 | Denis 'GNUtoo' Carikli | Then unpack the zip file: |
47 | <pre> |
||
48 | 8 | Denis 'GNUtoo' Carikli | $ mkdir replicant-4.2-crespo && cd replicant-4.2-crespo && unzip ../replicant-4.2-crespo.zip |
49 | 7 | Denis 'GNUtoo' Carikli | </pre> |
50 | |||
51 | 9 | Denis 'GNUtoo' Carikli | That should have extracted a boot.img. We then should not forget to look at what format the boot.img is in: |
52 | <pre> |
||
53 | $ file boot.img |
||
54 | 1 | Denis 'GNUtoo' Carikli | boot.img: Android bootimg, kernel (0x30008000), ramdisk (0x31000000), page size: 4096, cmdline (console=ttyFIQ0 no_console_suspend) |
55 | </pre> |
||
56 | Here it says it's an "Android bootimg", so we need the following tools: |
||
57 | 10 | Denis 'GNUtoo' Carikli | * mkbootimg to pack an image |
58 | * unbootimg to unpack an image |
||
59 | |||
60 | Ways to get such tools: |
||
61 | * Pre-built by Replicant at http://ftp-osl.osuosl.org/pub/replicant/images/replicant-4.2/0004/tools/ |
||
62 | * Build Replicant and use its tools. That defeat the purpose here since we want to avoid building Replicant fully. |
||
63 | |||
64 | Some android tools were converted to build on GNU/Linux without requiring the Android build system. |
||
65 | * In git://git.freesmartphone.org/utilities.git you have adb in android/adb, mkbootimg and unbootimg in android/image-utils |
||
66 | |||
67 | Some GNU/Linux distributions also have packages for some of the tools. |
||
68 | 9 | Denis 'GNUtoo' Carikli | |
69 | 11 | Denis 'GNUtoo' Carikli | Now we can finally get the right parameters that we will use later to rebuild a boot.img |
70 | 1 | Denis 'GNUtoo' Carikli | <pre> |
71 | 11 | Denis 'GNUtoo' Carikli | $ unbootimg -i boot.img |
72 | total image size: 3100672 |
||
73 | kernel size: 2903532 |
||
74 | kernel load addr: 0x30008000 |
||
75 | ramdisk size: 189142 |
||
76 | ramdisk load addr: 0x31000000 |
||
77 | 2nd boot size: 0 |
||
78 | 2nd boot load addr: 0x30f00000 |
||
79 | kernel tags addr: 0x30000100 |
||
80 | page size: 4096 |
||
81 | board: `' |
||
82 | cmdline: `console=ttyFIQ0 no_console_suspend' |
||
83 | id: bd59d387bf083b0946e25a8f17f1aaef4bcc7412000 |
||
84 | </pre> |
||
85 | |||
86 | h3. Building |
||
87 | |||
88 | <pre> |
||
89 | 4 | Denis 'GNUtoo' Carikli | $ git clone https://git.replicant.us/replicant/kernel_samsung_crespo.git |
90 | 1 | Denis 'GNUtoo' Carikli | </pre> |
91 | 11 | Denis 'GNUtoo' Carikli | |
92 | h3. Repacking |
||
93 | |||
94 | h3. Testing |