Hello all,
A few months back I unlocked my Mi 9 SE and rooted it using TWRP+Magisk, so fine so good. I then wanted to go on and install a custom ROM, but every time I tried, I just got my phone stuck in a bootloop and had to reflash MIUI using the scripts provided by Xiaomi (MiFlash/ .flash_all). After that, I decided I would not try meddling with ROMs again until had a better understanding of the (basic) underlying workings of this stuff.
After doing some research on my own I got answers to some of my confusion, but a lot remain, which is why I'm now trying my luck here. Maybe there is a "beginner's guide" of sorts somewhere on this forum, but so far I haven't been lucky in finding any. So, if any more experienced "flasher" or maybe even developer could clarify some things for me, and perhaps others, that would be great!
Firmware/Vendor
Firstly, the thing that has confused me since the beginning is the concept of firmware/vendor. I understand that the firmware of Xiaomi phones can be found easily on the internet and that it contains some amount of proprietary software such as drivers. However, while in some flashing instructions it is clearly indicated to "flash fw" after wiping, in others this is not mentioned at all. Is this because some ROMS already contain those drivers and others don't?
Then comes the question of "vendor". Again, some guides mention this, some don't, and on the site http://xiaomifirmwareupdater.com/, where one can find the fw, there is also a section for "vendor" files. So my question here is: what is the difference between vendor and firmware, and is either of them necessary before installing ROMS?
General Questions
From all of this, the way I picture the contents of an android phone are, from low to high level:
Bootloader (like the BIOS on a computer) ==> Firmware (Basic proprietary drivers) ==> Kernel ==> Rest of the OS (Implicit question: how correct is this picture?)
The kernel, from what I gather, is included in the flashable images of most ROMS, and the devs in turn use either the stock kernel from Xiaomi of some custom one like Kowalski's.
Question: What is the distinction between the firmware and the kernel? Since both are, in the beginning, made by Xiaomi, why are they separate things if they serve a similar purpose (drivers and Hardware/Software communication)?
Also, "bonus question" (just out of curiosity): I've heard that the only way to actually hard-brick your phone (other than hardware damage) is to somehow mess up the bootloader (kind of like corrupting the BIOS on a computer). How could this happen?
ROM Build
Finally, a few questions if any ROM dev stumbles upon this post, since apart from the practical aspects I'm also curious about the way a ROM is actually ported to a specific device, say our beloved little grus. Again, I'll just say what I understood so far and you guys can then correct me. From what I read in the building instructions for LineageOS on other devices, the way to proceed is to get the source code of the ROM itself by cloning the repo and then adding device-specific code (Kernel, device tree and Vendor Blobs) before proceeding to actually build the Image. My questions are, apart from if this is correct:
- How intercompatible are these components? Is a device tree specific to a certain kernel? To a certain ROM? Could one use, say, the kowalski DT with the stock kernel from Xiaomi?
- Again, what is the difference between "vendor blobs" and the "vendor" files mentioned above?
I know this is a very long post and I'm asking a lot of unrelated questions, but I hope that if someone takes the time to read through it and answer at least some parts of it, this could be useful in the future not only for me but also any other beginner trying to get into custom ROMS on Xiaomi phones. Cheers!
A few months back I unlocked my Mi 9 SE and rooted it using TWRP+Magisk, so fine so good. I then wanted to go on and install a custom ROM, but every time I tried, I just got my phone stuck in a bootloop and had to reflash MIUI using the scripts provided by Xiaomi (MiFlash/ .flash_all). After that, I decided I would not try meddling with ROMs again until had a better understanding of the (basic) underlying workings of this stuff.
After doing some research on my own I got answers to some of my confusion, but a lot remain, which is why I'm now trying my luck here. Maybe there is a "beginner's guide" of sorts somewhere on this forum, but so far I haven't been lucky in finding any. So, if any more experienced "flasher" or maybe even developer could clarify some things for me, and perhaps others, that would be great!
Firmware/Vendor
Firstly, the thing that has confused me since the beginning is the concept of firmware/vendor. I understand that the firmware of Xiaomi phones can be found easily on the internet and that it contains some amount of proprietary software such as drivers. However, while in some flashing instructions it is clearly indicated to "flash fw" after wiping, in others this is not mentioned at all. Is this because some ROMS already contain those drivers and others don't?
Then comes the question of "vendor". Again, some guides mention this, some don't, and on the site http://xiaomifirmwareupdater.com/, where one can find the fw, there is also a section for "vendor" files. So my question here is: what is the difference between vendor and firmware, and is either of them necessary before installing ROMS?
General Questions
From all of this, the way I picture the contents of an android phone are, from low to high level:
Bootloader (like the BIOS on a computer) ==> Firmware (Basic proprietary drivers) ==> Kernel ==> Rest of the OS (Implicit question: how correct is this picture?)
The kernel, from what I gather, is included in the flashable images of most ROMS, and the devs in turn use either the stock kernel from Xiaomi of some custom one like Kowalski's.
Question: What is the distinction between the firmware and the kernel? Since both are, in the beginning, made by Xiaomi, why are they separate things if they serve a similar purpose (drivers and Hardware/Software communication)?
Also, "bonus question" (just out of curiosity): I've heard that the only way to actually hard-brick your phone (other than hardware damage) is to somehow mess up the bootloader (kind of like corrupting the BIOS on a computer). How could this happen?
ROM Build
Finally, a few questions if any ROM dev stumbles upon this post, since apart from the practical aspects I'm also curious about the way a ROM is actually ported to a specific device, say our beloved little grus. Again, I'll just say what I understood so far and you guys can then correct me. From what I read in the building instructions for LineageOS on other devices, the way to proceed is to get the source code of the ROM itself by cloning the repo and then adding device-specific code (Kernel, device tree and Vendor Blobs) before proceeding to actually build the Image. My questions are, apart from if this is correct:
- How intercompatible are these components? Is a device tree specific to a certain kernel? To a certain ROM? Could one use, say, the kowalski DT with the stock kernel from Xiaomi?
- Again, what is the difference between "vendor blobs" and the "vendor" files mentioned above?
I know this is a very long post and I'm asking a lot of unrelated questions, but I hope that if someone takes the time to read through it and answer at least some parts of it, this could be useful in the future not only for me but also any other beginner trying to get into custom ROMS on Xiaomi phones. Cheers!
Last edited: