Building and installing
There is one tested installation method for your Motorola Moto G5 Plus. It relies on flashing one or more partitions on your device and creating a filesytem for the boot image.
Note
|
===
These instructions depend on adb being enabled, so
will not work with an "unconfigured" Mobile NixOS image. If you have
changed nothing else in your Mobile NixOS system then you will at
minimum need something like
{ lib, … }: { mobile.adbd.enable = true; } in the local.nix file.
|
Warning
|
All installation methods can lead to data loss. Flashing a partition will erase everything on the partition. Additionally,
the common backups methods, e.g. TWRP, will not backup the Make backups. |
Using Fastboot
This will produce a folder with the partition images for your Motorola Moto G5 Plus.
$ nix-build --argstr device motorola-potter -A outputs.android-fastboot-images
Alternatively, you can build a specific partition image:
$ nix-build --argstr device motorola-potter -A outputs.android-bootimg $ nix-build --argstr device motorola-potter -A outputs.rootfs
The device requires the
lk2nd secondary
bootloader to be installed in the boot
partition. This runs after
your existing bootloader and does some hardware setup required to
allow mainline kernels to run on your device - as well as providing a
"fastboot" interface for devices that don’t already have one.
You can build lk2nd for your device as follows:
$ nix-build --argstr device motorola-potter -A pkgs.pkgsBuild.lk2ndMsm8953 -o lk2nd
To install it, reboot into the bootloader (fastboot
mode), then run
$ fastboot flash boot lk2nd/lk2nd.img
Now you can boot into lk2nd - press Volume Down while booting to enter Fastboot mode. If your stock bootloader uses the same key combinations, you need to wait a bit before pressing the volume keys. Usually, waiting until the screen turns on and/or the device vibrates should be enough to make the stock bootloader ignore the keys.
The suggested filesystem arrangement is to put the Mobile NixOS
system.img
into the userdata
partition, and use the system
partition for the stage-1 boot.img
which on some devices is too
large for the boot
partition. Once running lk2nd you can do this
as follows
$ fastboot flash userdata result/system.img $ fastboot flash recovery result/recovery.img
Now use the up/down keys and power key to select "Recovery mode", then connect to the device with adb
$ adb shell ~ $ mke2fs /dev/disk/by-partlabel/system ~ # mkdir /mnt2 ~ # mount /dev/disk/by-partlabel/system /mnt2 ~ # exit
$ adb push result/boot.img /mnt2 $ adb reboot
Device-specific notes
Firmware for Wi-Fi
This particular phone keeps the firmware files on a partition named
modem
.
To make use of the Wi-Fi capabilities of this phone you will need to make them available to the firmware derivation.
The files can be acquired through different methods. You can use an
alternate recovery like TWRP, mount the partition (identified using
blkid
) and copy the files.
Another way is to do it using an installed Mobile NixOS system, where, too, you mount the partition and copy them:
$ sudo mount -o ro /dev/disk/by-partlabel/modem /mnt
$ cp -r /mnt ./modem
$ sudo umount /mnt
The copy of the firmware files will be in the modem directory, in the current working directory, ready to be referred to.
Touchscreen
There seem to be three distinct versions of the Synaptics DSx
touchscreen driver in the vendor kernel: one in
drivers/input/touchscreen/synaptics_*.[ch]/
, plus two others in
subdirectories drivers/input/touchscreen/synaptics_dsx/
Since commit 219587de9e92a in the vendor kernel, the touchscreen is
declared in the device tree as compatible = "synaptics,dsx-i2c"
which corresponds to the code in
drivers/input/touchscreen/synaptics_dsx_2.6/
, but the kernel config
options specify a weird mismash of that code and and some of the files
in the parent folder. I tried cleaning this up but it broke more than
it fixed.
The option for CONFIG_SCREEN_OFF_GESTURES
is disabled because it is
incompatible with CONFIG_FB