Tuning sysfs

After porting postmarketOS to your device, you might find that still some features don't work. You may need to adjust some values inside the /sys directory.

sysfs is a pseudo file system provided by the Linux kernel that exports information about various kernel subsystems, hardware devices, and associated device drivers from the kernel's device model to user space through virtual files. In addition to providing information about various devices and kernel subsystems, exported virtual files are also used for their configuring.

diff method
One approach is comparing the contents of these files when TWRP or LineageOS is running and the same for pmOS.

The following script dumps the content of /sys/devices. Copy it as

DIR=&quot;/sys/devices&quot;
 * 1) !/bin/sh
 * 2) dumpsys.sh

walk { for file in $(ls $1); do       path=&quot;$1/$file&quot; if test -L &quot;$path&quot;; then continue fi       if test -f &quot;$path&quot;; then echo &quot;$path&quot; cat &quot;$path&quot; fi       if test -d &quot;$path&quot;; then walk &quot;$path&quot; fi   done }

others { cat /proc/cpuinfo cat /proc/cmdline }

walk &quot;$DIR&quot; others Upload it to your device when running TWRP (use ) and when running postmarketOS (use  ). Run it and then compare the output.

For TWRP/LineageOS:

adb push dumpsys.sh / adb shell &quot;sh /dumpsys.sh &gt; /devices-twrp.dump&quot; adb pull /devices-twrp.dump. For pmOS:

scp dumpsys.sh user@172.16.42.1:~ scp user@172.16.42.1:~/devices-pmos.dump. Then get the differences (example):
 * 1) sh dumpsys.sh &gt; devices-pmos.dump

diff -au devices-pmos.dump devices-twrp.dump &gt; devices.diff You could also run it in even in the stock ROM but it is important that you run the same kernel version in postmarketOS then.

Script hanging
On some devices (like Xperia Z) this script will hang on  files. To continue the script to the next file we just kill the process that processes the  file:

ps w | grep vsync_event # To find process id of the cat command that was processing vsync_event kill -SIGTERM # Kill the process

Script reboots system
On some devices (like Xperia Z1) this script can reboot the device when executed in TWRP. To fix this, you need to find out which file is causing the reboot and skip it. You can find the file by running the script without output redirection (it should be the last line printed before the reboot - see example below). $ adb shell "sh /dumpsys.sh" /sys/devices/0.qcom,msm-cpufreq/modalias platform:0.qcom,msm-cpufreq ... /sys/devices/mdss_dsi_panel/interval_array        -> THE FILE THAT CAUSES A REBOOT --> THE DEVICE REBOOTS Now that you found the file, you can exclude it by updating the script. Change this part: if test -f &quot;$path&quot;; then echo &quot;$path&quot; cat &quot;$path&quot; fi To this: if test -f "$path"; then if [ "$path" = "/sys/devices/mdss_dsi_panel/interval_array" ] then continue fi   echo "$path" cat "$path" fi If there are two or more entries to skip, combine them with a logical OR (||) like this: if test -f "$path"; then if [ "$path" = "/sys/devices/mdss_dsi_panel/interval_array" ] || [ "$path" = "/sys/devices/iio:device0/self_test_run" ] || [ "$path" = "/sys/devices/iio:device1/self_test_run" ] then continue fi   echo "$path" cat "$path" fi

Applying tuning
To make changes to the device, create "initfs-hook.sh" in the device folder and add "initfs-hook.sh" to the source list.

The initfs-hook.sh runs commands before booting. Look at the examples section to see how the file should be used.

i9070 port
This way, user  figured out two values needed for the framebuffer configuration for the i9070 port.

echo 16 &gt; /sys/devices/platform/mcde_fb/graphics/fb0/bits_per_pixel echo 960,1600 &gt; /sys/devices/platform/mcde_fb/graphics/fb0/virtual_size