Building and installing
There are multiple installation methods for your Sony Xperia XA2. They all rely on flashing one or more partitions on your device.
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 a flashing script, and the partition images for your Sony Xperia XA2.
$ nix-build --argstr device sony-pioneer -A build.android-fastboot-images
Alternatively, you can build a specific partition image:
$ nix-build --argstr device sony-pioneer -A build.android-bootimg $ nix-build --argstr device sony-pioneer -A build.rootfs
The device will need to be booted in its bootloader, or fastboot
, mode.
The boot images can be installed using the following command, assuming the
android-fastboot-images
output was used.
$ result/flash-critical.sh
If you have a system image (system.img
) built, you can use fastboot
to
flash it to the device. Note that it might be too big to fit over the system
partition. In such case, it can be flashed on the userdata
partition.
$ fastboot flash userdata system.img
Using a flashable zip
An alternative installation method is to use a flashable zip. The flashable zip can be built for your Sony Xperia XA2 using one of the following commands:
$ nix-build --argstr device sony-pioneer -A build.android-flashable-bootimg $ nix-build --argstr device sony-pioneer -A build.android-flashable-system $ nix-build --argstr device sony-pioneer -A build.android-flashable-zip
The first two will flash only a specific partition. The last one contains the partitions of the two previous one.
The zip can either be copied to the device and selected in a compatible
Android recovery, or sent to the device through adb sideload
.
$ adb sideload /nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-flashable-sony-pioneer-boot.zip
By default it will flash to the system
partition. Some configurations may
change this to flash to the userdata
partition. In that case, no warning is
given before flashing.
Device-specific notes
Fastboot
This device has a quirky way to get to fastboot.
-
You have to have the device connected to a computer, or else it will not activate fastboot mode.
-
Fastboot shows nothing on the display
With the phone connected to a computer, hold volume up and somehow cause a reboot (from the system, or by holding power to force reset).
Alternatively, from a powered-off state, hold volume up and connect to your computer.
Finally, you can always trigger a reboot to bootloader via software. From
within Mobile NixOS, sudo reboot bootloader
, or from an Android-based system
using adb reboot bootloader
or equivalent methods.
Note that the LED will light up blue when in fastboot mode.
Failure to fastboot flash
It is possible that you might run into issues with this device when connected to a USB3 port with a USB3 cable. If that happens:
-
Check if there is a USB2 port on your computer or on the USB hub you are using. Connect your phone to the USB2 port for flashing instead.
-
If your USB hub only has USB3 ports, then connect the hub to PC with a USB2 data cable, and XA2 to the hub with any USB data cable ("USB Type-C" in the XA2 end).
-
If there are only USB3 ports available, you can force your USB3 ports to USB2 mode.
Forcing USB3 ports to USB2 mode
The following commands will force all USB3 ports to USB2 mode temporarily.
$ nix-shell -p pciutils [nix-shell:~]$ lspci -nn | grep USB | cut -d '[' -f3 | cut -d ']' -f1 | xargs -I@ sudo setpci -H1 -d @ d0.l=0
After which hopefully the procedure works. After successfully flashing, restart your computer to bring the USB3 ports to their normal mode.
Alternatively, the following commands can be used to revert the change.
$ nix-shell -p pciutils [nix-shell:~]$ lspci -nn | grep USB | cut -d '[' -f3 | cut -d ']' -f1 | xargs -I@ sudo setpci -H1 -d @ d0.l=1
See also: