posts » Installing CalyxOS on a pixel 4a

Installing CalyxOS on a pixel 4a

It's been a long time, but I've finally got a new phone. My last one was a Samsung Galaxy S2, first released in 2011 -- I should, perhaps, say last one_s_, as I have had more than one over the years. Indeed, you can still get them for about 40 euros on ebay, but the software I was using (LineageOS) now no longer really supports them. So it was time for something new and, after discussion with one of my friends, I decided to follow his advice and get a Google Pixel 4a.

Shock horror! Conversion to the devil? But no, I'm installing CalyxOS. This post describes how I did it.

First off, you need to ensure the bootloader is unlocked. This, unfortunately, requires turning the phone on and connecting to the internet - so there is already some data leakage that occurs. The guidance on the CalyxOS page wasn't particularly helpful here, but there's plenty out there: the top hit for me in duckduckgo was on xda-developers where it is very clear:

  1. Go to System settings -> About phone -> tap on ‘Build number’ several times until Developer options is enabled
  2. Back out into settings and go to System -> Advanced -> Developer Options -> Enabled ‘OEM Unlocking’

I did get a scare after step 1 as the option was grayed out, so this was the point that I had to first connect to the internet and "finalise" the setup process. However, I did not (luckily!) have to sent any personal data (other, I presume, the phone's IMEI number being automatically sent, although I can't verify that). One thing I did find interesting was that when you connect to wireless, the phone uses a "randomised MAC (default)" so it's not actually that simple to connect to a wireless point that is restricted to authenticated devices with pre-specified MAC addresses.

Then, download the relevant files, and check they've downloaded correctly. As well as the command line installer device-flasher.linux from the install page, I downloaded the firmware for the Pixel 4a which is called sunfish. I used sha256sum to check them, using the codes on the respective pages:

0 asm@laptop:~/src$ ls -l
total 1349736
-rwxr-xr-x 1 asm asm    6988130 Feb 17 23:26 device-flasher.linux
-rw-r--r-- 1 asm asm 1375132290 Feb 17 23:50 sunfish-factory-2021.02.02.18.zip
0 asm@laptop:~/src$ sha256sum device-flasher.linux 
433c34770081af408ee7258c4a2cbcbe314fe770f0e9962a5c40554dac1a03c9  device-flasher.linux
0 asm@laptop:~/src$ ## 433c34770081af408ee7258c4a2cbcbe314fe770f0e9962a5c40554dac1a03c9 (copied from website)
0 asm@laptop:~/src$ ## 433c34770081af408ee7258c4a2cbcbe314fe770f0e9962a5c40554dac1a03c9  device-flasher.linux
0 asm@laptop:~/src$ sha256sum sunfish-factory-2021.02.02.18.zip 
272d27b60c9fb1071170d60ac1413ea8633545e9eba5691632c578b3d9c89109  sunfish-factory-2021.02.02.18.zip
0 asm@laptop:~/src$ ## 272d27b60c9fb1071170d60ac1413ea8633545e9eba5691632c578b3d9c89109 (copied from website)
0 asm@laptop:~/src$ ## 272d27b60c9fb1071170d60ac1413ea8633545e9eba5691632c578b3d9c89109  sunfish-factory-2021.02.02.18.zip

extracting product.img (793 MB) to disk...ziparchive W 02-19 21:22:09 26970 26970 Zip: unable to allocate 831578392 bytes at offset 0: No space left on device

(I always compare those things like that: copy the original version I want to check from the website or wherever and paste it in (with a comment sign at the beginning of the line!) followed by a copy of the output I've just run. I find it easier to compare when they're directly one on top of the other like that.)

Then, onto installing. At this point, I was unsure how I should do stuff - did the phone need to already be rebooted into the bootloader, or was just "on" sufficient? I mean, I presumed it needed to be on! And presumably it had to be plugged in, too.... I jumped into the #calyx channel on freenode, where as ever Nick and colleagues were super-helpful. The answer was, simply, just plug it in (turned on) and go - from whatever state I wanted.

