General Starting kernel from source

Search This thread

thomas1991_12

Senior Member
Dec 20, 2009
834
2,362
Liempde
Hello everyone,

I recently got this phone and of course noticed xiaomi didn't release the kernel source.
So I'm planning on trying to build a kernel from source that would work with stock miui (I'm aiming for 13.0.13.0 EU android 11 version at first).
My starting point is the source from CAF: LA.UM.9.15.1.r1-07200-KAMORTA.0. If you think a different source would be better please let me know, but I thought this one came closest).
Now I am looking at the Mi github for devices comparable so I can get some specific xiaomi/component source stuff. Currently looking at Redmi POCO M3 its A10 but should be okay.
I will post a link to github soon.

Just letting you know.

SOURCE: https://github.com/daeiron/spes_kernel
 
Last edited:

thomas1991_12

Senior Member
Dec 20, 2009
834
2,362
Liempde
Okay so here is the first result, this is untested. But if someone wants to test it go ahead. My phone isn't unlocked yet ;)
You could first try flashing test_boot.img to boot partition and see what it does (you should be on 13.0.13.0 stock), if that doesn't work you could try flashing dtbo.img to the dtbo partition.
Please make a backup first! This probably won't work.
 

Attachments

  • test_boot.img
    96 MB · Views: 65
  • dtbo.img
    13.1 MB · Views: 43

Vagelis1608

Senior Member
Sep 16, 2012
2,249
870
Athens
LG G2 Mini
Xiaomi Redmi Note 4
This is very interesting.
It's great to see that there is another way to have a kernel source, even if Xiaomi doesn't want to release the official.
I'm in the middle of a move, so I can't test it because I need my phone fully functional, but I should be able to help out in time, especially once the kernel is more stable.
 

thomas1991_12

Senior Member
Dec 20, 2009
834
2,362
Liempde
Can someone provide me a full dmesg log and maybe a logcat from just after boot. I could take a look at that while I am waiting for the unlock time of a stupid 7 days.
 

thomas1991_12

Senior Member
Dec 20, 2009
834
2,362
Liempde
I have some of the drivers, extra functions, device specific stuff ready in the source with some cherry picking and reverse engineering the stock kernel with ghidra, but not (nearly) everything. I was planning to find if there are uart pins on the main board with a logic analyzer as it wouldnt make sense to go forth without testing and getting it booting. Because it isn't booting yet. But Im going on a vacation to mid February so there won't be much progress until then unfortunately. If i remember correctly I still need to do the touchscreen/lcd driver (nt36...& focaltech, bq25.. charge driver, all camera's, all connectivity (this shouldn't be hard) and probably some more stuff. There is some source code out there for some of the things but they are not identical to the reversed source so that will be more tricky.
 

Vagelis1608

Senior Member
Sep 16, 2012
2,249
870
Athens
LG G2 Mini
Xiaomi Redmi Note 4
Something to keep in mind, there is most likely a bug in the wifi or the Bluetooth driver ( perhaps both? ) that causes the device to freeze a bit when both are on and the wifi signal is bad.
My guess is that the wifi driver tries to reconnect way too often and something freezes
 

Renate

Recognized Contributor / Inactive Recognized Dev
Does anyone have a schematic diagram for our phone? Im trying to find the UART pins.
I've never seen any schematics for anything and I can't believe they would be helpful.
A PCB layout would be helpful, but I haven't seen that either.

In ye old day a UART might have some level shifters.
Nowadays things are more minimal.
You'll get the raw pins out of the SoC.
You'll probably need a USB UART adapter that can work with 1.8V logic levels.

It would be nice to find the reset line, that's very helpful for hacking.
That way you don't have to wait for 10 second power button pushes.

An oscilloscope on likely test points on the board while booting is the easiest way to find a UART.

My specialty is Android ereaders and I've got a half dozen with permanently installed UART connectors.
 

Attachments

  • poke3coverc.jpg
    poke3coverc.jpg
    303.2 KB · Views: 77
  • Like
Reactions: NeoPreacher

sonic011gamer

Member
Mar 28, 2021
13
7
I think UART should be your last resort, pretty sure the kernel should be writing to RAM and you can read that.
 
Okay so here is the first result, this is untested. But if someone wants to test it go ahead. My phone isn't unlocked yet ;)
You could first try flashing test_boot.img to boot partition and see what it does (you should be on 13.0.13.0 stock), if that doesn't work you could try flashing dtbo.img to the dtbo partition.
Please make a backup first! This probably won't work.
well Im going right now try it on pixelexperience 12.1. after that I give some feedback ;)

well, phone instantly boot in to fastboot so nothing there, I was thinking if the source code is not out yet, then what source is used to create kernel for PE roms?
 
Last edited:
I do little searching and found this...


EDIT: here is original source from is forked https://github.com/MiCode/Xiaomi_Kernel_OpenSource/tree/lime-q-oss

is for "bengal" board but not SM6225 (sdm665) but SM6222 (sdm662)

but I think when we use kernel configuration from stock kernel (like in /proc/config.gz) we maybe get working kernel?

I am going to try it, I downloaded it and we will see
 
  • Like
Reactions: Zylam Marex

7uta

New member
Apr 11, 2023
3
0
This seems interesting. Does it work as nicely as the kernel extracted from MIUI that all these custom ROMs are using?
 

Top Liked Posts

  • There are no posts matching your filters.
  • 14
    Hello everyone,

    I recently got this phone and of course noticed xiaomi didn't release the kernel source.
    So I'm planning on trying to build a kernel from source that would work with stock miui (I'm aiming for 13.0.13.0 EU android 11 version at first).
    My starting point is the source from CAF: LA.UM.9.15.1.r1-07200-KAMORTA.0. If you think a different source would be better please let me know, but I thought this one came closest).
    Now I am looking at the Mi github for devices comparable so I can get some specific xiaomi/component source stuff. Currently looking at Redmi POCO M3 its A10 but should be okay.
    I will post a link to github soon.

    Just letting you know.

    SOURCE: https://github.com/daeiron/spes_kernel
    6
    I have some of the drivers, extra functions, device specific stuff ready in the source with some cherry picking and reverse engineering the stock kernel with ghidra, but not (nearly) everything. I was planning to find if there are uart pins on the main board with a logic analyzer as it wouldnt make sense to go forth without testing and getting it booting. Because it isn't booting yet. But Im going on a vacation to mid February so there won't be much progress until then unfortunately. If i remember correctly I still need to do the touchscreen/lcd driver (nt36...& focaltech, bq25.. charge driver, all camera's, all connectivity (this shouldn't be hard) and probably some more stuff. There is some source code out there for some of the things but they are not identical to the reversed source so that will be more tricky.
    5
    So I now have a compilable source here: https://github.com/daeiron/spes_kernel
    I used proton clang to compile.
    3
    Okay so here is the first result, this is untested. But if someone wants to test it go ahead. My phone isn't unlocked yet ;)
    You could first try flashing test_boot.img to boot partition and see what it does (you should be on 13.0.13.0 stock), if that doesn't work you could try flashing dtbo.img to the dtbo partition.
    Please make a backup first! This probably won't work.
    1
    Does anyone have a schematic diagram for our phone? Im trying to find the UART pins