Difference between revisions of "How to find device-specific information"

From postmarketOS
Jump to navigation Jump to search
Line 101: Line 101:
== Firmware files ==
== Firmware files ==
If your device has an official LineageOS port, you can find the proprietary files, which often also include the firmware, at [http://github.com/TheMuppets TheMuppets]. Do note, that if you're using the "Find file" (shortcut: T), that it might not find all files as those repositories are generally quite big and not completely indexed by GitHub.
See [[Firmware]].
In the case that your device has an unofficial LineageOS port, you can often find a repository in the same naming scheme (proprietary_vendor_MANUFACTURER) at the same location as the kernel source and device tree.
=== Find ===
If you can't find the firmware for your device in an existing repo, you will have to grab them from your device or an OTA image.
In some cases it's a partition that's mounted at <code>/firmware</code> (e.g. labelled <code>modem</code>), in other cases <code>/firmware</code> will have multiple partitions mounted into subdirectories (e.g. labelled <code>radio</code>, <code>adsp</code> & <code>wcnss</code>). Consult the fstab of your installation for different mount points.
In other cases, the firmware will just be in the normal filesystem, e.g. at <code>/vendor/firmware/</code>, <code>/etc/firmware</code> or other locations. You can use the <code>find</code> command to search for e.g. <code>*.mbn</code>
There's also the possibility of extracting the firmware from a file called <code>NON-HLOS.bin</code> which is sometimes delivered with OTA updates. These images are FAT32 images which can be mounted with <code>sudo mount -o ro NON-HLOS.bin mountpoint</code>.
=== Extract ===
The firmware of interest for us is <code>adsp.*</code>, <code>mba.*</code>, <code>modem.*</code> and <code>wcnss.*</code>. Note that not all of those firmware files exist on all devices.
The next step is to import those files into a git repository and pushing it to a publicly accessible location.
=== Package ===
The procedure on how to package firmware and how to add a nonfree-firmware subpackage to the device package is [[Device_specific_package#Proprietary_firmware_or_userland_blobs|documented here]].
== Device tree source (dts) ==
== Device tree source (dts) ==

Revision as of 20:49, 19 January 2020


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.

Fastboot (boot.img) flash offsets

Note pmbootstrap bootimg_analyze automatizes 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_TAGS_OFFSET 02700000

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

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)
  • DEFCONFIG= line inside the build.config inside the kernel repository (if available) (example)
  • Official listing
  • If you found the android_device_ repository (as shown in LineageOS kernel source repository above), look for a TARGET_KERNEL_CONFIG line in the BoardConfig.mk.

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.