Jump to content

How to find device-specific information: Difference between revisions

From postmarketOS Wiki
Fresh.job (talk | contribs)
add getprop example for extracting device info
 
(25 intermediate revisions by 18 users not shown)
Line 1: Line 1:
= Android =
== Generic device information ==
== Generic device information ==


* [https://github.com/LineageOS/lineage_wiki/blob/master/_data/devices/ LineageOS devices database] (hardware specs: architecture, screen resolution, ... and key combinations for flash/recovery mode)
* [https://github.com/LineageOS/lineage_wiki/blob/master/_data/devices/ LineageOS devices database] (hardware specs: architecture, screen resolution, ... and key combinations for flash/recovery mode)
* Use the "cat /proc/cpuinfo" in terminal to get some CPU information.
* Use the `cat /proc/cpuinfo` in terminal to get some CPU information.
* Use `adb shell getprop` to get product manufacturer and product display name.
 
== Kernel version ==
 
* [https://stackoverflow.com/a/12151781 Look at the Makefile inside the kernel repository]
 
== Device Architecture ==
 
* You can find the architecture while the device is running another kernel (e.g. original Android or TWRP). Run <code>adb shell</code> to gain access to the console on the device, and type <code>uname -m</code>.
* pmOS supports the <code>armhf</code>, <code>armv7</code>, and <code>aarch64</code> architectures. If the output is <code>armv7l</code>, for example, you should use <code>armv7</code> as your device architecture.
 
== Device code name ==
 
* [https://desktop.firmware.mobi/ firmware.mobi]
* [https://wiki.lineageos.org/devices/ LineageOS List]
* [https://www.droidviews.com/codenames-of-samsung-galaxy-devices/ List for Samsung Galaxy Devices]
* [https://storage.googleapis.com/play_public/supported_devices.html List of supported devices of Android by Google]
* [https://github.com/jaredrummler/AndroidDeviceNames Android library to get device name] (json database file replaced with binary db file)
* You can also find the code name by looking for <code>ro.build.product</code> or <code>ro.product.device</code> in <code>/system/build.prop</code> on a running Android system (e.g. through <code>adb shell</code>) or in an extracted system.img (Android recovery zips work too).
 
== LineageOS kernel source repository ==
 
* Find out the code name of your device (see above)
* Usually, you can find the ''kernel'' source repository by typing in the code name of your device into the [https://github.com/LineageOS?utf8=%E2%9C%93&q=&type=&language= LineageOS GitHub page]
* If you can't find it, but you found a repository starting with <code>android_device_</code>, open that repository and look into the <code>lineage.dependencies</code> file. It lists other LineageOS repositories there - open these repositories, until you finally find the repository with &quot;kernel&quot; in the name. Example: [https://github.com/LineageOS/android_device_htc_evita/blob/cm-14.1/lineage.dependencies#L3 First], [https://github.com/LineageOS/android_device_htc_s4-common/blob/630a97ee53f1b6a43f02f9fb3841db026967f5ed/lineage.dependencies#L11 Second], [https://github.com/LineageOS/android_kernel_htc_msm8960 Third: Kernel repo!]
 
== Other locations for kernel repositories ==
 
* [https://github.com/cyanogenmod CyanogenMod] (same instructions as for LineageOS)
* [https://legacyxperia.github.io/ legacyxperia project]
* [http://opensource.samsung.com/reception.do Samsung Opensource Release Center]
* [http://opensource.lge.com LG Electronics Open Source Distribution system]
* [https://github.com/MiCode/Xiaomi_Kernel_OpenSource Xiaomi Open Source Kernel Repository]
* [https://github.com/MotorolaMobilityLLC Motorola Kernel sources?]
* [https://github.com/OnePlusOSS OnePlus kernel sources]
* [https://support.lenovo.com/us/en/solutions/HT511330 Lenovo Open Source Portal]
* [https://github.com/TeamWin?utf8=%E2%9C%93&q=kernel&type=&language= TWRP]
* Download a working recovery OS (TWRP/CWM), and [https://stackoverflow.com/a/37689814 extract the Linux version string from the kernel], then search for that kernel on GitHub / on the web
* [https://github.com/rockchip-linux/kernel/ Rockchip Linux] (Note there are multiple branches for different versions of the Linux Kernel, and <code>release</code> branches might work better than <code>develop</code> branches)
 
== Kernel defconfig (default config) ==
{{note|Sometimes the Android build process uses more than one kernel config and merges them, see [https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/issues/1307#note_85245297 #1307 (comment)]}}
 
* <code>DEFCONFIG=</code> line inside the <code>build.config</code> inside the kernel repository (if available) ([https://github.com/LineageOS/android_kernel_lge_hammerhead/blob/cm-14.1/build.config#L4 example])
* [https://source.android.com/source/building-kernels Official listing]
* If you found the <code>android_device_</code> repository (as shown in ''LineageOS kernel source repository'' above), look for a <code>TARGET_KERNEL_CONFIG</code> line in the [https://github.com/LineageOS/android_device_htc_evita/blob/25b93bf95fac520fa1952a8b756b536d4fd4fcab/BoardConfig.mk#L42 BoardConfig.mk].
* If you've got the stock <code>boot.img</code>, you can try to extract the config from this kernel, either on your pc using [https://github.com/torvalds/linux/blob/master/scripts/extract-ikconfig this script] or by booting in postmarketOS with a [https://wiki.postmarketos.org/wiki/Using_prebuilt_kernels prebuilt kernel] and then [https://superuser.com/questions/287371/obtain-kernel-config-from-currently-running-linux-system extracting the config from the running system].
 
 
In the case where you have located the kernel source for your device but there is no <code>build.config</code>, have a look at the <code>arch/arm/configs/</code> directory. E.g. for Moto G 2014 &quot;titan&quot; that uses android_kernel_motorola_msm8226 you have a [https://github.com/LineageOS/android_kernel_motorola_msm8226/blob/cm-14.1/arch/arm/configs/titan_defconfig titan_defconfig] file there.
 
== Misc info from BoardConfig.mk ==
 
[https://github.com/LineageOS/android_device_lge_hammerhead/blob/4bacb98a5dc736a6c832fe1e03d3bbe7320cd7f5/BoardConfig.mk#L25-L30 Example], contains the following information:
 
* kernel commandline
* ramdisk offset, tags offset, pagesize, base
* boot partition size
 
== Firmware files ==
 
See [[Firmware]].
 
== Device tree source (dts) ==
 
If you can't find the proper dts anywhere, and typical sources like LineageOS or TWRP are just appending a binary blob (dtb, device tree blob), it should be possible to decompile that blob and add it as patch to your linux package. It was done like this in {{MR|573|pmaports}} for example. From a license perspective, this should also be fine, because the Linux kernel is released under the GPLv2.


== Fastboot (boot.img) flash offsets ==
== Fastboot (boot.img) flash offsets ==
{{note|<code>pmbootstrap bootimg_analyze</code> automatizes this and directly gives you what you need to put in the <code>deviceinfo</code> file ([[Porting_to_a_new_device#Flash_method|more]]). The information below is only kept for reference, but do yourself a favor and use the automated version instead.}}
{{note|<code>pmbootstrap bootimg_analyze</code> automates this and directly gives you what you need to put in the <code>deviceinfo</code> file ([[Porting_to_a_new_device#Flash_method|more]]). The information below is only kept for reference, but do yourself a favor and use the automated version instead.}}
''If you can't find a full ROM image for your device, consider extracting the boot.img file directly from your device [https://wiki.postmarketos.org/wiki/Using_prebuilt_kernels with adb].''
''If you can't find a full ROM image for your device, consider extracting the boot.img file directly from your device [https://wiki.postmarketos.org/wiki/Using_prebuilt_kernels with adb].''


Line 50: Line 114:


''NOTE: Some useful info can be pulled via fastboot too (in case you have the device at hand) by executing <code>fastboot getvar all</code>''
''NOTE: Some useful info can be pulled via fastboot too (in case you have the device at hand) by executing <code>fastboot getvar all</code>''
== Kernel version ==
* [https://stackoverflow.com/a/12151781 Look at the Makefile inside the kernel repository]
== Device Architecture ==
* You can find the architecture while the device is running another kernel (e.g. original Android or TWRP). Run <code>adb shell</code> to gain access to the console on the device, and type <code>uname -m</code>.
* pmOS supports the <code>armhf</code> and <code>aarch64</code> architectures. If the output is <code>armv7l</code>, for example, you should use <code>armhf</code> as your device architecture.
== Device code name ==
* [http://wiki.lineageos.org/devices.html LineageOS List]
* [http://www.droidviews.com/codenames-of-samsung-galaxy-devices/ List for Samsung Galaxy Devices]
* [https://github.com/jaredrummler/AndroidDeviceNames/blob/master/json/manufacturers/ List of codenames from the AndroidDeviceNames library]
== LineageOS kernel source repository ==
* Find out the code name of your device (see above)
* Usually, you can find the ''kernel'' source repository by typing in the code name of your device into the [https://github.com/LineageOS?utf8=%E2%9C%93&q=&type=&language= LineageOS GitHub page]
* If you can't find it, but you found a repository starting with <code>android_device_</code>, open that repository and look into the <code>lineage.dependencies</code> file. It lists other LineageOS repositories there - open these repositories, until you finally find the repository with &quot;kernel&quot; in the name. Example: [https://github.com/LineageOS/android_device_htc_evita/blob/cm-14.1/lineage.dependencies#L3 First], [https://github.com/LineageOS/android_device_htc_s4-common/blob/630a97ee53f1b6a43f02f9fb3841db026967f5ed/lineage.dependencies#L11 Second], [https://github.com/LineageOS/android_kernel_htc_msm8960 Third: Kernel repo!]
== Other locations for kernel repositories ==
* [https://github.com/cyanogenmod CyanogenMod] (same instructions as for LinageOS)
* [https://legacyxperia.github.io/ legacyxperia project]
* [http://opensource.samsung.com/reception.do Samsung Opensource Release Center]
* [https://github.com/TeamWin?utf8=%E2%9C%93&q=kernel&type=&language= TWRP]
* Download a working recovery OS (TWRP/CWM), and [https://stackoverflow.com/a/37689814 extract the Linux version string from the kernel], then search for that kernel on GitHub / on the web
== Kernel defconfig (default config) ==
{{note|Sometimes the Android build process uses more than one kernel config and merges them, see [https://github.com/postmarketOS/pmbootstrap/issues/1307#issuecomment-377407456 #1307 (comment)]}}
* <code>DEFCONFIG=</code> line inside the <code>build.config</code> inside the kernel repository (if available) ([https://github.com/LineageOS/android_kernel_lge_hammerhead/blob/cm-14.1/build.config#L4 example])
* [https://source.android.com/source/building-kernels Official listing]
* If you found the <code>android_device_</code> repository (as shown in ''LineageOS kernel source repository'' above), look for a <code>TARGET_KERNEL_CONFIG</code> line in the [https://github.com/LineageOS/android_device_htc_evita/blob/25b93bf95fac520fa1952a8b756b536d4fd4fcab/BoardConfig.mk#L42 BoardConfig.mk].
In the case where you have located the kernel source for your device but there is no <code>build.config</code>, have a look at the <code>arch/arm/configs/</code> directory. E.g. for Moto G 2014 &quot;titan&quot; that uses android_kernel_motorola_msm8226 you have a [https://github.com/LineageOS/android_kernel_motorola_msm8226/blob/cm-14.1/arch/arm/configs/titan_defconfig titan_defconfig] file there.
== Misc info from BoardConfig.mk ==
[https://github.com/LineageOS/android_device_lge_hammerhead/blob/4bacb98a5dc736a6c832fe1e03d3bbe7320cd7f5/BoardConfig.mk#L25-L30 Example], contains the following information:
* kernel commandline
* ramdisk offset, tags offset, pagesize, base
* boot partition size
== Firmware files ==
Find the LineageOS repository for your device by using the repository filter function [https://github.com/LineageOS/ here] and typing in your device's code name. You need the repository starting with <code>android_device_</code>. Inside that repository, there should be a <code>proprietary_components.txt</code>, <code>proprietary-files.txt</code> or <code>device-proprietary-files.txt</code>
, which has among lots of files, that we do not need, the paths to the firmware files - starting with <code>/vendor/firmware</code>. Combined with some additional research, you should be able to find the files needed for the hardware, that you want to get running (e.g. wifi). Now you have the names of the firmware files. First look if they are provided by [https://pkgs.alpinelinux.org/contents?file=&path=&name=linux-firmware&branch=&repo=&arch= <code>linux-firmware</code>], and if not, find them elsewhere and package them yourself (as in [https://wiki.postmarketos.org/wiki/Samsung_Galaxy_S_Advance_(samsung-i9070) samsung-i9070]).
See also: [https://github.com/postmarketOS/pmbootstrap/wiki/Wifi Wifi]


[[Category:Guide]]
[[Category:Guide]]

Latest revision as of 19:14, 23 January 2025

Generic device information

  • LineageOS devices database (hardware specs: architecture, screen resolution, ... and key combinations for flash/recovery mode)
  • Use the `cat /proc/cpuinfo` in terminal to get some CPU information.
  • Use `adb shell getprop` to get product manufacturer and product display name.

Kernel version

Device Architecture

  • You can find the architecture while the device is running another kernel (e.g. original Android or TWRP). Run adb shell to gain access to the console on the device, and type uname -m.
  • pmOS supports the armhf, armv7, and aarch64 architectures. If the output is armv7l, for example, you should use armv7 as your device architecture.

Device code name

LineageOS kernel source repository

  • Find out the code name of your device (see above)
  • Usually, you can find the kernel source repository by typing in the code name of your device into the LineageOS GitHub page
  • If you can't find it, but you found a repository starting with android_device_, open that repository and look into the lineage.dependencies file. It lists other LineageOS repositories there - open these repositories, until you finally find the repository with "kernel" in the name. Example: First, Second, Third: Kernel repo!

Other locations for kernel repositories

Kernel defconfig (default config)

Note Sometimes the Android build process uses more than one kernel config and merges them, see #1307 (comment)


In the case where you have located the kernel source for your device but there is no build.config, have a look at the arch/arm/configs/ directory. E.g. for Moto G 2014 "titan" that uses android_kernel_motorola_msm8226 you have a titan_defconfig file there.

Misc info from BoardConfig.mk

Example, contains the following information:

  • kernel commandline
  • ramdisk offset, tags offset, pagesize, base
  • boot partition size

Firmware files

See Firmware.

Device tree source (dts)

If you can't find the proper dts anywhere, and typical sources like LineageOS or TWRP are just appending a binary blob (dtb, device tree blob), it should be possible to decompile that blob and add it as patch to your linux package. It was done like this in pmaports!573 for example. From a license perspective, this should also be fine, because the Linux kernel is released under the GPLv2.

Fastboot (boot.img) flash offsets

Note pmbootstrap bootimg_analyze automates this and directly gives you what you need to put in the deviceinfo file (more). The information below is only kept for reference, but do yourself a favor and use the automated version instead.

If you can't find a full ROM image for your device, consider extracting the boot.img file directly from your device with adb.

  1. Find the download link for a full image on https://download.lineageos.org/
  2. Run the following commands (replace the download link accordingly)

    pmbootstrap build mkbootimg-osm0sis
    pmbootstrap chroot
    apk add mkbootimg-osm0sis
    su - user
    mkdir /tmp/bootimg_info
    cd /tmp/bootimg_info
    wget "https://mirrorbits.lineageos.org/full/hammerhead/20170530/lineage-14.1-20170530-nightly-hammerhead-signed.zip"
    unzip *.zip
    unpackbootimg -i boot.img
  3. Example output:

    Android magic found at: 0
    BOARD_KERNEL_CMDLINE console=ttyHSL0,115200,n8 androidboot.hardware=hammerhead
    user_debug=31 maxcpus=2 msm_watchdog_v2.enable=1
    androidboot.bootdevice=msm_sdcc.1 buildvariant=userdebug
    BOARD_KERNEL_BASE 00008000
    BOARD_RAMDISK_OFFSET 02900000
    BOARD_SECOND_OFFSET 00f00000
    BOARD_TAGS_OFFSET 02700000
    BOARD_PAGE_SIZE 2048
    BOARD_SECOND_SIZE 0
    BOARD_DT_SIZE 0

Translate the variables as follows into your deviceinfo:

  • BOARD_KERNEL_CMDLINE -> deviceinfo_kernel_cmdline
  • BOARD_KERNEL_BASE -> deviceinfo_flash_offset_kernel
  • BOARD_RAMDISK_OFFSET -> deviceinfo_flash_offset_ramdisk
  • BOARD_SECOND_OFFSET -> deviceinfo_flash_offset_second
  • BOARD_TAGS_OFFSET -> deviceinfo_flash_offset_tags
  • BOARD_PAGE_SIZE -> deviceinfo_flash_pagesize
  • BOARD_SECOND_SIZE and BOARD_DT_SIZE can both be ignored
  • (contents of the extracted boot.img-base file) -> deviceinfo_flash_offset_base (defaults to 0x10000000)



NOTE: Some useful info can be pulled via fastboot too (in case you have the device at hand) by executing fastboot getvar all