Difference between revisions of "How to customize kernel for Android"

[quality revision] [checked revision]
(Prerequisites)
 


This page explains how to change the kernel configuration and device tree. It is intended for Distribution Package users.

1 Prerequisites[edit]

The environment must be installed using the Distribution Package adapted to your selected microprocessor device. See the list of Android Distribution Package.

You must get Get the kernel sources as explained in How to build kernel for Android.

To be able to execute the following instructions you need , go to work from your distribution root directory and initialise initialize your environment as follows:

PC $> source build/envsetup.sh
PC $> bspsetup
PC $> lunch aosp-_<BoardId>-userdebug
Info.png The bspsetup command needs to be run only one time once for the distribution

2 Updating the kernel configuration[edit]

Info.png

The kernel configuration file used is merged between the following files (this operation is performed at the beginning of the kernel build process):

  • The Android configuration files named android-base.config and android-recommended.config files available in the device/stm/<STM32Series>-kernel/source/kconfig/<kernel version>/ directory.
  • The android-soc.config file available in the device/stm/<STM32Series>-kernel/source/kconfig/<kernel version>/ directory.

By using menuconfig, you can update adapt the configuration file for to your needs. Some guidelines are given below.

2.1 Save Saving the current configuration[edit]

Before making any changes to changing the kernel configuration, it is advised recommended to build the kernel with using the current configuration:

PC $> build_kernel

A default config file named defconfig.default is generated in out-bsp/<STM32Series>/KERNEL_OBJ/ directory.

2.2 Create Creating a new kernel configuration[edit]

Start menuconfig:

PC $> build_kernel menuconfig

You can load a .config file and modify any entry using this interface. Please read on Instructions on how to navigate are provided at the top of the windows the instructions to navigate.

Do not forget to hit click save.

This will generate generates a .config file located in out-bsp/<STM32Series>/KERNEL_OBJ/, and will also generate as well as a defconfig file in at the same placelocation.

2.3 Test Testing the new kernel configuration[edit]

To test your the new configuration you need to , rebuild the kernel, then update the prebuilts and flash, like explain in more details in as explained in How to build kernel for Android.

2.4 Applying the newly generated kernel configuration[edit]

To make your change permanent, you need first to compare the new defconfig file with the defconfig.default file generated at first build.

You can use a graphical tool like such as meld.

PC $> meld out-bsp/<STM32Series>/KERNEL_OBJ/defconfig out-bsp/<STM32Series>/KERNEL_OBJ/defconfig.default


Then report the changes to into the android-soc.config file located in device/stm/<STM32Series>-kernel/source/kconfig/<kernel version>/.

And Eventually force the regeneration of the .config:

PC $> build_kernel defaultconfig

Note: the defconfig.default is then updated.

To test your configuration you need to , rebuild the kernel , then and update the prebuilts and flash, like as explain in more details in How to build kernel for Android.

3 Changing the kernel command line[edit]

You can customize the kernel command line call at boot time. Arguments The arguments are defined in the BoardConfig.mk file located in device/stm/<STM32Series>/<BoardId>/.

Change Adapt the value of the BOARD_KERNEL_CMDLINE variable to your needs.

To Rebuild the bootimage to apply the changes, you need to rebuild the bootimage:

PC $> make bootimage-nodeps

And then Then flash the boot partition. :

Info.png To control the command line after compilation you can execute:
PC $> ./system/core/mkbootimg/unpack_bootimg --boot_img out/target/product/<BoardId>/boot.img

Check the "command line args" value from the output, : it must match your changes.

4 Changing the Device Tree[edit]

The kernel device tree used is set in the dt.mk file available in under the device/stm/<STM32Series>/build/tasks/ directory. For more information please refer to the Device tree and How to create your board device tree pages.

This The device trees are located inside the Linux® kernel source code previously loaded and . A Device Tree can be modified directly in device/stm/<STM32Series>-kernel/linux-<STM32Series>/arch/arm/boot/dts.

After modification you need to rebuild the device tree byOnce the Device Tree has been modified, rebuild it:

PC $> build_kernel -i dtb

PC $> make -j

And then re-Then flash again the DT partition.


This page explains how to change the kernel configuration and device tree. It is intended for Distribution Package users.
{{ReviewsComments | AJ 19W42 - I suggest to change the title into "How to customize the kernel for Android"}}
== Prerequisites ==

The environment must be installed using the Distribution Package adapted to your selected microprocessor device.
See the list of Android [[Which_STM32MPU_Embedded_Software_Package_for_Android_better_suits_your_needs#Distribution_Package | Distribution Package]].
You must get Get the kernel sources as explained in [[How to build kernel for Android]].

To be able to execute following instructions you need to work from execute the following instructions, go to your distribution root directory and initialiseinitialize your environment as follows:

 {{PC$}} source build/envsetup.sh
 {{PC$}} bspsetup
 {{PC$}} lunch aosp-_{{HighlightParam|''<BoardId>''}}-userdebug
{{Info| The <code>bspsetup</code> command needs to be run only one time once for the distribution}}

== Updating the kernel configuration ==
{{Info |
The kernel configuration file used is merged between the following files (this operation is performed at the beginning of the kernel build process): 
* The Android configuration files named <code>android-base.config</code> and <code>android-recommended.config</code> files available in the <code>device/stm/{{HighlightParam|''<STM32Series>''}}-kernel/source/kconfig/{{HighlightParam|''<kernel version>''}}/</code> directory.
* The <code>android-soc.config</code> file available in the <code>device/stm/{{HighlightParam|''<STM32Series>''}}-kernel/source/kconfig/{{HighlightParam|''<kernel version>''}}/</code> directory.
}}

By using <code>menuconfig</code>, you can updateadapt the configuration file forto your needs. Some guidelines are given below.

=== SaveSaving the current configuration ===

Before making any changes to changing the kernel configuration, it is advisedrecommended to build the kernel withusing the current configuration:

 {{PC$}} build_kernel

A default config file named <code>defconfig.default</code> is generated in <code>out-bsp/{{HighlightParam|''<STM32Series>''}}/KERNEL_OBJ/</code> directory.

=== CreateCreating a new kernel configuration ===

Start <code>menuconfig</code>:

 {{PC$}} build_kernel menuconfig

You can load a <code>.config</code> file and modify any entry using this interface. Please read Instructions on how to navigate are provided at the top of the windows the instructions to navigate.

Do not forget to hit click '''save'''.

This will generate generates a <code>.config</code> file located in <code>out-bsp/{{HighlightParam|''<STM32Series>''}}/KERNEL_OBJ/</code>, and will also generate as well as a <code>defconfig</code> file inat the same place.

=== Test location.

=== Testing the new kernel configuration===

To test yourthe new configuration you need to , rebuild the kernel, then update the prebuilts and flash, like explainas explained in more details in [[How to build kernel for Android]].

=== Applying the newly generated kernel configuration ===

To make your change permanent, you need first to compare the new <code>defconfig</code> file with the <code>defconfig.default</code> file generated at first build.

You can use a graphical tool like such as <code>meld</code>.
 {{PC$}} meld out-bsp/{{HighlightParam|''<STM32Series>''}}/KERNEL_OBJ/defconfig out-bsp/{{HighlightParam|''<STM32Series>''}}/KERNEL_OBJ/defconfig.default

Then report the changes tointo the <code>android-soc.config</code> file located in <code>device/stm/{{HighlightParam|''<STM32Series>''}}-kernel/source/kconfig/{{HighlightParam|''<kernel version>''}}/</code>.
AndEventually force the regeneration of the .config:
 {{PC$}} build_kernel defaultconfig
''Note: the  <code>defconfig.default </code> is then updated''.

To test your configuration you need to , rebuild the kernel, then and update the prebuilts and flash, likeas explain in more details in [[How to build kernel for Android]].

== Changing the kernel command line ==

You can customize the kernel command line call at boot time.Arguments The arguments are defined in the <code>BoardConfig.mk</code> file located in <code>device/stm/{{HighlightParam|''<STM32Series>''}}/{{HighlightParam|''<BoardId>''}}/</code>.
ChangeAdapt the value of the '''BOARD_KERNEL_CMDLINE''' variable to your needs.
To apply changes, you need to rebuild the bootimageRebuild the bootimage to apply the changes:

 {{PC$}} make bootimage-nodeps
And then Then flash the boot partition.:


{{ Info| To control the command line after compilation you can execute:

 {{PC$}} ./system/core/mkbootimg/unpack_bootimg --boot_img out/target/product/{{HighlightParam|''<BoardId>''}}/boot.img

Check the '''"command line args"''' value from the output,: it must match your changes.
}}

== Changing the Device Tree ==

The kernel device tree used is set in the <code>dt.mk</code> file available inunder the <code>device/stm/{{HighlightParam|''<STM32Series>''}}/build/tasks/</code> directory. For more information please refer to the [[Device tree]] and [[How to create your board device tree]] pages.
ThisThe device trees are located inside the Linux<sup>&reg;</sup> kernel source code previously loaded and . A Device Tree can be modified directly in <code>device/stm/{{HighlightParam|''<STM32Series>''}}-kernel/linux-{{HighlightParam|''<STM32Series>''}}/arch/arm/boot/dts</code>.
After modification you need to rebuild the device tree byOnce the Device Tree has been modified, rebuild it:

 {{PC$}} build_kernel -i dtb

 {{PC$}} make -j
And then re-flash Then flash again the DT partition.
<noinclude>

[[Category:How to Android]]
[[Category:Android]]
{{PublicationRequestId |13270 | 2019-09-12}}</noinclude>
(12 intermediate revisions by 2 users not shown)
Line 1: Line 1:
This page explains how to change the kernel configuration and device tree. It is intended for Distribution Package users.
+
{{ReviewsComments | AJ 19W42 - I suggest to change the title into "How to customize the kernel for Android"}}
   
 
== Prerequisites ==
 
== Prerequisites ==
   
The environment must be installed using the Distribution Package adapted to your selected microprocessor device.
+
The environment must be installed using the Distribution Package adapted to your microprocessor device.
 
See the list of Android [[Which_STM32MPU_Embedded_Software_Package_for_Android_better_suits_your_needs#Distribution_Package | Distribution Package]].
 
See the list of Android [[Which_STM32MPU_Embedded_Software_Package_for_Android_better_suits_your_needs#Distribution_Package | Distribution Package]].
   
You must get kernel sources as explained in [[How to build kernel for Android]].
+
Get the kernel sources as explained in [[How to build kernel for Android]].
   
To be able to execute following instructions you need to work from your distribution root directory and initialise your environment:
+
To execute the following instructions, go to your distribution root directory and initialize your environment as follows:
   
 
  {{PC$}} source build/envsetup.sh
 
  {{PC$}} source build/envsetup.sh
 
  {{PC$}} bspsetup
 
  {{PC$}} bspsetup
  {{PC$}} lunch aosp-{{HighlightParam|''<BoardId>''}}-userdebug
+
  {{PC$}} lunch aosp_{{HighlightParam|''<BoardId>''}}-userdebug
{{Info| The <code>bspsetup</code> command needs to be run only one time for the distribution}}
+
{{Info| The <code>bspsetup</code> command needs to be run only once for the distribution}}
   
 
== Updating the kernel configuration ==
 
== Updating the kernel configuration ==
 
{{Info |
 
{{Info |
 
The kernel configuration file used is merged between the following files (this operation is performed at the beginning of the kernel build process):  
 
The kernel configuration file used is merged between the following files (this operation is performed at the beginning of the kernel build process):  
* The Android configuration files named <code>android-base.config</code> and <code>android-recommended.config</code> files available in the <code>device/stm/{{HighlightParam|''<STM32Series>''}}-kernel/source/kconfig/{{HighlightParam|''<kernel version>''}}/</code> directory.
+
* The Android configuration files named <code>android-base.config</code> and <code>android-recommended.config</code> available in the <code>device/stm/{{HighlightParam|''<STM32Series>''}}-kernel/source/kconfig/{{HighlightParam|''<kernel version>''}}/</code> directory.
 
* The <code>android-soc.config</code> file available in the <code>device/stm/{{HighlightParam|''<STM32Series>''}}-kernel/source/kconfig/{{HighlightParam|''<kernel version>''}}/</code> directory.
 
* The <code>android-soc.config</code> file available in the <code>device/stm/{{HighlightParam|''<STM32Series>''}}-kernel/source/kconfig/{{HighlightParam|''<kernel version>''}}/</code> directory.
 
}}
 
}}
   
By using <code>menuconfig</code>, you can update the configuration file for your needs. Some guidelines are given below.
+
By using <code>menuconfig</code>, you can adapt the configuration file to your needs. Some guidelines are given below.
   
=== Save the current configuration ===
+
=== Saving the current configuration ===
   
Before making any changes to the kernel configuration, it is advised to build the kernel with the current configuration:
+
Before changing the kernel configuration, it is recommended to build the kernel using the current configuration:
   
 
  {{PC$}} build_kernel
 
  {{PC$}} build_kernel
Line 32: Line 32:
 
A default config file named <code>defconfig.default</code> is generated in <code>out-bsp/{{HighlightParam|''<STM32Series>''}}/KERNEL_OBJ/</code> directory.
 
A default config file named <code>defconfig.default</code> is generated in <code>out-bsp/{{HighlightParam|''<STM32Series>''}}/KERNEL_OBJ/</code> directory.
   
=== Create a new kernel configuration ===
+
=== Creating a new kernel configuration ===
   
 
Start <code>menuconfig</code>:
 
Start <code>menuconfig</code>:
Line 38: Line 38:
 
  {{PC$}} build_kernel menuconfig
 
  {{PC$}} build_kernel menuconfig
   
You can load a <code>.config</code> file and modify any entry using this interface. Please read on the top of the windows the instructions to navigate.
+
You can load a <code>.config</code> file and modify any entry using this interface. Instructions on how to navigate are provided at the top of the windows.
   
Do not forget to hit save.
+
Do not forget to click '''save'''.
   
This will generate a <code>.config</code> file located in <code>out-bsp/{{HighlightParam|''<STM32Series>''}}/KERNEL_OBJ/</code>, and will also generate a <code>defconfig</code> file in the same place.
+
This generates a <code>.config</code> file located in <code>out-bsp/{{HighlightParam|''<STM32Series>''}}/KERNEL_OBJ/</code>, as well as a <code>defconfig</code> file at the same location.
   
=== Test new kernel configuration===
+
=== Testing the new kernel configuration===
   
To test your new configuration you need to rebuild the kernel, then update the prebuilts and flash, like explain in more details in [[How to build kernel for Android]].
+
To test the new configuration, rebuild the kernel, update the prebuilts and flash, as explained in [[How to build kernel for Android]].
   
 
=== Applying the newly generated kernel configuration ===
 
=== Applying the newly generated kernel configuration ===
   
To make your change permanent, you need first to compare the new <code>defconfig</code> file with the <code>defconfig.default</code> file generated at first build.
+
To make your change permanent, first compare the new <code>defconfig</code> file with the <code>defconfig.default</code> file generated at first build.
   
You can use a graphical tool like <code>meld</code>.
+
You can use a graphical tool such as <code>meld</code>.
 
  {{PC$}} meld out-bsp/{{HighlightParam|''<STM32Series>''}}/KERNEL_OBJ/defconfig out-bsp/{{HighlightParam|''<STM32Series>''}}/KERNEL_OBJ/defconfig.default
 
  {{PC$}} meld out-bsp/{{HighlightParam|''<STM32Series>''}}/KERNEL_OBJ/defconfig out-bsp/{{HighlightParam|''<STM32Series>''}}/KERNEL_OBJ/defconfig.default
   
   
Then report the changes to the <code>android-soc.config</code> file located in <code>device/stm/{{HighlightParam|''<STM32Series>''}}-kernel/source/kconfig/{{HighlightParam|''<kernel version>''}}/</code>.
+
Then report the changes into the <code>android-soc.config</code> file located in <code>device/stm/{{HighlightParam|''<STM32Series>''}}-kernel/source/kconfig/{{HighlightParam|''<kernel version>''}}/</code>.
   
And force the regeneration of the .config:
+
Eventually force the regeneration of the .config:
 
  {{PC$}} build_kernel defaultconfig
 
  {{PC$}} build_kernel defaultconfig
 
''Note: the  <code>defconfig.default </code> is then updated''.
 
''Note: the  <code>defconfig.default </code> is then updated''.
   
To test your configuration you need to rebuild the kernel, then update the prebuilts and flash, like explain in more details in [[How to build kernel for Android]].
+
To test your configuration, rebuild the kernel and update the prebuilts and flash, as explain in [[How to build kernel for Android]].
   
 
== Changing the kernel command line ==
 
== Changing the kernel command line ==
   
 
You can customize the kernel command line call at boot time.
 
You can customize the kernel command line call at boot time.
Arguments are defined in the <code>BoardConfig.mk</code> file located in <code>device/stm/{{HighlightParam|''<STM32Series>''}}/{{HighlightParam|''<BoardId>''}}/</code>.
+
The arguments are defined in the <code>BoardConfig.mk</code> file located in <code>device/stm/{{HighlightParam|''<STM32Series>''}}/{{HighlightParam|''<BoardId>''}}/</code>.
   
Change the value of the '''BOARD_KERNEL_CMDLINE''' variable to your needs.
+
Adapt the value of the '''BOARD_KERNEL_CMDLINE''' variable to your needs.
   
To apply changes, you need to rebuild the bootimage:
+
Rebuild the bootimage to apply the changes:
   
 
  {{PC$}} make bootimage-nodeps
 
  {{PC$}} make bootimage-nodeps
   
And then flash the boot partition.
+
Then flash the boot partition:
   
 
{{ Info| To control the command line after compilation you can execute:
 
{{ Info| To control the command line after compilation you can execute:
Line 81: Line 81:
 
  {{PC$}} ./system/core/mkbootimg/unpack_bootimg --boot_img out/target/product/{{HighlightParam|''<BoardId>''}}/boot.img
 
  {{PC$}} ./system/core/mkbootimg/unpack_bootimg --boot_img out/target/product/{{HighlightParam|''<BoardId>''}}/boot.img
   
Check the '''"command line args"''' value from the output, it must match your changes.
+
Check the '''"command line args"''' value from the output: it must match your changes.
 
}}
 
}}
   
 
== Changing the Device Tree ==
 
== Changing the Device Tree ==
   
The kernel device tree used is set in the <code>dt.mk</code> file available in the <code>device/stm/{{HighlightParam|''<STM32Series>''}}/build/tasks/</code> directory. For more information please refer to the [[Device tree]] and [[How to create your board device tree]] pages.
+
The kernel device tree used is set in the <code>dt.mk</code> file available under the <code>device/stm/{{HighlightParam|''<STM32Series>''}}/build/tasks/</code> directory. For more information refer to the [[Device tree]] and [[How to create your board device tree]] pages.
   
This device trees are located inside the Linux kernel source code previously loaded and can be modified directly in <code>device/stm/{{HighlightParam|''<STM32Series>''}}-kernel/linux-{{HighlightParam|''<STM32Series>''}}/arch/arm/boot/dts</code>.
+
The device trees are located inside the Linux<sup>&reg;</sup> kernel source code previously loaded. A Device Tree can be modified directly in <code>device/stm/{{HighlightParam|''<STM32Series>''}}-kernel/linux-{{HighlightParam|''<STM32Series>''}}/arch/arm/boot/dts</code>.
   
After modification you need to rebuild the device tree by:
+
Once the Device Tree has been modified, rebuild it:
   
 
  {{PC$}} build_kernel -i dtb
 
  {{PC$}} build_kernel -i dtb
Line 96: Line 96:
 
  {{PC$}} make -j
 
  {{PC$}} make -j
   
And then re-flash the DT partition.
+
Then flash again the DT partition.
   
 
<noinclude>
 
<noinclude>

Attachments

Discussions