Development [Kernel][02.07.2022][Android 12] Kirisakura 2.0.0 for Sony Xperia 1 III aka "Sagami"

Search This thread

Freak07

Recognized Developer / Recognized Contributor
Jan 2, 2011
5,746
19,207
Hi Freak, I'm using a GSI ROM, Corvus to be exact. Honestly I'm not so sure the information I've found is relevant. I think the ROM is misconfigured as AOD is also disabled, should definitely be enabled.

According to the overlay from Sony themselves AOD should be supported, but DT2W should not.

But that doesn't make sense as DT2W works in the vanilla ROM...

Corvus is based on PHH Treble and missing the overlay anyways.
(Missing PDX215 entry)
No, I mean double tap to wake, not sleep. If you meant double tap to wake, do tell how.
Swipe is also fine, but now I have to pick it up every time I want to do something. That's... Cumbersome to put it mildly.
Ah well, gsi is the problem, incomplete and buggy, miuistone is working hard to make a more complete gsi over time, if you need it now I suggest you wait on a customized stock for the time being.

I think here´s not the best place to discuss this :) the kernel is primarily intended to be used with the stock firmware and I like to keep the discussion at least somewhat related to the kernel itself. I don´t mind occasional off-topic, but I think this is just something else entirely.

Maybe open a new thread and somebody might know a way to get it working on GSIs, look at other devices how it´s implemented on custom roms etc. :)

I´m not much familar with ROM development so I´m afraid I´m also not of much help.


Thanks for your sharing, I am trying to build an Android 12 kernel with Xperia 1 III to support running Docker, I am a novice, can I do it with KirisakurA_sagami_s_2.0.0?


Here's a way to check if the kernel supports Docker:
Sorry I have no clue about that either. :) I suppose if those required patches are generic you should be able to apply them to my source and compile the kernel with the changes yourself.
 

1219545479

New member
Jul 21, 2017
2
0
Sony Xperia 1 III
I think here´s not the best place to discuss this :) the kernel is primarily intended to be used with the stock firmware and I like to keep the discussion at least somewhat related to the kernel itself. I don´t mind occasional off-topic, but I think this is just something else entirely.

Maybe open a new thread and somebody might know a way to get it working on GSIs, look at other devices how it´s implemented on custom roms etc. :)

I´m not much familar with ROM development so I´m afraid I´m also not of much help.



Sorry I have no clue about that either. :) I suppose if those required patches are generic you should be able to apply them to my source and compile the kernel with the changes yourself.
Can I get the xperia 1 III A12 kernel source code? I want to enable some kernel features by make menuconfig so THAT I can use Docker. Here are some missing functions to check for when using Docker: docker_check.txt

I used this script to check which kernel features docker needs to enable: check-config.sh
 

Attachments

  • docker_check.txt
    3.1 KB · Views: 10
  • check-config.zip
    4.2 KB · Views: 5

jaungster

Member
Aug 10, 2013
19
1
I just rooted my phone, USA variant running build 61.1.A.9.128. I can see it looks like the latest 2.0.0 release is for build.

Can I still flash the kernel, or do I need to update? How do I update anyway now that I'm rooted? Do I need to xperifirm patch the firmware boot everytime?
 

Freak07

Recognized Developer / Recognized Contributor
Jan 2, 2011
5,746
19,207
I just rooted my phone, USA variant running build 61.1.A.9.128. I can see it looks like the latest 2.0.0 release is for build.

Can I still flash the kernel, or do I need to update? How do I update anyway now that I'm rooted? Do I need to xperifirm patch the firmware boot everytime?
as soon as you bootloader unlock you´ll no longer receive FOTAs. Yes you´ll need to update using the tools available here on XDA.

If you want to stay rooted you have to magisk patch the boot.img from the newly installed firmware and flash that. Afterwards reflash the kernel here following the instructions. I don´t have the USA variant, but the kernel should work just fine on that as well.

but as always make sure to keep a backup before flashing.
 

jaungster

