<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Sony Xperia on Ivon's Blog</title><link>https://ivonblog.com/en-us/tags/sony-xperia/</link><description>Recent content in Sony Xperia on Ivon's Blog</description><generator>Hugo -- gohugo.io</generator><language>en</language><managingEditor>infoivonblog.nkfjt@aleeas.com (Ivon Huang)</managingEditor><webMaster>infoivonblog.nkfjt@aleeas.com (Ivon Huang)</webMaster><copyright>You are welcome to share articles from Ivon's blog (ivonblog.com). Please cite the source article URL when sharing. All article content is licensed under a Creative Commons Attribution-ShareAlike 4.0 license, unless otherwise stated. For commercial use, please contact me first.</copyright><lastBuildDate>Sat, 10 Sep 2022 10:01:46 +0800</lastBuildDate><atom:link href="https://ivonblog.com/en-us/tags/sony-xperia/index.xml" rel="self" type="application/rss+xml"/><follow_challenge><feedId>56005902658351104</feedId><userId>1132431067563556864</userId></follow_challenge><item><title>Porting postmarketOS, Using the Sony Xperia 5 II as an Example</title><link>https://ivonblog.com/en-us/posts/sony-xperia-5-ii-postmarketos-porting/</link><pubDate>Sat, 10 Sep 2022 10:01:46 +0800</pubDate><author>infoivonblog.nkfjt@aleeas.com (Ivon Huang)</author><guid>https://ivonblog.com/en-us/posts/sony-xperia-5-ii-postmarketos-porting/</guid><description>&lt;!-- Co-translated by ChatGPT --&gt;
&lt;p&gt;This article records my attempt at porting postmarketOS myself. It is currently unfinished.&lt;/p&gt;
&lt;p&gt;The porting tutorials on the postmarketOS Wiki, &lt;a href="https://wiki.postmarketos.org/wiki/Porting_to_a_new_device" target="_blank" rel="noreferrer"&gt;Porting to a new device&lt;/a&gt; and &lt;a href="https://wiki.postmarketos.org/wiki/Mainlining_Guide" target="_blank" rel="noreferrer"&gt;Mainlining Guide&lt;/a&gt;, are already very clear. This article is basically a Chinese translation of the Wiki content plus a few notes of my own.&lt;/p&gt;

&lt;h2 class="relative group"&gt;1. Hardware Requirements
 &lt;div id="1-hardware-requirements" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#1-hardware-requirements" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Phone to port: Sony Xperia 5 II (XQ-AS72, codename sony-pdx206), Bootloader already unlocked.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This model has an entry on the &lt;a href="https://wiki.postmarketos.org/wiki/Sony_Xperia_5_II_%28sony-pdx206%29" target="_blank" rel="noreferrer"&gt;postmarketOS Wiki&lt;/a&gt;, and it can also boot with the &lt;a href="https://docs.somainline.org/platform/sm8250/sony/pdx206/" target="_blank" rel="noreferrer"&gt;mainline kernel developed by somainline&lt;/a&gt;. But because UFS has a bug (described later), there is no official port yet.&lt;/p&gt;</description><content:encoded>&lt;!-- Co-translated by ChatGPT --&gt;
&lt;p&gt;This article records my attempt at porting postmarketOS myself. It is currently unfinished.&lt;/p&gt;
&lt;p&gt;The porting tutorials on the postmarketOS Wiki, &lt;a href="https://wiki.postmarketos.org/wiki/Porting_to_a_new_device" target="_blank" rel="noreferrer"&gt;Porting to a new device&lt;/a&gt; and &lt;a href="https://wiki.postmarketos.org/wiki/Mainlining_Guide" target="_blank" rel="noreferrer"&gt;Mainlining Guide&lt;/a&gt;, are already very clear. This article is basically a Chinese translation of the Wiki content plus a few notes of my own.&lt;/p&gt;