0 asm@laptop:~/git/calyxos$ ./device-flasher.linux
Android Factory Image Flasher version 1.0.2
Extracting sunfish-factory-2021.02.02.18.zip
Verifying platform-tools_r30.0.4-linux.zip
Extracting platform-tools_r30.0.4-linux.zip
1. Connect to a wifi network and ensure that no SIM cards are installed             
2. Enable Developer Options on device (Settings -> About Phone -> tap "Build number" 7 times)
3. Enable USB debugging on device (Settings -> System -> Advanced -> Developer Options) and allow the computer to debug (hit "OK" on the popup when USB is connected)
4. Enable OEM Unlocking (in the same Developer Options menu)

Press ENTER to continue

Detected  00093f2e47e23f. No matching factory image found
Detected sunfish 11081JEC205612

Devices to be flashed: 
sunfish 11081JEC205612

Press ENTER to continue
Unlocking sunfish 11081JEC205612 bootloader...
5. Please use the volume and power keys on the device to unlock the bootloader
Flashing sunfish 11081JEC205612 bootloader...
Sending 'bootloader_a' (8341 KB)                   OKAY [  0.160s]
Writing 'bootloader_a'                             (bootloader) Flashing Pack version s5-0.3-6835615
(bootloader) Flashing partition table for Lun = 0
(bootloader) Flashing partition table for Lun = 1
(bootloader) Flashing partition table for Lun = 2
(bootloader) Flashing partition table for Lun = 4
(bootloader) Flashing partition table for Lun = 5
(bootloader) Flashing partition xbl_a
(bootloader) Flashing partition xbl_config_a
(bootloader) Flashing partition aop_a
(bootloader) Flashing partition tz_a
(bootloader) Flashing partition hyp_a
(bootloader) Flashing partition abl_a
(bootloader) Flashing partition keymaster_a
(bootloader) Flashing partition cmnlib_a
(bootloader) Flashing partition cmnlib64_a
(bootloader) Flashing partition devcfg_a
(bootloader) Flashing partition qupfw_a
(bootloader) Flashing partition uefisecapp_a
(bootloader) Flashing partition logfs
OKAY [  0.232s]
Finished. Total time: 0.664s
Rebooting into bootloader                          OKAY [  0.063s]
Finished. Total time: 0.214s
Sending 'radio_a' (72372 KB)                       OKAY [  0.520s]
Writing 'radio_a'                                  (bootloader) Flashing Pack version SSD:g7150-00023-201008-B-6891498
(bootloader) Flashing partition modem_a
OKAY [  0.355s]
Finished. Total time: 1.097s
Rebooting into bootloader                          OKAY [  0.063s]
Finished. Total time: 0.213s
Erasing 'avb_custom_key'                           OKAY [  0.214s]
Finished. Total time: 0.296s
Sending 'avb_custom_key' (0 KB)                    OKAY [  0.140s]
Writing 'avb_custom_key'                           OKAY [  0.225s]
Finished. Total time: 0.568s
Rebooting into bootloader                          OKAY [  0.062s]
Finished. Total time: 0.213s
--------------------------------------------
Bootloader Version...: s5-0.3-6835615
Baseband Version.....: g7150-00023-201008-B-6891498
Serial Number........: 11081JEC205612
--------------------------------------------
extracting android-info.txt (0 MB) to RAM...
Checking 'product'                                 OKAY [  0.070s]
Checking 'version-bootloader'                      OKAY [  0.070s]
Checking 'version-baseband'                        OKAY [  0.070s]
Setting current slot to 'a'                        OKAY [  0.084s]
extracting boot.img (64 MB) to disk... took 0.277s
archive does not contain 'boot.sig'
Sending 'boot_a' (65536 KB)                        OKAY [  0.470s]
Writing 'boot_a'                                   OKAY [  0.235s]
extracting dtbo.img (8 MB) to disk... took 0.053s
archive does not contain 'dtbo.sig'
Sending 'dtbo_a' (8192 KB)                         OKAY [  0.160s]
Writing 'dtbo_a'                                   OKAY [  0.094s]
archive does not contain 'dt.img'
archive does not contain 'recovery.img'
extracting vbmeta.img (0 MB) to disk... took 0.000s
archive does not contain 'vbmeta.sig'
Sending 'vbmeta_a' (4 KB)                          OKAY [  0.140s]
Writing 'vbmeta_a'                                 OKAY [  0.087s]
extracting vbmeta_system.img (0 MB) to disk... took 0.000s
archive does not contain 'vbmeta_system.sig'
Sending 'vbmeta_system_a' (4 KB)                   OKAY [  0.140s]
Writing 'vbmeta_system_a'                          OKAY [  0.077s]
archive does not contain 'vendor_boot.img'
extracting super_empty.img (0 MB) to disk... took 0.000s
Rebooting into fastboot                            OKAY [  0.070s]
< waiting for any device >
Sending 'super' (4 KB)                             OKAY [  0.000s]
Updating super partition                           OKAY [  0.007s]
Resizing 'product_a'                               OKAY [  0.005s]
Resizing 'system_a'                                OKAY [  0.006s]
Resizing 'system_ext_a'                            OKAY [  0.004s]
Resizing 'system_b'                                OKAY [  0.004s]
Resizing 'vendor_a'                                OKAY [  0.004s]
Resizing 'vendor_b'                                OKAY [  0.005s]
archive does not contain 'boot_other.img'
archive does not contain 'odm.img'
extracting product.img (793 MB) to disk...ziparchive W 02-19 20:09:16 23119 23119 Zip: unable to allocate 831578392 bytes at offset 0: No space left on device
fastboot: error: 
failed to extract 'product.img': I/O error
Rebooting into bootloader                          OKAY [  0.001s]
Finished. Total time: 0.151s
Locking sunfish 11081JEC205612 bootloader...
6. Please use the volume and power keys on the device to lock the bootloader
Rebooting sunfish 11081JEC205612...
7. Disable OEM unlocking from Developer Options after setting up your device

Flashing complete
0 asm@laptop:~/git/calyxos$ 

uh-oh! Errors.... what is wrong? It turns out that my /tmp partition was too small:

/dev/mapper/vg_volume-lv_tmp   881M  7.9M  806M   1% /tmp

so I needed to fix that. How? Well, Nick prompted me, which was nice:

<nickcalyx> it needs to unzip the factory image on your local computer
<nickcalyx> to wherever the TMPDIR environment variable points... often /tmp
<nickcalyx> no you don't need to reinstall stock android

A quick bit of searching to remind me, and as ever sx had the answer:

$ export TMPDIR=/my/new/tmp

So, fixed:

0 asm@laptop:/home/asm/calyxos$ ./device-flasher.linux 
Android Factory Image Flasher version 1.0.2
Extracting sunfish-factory-2021.02.02.18.zip
Verifying platform-tools_r30.0.4-linux.zip
Extracting platform-tools_r30.0.4-linux.zip
1. Connect to a wifi network and ensure that no SIM cards are installed
2. Enable Developer Options on device (Settings -> About Phone -> tap "Build number" 7 times)
3. Enable USB debugging on device (Settings -> System -> Advanced -> Developer Options) and allow the computer to debug (hit "OK" on the popup when USB is connected)
4. Enable OEM Unlocking (in the same Developer Options menu)

Press ENTER to continue

Detected sunfish 11081JEC205612

Devices to be flashed: 
sunfish 11081JEC205612

