I’m planning to move towards using custom ROMs in order to have more control over what is and isn’t installed on my phone.

I’ve got an old spare S8 that I’m going to use as a testbed first to get hands on and learn a bit more. It looks like LineageOS doesn’t provide a build for that model so I’ll need to learn how to prepare one myself.

I’m no stranger to Linux - I’ve built my own kernel (and even once an LFS system) back in the day - what resources would be ideal for getting up to speed with Android?

I’d hopefully like resources that help me understand what’s going on rather than focus purely on completing one task or another.

  • wololo@lemmy.dbzer0.com
    link
    fedilink
    English
    arrow-up
    0
    ·
    6 months ago

    if there are no custom roms for your device you should just give up. it requires so much resources that it’s almost tiring. If you really want to build lineage for your phone though, there’s a guide on lineage wiki to port the rom. It’s really easy, you just have to download the source code of the rom, add the source code of your phone with its proprietary blobs, then build. The hard part is wether you have the hardware to build or no. You need: 64gb of ram, ccache and zram enabled, 300gbs of storage, and an 8 cores cpu

    • Big P@feddit.uk
      link
      fedilink
      English
      arrow-up
      0
      ·
      6 months ago

      A vanilla build of lineage won’t give you any of the actual advantages of a custom ROM either

    • Skull giver@popplesburger.hilciferous.nl
      link
      fedilink
      English
      arrow-up
      0
      ·
      edit-2
      6 months ago

      You can build Android just fine with 16GB of RAM and 100GB of storage (I did). ccache helps with subsequent builds but isn’t required. zram helps if you’re low on RAM but isn’t required either. As for cores, I think a dual core would work just fine, it’ll just take longer. It’s all a balance of specs versus speed.

      Building Android itself is actually quite easy (I think three or four commands). If your phone has received all the necessary updates, there’s a good chance all the binaries you need to pull from the original ROM are in /vendor on a separate partition.

      It’s a project for sure, but individual volunteers are doing it all over the internet.

    • henfredemars@infosec.pub
      link
      fedilink
      English
      arrow-up
      0
      ·
      6 months ago

      You might be overlooking the economics in the sense that there tends to be a reason why devices aren’t supported. Oftentimes there is no sources available to build the necessary hardware support.

      • wololo@lemmy.dbzer0.com
        link
        fedilink
        English
        arrow-up
        0
        ·
        6 months ago

        yeah true some OEMs take ages to release their source code, or sometimes don’t do it at all even though they’re obligated by their GPL license

  • henfredemars@infosec.pub
    link
    fedilink
    English
    arrow-up
    0
    ·
    edit-2
    6 months ago

    My answer is not going to be complete in any way, but your biggest problem is going to be getting your hands on kernel sources that build and that actually work for your hardware.

    To complicate the matter, not any kernel will do. The kernel you use must support the Android userspace you want. You cannot arbitrarily pair your kernel version with your Android version. Further, the state of open source kernels on Android is quite poor. Many vendors–Samsung for example release kernel sources but they’re not actually in a buildable, usable state. If you’re just starting out, I would recommend starting with a Pixel where you know you will have sufficient sources to produce a compatible kernel, else you have the unenviable task of patching together something that works from the bits and pieces that get released that comply with the letter of the GPL but not the spirit of it.

    Whether or not you can even build a custom ROM for a device is largely a matter of opportunity and whether the resources you need actually exist to begin building one.

  • ijhoo@lemmy.ml
    link
    fedilink
    English
    arrow-up
    0
    ·
    6 months ago

    I’m a beginner as well and I found Alaska Linux user channel on yt a good source for explanations. First videos are a bit outdated… some new tech like Soong was introduced - which is a new, google developed, build system for Android.

    https://www.youtube.com/channel/UCnGqG_jyyXmTzdamBpKfeHA

    Go to the playlist section. It groups videos per topic, e.g. building a device tree from scratch.

    S8 is a not a good choice If I remember correctly, no custom roms exist for that phone. Reasons might be due to exynos of that era…

  • Pantherina@feddit.de
    link
    fedilink
    English
    arrow-up
    0
    ·
    6 months ago

    The thing is, “building a kernel” for Linux is NOTHING compared to a custom ROM. Linux Kernel:

    • one repo, just clone it
    • tooling to easily build it, just set some flags
    • a huge monokernel, not including the entire OS and all the SOC stuff

    Android is different. It doesnt use a huge monokernel. They use mostly the upstream kernel, but the drivers are not in there afaik. There are many proprietary parts also in the firmware. And those come from the hardware suppliers, signed by them, you cant replace it. This totally sucks.

    If you look at it the Laptop market is equally bad as firmwares are often not updated at all. But every system simply continues to run, so nobody cares.

    On Android its all one thing. A distro / custom OS (ROM is not correct, the OS is not read only otherwise you cant change it, lol) deals with all of that.

    Look at the GrapheneOS information articles. They explain very well what they all do to make AOSP

    • secure with monthly updates
    • hardened in maaany areas
    • functional (removing Vendor app dependency, integrating some Pixel and even Samsung components, Sandboxed Play services, …)

    Its a on of work to REALLY support a device, its simply a real OS. LineageOS or even worse PostmarketOS are just random projects often. Using some generic software with missing firmware updates and timely security patches.

    It works, somehow. But it is nothing worth investing a lot of time in really, if the phone is not super special.

    Just get a used Google Pixel ≥ 6a and install GrapheneOS. Contribute Code to healthy upstream projects.

    The work for supporting a single device is insane. And samsung is especially shit, security features would be close to Pixels but they block lots of features for alternative OSses and different software everywhere. Also completely anti-repairable.

    • StryderNotavi@infosec.pubOP
      link
      fedilink
      English
      arrow-up
      0
      ·
      6 months ago

      Ooh, this may be more worth a look then. I had hoped I’d be able to use the old phone to get up to speed before considering going to a custom ROM on my main device but it sounds like a Samsung S8 may be an exceptionally poor choice due to driver availability and other issues.

      Graphene sounds like it addresses a lot of the needs that are pushing me away from stock Android (unnecessary bundled services, concern about Google harvesting more data than they should, Bixby / Google Assistant re-enabling itself every few updates and being pushed on users) but does so in a way won’t sacrifice too much functionality (will definitely learn more about sandboxed Play services - that sounds useful).

      I may have to consider getting a refurbished Pixel and setting it up with Graphene.

      • Pantherina@feddit.de
        link
        fedilink
        English
        arrow-up
        0
        ·
        6 months ago

        Yes, do that. Relying on Pixels suck, but they are the best to work with, have best updates, no weirdly blocked security features on custom ROMs and you can unlock them easily.

        GrapheneOS lacks a lot of nice UI stuff as they simply not prioritize it. But an example of what yo can do:

        • use a cracked Nova Launcher Prime
        • use any Keyboard app you like, I like Florisboard
        • use VolumeStyles to give that slider more features
        • use SaverTuner to access deep energy saving settings
        • use any Browser you like (I recommend Mull, Brave or Vanadium)
        • install Tiktok or whatever, best in a work profile or secondary profile
        • install the Google camera, it works out of the box without any hassle, even though GrapheneOS even having a good own Camera app
        • use syncthing, davx5 and more to sync your stuff
        • use F-Droid basic, Auroastore, Accrescent or even Google Play. Get the apps you like

        It is barebones but the Android ecosystem allows to insall a damn fake iOS launcher and it works.

  • Skull giver@popplesburger.hilciferous.nl
    link
    fedilink
    English
    arrow-up
    0
    ·
    edit-2
    6 months ago

    Edit: some work has already been done for you, there’s an XDA forum for your device. Be sure to read through that, and make sure you double check that you’re reading about the right SoC (Exynos/Snapdragon, there are usually two versions of the Samsung S series) if you’re downloading sources or ROMs from there.

    Building Android is a bit like building Gentoo: you’ll be building almost everything. It requires quite a bit of effort. You can do it with relatively limited hardware, but the beefier your PC, the better. If you don’t have at least 200GB of storage space, 16GB of free RAM, and 4 relatively recent CPU cores, I wouldn’t even bother. The LineageOS wiki recommends 300GB of SSD space + space for a compiler cache + tooling, 32GB of RAM, and as many CPU cores as you can get your hands on.

    First, I would start by verifying that you can actually unlock the bootloader. If your bootloader is locked and cannot be unlocked, running a custom ROM will be very very difficult (you will need to find/write exploits for the protection mechanisms and basically rootkit your phone into booting your ROM). Note that unlocking the bootloader will wipe all data on your phone.

    I would recommend you start with this guide: https://wiki.lineageos.org/emulator That’ll teach you how to compile LineageOS for the Android emulator; a relatively straightforward target. It’ll guide you through the tooling and the setup so you can get a feel for what’s necessary.

    If you’ve got a working Android emulator image, you’ll want to start looking for sources of other custom ROMs for your device as a starting point. Most likely, all you’ll need is the kernel (must be published, of course) and the vendor binaries for drivers and such. If you have those handy, you’ll be able to start compiling your own version of LineageOS from source relatively quickly, you’ll just need to download some binaries from your phone and edit some XML files.

    If you don’t have any starting point at all, you should get the kernel sources from Samsung. They’re legally obligated to hand them to you, as a customer, because of the GPL. Finding out what binaries are necessary will be harder, you can try looking at custom ROMs for similar phones to see what binaries you may need to get everything to work.

    This guide: https://gitlab.e.foundation/e/documentation/a-generic-guide-on-porting-eos/-/wikis/01:-Introduction for /e/, a ROM that’s generally outdated but was designed to go completely Google free, has some more instructions on how to port to a new device.

    Note that most guides assume you’re compiling a ROM of the same Android version as the stock ROM on your device. If you’re planning on upgrading to the latest Android sources, you’ll have to take on the responsibility to port the device specific configurations from their current versions to the latest ones. In that case, be sure to check if someone else has already done this work for hardware that other devices may have in common with yours, because this process can contain hacks (like adding kernel APIs to make modern drivers work, or modifying system service permissions so drivers can execute).

    Once you have an Android build, you’ll also need some more tools: a recovery (TWRP is the de facto one but there are others) from which you can flash your image, and possibly some Google Apps if you want to be able to use the Play Store. You can download GApps as a package, but if there are no ROMs whatsoever for your device, you may also need to port TWRP (or another recovery of your choosing, if you have a preferred alternative).

    Be sure to make a backup before flashing the system image, or you may end up with an unbootable device!

    Lastly, if you want to publish your image so others can use it, be sure to post your images in the relevant XDA threads. XDA is also the best place to look for ROMs, and maybe get in contact with ROM makers that have since abandoned ROMs for your device.

    Depending on your free time and experience with Android, porting your own ROM can take weeks or months. It’s not something you do in an afternoon. The compilation alone will take hours (I clocked about 1:45 on my i7700k with 32GB of RAM and about 400GB of SSD storage) and you’ll constantly be debugging bootloops and selinux issue at first (don’t run a daily driver with selinux disabled, selinux is how Android keeps its sandboxing from breaking down, but you may want to disable it during the first builds to make the process slightly easier).

    There is one alternative that you may be able to use: GSI. Google has been pushing vendors to standardise their hardware and software to a certain point where standard images will be able to boot on most phones. These images may lack things like “hardware accelerated graphics” or “more than VGA camera support” or “fingerprint scanner working”, but they should boot on any device released with Android 9 or newer, and in some rare cases on devices upgraded to Android 9. You can download ready-made GSI images from all kinds of places, but there’s no guarantee they’ll work. You can build your own GSI build (just build for device codename treble, I believe) or download a ROM from here.