Member
Aug 10, 2013
19
1
So it looks like I have to wait for USA firmware 61....149 on xperifirm, then patch boot and update before flashing the kernel. Just wanted to confirm
 

jaungster

Member
Aug 10, 2013
19
1
It's been a while since I've messed with root and all that. The last phone I went all in for was an axon 7. If I were to try to flash this kernel and it's not compatible, what steps can I use to reflash the old kernel (as well as backup my current stock kernel)
 

Pandemic

Senior Member
Aug 30, 2010
24,081
23,193
Meppel
talk.sonymobile.com
Xperia XZ2
Sony Xperia 1
It's been a while since I've messed with root and all that. The last phone I went all in for was an axon 7. If I were to try to flash this kernel and it's not compatible, what steps can I use to reflash the old kernel (as well as backup my current stock kernel)
Look buddy this stands in the 1st post:

How to flash the Kernel:
1. Download the latest kernel.zip and make sure you have properly updated to the latest matching Firmware (check the feature list for the current firmware the source is based on). When there´s an OTA update for the Sony Xperia 1 III it takes Sony a while to release the source code for the new OS and me a while to build a new kernel. If you don´t want to face any issues, wait until I either release an updated kernel or give green light because there were no kernel changes.
If you want to be sure there are no issues, always make sure to run the firmware the kernel is built for!
If you feel adventurous and try in advance, make sure you have a backup ready!

2. Flash the kernel.zip via latest TWRP (if available), EXKM or FKM app and do a full reboot.

3. Reboot and profit.
 

jaungster

Member
Aug 10, 2013
19
1
Look buddy this stands in the 1st post:

How to flash the Kernel:
1. Download the latest kernel.zip and make sure you have properly updated to the latest matching Firmware (check the feature list for the current firmware the source is based on). When there´s an OTA update for the Sony Xperia 1 III it takes Sony a while to release the source code for the new OS and me a while to build a new kernel. If you don´t want to face any issues, wait until I either release an updated kernel or give green light because there were no kernel changes.
If you want to be sure there are no issues, always make sure to run the firmware the kernel is built for!
If you feel adventurous and try in advance, make sure you have a backup ready!

2. Flash the kernel.zip via latest TWRP (if available), EXKM or FKM app and do a full reboot.

3. Reboot and profit.
Sorry I was just asking since his firmware it's based on is 61.1.A.9.149 and I'm running 61.1.A.9.128 (latest on USA xc-62). If it wasn't compatible and someone knew I was hoping they'd chime in so I wouldn't risk bricking my device (it doubles as my work phone). I wasn't sure if there was a kernel difference between the firmwares that'd cause my phone to crash.
 

Pandemic

Senior Member
Aug 30, 2010
24,081
23,193
Meppel
talk.sonymobile.com
Xperia XZ2
Sony Xperia 1
Sorry I was just asking since his firmware it's based on is 61.1.A.9.149 and I'm running 61.1.A.9.128 (latest on USA xc-62). If it wasn't compatible and someone knew I was hoping they'd chime in so I wouldn't risk bricking my device (it doubles as my work phone). I wasn't sure if there was a kernel difference between the firmwares that'd cause my phone to crash.
I use this kernel to on latest fw .128 and no issues at all trust me, i use my phone also for everything.
 

htcmage

Senior Member
May 3, 2020
111
31
HTC U11+
HTC U12+
Hi, developer, can I ask you to develop the same (Snapdragon 888) xperia PRO-I kernel as Xperia 1 III (5 III)? I'd be happy to donate if I could.
IMG_20220803_083800.jpg
 

Freak07

Recognized Developer / Recognized Contributor
Jan 2, 2011
5,746
19,207
Hi, developer, can I ask you to develop the same (Snapdragon 888) xperia PRO-I kernel as Xperia 1 III (5 III)? I'd be happy to donate if I could.
I checked the possibility. It boots normally. The camera doesn't work and of course stutters a bit. Can you help with development? . if there is a chance ..
sorry I don´t work on devices that I don´t physically own and can test on.
If it´s just a matter of getting the camera working maybe someone that owns the phone can take my work and adjust it to function properly with the PRO-I.

Hi all! Is it possible to force 4k output through the kernel/kernel manager since the adb method has been locked? Thx. :)
Unfortunately not and I´m not sure at this point that 4K works properly at all on A12.

I can force the panel itself to run at 4K via kernel, but content is still rendered at lower resolution.
Looking at the logs, forcing the panel via kernel to run at 4K produces the exact same lines in logcat and dmesg as when running any app that triggers 4K without the hack. So I´m really not sure if rendering is ever at 4K on A12, even in supported apps. That panel itself switches to 4K, but content seems to me still rendered at lower resolution. I´m not 100% sure about this, but I found no way to force it like on A11.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 8
    Kirisakura-Kernel for the Sony Xperia 1 III

    Hello everyone,

    To keep it short: Here is Kirisakura - Kernel for the Sony Xperia 1 III aka Sagami. Sagami is the internal codename for this years development platform of Sony Mark III devices. Please note this kernel is made to run only on Xperia 1 III.
    I would appreciate if everybody that flashes the kernel, reads at least once through this opening post and the following ones.

    Kirisakura - Kernel is designed to bring a handful of beneficial features to the device, while ensuring excellent performance and smoothness to get you safely through the day!
    If you expect a custom kernel to magically improve your devices battery life manifold and this is your only priority then this might not be the right place for you.
    However the kernel is built to keep battery life close to the same as you would experience the on stock kernel while being tuned to perform better in various UI related benchmarks. The same benches are used by google to verify and ensure UI smoothness on the Pixel devices.
    There´s also a cpu-battery saver mode that cuts back the CPU max- freqs, but without the disadvantages like delayed notifications from built into the system user-space power-saving modes.
    If that got your curious, I welcome you to continue reading if you´re still interested!

    The kernel includes a lot of improvements and contributions from other developers as well. Without this kernel would not exist.
    A big part of improvements originate from @arter97´s, @kdrag0n´s and @Sultanxda´s work. Many others contributed in some way or another to this kernel.
    A big thanks to all of them at this place!

    Now lets continue with a list of features in the next paragraph!


    Main Features:
    - Based on latest kernel sources from Sony for Android 12 and intended to be used on the latest Stock-Firmware
    - compiled with Clang 14.0.7 and built with -O3 speed optimizations
    - Linux-Stable-Upstream included to 5.4.202
    - upstreamed CAF base for the Snapdragon 888 (qcoms internal codename "lahaina")
    - CPU-Battery saver to be able to restrict max cpufreqs on the fly, without enabling powersaving modes that might cause missed notifications (more info here)
    - include important fixes/improvements from kernel/common
    - reduce power consumption during deep sleep
    - remove logging while device is suspended
    - disable various debugging mechanisms for drivers which are not needed on a perf build (e.g. binder)
    - disable selinux auditing (we don´t have to adress selinux denials running a stock rom)
    - disable unnecessary CPU errata for our specific SoC
    - implement LRNG (thanks @arter97, see arter kernel OP for more info )
    - Flashing the kernel will keep root!
    - Flashable via EXKM, FKM or TWRP (if available) on a rooted system!


    EAS related features:
    - Implement dynamic WALT-Window size depending on current FPS, collecting information about CPU-Load to provide more precise information for the scheduler
    - EAS implementation patched up to latest CAF state
    - updates from kernel/common
    - scheduler updates from sd888/ 5.4 kernel

    CPU related features:
    - Power saving workingqueues enabled by default (toggleable in EXKM)
    - Change various drivers (WLAN, MM, audio, charger, power, thermal, glink etc) to use power efficient workingqueues. This compliments EAS in general
    - improvements to cpufreq/times/stats
    - vdso32 patches as found on Google Pixel devices (brief documentation here) (CAF 5.4 default, keep for documentation)
    - remove event debug logging
    - disable broken irq detection, disable debugmon
    - improve suspend/resume from audio driver (caf-upstream for audio-kernel)
    - cpuidle: wake only cpus for which qos has changed (this allows cores to keep idle states better)
    - disable debugging during sleep states as per qcom recommendation
    - remove RTB logging to reduce overhead
    - disable trace_printk as it shouldn´t be used on production/perf kernel builds
    - enable suspend_skip_sync to save power during suspend/resume
    - disable edac and coresight (following google on the pixel kernels)
    - disable jtagv8 debugging as recommended by qcom for perf builds to avoid potential power, performance and memory penalty
    - disable s2idle in favor of deep idle state -> improves deep sleep drain (google initially used 2idle for improved suspend/resume latency on pixel 3 and pixel 4, but disabled it on pixel 5. qcom followed suit for sd 888, but apparently didn´t see google reverting it on pixel 5. Other OEMs such as Xiaomi or OnePlus already disabled s2idle on their SD888 devices in favor of deep- read more about s2idle vs deep here)

    GPU related features:
    - GPU driver updated to latest CAF-State
    - gpu/kgsl improvements from pixel 4/pixel 5 kernel
    - add low_prio_worker thread for gpu driver (Improves performance when tearing down processes (eg, via LMK) and not blocking currently running UI from submitting work to the GPU

    File System related features:
    - upstream BFQ-MQ to latest state in linux-mainline and default to 128KB readahead
    - improve memory allocations in kernfs
    - ufs improvements from pixel 4/ pixel 5 kernel
    - improve GC as to not interfere while user interaction is happening and prevent possible jitter or latency spikes

    Network related features:
    - Wireguard Support (Details)
    - advanced TCP algorithms enabled
    - use bbr as default TCP congestion algorithm (fasted algo according to this excellent research from @kdrag0n found here )
    - improved networking drivers from caf-upstream (especially wifi)
    - remove unnecessary wakelock from WLAN driver to reduce thousands of very short wakeups during a 7 hour deep sleep period
    - improved bluetooth performance (¹, ²)
    - Enable support for TTL spoofing

    Memory related features:
    - Speculative Page Faults left enabled (1. 2) (CAF 5.4 default, keep for documentation)
    - Fix various memory leaks in different subsystems
    - improved mm with patches from mainline
    - patches from kernel/common
    - improve memory allocations in various subsystems, video encode/decode, kernfs, cgroup
    - Backport to enable CONFIG_HAVE_MOVE_PMD (see here) , thanks @arter97
    - Backport to enable CONFIG_HAVE_MOVE_PUD (commit here) , thanks @arter97
    - free more RAM by removing unused reserved memory regions
    - mm: Micro-optimize PID map reads for arm64 (improves game performance, especially unity based games such as genshin impact)
    - MGLRU added (info here and here

    Security related features:
    - Control-Flow-Integration (CFI) and Link-Time-Optimization (LTO) (CAF 5.4 default, keep for documentation)
    - Use ThinLTO which was first used in the Pixel 4 XL Android R-Kernel instead of full LTO (CAF 5.4 default, keep for documentation)
    - Shadow Call Stack (SCS) Security-Feature ( 5.4 default, keep for documentation)
    - enable init_on_alloc for even more security, more information can be found in the commit message (CAF 5.4 default, keep for documentation)


    Misc Features:

    Wakelock Blocker:
    - advanced wakelock blocker with the ability to block any wakelocks (dangerous, use with caution)
    - please read [URL="https://arstechnica.com/gadgets/2018/08/p-is-for-power-how-google-tests-tracks-and-improves-android-battery-life/"]this for further info
    - blocking a kernel wakelock should only be done in case of firmware incompatabilities (WiFi network at work (can´t be changed) causes deep sleep to not work on the phone.) That´s the only use case I see for this feature. The kernel does not features this to improve battery life!

    Other features:
    - clean up asus drivers and fix a few warnings in kernel log
    - disable logging and debugging to make the kernel more lightweight in various places (includes binder, mm, vma, gpu, ipa etc)
    - fix several coding issues detected by newer Clang-Toolchains
    - enlarge dmesg size to ease debugging


    Flashing Guide, Download and Changelog

    Requirements:
    - unlocked Bootloader
    - USB-Debugging in developer options enabled
    - latest adb and fastboot binaries
    - working adb and fastboot environment
    - magisk root
    - a backup of stock boot.img or your magisk patched boot.img in case you want to go back to stock.

    How to flash the Kernel:
    1. Download the latest kernel.zip and make sure you have properly updated to the latest matching Firmware (check the feature list for the current firmware the source is based on). When there´s an OTA update for the Sony Xperia 1 III it takes Sony a while to release the source code for the new OS and me a while to build a new kernel. If you don´t want to face any issues, wait until I either release an updated kernel or give green light because there were no kernel changes.
    If you want to be sure there are no issues, always make sure to run the firmware the kernel is built for!
    If you feel adventurous and try in advance, make sure you have a backup ready!

    2. Flash the kernel.zip via latest TWRP (if available), EXKM or FKM app and do a full reboot.

    3. Reboot and profit.


    DOWNLOAD:
    Download is located always in this folder:

    Important: Read after Download
    Please take a look at the second post after flashing the kernel!

    Changelog:

    Android 11

    1.0.0 Initial Release
    1.0.1 https://forum.xda-developers.com/t/...xperia-1-iii-aka-sagami.4377449/post-86140929

    Android 12
    2.0.0

    Donations:
    Donations are not mandatory but very welcome if you want to support development or just buy me a coffee/tea :)
    If you like my work: http://paypal.me/freak07

    Credits:
    Sony for the development device, giving me the opportunity to create this project!
    @osm0sis for all his work, including the ak3 installer!
    @tbalden for being the best HTC, Pixel, OnePlus and now Asus wingman!
    @LeeDroid and @mwilky for their awesome roms and work I used on multiple devices!
    @Captain_Throwback for all the mentoring and guidance!
    @Eliminater74 for bringing me into the game and the Inspiration
    @nathanchance for his upstream guidance and assistance
    @RenderBroken for helping me out
    @flar2 for all his work
    @joshuous for all the help he provided to me in the past!
    @arter97 for giving me advice
    @kdrag0n for his help and advices!
    @topjohnwu for magisk!


    Source Code: https://github.com/freak07/Kirisakura_Sagami
    5
    Update to 2.0.0

    Hey guys and girls,


    Alright. The source code for Xperia 1 III for Android 12 firmware was finally released after 6 months of waiting time. 🥳
    USB connection issues are fixed now. Charger detection is fixed. Smart charging features work fine as well.

    The kernel is fully compiled from source with a lot of optimizations as well as latest CAF-Upstream and linux-stable.
    I´ll update the OP to reflect all the changes.

    More changes in the Changelog below:


    Changelog:
    - Import kernel source from 61.1.A.1.149 (works fine on latest a12 firmware)
    - Linux-Stable upstream bumped to 5.4.201
    - use prebuilt clang 14.0.7 for compilation
    - latest caf-upstream
    - for more details please check the first post
    - other improvements and tweaks please check github if you´re interested in details


    Download:



    Instructions can be found in the OP!
    But look at this post too :)

    Have fun, enjoy the kernel and your phone.

    Donations are not mandatory but very welcome.
    If you like my work and want to buy me a coffee/green tea to keep development going: http://paypal.me/freak07
    4
    Android 12 Kernel

    Hey everyone :)


    So I have to be honest with this post. It´s extremely frustrating for me that there´s no source code pushed yet for the Android 12 firmware. The first Android 12 Firmware (.149) was released at the beginning of January, with another update to .211 a while ago.

    No source whatsoever for A12 at this point. It´s frustrating after 2 months.
    I understand not every OEM has the ecosystem and means of google to push the source hours after the OTA is live, but 2 months is a really long time. It´s still a long time considering the kernel is based on a completely new qcom base and probably needs to be "re-edited" (deleting comments, wip progress marks, etc) before uploading the source archive in contrast to the more "simple" A11 updates, which is probably just a drag and drop operation and happened way more quickly.
    Given Sony more or less advertises their open source ambitions in various places it´s disappointing from my perspective.


    The A11 kernel source isn´t compatible with A12 and doesn´t boot.

    However the more I got frustrated over time I more or less hacked together a kernel for A12, which is working as best as its going to get without a matching source.
    That kernel is based on latest linux-stable and latest caf-upstream, with loads of other optimizations that were not in the A11 kernel, but were contained in my other kernels for 5.4 devices.

    The only real issue on that kernel is that usb port detection is wonky. It takes a while to detect a pc and for the usb file transfer dialog to pop up.
    My old Pixel charging brick works fine ( it takes a little while to get detected sometimes), while the stock charger only works if I connect the phone to my PC usb and directly afterwards to the stock sony charging brick.
    Otherwise there are no real issues for me.


    Feel free to test, but I probably won´t be able to fix any problems until we have a source code for the A12 kernel.
    4
    Alright here´s a kernel.zip that just force loads all drivers built as kernel modules that come bundled with the firmware. This means instead of building the full kernel from source, we just build the core and load all drivers from the stock firmware compilation from sony. This includes, fingerprint, camera, touchscreen etc and also the sony driver that´s responsible for battery care/smart charging. I think this should fix the smart charging issue for now.

    However I don´t like to do this as force loading modules can cause issues, if the kernel gets to far from the stock base as already happened on the initial release.
    I already needed to revert certain changes done to the full source built kernel, as force loading modules on the previous 1.0.1 release would just crash the device during startup.
    For now it´s fine, but the kernel I plan to do once A12 drops won´t be able to resort to this approach as it will contain a lot more changes.

    I hope I can get this driver somewhere so I can proceed to go forward as planned.

    Source is pushed to a different branch.

    Enjoy the holidays and have a nice Christmas time if you celebrate it. :)
    3
    F.A.Q:

    Question:
    Is root preserved when flashing this kernel?
    Answer: Yes, the AnyKernel.zip will detect root and keep it.

    Question: Safetynet does not pass on my phone since I unlocked the phone, why is this so?
    Answer: Google introduced hardware backed attestation recently. Unfortunately the old kernel tricks to still get safetynet passing won´t work. Instead you will have to rely on some magisk modules. Short guide in post #4 below.

    Question: How do I return back to stock or another kernel.
    Answer: Extract boot.img from the matching firmware you are on (you can do so by using this tool or similar ones found on XDA and when googling around) and flash them via fastboot. If you want to keep root flash back the magisk_patched_boot.img. Or dirty flash your rom and re-root.

    Question: Why is having Magisk installed mandatory for this kernel?
    Answer: The kernel uses a ramdisk overlay to apply some settings after boot. If you are not rooted these settings will not get applied and you miss some of the optimizations.

    Question: How to report bugs properly?
    Answer: Have a look at post #3 in the linked thread. The linked guide is a pretty good starting point.
    Before reporting any bug make sure you´re running on a stock configuration. That´s means you´re not using any mods, tweaks in kernel managers or other root tweaks , magisk modules, scripts or other modifications that alter various functions like sound mods, data traffic, sleeping behaviour, scheduler, magical battery tweaks etc.
    Try to describe the issue as detailed as possible! Give your exact setup, like rom, magisk version, kernel version.
    Is the issue reproducible? Does it happen frequently?
    Provide logs, otherwise debugging is a lot harder. If you can already reproduce the issue and provide logs it greatly limits the amount of time I have to spent until I figure out how to reproduce it.

    If the device force reboots/randomly reboots (that means you see the bootloader unlocked screen!) provide a .zip of /asdf.
    Easiest way is immediately after booting up, with a root explorer navigate to /asdf. Copy the contents to your internal storage, zip it up and send it to me.

    If the issue happens while the device is running provide a dmesg plus a logcat that you take while/shortly after the issue happens. This will log what´s running in the current session. Try to be as detailed as possible what´s happening when the issue appears. It will also help me in reading the log!