&lt;h2 class="relative group"&gt;1. Hardware Requirements
 &lt;div id="1-hardware-requirements" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#1-hardware-requirements" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Phone to port: Sony Xperia 5 II (XQ-AS72, codename sony-pdx206), Bootloader already unlocked.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This model has an entry on the &lt;a href="https://wiki.postmarketos.org/wiki/Sony_Xperia_5_II_%28sony-pdx206%29" target="_blank" rel="noreferrer"&gt;postmarketOS Wiki&lt;/a&gt;, and it can also boot with the &lt;a href="https://docs.somainline.org/platform/sm8250/sony/pdx206/" target="_blank" rel="noreferrer"&gt;mainline kernel developed by somainline&lt;/a&gt;. But because UFS has a bug (described later), there is no official port yet.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;PC: must be 64-bit Linux. A VM also works. My CPU is an i5-7400 with 16GB RAM.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;postmarketOS system files are tiny. You do not need to download tens of gigabytes of source code, and compilation does not take several hours. Refreshing, honestly.&lt;/p&gt;

&lt;h2 class="relative group"&gt;2. Install pmbootstrap
 &lt;div id="2-install-pmbootstrap" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#2-install-pmbootstrap" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;pmbootstrap is the tool used to create postmarketOS installation files and do porting work.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Install Python3, openSSL, Pip, and Git on the system:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sudo apt install python3 openssl python-pip3 git&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ol start="2"&gt;
&lt;li&gt;Install pmbootstrap with pip and refresh the environment:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;pip3 install --user pmbootstrap
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;source&lt;/span&gt; ~/.profile&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ol start="3"&gt;
&lt;li&gt;Install autocompletion and add it to &lt;code&gt;~/.bashrc&lt;/code&gt;:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; pip3 install --user argcomplete
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;eval &amp;#34;$(register-python-argcomplete3 pmbootstrap)&amp;#34;&amp;#39;&lt;/span&gt; &amp;gt;&amp;gt; ~/.bashrc
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;source&lt;/span&gt; ~/.bashrc&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ol start="4"&gt;
&lt;li&gt;If entering &lt;code&gt;pmbootstrap&lt;/code&gt; still says the command cannot be found after installation, reboot.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 class="relative group"&gt;3. Initialize Device Settings
 &lt;div id="3-initialize-device-settings" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#3-initialize-device-settings" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;Initialize pmbootstrap and enter the device settings according to the prompts. The settings for the following questions are stored in &lt;code&gt;~/.config/pmbootstrap.cfg&lt;/code&gt;.&lt;/p&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;~ $ pmbootstrap init
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Work directory&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Work path &lt;span class="o"&gt;[&lt;/span&gt;/home/ivon/.local/var/pmbootstrap&lt;span class="o"&gt;]&lt;/span&gt;: Enter
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# For the update channel, enter stable or edge. edge may sometimes break dependencies because of Alpine upstream updates&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Channel &lt;span class="o"&gt;[&lt;/span&gt;edge&lt;span class="o"&gt;]&lt;/span&gt;: v22.06
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Select vendor&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Vendor &lt;span class="o"&gt;[&lt;/span&gt;qemu&lt;span class="o"&gt;]&lt;/span&gt;: sony
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Enter Sony&amp;#39;s official device codename&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Device codename: pdx206
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Confirm porting a new device&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;You are about to &lt;span class="k"&gt;do&lt;/span&gt; a new device port &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;sony-pdx206&amp;#39;&lt;/span&gt;.
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Continue? &lt;span class="o"&gt;(&lt;/span&gt;y/n&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;y&lt;span class="o"&gt;]&lt;/span&gt;: y
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Enter the processor architecture&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Device architecture &lt;span class="o"&gt;(&lt;/span&gt;armv7/aarch64/x86_64/x86&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;armv7&lt;span class="o"&gt;]&lt;/span&gt;: aarch64
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Enter the manufacturer&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Who produced the device &lt;span class="o"&gt;(&lt;/span&gt;e.g. LG&lt;span class="o"&gt;)&lt;/span&gt;? sony
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Enter the full phone name&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;What is the official name &lt;span class="o"&gt;(&lt;/span&gt;e.g. Google Nexus 5&lt;span class="o"&gt;)&lt;/span&gt;? Sony Xperia &lt;span class="m"&gt;5&lt;/span&gt; II
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Phone release year&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;In what year was the device released &lt;span class="o"&gt;(&lt;/span&gt;e.g. 2012&lt;span class="o"&gt;)&lt;/span&gt;? &lt;span class="m"&gt;2020&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Set the device type to handset&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;What &lt;span class="nb"&gt;type&lt;/span&gt; of device is it? handset
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# No hardware keyboard, answer n&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Does the device have a hardware keyboard? &lt;span class="o"&gt;(&lt;/span&gt;y/n&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;n&lt;span class="o"&gt;]&lt;/span&gt;: n
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Whether there is an SD card slot, answer y&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Does the device have a sdcard or other external storage medium? &lt;span class="o"&gt;(&lt;/span&gt;y/n&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;n&lt;span class="o"&gt;]&lt;/span&gt;: y
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Choose fastboot as the flashing method&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Which flash method does the device support?
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Flash method &lt;span class="o"&gt;(&lt;/span&gt;0xffff/fastboot/heimdall/none/rkdeveloptool/uuu&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;0xffff&lt;span class="o"&gt;]&lt;/span&gt;: fastboot
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Let pmbootstrap analyze the boot parameters of boot.img. I used the boot.img from a third-party ROM&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;[&lt;/span&gt;11:15:10&lt;span class="o"&gt;]&lt;/span&gt; You can analyze a known working boot.img file to automatically fill out the flasher information &lt;span class="k"&gt;for&lt;/span&gt; your deviceinfo file. Either specify the path to an image or press &lt;span class="k"&gt;return&lt;/span&gt; to skip this step &lt;span class="o"&gt;(&lt;/span&gt;you can &lt;span class="k"&gt;do&lt;/span&gt; it later with &lt;span class="s1"&gt;&amp;#39;pmbootstrap bootimg_analyze&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;.
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Path: /home/ivon/下載/Evo/extracted_20220826_113410/boot.img
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Default username&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Username &lt;span class="o"&gt;[&lt;/span&gt;user&lt;span class="o"&gt;]&lt;/span&gt;: user
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Choose the graphical interface. Before confirming hardware acceleration works, choose XFCE4 first&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;User interface &lt;span class="o"&gt;[&lt;/span&gt;weston&lt;span class="o"&gt;]&lt;/span&gt;: xfce4
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Keep the default boot partition settings, enter n&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Additional options: extra free space: &lt;span class="m"&gt;0&lt;/span&gt; MB, boot partition size: &lt;span class="m"&gt;256&lt;/span&gt; MB, parallel jobs: 9, ccache per arch: 5G, sudo timer: False, mirror: http://mirror.postmarketos.org/postmarketos/
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Change them? &lt;span class="o"&gt;(&lt;/span&gt;y/n&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;n&lt;span class="o"&gt;]&lt;/span&gt;: n
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Whether to install extra packages&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Additional packages that will be installed to rootfs. Specify them in a comma separated list &lt;span class="o"&gt;(&lt;/span&gt;e.g.: vim,file&lt;span class="o"&gt;)&lt;/span&gt; or &lt;span class="s2"&gt;&amp;#34;none&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Extra packages &lt;span class="o"&gt;[&lt;/span&gt;none&lt;span class="o"&gt;]&lt;/span&gt;: none
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Set the system timezone&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Your host timezone: Asia/Taipei
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Use this timezone instead of GMT? &lt;span class="o"&gt;(&lt;/span&gt;y/n&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;y&lt;span class="o"&gt;]&lt;/span&gt;: y
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Set the system language. English is recommended first&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Choose default locale &lt;span class="k"&gt;for&lt;/span&gt; installation: en_US.UTF-8
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Set the device name&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Device hostname &lt;span class="o"&gt;(&lt;/span&gt;short form, e.g. &lt;span class="s1"&gt;&amp;#39;foo&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;sony-pdx206&lt;span class="o"&gt;]&lt;/span&gt;: Enter
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Whether to copy local SSH keys to the postmarketOS system&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Would you like to copy your SSH public keys to the device? &lt;span class="o"&gt;(&lt;/span&gt;y/n&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;n&lt;span class="o"&gt;]&lt;/span&gt;: n
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Automatically build outdated packages&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;After pmaports are changed, the binary packages may be outdated. If you want to install postmarketOS without changes, reply &lt;span class="s1"&gt;&amp;#39;n&amp;#39;&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; a faster installation.
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Build outdated packages during &lt;span class="s1"&gt;&amp;#39;pmbootstrap install&amp;#39;&lt;/span&gt;? &lt;span class="o"&gt;(&lt;/span&gt;y/n&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;y&lt;span class="o"&gt;]&lt;/span&gt;: y&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 class="relative group"&gt;4. Set Kernel Build Options
 &lt;div id="4-set-kernel-build-options" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#4-set-kernel-build-options" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;pmbootstrap automatically creates an ARM chroot environment, so remember to enter your password when needed. While compiling, open another terminal and run &lt;code&gt;pmbootstrap log&lt;/code&gt; to watch the error messages.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;First, get the phone&amp;rsquo;s kernel source code. postmarketOS recommends looking for the kernel from &lt;a href="https://github.com/LineageOS" target="_blank" rel="noreferrer"&gt;LineageOS&amp;rsquo;s Github&lt;/a&gt;, but LineageOS does not currently have one for the Xperia 5 II. So I had to use a third-party kernel from XDA, such as &lt;a href="https://github.com/XperiaBrickers/android_kernel_sony_sm8250" target="_blank" rel="noreferrer"&gt;XperiaBricker&amp;rsquo;s version&lt;/a&gt;, which is what I used. &lt;a href="https://github.com/sonyxperiadev/kernel-copyleft/tree/58.1.A.5.xxx" target="_blank" rel="noreferrer"&gt;Sony also releases kernel source&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Switch to the working directory:&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; /home/&lt;span class="nv"&gt;$USER&lt;/span&gt;/.local/var/pmbootstrap/cache_git/pmaports/device/testing/linux-sony-pdx206&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ol start="3"&gt;
&lt;li&gt;
&lt;p&gt;There will be an &lt;code&gt;APKBUILD&lt;/code&gt; file inside. This is the kernel build configuration file. The &lt;code&gt;#Source&lt;/code&gt; block is the source repository for the kernel.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Since this does not use LineageOS&amp;rsquo;s official repo, modify the &lt;code&gt;#Source&lt;/code&gt; block as follows. The items under &lt;code&gt;$_config&lt;/code&gt; on the last line are the patches to apply during compilation.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Source&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;_repository&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;android_kernel_sony_sm8250&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;_commit&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;8bdbbde86f74be117281c82f4181d1f938659ce0&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;_config&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;config-&lt;/span&gt;&lt;span class="nv"&gt;$_flavor&lt;/span&gt;&lt;span class="s2"&gt;.&lt;/span&gt;&lt;span class="nv"&gt;$arch&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;source&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="s2"&gt;	&lt;/span&gt;&lt;span class="nv"&gt;$pkgname&lt;/span&gt;&lt;span class="s2"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;$_commit&lt;/span&gt;&lt;span class="s2"&gt;.tar.gz::https://github.com/XperiaBrickers/&lt;/span&gt;&lt;span class="nv"&gt;$_repository&lt;/span&gt;&lt;span class="s2"&gt;/archive/&lt;/span&gt;&lt;span class="nv"&gt;$_commit&lt;/span&gt;&lt;span class="s2"&gt;.tar.gz
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="s2"&gt;	&lt;/span&gt;&lt;span class="nv"&gt;$_config&lt;/span&gt;&lt;span class="s2"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="s2"&gt;	gcc10-extern_YYLOC_global_declaration.patch
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="s2"&gt; gcc7-give-up-on-ilog2-const-optimizations.patch
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="s2"&gt; gcc8-fix-put-user.patch
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="s2"&gt; kernel-use-the-gnu89-standard-explicitly.patch
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ol start="5"&gt;
&lt;li&gt;In the kernel source repository, find the &lt;code&gt;Makefile&lt;/code&gt;. Based on the &lt;code&gt;VERSION&lt;/code&gt;, &lt;code&gt;PATCHLEVEL&lt;/code&gt;, and &lt;code&gt;SUBLEVEL&lt;/code&gt; written inside, fill in the version number for &lt;code&gt;pkgver&lt;/code&gt; in APKBUILD. In this example, it is 4.19.195. Then save the file.&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;pkgver&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;4.19.195&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ol start="6"&gt;
&lt;li&gt;Find &lt;code&gt;defconfig&lt;/code&gt; from the kernel source repository. This is the file used to generate the kernel config. For example, this kernel&amp;rsquo;s config is located under &lt;code&gt;arch/arm64/configs&lt;/code&gt;. Download it to the working directory, then rename it to config-device-name-codename-arch:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;wget https://raw.githubusercontent.com/XperiaBrickers/android_kernel_sony_sm8250/base/arch/arm64/configs/pdx206_defconfig
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mv pdx206_defconfig config-sony-pdx206.aarch64&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ol start="7"&gt;
&lt;li&gt;Download the kernel source and generate checksums. Run this command whenever the APKBUILD file has changed.&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;pmbootstrap checksum linux-sony-pdx206&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ol start="8"&gt;
&lt;li&gt;Before compiling, edit the kernel config. In the kernel editor page, use the left and right arrow keys to move to Exit, press Enter, and save the kernel config.&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;pmbootstrap kconfig edit&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ol start="9"&gt;
&lt;li&gt;
&lt;p&gt;Newly ported devices add four patches by default. If kconfig shows cannot apply patch, remove the patch filename from &lt;code&gt;$config&lt;/code&gt; in APKBUILD. If &amp;ldquo;Please don&amp;rsquo;t include linux directly&amp;rdquo; appears, add &lt;code&gt;REPLACE_GCCH=0&lt;/code&gt; at the very beginning of APKBUILD.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Generate the checksums again and edit the kernel config.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;pmbootstrap checksum linux-sony-pdx206
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;pmbootstrap kconfig edit&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ol start="11"&gt;
&lt;li&gt;
&lt;p&gt;In the kernel editor page, use the left and right arrow keys to move to Exit, press Enter, and save the kernel config.
&lt;figure&gt;
 &lt;img
 class="my-0 rounded-md"
 loading="lazy"
 decoding="async"
 fetchpriority="low"
 alt=""
 src="https://i.postimg.cc/cCTCsBG4/2021-12-15-00-00-11.png"
 onerror="this.onerror=null;this.src='https://ivonblog.com/images/unable-to-load-the-image-pepe.webp'"
 &gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;pmbootstrap will then check which kernel configs are missing and show yellow WARNING messages:&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;[&lt;/span&gt;12:15:36&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;native&lt;span class="o"&gt;)&lt;/span&gt; generate checksums &lt;span class="k"&gt;for&lt;/span&gt; linux-sony-pdx206
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;[&lt;/span&gt;12:15:37&lt;span class="o"&gt;]&lt;/span&gt; WARNING: linux-sony-pdx206/config-sony-pdx206.aarch64: CONFIG_ANDROID_PARANOID_NETWORK should *not* be set. See &amp;lt;https://wiki.postmarketos.org/wiki/kconfig#CONFIG_ANDROID_PARANOID_NETWORK&amp;gt; &lt;span class="k"&gt;for&lt;/span&gt; details.
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;[&lt;/span&gt;12:15:37&lt;span class="o"&gt;]&lt;/span&gt; WARNING: linux-sony-pdx206/config-sony-pdx206.aarch64: CONFIG_DEVTMPFS should be set. See &amp;lt;https://wiki.postmarketos.org/wiki/kconfig#CONFIG_DEVTMPFS&amp;gt; &lt;span class="k"&gt;for&lt;/span&gt; details.
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;[&lt;/span&gt;12:15:37&lt;span class="o"&gt;]&lt;/span&gt; WARNING: linux-sony-pdx206/config-sony-pdx206.aarch64: CONFIG_SYSVIPC should be set. See &amp;lt;https://wiki.postmarketos.org/wiki/kconfig#CONFIG_SYSVIPC&amp;gt; &lt;span class="k"&gt;for&lt;/span&gt; details.
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;[&lt;/span&gt;12:15:37&lt;span class="o"&gt;]&lt;/span&gt; WARNING: linux-sony-pdx206/config-sony-pdx206.aarch64: CONFIG_VT should be set. See &amp;lt;https://wiki.postmarketos.org/wiki/kconfig#CONFIG_VT&amp;gt; &lt;span class="k"&gt;for&lt;/span&gt; details.
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;[&lt;/span&gt;12:15:37&lt;span class="o"&gt;]&lt;/span&gt; WARNING: linux-sony-pdx206/config-sony-pdx206.aarch64: CONFIG_USER_NS should be set. See &amp;lt;https://wiki.postmarketos.org/wiki/kconfig#CONFIG_USER_NS&amp;gt; &lt;span class="k"&gt;for&lt;/span&gt; details.&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ol start="13"&gt;
&lt;li&gt;Copy these WARNING lines. Then click the URL after each WARNING and check the Wiki to see which configs need to be enabled or disabled. Open the kernel editor page and enable or disable them with the Space key:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;pmbootstrap kconfig edit&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ol start="14"&gt;
&lt;li&gt;After adjusting everything, Exit and save. Check whether the kernel config meets postmarketOS requirements. If successful, it returns &lt;code&gt;kconfig check succeeded!&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;pmbootstrap kconfig check&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 class="relative group"&gt;5. Compile the Kernel
 &lt;div id="5-compile-the-kernel" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#5-compile-the-kernel" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;Now start compiling the kernel. This may be the longest step. While compiling, remember to open another terminal and run &lt;code&gt;pmbootstrap log&lt;/code&gt; to check error messages.&lt;/p&gt;
&lt;p&gt;pmbootstrap compiles the kernel according to the steps written in APKBUILD. First it downloads the kernel source from the URL in &lt;code&gt;#Sources&lt;/code&gt;, then applies &lt;code&gt;config-sony-pdx206.aarch64&lt;/code&gt; as the kernel config. After that it runs make according to the commands in the &lt;code&gt;build()&lt;/code&gt; block, so you can add &lt;code&gt;make -j8&lt;/code&gt; here to speed up compilation.&lt;/p&gt;

&lt;h3 class="relative group"&gt;5.1. Start Compiling the Kernel
 &lt;div id="51-start-compiling-the-kernel" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#51-start-compiling-the-kernel" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Run the following command to start compiling:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;pmbootstrap build linux-sony-pdx206
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# If you want to modify the kernel source yourself, add the src parameter during build and compile from your extracted files:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;pmbootstrap build linux-sony-pdx206 --src&lt;span class="o"&gt;=&lt;/span&gt;/home/ivon/下載/android_kernel_sony_sm8250/&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ol start="2"&gt;
&lt;li&gt;If things go smoothly, it should finish in about half an hour:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;gt;&amp;gt;&amp;gt; linux-sony-pdx206*: Tracing dependencies...
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;gt;&amp;gt;&amp;gt; linux-sony-pdx206*: Package size: 55.0 MB
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;gt;&amp;gt;&amp;gt; linux-sony-pdx206*: Compressing data...
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;gt;&amp;gt;&amp;gt; linux-sony-pdx206*: Create checksum...
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;gt;&amp;gt;&amp;gt; linux-sony-pdx206*: Create linux-sony-pdx206-4.19.195_p20220910214444-r0.apk
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;gt;&amp;gt;&amp;gt; linux-sony-pdx206: Build &lt;span class="nb"&gt;complete&lt;/span&gt; at Sat, &lt;span class="m"&gt;10&lt;/span&gt; Sep &lt;span class="m"&gt;2022&lt;/span&gt; 14:03:42 +0000 elapsed &lt;span class="nb"&gt;time&lt;/span&gt; 0h 18m 58s
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;gt;&amp;gt;&amp;gt; linux-sony-pdx206: Updating the pmos/aarch64 repository index...
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;gt;&amp;gt;&amp;gt; linux-sony-pdx206: Signing the index...&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Of course, things usually are not that simple. If compilation hits an error, it stops. At that point, read the error messages in &lt;code&gt;pmbootstrap log&lt;/code&gt; or &lt;code&gt;~/.local/var/pmbootstrap/log.txt&lt;/code&gt; and start debugging.&lt;/p&gt;

&lt;h3 class="relative group"&gt;5.2. Debugging
 &lt;div id="52-debugging" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#52-debugging" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h3&gt;
&lt;p&gt;Warnings from compilation can be ignored for now. The thing to fix first is error.&lt;/p&gt;
&lt;p&gt;Things you can try:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Use &lt;code&gt;grep&lt;/code&gt; to search other postmarketOS devices for similar error messages, add their patch file to this phone&amp;rsquo;s APKBUILD, run &lt;code&gt;pmbootstrap checksum linux-sony-pdx206&lt;/code&gt;, then build again.&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;grep -r &lt;span class="s1"&gt;&amp;#39;perf_trace_counters\.c&amp;#39;&lt;/span&gt; ~/.local/var/pmbootstrap/cache_git/pmaports/device/testing/&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ol start="2"&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://wiki.postmarketos.org/wiki/Porting_to_a_new_device#Changing_compiler" target="_blank" rel="noreferrer"&gt;Change compiler&lt;/a&gt;. pmbootstrap uses the latest GCC by default. Some Android kernels only compile with older GCC, or you can consider using CLANG.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Switch to another kernel source with fewer problems.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Ask for help in the &lt;a href="https://matrix.to/#/%23porting:postmarketos.org" target="_blank" rel="noreferrer"&gt;postmarketOS Matrix channel&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 class="relative group"&gt;6. Set Device Parameters and Build the Device-specific Package
 &lt;div id="6-set-device-parameters-and-build-the-device-specific-package" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#6-set-device-parameters-and-build-the-device-specific-package" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;This step configures and builds the device specific package for this model.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;After the kernel compiles successfully, switch to the device package directory:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; /home/&lt;span class="nv"&gt;$USER&lt;/span&gt;/.local/var/pmbootstrap/cache_git/pmaports/device/testing/device-sony-pdx206&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ol start="2"&gt;
&lt;li&gt;At this point, you can let pmbootstrap analyze boot.img&amp;rsquo;s boot parameters again and add the results to &lt;code&gt;deviceinfo&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;pmbootstrap bootimg_analyze /home/ivon/下載/Evo/extracted_20220826_113410/boot.img&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ol start="2"&gt;
&lt;li&gt;Edit &lt;code&gt;deviceinfo&lt;/code&gt; and set the screen resolution:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;deviceinfo_screen_width&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;1080&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;deviceinfo_screen_height&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;2520&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ol start="3"&gt;
&lt;li&gt;
&lt;p&gt;According to the sony-pdx206 notes on the postmarketOS Wiki, Sony&amp;rsquo;s software implementation has a problem: enabling UFS will cause the bootloader to be erased. So do not flash rootfs to the phone.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Check the files again, then build the device-specific package:&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;pmbootstrap checksum device-sony-pdx206
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;pmbootstrap build device-sony-pdx206&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Now the postmarketOS kernel and device package for the Sony Xperia 5 II are built. Next, create the installation files.&lt;/p&gt;

&lt;h2 class="relative group"&gt;7. Flash to the Phone
 &lt;div id="7-flash-to-the-phone" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#7-flash-to-the-phone" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Create the postmarketOS installation files. It takes about 10 minutes. During the process, it will ask you to create a user password.&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;pmbootstrap install&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ol start="2"&gt;
&lt;li&gt;Since UFS cannot be used, the installation files can only be flashed to the phone&amp;rsquo;s SD card:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;pmbootstrap install --sdcard&lt;span class="o"&gt;=&lt;/span&gt;/dev/sdX&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ol start="3"&gt;
&lt;li&gt;Put the phone into fastboot mode and boot from the kernel.&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;pmbootstrap flasher boot
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Because of the Sony software issue described above, do not use this command unless you really want to flash to the phone&amp;#39;s boot partition&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;pmbootstrap flasher flash_kernel&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ol start="4"&gt;
&lt;li&gt;Shut down pmbootstrap on the PC:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;pmbootstrap shutdown&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 class="relative group"&gt;8. Results
 &lt;div id="8-results" class="anchor"&gt;&lt;/div&gt;
 
 &lt;span
 class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none"&gt;
 &lt;a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#8-results" aria-label="Anchor"&gt;#&lt;/a&gt;
 &lt;/span&gt;
 
&lt;/h2&gt;
&lt;p&gt;If the screen shows nothing, you can still connect the phone to the PC over USB and then use ssh to see whether it entered the system.&lt;/p&gt;
&lt;p&gt;The result: this Sony still has no display.&lt;/p&gt;
&lt;p&gt;If you can enter the desktop, submit a merge on GitLab and put result photos on the Wiki.&lt;/p&gt;
&lt;p&gt;The next step is to replace the downstream kernel with a mainline kernel. Stock Android kernels are usually downstream kernels, with a pile of extra patches and closed firmware. Replacing the kernel with a mainline kernel is the actual endgame of postmarketOS.&lt;/p&gt;</content:encoded></item></channel></rss>