robotnix icon indicating copy to clipboard operation
robotnix copied to clipboard

Build Glodroid flavor?

Open colemickens opened this issue 5 years ago • 10 comments

Hi,

I was telling samueldr about how I am looking forward to being able to boot Glodroid and mobile-nixos on my Pinephone. They pointed me towards this project. I'm not super well-versed in AOSP to understand where boundaries of projects lie, but maybe you are familiar with Glodroid?

Would it be possible to build Glodroid with Robotnix?

https://glodroid.github.io/ https://github.com/GloDroid/glodroid_manifest

colemickens avatar Sep 02 '20 02:09 colemickens

I guess it wouldn't be a variant like lineageos/grapheneos, but rather a board/target?

colemickens avatar Sep 02 '20 03:09 colemickens

AFAIUI it would be both.

A ~~variant~~ flavour that can't build most other ~~boards~~ devices...

And a ~~board/target~~ device that can't be built using most ~~variants~~ flavours.

samueldr avatar Sep 02 '20 03:09 samueldr

No, I wasn't familiar with Glodroid until you mentioned it. It certainly looks interesting, and they have goals I like: sticking close to mainline Android, upstreaming their changes, etc. It definitely should be possible to build with robotnix. (And it incentivizes me to get a pinephone at some point!)

I've been trying to stick somewhat to the terminology described here. So, instead of "variant" , I've been using "flavor" in robotnix for things like vanilla, grapheneos, and lineageos.

I would probably call GloDroid a "flavor" which supports a number of "devices". One thing supporting calling them a flavor is the fact that they publish their own manifests which override a bunch of upstream AOSP repos with patched versions. They don't do this nearly to the same extent as something like LineageOS or GrapheneOS, but it is still looks different enough that I wouldn't be comfortable with the other option, which would be adding this as a bunch of devices inside the existing vanilla flavor.

Here's a few notes to hopefully get started if you are interested in trying this out, based on reading the documentation here: You'd need to create a new "repo" json file using mk-repo-file.py. Then, in your configuration, add something like source.dirs = lib.importJSON ./repo-v0.3.0.json;. It looks like you'd also need { productNamePrefix = ""; device = "pinephone"; }. Finally, it looks like they want you to build the images make target instead of target-files-package. So, you'd need to use the build.mkAndroid function from modules/base.nix to have it build that.

If I have some extra time, I might take a stab at this as well--but I don't have any devices to test.

danielfullmer avatar Sep 02 '20 18:09 danielfullmer

I just noticed they have WIP support for RPI3, so if we're lucky I might actually be able to test this on a real device.

danielfullmer avatar Sep 03 '20 04:09 danielfullmer

So I was able to get it to build for pinephone, with the configuration file and repo file here: https://gist.github.com/danielfullmer/fe9c7cf8579c9b0ecc373fc456790fa4 This command should be enough to build it (pinned to the robotnix revision I tested it on):

nix-build "https://gist.github.com/danielfullmer/fe9c7cf8579c9b0ecc373fc456790fa4/archive/8c712df004379537ad1deb754742c83cc2d365ab.tar.gz" -A build.images

After a long wait, this will produce images.tar.gz under result. I'd presume you'd follow the instructions to flash this onto a device.

The support for signed builds in robotnix will not work with this, since it relies on signing target-files, and the glodroid instructions don't seem to consider that. It probably wouldn't be too hard to reimplement the final steps they have in their images target in nix, using the images from a signed target-files-package.

Also, I wasn't able to test this on my RPI3, since it fails to compile for me, which is understandable given the RPI3 support isn't released yet.

danielfullmer avatar Sep 03 '20 20:09 danielfullmer

I'd like to give building and flashing the pinephone variant a try. I'm currently building the variant you mentioned, but I think it would give better results to build a more up-to-date version.

I'm not 100% certain about the steps, but this is what I think I should do:

  1. use scripts/mk_repo_file https://github.com/GloDroid/glodroid_manifest v0.7.0 to generate a repo file
  2. Update the nix script with any new requirements w.r.t. build packages
  3. Build it
  4. Flash it (according to their instructions)

Does that sound about right?

Mindavi avatar Oct 05 '21 15:10 Mindavi

Yes, that sounds right to me. Let us know if you're able to successfully build and flash an image, or if you run into any other issues.

danielfullmer avatar Oct 05 '21 16:10 danielfullmer

I did get the version you posted built, but when I put it on an SD card and try to boot the pinephone from that SD, absolutely nothing seems to happen (not even a LED showing life). Unfortunately I don't have a 3.5mm debug cable, otherwise I might be able to see debug logging -- if there is anything.

I also found that there's an adb, fastboot and mke2fs shipped inside the images.tar.gz, they don't work on nixos since they have the incorrect dynamic linker (among other things, possibly). But I can just use ones from my PATH when I install them, that's no biggie.

Edit: I might need to charge the phone a bit before giving up...

Mindavi avatar Oct 21 '21 18:10 Mindavi

@Mindavi note that enabling LEDs is entirely software-driven on Pinephone.

IIRC the default U-Boot configs don't touch LEDs at all. So it's entirely plausible you can't expect to see the LED being turned on.

samueldr avatar Oct 21 '21 19:10 samueldr

I should get a (bigger) sd card and a serial cable soon, hopefully I can at least get some logs then.

Mindavi avatar Nov 22 '21 17:11 Mindavi