Android Customizing the Linux kernel: Difference between revisions

From Variscite Wiki
No edit summary
 
(42 intermediate revisions by 4 users not shown)
Line 1: Line 1:
== Manual build Android Linux Kernel ==
<!-- Set release according to "release" parameter in URL and use RELEASE_N7.1.1_1.0.0_VAR-SOM-MX6 as default
Change to Android top level directory.
--> {{#vardefine:RELEASE_PARAM|{{#urlget:release}}}} <!--
{{#ifeq: {{#var:ANDROID_NXP_VERSION}} | O8.0.0_1.0.0 |
--> {{#lst:Android_Platform_Customization|{{#var:RELEASE_PARAM|RELEASE_N7.1.1_1.0.0_VAR-SOM-MX6}}}} <!--
$ cd {{#var:BUILD_FOLDER_ANDROID}}
--> {{PageHeader|{{#var:HARDWARE_NAME}} - {{#var:ANDROID_VERSION}} - Customizing the Linux kernel}} {{DocImage|category1=Android|category2={{#var:HARDWARE_NAME}}}} __toc__
|  
$ cd {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}
|}}
{{#ifeq: {{#var:ANDROID_NXP_VERSION}} | O8.0.0_1.0.0 |
$ source build/envsetup.sh
$ lunch var_mx6-eng
or
$ lunch var_mx6-userdebug
<span style="color:red">Note: </span> var_mx6-userdebug creates a debuggable version of Android.
var_mx6-eng creates an engineering version of Android. Development mode enable and development tools are available on target.
|
$ source build/envsetup.sh
$ lunch var_mx6-eng
or
$ lunch var_mx6-user
<span style="color:red">Note: </span> var_mx6-user creates a production version of Android.
var_mx6-eng creates an engineering version of Android. Development mode enable and development tools are available on target.
|}}


== Switching from eMMC build to SD card build and vice versa ==
== Making changes to kernel configuration ==
When you switch your target MMC device you need to remove the fstab file. This will guarantee that the make system will copy the right one into target.
$ cd {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}/vendor/variscite/kernel_imx/
  $ rm out/target/product/var_mx6/recovery/root/fstab* out/target/product/var_mx6/root/fstab*
$ make ARCH={{#ifeq: {{#var:HARDWARE_NAME}} |VAR-SOM-MX6|arm|arm64}} mrproper
$ make ARCH={{#ifeq: {{#var:HARDWARE_NAME}} |VAR-SOM-MX6|arm|arm64}} {{#var:KERNEL_DEFCONFIG}}
$ make ARCH={{#ifeq: {{#var:HARDWARE_NAME}} |VAR-SOM-MX6|arm|arm64}} menuconfig
Navigate through the menu, and select the desired kernel functionalities, save the new configuration, and exit.<br>
Then, save the new configuration as the default configuration:<br>
$ make ARCH={{#ifeq: {{#var:HARDWARE_NAME}} |VAR-SOM-MX6|arm|arm64}} savedefconfig
  $ cp arch/{{#ifeq: {{#var:HARDWARE_NAME}} |VAR-SOM-MX6|arm|arm64}}/configs/{{#var:KERNEL_DEFCONFIG}} arch/{{#ifeq: {{#var:HARDWARE_NAME}} |VAR-SOM-MX6|arm|arm64}}/configs/{{#var:KERNEL_DEFCONFIG}}.orig
$ cp defconfig arch/{{#ifeq: {{#var:HARDWARE_NAME}} |VAR-SOM-MX6|arm|arm64}}/configs/{{#var:KERNEL_DEFCONFIG}}


== Build Android for SD card ==
== Making changes to the device tree ==
$ make -j4 BUILD_TARGET_DEVICE=sd bootimage 2>&1 | tee build1-1.log
For example, edit the following file: {{#ifeq: {{#var:HARDWARE_NAME}}|VAR-SOM-MX6| * VAR-SOM-MX6 : {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}/vendor/variscite/kernel_imx/arch/arm/boot/dts/imx6qdl-var-som.dtsi <br>
 
*DART-MX6: {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}/vendor/variscite/kernel_imx/arch/arm/boot/dts/imx6qdl-var-dart.dtsi| {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}/vendor/variscite/kernel_imx/arch/arm64/boot/dts/{{#ifeq: {{#var:HARDWARE_NAME}} | DART-MX8M |freescale/fsl-imx8mq-var-dart-common.dtsi | freescale/fsl-imx8mm-var-dart.dts}}}} <br>
*Note: When running Android from an SD card, the eMMC will be detected and presented as an SD card storage.
For example, if you want to make changes related to the SPI configuration you can refer to: {{#ifeq: {{#var:HARDWARE_NAME}}|VAR-SOM-MX6 |[[{{#var:HARDWARE_NAME}} SPI|SPI]]|{{Varlink|DART-MX8M SPI|{{#var:RELEASE_LINK}}|SPI}}}}
 
== Build Android for on-SOM eMMC ==
$ make -j4 BUILD_TARGET_DEVICE=emmc bootimage 2>&1 | tee build1-1.log
 
 
This will generate image as per table below
 
{| class="wikitable"
|-
! scope="col" | Setup Name<br/>
! scope="col" | Images Names<br/>
! scope="col" | SOM type<br/>
! scope="col" | Carrier Board type<br/>
! scope="col" | LCD Type<br/>
! scope="col" | Evaluation Kit name<br/>
|-
| style="padding: 5px;"| som-mx6qp-c
| style="padding: 5px;"| boot-som-mx6qp-c.img,<br>recovery-som-mx6qp-c.img
| style="padding: 5px;"| VAR-SOM-MX6_V2 (Quad Plus)
| style="padding: 5px;"| VAR-MX6CustomBoard
| style="padding: 5px;"| Capacitive touch
| style="padding: 5px;"| VAR-DVK-MX6_V2-PRO,<br>VAR-STK-MX6_V2
|-
| style="padding: 5px;"| som-mx6qp-r
| style="padding: 5px;"| boot-som-mx6qp-r.img,<br>recovery-som-mx6qp-r.img
| style="padding: 5px;"| VAR-SOM-MX6_V2 (Quad Plus)
| style="padding: 5px;"| VAR-MX6CustomBoard
| style="padding: 5px;"| Resistive touch
| style="padding: 5px;"| VAR-DVK-MX6_V2,<br>VAR-STK-MX6_V2
|-
| style="padding: 5px;"| som-mx6qp-vsc
| style="padding: 5px;"| boot-som-mx6qp-vsc.img,<br>recovery-som-mx6qp-vsc.img
| style="padding: 5px;"| VAR-SOM-MX6_V2 (Quad Plus)
| style="padding: 5px;"| VAR-SOLOCustomBoard
| style="padding: 5px;"| Capacitive LVDS touch
| style="padding: 5px;"| N/A
|-
| style="padding: 5px;"| som-mx6q-c
| style="padding: 5px;"| boot-som-mx6q-c.img,<br>recovery-som-mx6q-c.img
| style="padding: 5px;"| VAR-SOM-MX6_V2 (Quad / Dual)
| style="padding: 5px;"| VAR-MX6CustomBoard
| style="padding: 5px;"| Capacitive touch
| style="padding: 5px;"| VAR-DVK-MX6_V2-PRO,<br>VAR-STK-MX6_V2
|-
| style="padding: 5px;"| som-mx6q-r
| style="padding: 5px;"| boot-som-mx6q-r.img,<br>recovery-som-mx6q-r.img
| style="padding: 5px;"| VAR-SOM-MX6_V2 (Quad / Dual)
| style="padding: 5px;"| VAR-MX6CustomBoard
| style="padding: 5px;"| Resistive touch
| style="padding: 5px;"| VAR-DVK-MX6_V2,<br>VAR-STK-MX6_V2
|-
| style="padding: 5px;"| som-mx6q-vsc
| style="padding: 5px;"| boot-som-mx6q-vsc.img,<br>recovery-som-mx6q-vsc.img
| style="padding: 5px;"| VAR-SOM-MX6_V2 (Quad / Dual)
| style="padding: 5px;"| VAR-SOLOCustomBoard
| style="padding: 5px;"| Capacitive LVDS touch
| style="padding: 5px;"| N/A
|-
| style="padding: 5px;"| som-mx6dl-c
| style="padding: 5px;"| boot-som-mx6dl-c.img,<br>recovery-som-mx6dl-c.img
| style="padding: 5px;"| VAR-SOM-MX6_V2 (DualLite/ Solo)
| style="padding: 5px;"| VAR-MX6CustomBoard
| style="padding: 5px;"| Capacitive touch
| style="padding: 5px;"| N/A
|-
| style="padding: 5px;"| som-mx6dl-r
| style="padding: 5px;"| boot-som-mx6dl-r.img,<br>recovery-som-mx6dl-r.img
| style="padding: 5px;"| VAR-SOM-MX6_V2 (DualLite/ Solo)
| style="padding: 5px;"| VAR-MX6CustomBoard
| style="padding: 5px;"| Resistive touch
| style="padding: 5px;"| N/A
|-
| style="padding: 5px;"| som-solo-vsc
| style="padding: 5px;"| boot-som-solo-vsc.img,<br>recovery-som-solo-vsc.img
| style="padding: 5px;"| VAR-SOM-SOLO / VAR-SOM-DUAL
| style="padding: 5px;"| VAR-SOLOCustomBoard
| style="padding: 5px;"| Capacitive LVDS touch
| style="padding: 5px;"| VAR-DVK-SOLO/DUAL,<br>VAR-STK-SOLO/DUAL
|-
| style="padding: 5px;"| som-solo-c
| style="padding: 5px;"| boot-som-solo-c.img,<br>recovery-som-solo-c.img
| style="padding: 5px;"| VAR-SOM-SOLO / VAR-SOM-DUAL
| style="padding: 5px;"| VAR-MX6CustomBoard
| style="padding: 5px;"| Capacitive touch
| style="padding: 5px;"| N/A
|-
| style="padding: 5px;"| imx6q-var-dart
| style="padding: 5px;"| boot-imx6q-var-dart.img,<br>recovery-imx6q-var-dart.img
| style="padding: 5px;"| DART-MX6
| style="padding: 5px;"| VAR-DT6CustomBoard
| style="padding: 5px;"| Capacitive touch
| style="padding: 5px;"| VAR-STK-DT6,<br>VAR-DVK-DT6
|-
|}


== Build a new boot.img ==
When you perform changes to the kernel, you may build boot.img solely instead of building the whole Android.
$ cd {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_ANDROID}}
$ source build/envsetup.sh
$ lunch {{#var:ANDROID_MACHINE_NAME}}-userdebug
{{#ifeq: {{#var:HARDWARE_NAME}} | VAR-SOM-MX6 |
$ make bootimage
|
$ make bootimage
$ make dtboimage
}}


== Flashing bootimage to target ==
== Flashing the boot image to the target ==
Make sure device is in the fastboot mode if not , reboot in fastboot mode by using below commands. <br>
Run the following to boot the device into fastboot mode and reflash the boot image:<br>
$ adb reboot bootloader
$ sudo `which fastboot` flash boot{{#ifeq: {{#var:HARDWARE_NAME}} | VAR-SOM-MX6 | out/target/product/var_mx6/boot-<setup-name>.img |_a out/target/product/{{#var:ANDROID_MACHINE_NAME}}/boot.img }}
{{#ifeq: {{#var:HARDWARE_NAME}} | VAR-SOM-MX6 |


adb reboot bootloader
$ fastboot flash boot boot-<setup-name>.img
Replace setup-name as per above table.
Replace setup-name as per above table.
|
$ sudo `which fastboot` flash dtbo_a out/target/product/{{#var:ANDROID_MACHINE_NAME}}/dtbo-<name>.img
$ sudo `which fastboot` flash vbmeta_a out/target/product/{{#var:ANDROID_MACHINE_NAME}}/vbmeta-<name>.img
Replace <name> with the actual desired setup name according to the table in the {{Varlink|Android_NXP_Guide#Images_created_by_the_Android_build|{{#var:RELEASE_LINK}}|"images created by the Android build" section}} in the "Build Android from source code" page.
}}
$ sudo `which fastboot` reboot
{{#ifeq: {{#var:HARDWARE_NAME}} | VAR-SOM-MX6 ||
*Note: While flashing if you encouter like below <br>
$ sudo `which fastboot` flash boot_a out/target/product/{{#var:ANDROID_MACHINE_NAME}}/boot.img <br>
target reported max download size of 1073741824 bytes
Sending 'boot_a' (49152 KB)...
OKAY [  1.740s]
Writing 'boot_a'...
FAILED (remote:  device is locked.)
Finished. Total time: 1.772s
Make sure you unlock your device following<br>
{{Varlink|Fastboot Unlock|{{#var:RELEASE_LINK}}|Fastboot Unlock}} and then follow the steps above
}}

Latest revision as of 21:59, 12 September 2023

VAR-SOM-MX6 - N7.1.1 - Customizing the Linux kernel

Making changes to kernel configuration

$ cd ~/var_n_711_100/n_711_100_build/vendor/variscite/kernel_imx/
$ make ARCH=arm mrproper
$ make ARCH=arm imx_v7_var_android_defconfig
$ make ARCH=arm menuconfig

Navigate through the menu, and select the desired kernel functionalities, save the new configuration, and exit.
Then, save the new configuration as the default configuration:

$ make ARCH=arm savedefconfig
$ cp arch/arm/configs/imx_v7_var_android_defconfig arch/arm/configs/imx_v7_var_android_defconfig.orig 
$ cp defconfig arch/arm/configs/imx_v7_var_android_defconfig

Making changes to the device tree

For example, edit the following file:

  • VAR-SOM-MX6 : ~/var_n_711_100/n_711_100_build/vendor/variscite/kernel_imx/arch/arm/boot/dts/imx6qdl-var-som.dtsi
  • DART-MX6: ~/var_n_711_100/n_711_100_build/vendor/variscite/kernel_imx/arch/arm/boot/dts/imx6qdl-var-dart.dtsi

For example, if you want to make changes related to the SPI configuration you can refer to: SPI

Build a new boot.img

When you perform changes to the kernel, you may build boot.img solely instead of building the whole Android.

$ cd ~/var_n_711_100/n_711_100_build
$ source build/envsetup.sh
$ lunch -userdebug
$ make bootimage

Flashing the boot image to the target

Run the following to boot the device into fastboot mode and reflash the boot image:

$ adb reboot bootloader
$ sudo `which fastboot` flash bootout/target/product/var_mx6/boot-<setup-name>.img
Replace setup-name as per above table.
$ sudo `which fastboot` reboot