Press ENTER to continue
Unlocking sunfish 11081JEC205612 bootloader...
5. Please use the volume and power keys on the device to unlock the bootloader
Flashing sunfish 11081JEC205612 bootloader...
Sending 'bootloader_a' (8341 KB)                   OKAY [  0.170s]
Writing 'bootloader_a'                             (bootloader) Flashing Pack version s5-0.3-6835615
(bootloader) Flashing partition table for Lun = 0
(bootloader) Flashing partition table for Lun = 1
(bootloader) Flashing partition table for Lun = 2
(bootloader) Flashing partition table for Lun = 4
(bootloader) Flashing partition table for Lun = 5
(bootloader) Flashing partition xbl_a
(bootloader) Flashing partition xbl_config_a
(bootloader) Flashing partition aop_a
(bootloader) Flashing partition tz_a
(bootloader) Flashing partition hyp_a
(bootloader) Flashing partition abl_a
(bootloader) Flashing partition keymaster_a
(bootloader) Flashing partition cmnlib_a
(bootloader) Flashing partition cmnlib64_a
(bootloader) Flashing partition devcfg_a
(bootloader) Flashing partition qupfw_a
(bootloader) Flashing partition uefisecapp_a
(bootloader) Flashing partition logfs
OKAY [  0.246s]
Finished. Total time: 0.687s
Rebooting into bootloader                          OKAY [  0.060s]
Finished. Total time: 0.211s
Sending 'radio_a' (72372 KB)                       OKAY [  0.560s]
Writing 'radio_a'                                  (bootloader) Flashing Pack version SSD:g7150-00023-201008-B-6891498
(bootloader) Flashing partition modem_a
OKAY [  0.340s]
Finished. Total time: 1.127s
Rebooting into bootloader                          OKAY [  0.056s]
Finished. Total time: 0.207s
Erasing 'avb_custom_key'                           OKAY [  0.218s]
Finished. Total time: 0.309s
Sending 'avb_custom_key' (0 KB)                    OKAY [  0.140s]
Writing 'avb_custom_key'                           OKAY [  0.225s]
Finished. Total time: 0.564s
Rebooting into bootloader                          OKAY [  0.061s]
Finished. Total time: 0.212s
--------------------------------------------
Bootloader Version...: s5-0.3-6835615
Baseband Version.....: g7150-00023-201008-B-6891498
Serial Number........: 11081JEC205612
--------------------------------------------
extracting android-info.txt (0 MB) to RAM...
Checking 'product'                                 OKAY [  0.070s]
Checking 'version-bootloader'                      OKAY [  0.070s]
Checking 'version-baseband'                        OKAY [  0.070s]
Setting current slot to 'a'                        OKAY [  0.084s]
extracting boot.img (64 MB) to disk... took 0.274s
archive does not contain 'boot.sig'
Sending 'boot_a' (65536 KB)                        OKAY [  0.479s]
Writing 'boot_a'                                   OKAY [  0.235s]
extracting dtbo.img (8 MB) to disk... took 0.020s
archive does not contain 'dtbo.sig'
Sending 'dtbo_a' (8192 KB)                         OKAY [  0.159s]
Writing 'dtbo_a'                                   OKAY [  0.094s]
archive does not contain 'dt.img'
archive does not contain 'recovery.img'
extracting vbmeta.img (0 MB) to disk... took 0.000s
archive does not contain 'vbmeta.sig'
Sending 'vbmeta_a' (4 KB)                          OKAY [  0.140s]
Writing 'vbmeta_a'                                 OKAY [  0.077s]
extracting vbmeta_system.img (0 MB) to disk... took 0.000s
archive does not contain 'vbmeta_system.sig'
Sending 'vbmeta_system_a' (4 KB)                   OKAY [  0.140s]
Writing 'vbmeta_system_a'                          OKAY [  0.077s]
archive does not contain 'vendor_boot.img'
extracting super_empty.img (0 MB) to disk... took 0.000s
Rebooting into fastboot                            OKAY [  0.070s]
< waiting for any device >
Sending 'super' (4 KB)                             OKAY [  0.000s]
Updating super partition                           OKAY [  0.008s]
Resizing 'product_a'                               OKAY [  0.005s]
Resizing 'system_a'                                OKAY [  0.005s]
Resizing 'system_ext_a'                            OKAY [  0.005s]
Resizing 'system_b'                                OKAY [  0.006s]
Resizing 'vendor_a'                                OKAY [  0.005s]
Resizing 'vendor_b'                                OKAY [  0.005s]
archive does not contain 'boot_other.img'
archive does not contain 'odm.img'
extracting product.img (793 MB) to disk... took 2.955s
archive does not contain 'product.sig'
Resizing 'product_a'                               OKAY [  0.005s]
Sending sparse 'product_a' 1/4 (262140 KB)         OKAY [  1.657s]
Writing 'product_a'                                OKAY [  1.957s]
Sending sparse 'product_a' 2/4 (262140 KB)         OKAY [  1.678s]
Writing 'product_a'                                OKAY [  0.889s]
Sending sparse 'product_a' 3/4 (262140 KB)         OKAY [  1.584s]
Writing 'product_a'                                OKAY [  0.909s]
Sending sparse 'product_a' 4/4 (25668 KB)          OKAY [  0.163s]
Writing 'product_a'                                OKAY [  0.126s]
extracting system.img (849 MB) to disk... took 12.136s
archive does not contain 'system.sig'
Resizing 'system_a'                                OKAY [  0.006s]
Sending sparse 'system_a' 1/4 (262140 KB)          OKAY [  1.647s]
Writing 'system_a'                                 OKAY [  1.927s]
Sending sparse 'system_a' 2/4 (262140 KB)          OKAY [  1.659s]
Writing 'system_a'                                 OKAY [  0.904s]
Sending sparse 'system_a' 3/4 (262140 KB)          OKAY [  1.650s]
Writing 'system_a'                                 OKAY [  0.886s]
Sending sparse 'system_a' 4/4 (83308 KB)           OKAY [  0.528s]
Writing 'system_a'                                 OKAY [  0.346s]
extracting system_ext.img (151 MB) to disk... took 0.781s
archive does not contain 'system_ext.sig'
Resizing 'system_ext_a'                            OKAY [  0.005s]
Sending 'system_ext_a' (155512 KB)                 OKAY [  0.962s]
Writing 'system_ext_a'                             OKAY [  1.602s]
extracting system_other.img (36 MB) to disk... took 0.246s
archive does not contain 'system.sig'
Resizing 'system_b'                                OKAY [  0.005s]
Sending 'system_b' (37016 KB)                      OKAY [  0.235s]
Writing 'system_b'                                 OKAY [  0.165s]
extracting vendor.img (531 MB) to disk... took 15.610s
archive does not contain 'vendor.sig'
Resizing 'vendor_a'                                OKAY [  0.007s]
Sending sparse 'vendor_a' 1/3 (262140 KB)          OKAY [  1.668s]
Writing 'vendor_a'                                 OKAY [  1.922s]
Sending sparse 'vendor_a' 2/3 (262140 KB)          OKAY [  1.678s]
Writing 'vendor_a'                                 OKAY [  0.912s]
Sending sparse 'vendor_a' 3/3 (20228 KB)           OKAY [  0.133s]
Writing 'vendor_a'                                 OKAY [  0.117s]
archive does not contain 'vendor_dlkm.img'
archive does not contain 'vendor_other.img'
Erasing 'userdata'                                 OKAY [  8.567s]
Erase successful, but not automatically formatting.
File system type raw not supported.
Erasing 'metadata'                                 OKAY [  0.009s]
Erase successful, but not automatically formatting.
File system type raw not supported.
Finished. Total time: 92.391s
Rebooting into bootloader                          OKAY [  0.001s]
Finished. Total time: 0.151s
Locking sunfish 11081JEC205612 bootloader...
6. Please use the volume and power keys on the device to lock the bootloader
Rebooting sunfish 11081JEC205612...
7. Disable OEM unlocking from Developer Options after setting up your device

Flashing complete
0 asm@laptop:/home/asm/calyxos$ 

And that was it! I'm now a happy bunny :-) So much easier than my previous experiences with LineageOS (or, even, CyanogenMod) on my old phone. We seem to have come a long way over these recent years. I just wish I had as much faith in the hardware as I do the developers.