doc:appunti:hardware:xiaomi_mi_a1
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
doc:appunti:hardware:xiaomi_mi_a1 [2019/11/07 10:29] – [Upgrade Magisk and MagiskManager] niccolo | doc:appunti:hardware:xiaomi_mi_a1 [2020/03/25 15:47] – [March 2020 security update] niccolo | ||
---|---|---|---|
Line 68: | Line 68: | ||
< | < | ||
adb shell | adb shell | ||
- | tissot_sprout:/ | + | tissot_sprout:/ |
- | /dev/block/platform/soc/ | + | |
- | cd / | + | |
- | ls -l | + | |
... | ... | ||
lrwxrwxrwx 1 root root 21 1970-07-10 05:23 boot_a -> / | lrwxrwxrwx 1 root root 21 1970-07-10 05:23 boot_a -> / | ||
Line 78: | Line 75: | ||
</ | </ | ||
- | The meaning is: search into **/dev/** for a directory named " | + | The meaning is: search into **/dev/ |
Now we need to **boot** into an environment where we have **root privileges**, | Now we need to **boot** into an environment where we have **root privileges**, | ||
< | < | ||
- | adb reboot-bootloader | + | adb reboot bootloader |
</ | </ | ||
Line 114: | Line 111: | ||
< | < | ||
- | adb reboot-bootloader | + | adb reboot bootloader |
fastboot boot recovery-3.2.1-2-oreo.img | fastboot boot recovery-3.2.1-2-oreo.img | ||
</ | </ | ||
Line 125: | Line 122: | ||
{{ .: | {{ .: | ||
- | * **Do not swap Slot A and Slot B**. Some recipes found on the internet say to do that in TWRP (it is from the Reboot menu). I tried it and it was a nightmare! The Reboot menu was stating that the Slot B were active, so I switched to Slot A and installed TWRP. At the next reboot I got a non-working environment: | + | * **Do not swap Slot A and Slot B**. Some recipes found on the internet say to do that in TWRP (it is from the Reboot menu). I tried it and it was a nightmare! The Reboot menu was stating that the Slot B were active, so I switched to Slot A and installed TWRP. At the next reboot I got a non-working environment: |
* **Do not veryfy the ZIP archive**. The archive does not have the required info to check. | * **Do not veryfy the ZIP archive**. The archive does not have the required info to check. | ||
- | * **Do not wipe the Dalvik cache after the install**. Don't know if it was the culprit, but after installing TWRP, I clicked the button to wipe Dalvik cache, at the next reboot I had a damaged system. The **home button did not work**, the Developer options were no longer availables (// | + | * **Do not wipe the Dalvik cache after the install**. Don't know if it was the culprit, but after installing TWRP, I clicked the button to wipe Dalvik cache, at the next reboot I had a damaged system. The **home button did not work**, the Developer options were no longer availables (// |
==== Install Magisk, the SuperUser Tool ==== | ==== Install Magisk, the SuperUser Tool ==== | ||
Line 153: | Line 150: | ||
When an app requires root privileges, the Magisk management app will show a pop-up on the phone, allowing to grant or deny the permission, so be sure that the phone is not in screen-locked mode. | When an app requires root privileges, the Magisk management app will show a pop-up on the phone, allowing to grant or deny the permission, so be sure that the phone is not in screen-locked mode. | ||
===== Recovery Mode ===== | ===== Recovery Mode ===== | ||
+ | |||
+ | Android devices have a feature called **Android Recovery Mode**, which allows users to fix some problems. Technically, | ||
+ | |||
+ | To enter the Recover mode you can follow one of this ways: | ||
* **Power Off** the phone. | * **Power Off** the phone. | ||
* Press **VolumeUp + Power**, wait about 3 seconds for the Mi logo screen. | * Press **VolumeUp + Power**, wait about 3 seconds for the Mi logo screen. | ||
- | | + | |
+ | If you have installed the TWRP Recovery, its main screen will appear. If you have the stock ROM Recovery you have to: | ||
+ | |||
+ | | ||
* Press **Power + VolumeUp** shortly, the Recovery menu will appear. | * Press **Power + VolumeUp** shortly, the Recovery menu will appear. | ||
Line 162: | Line 166: | ||
{{.: | {{.: | ||
- | ===== Fastboot Mode ===== | + | When the phone is booted |
- | + | ||
- | Once in Recovery Menu, you can boot into the **Fastboot Mode** using the menu entry //Reboot to bootloader// | + | |
< | < | ||
- | adb reboot | + | adb reboot |
</ | </ | ||
+ | |||
+ | |||
+ | ===== Fastboot Mode ===== | ||
+ | |||
+ | In Android, **fastboot** is a special diagnostic protocol that you can boot your Android device into. While in fastboot, you can modify the file system images from a computer over a USB connection. | ||
+ | |||
+ | You can start fastboot mode in severl ways: | ||
+ | |||
+ | * Power off the phone, then press **VolumeDown + Power** buttons together, untill vibration. | ||
+ | * Executing the **adb reboot bootloader** command on a PC when the phone is booted normally and connected via the USB cable. It is required to enable //USB debugging// on the phone and to authorize the PC on the phone pop-up, once connected. | ||
+ | * From the **stock Recovery** menu, choosing the entry **Reboot to bootloader**. | ||
+ | * From the **TWRP Recovery**, choosing **Reboot** menu, then **Bootloader**. | ||
+ | |||
+ | The Xiaomi Mi A1 will show the following image when in fastboot mode: | ||
{{.: | {{.: | ||
+ | |||
+ | To control the fastboot mode of the phone, you have to install the **fastboot** command on your PC. On a Debian GNU/Linux install the **fastboot 8.1.0** package. **NOTICE**: Version 7.0.0 is not reccomended, | ||
+ | |||
+ | Here are some commands that can be used in fastboot mode: | ||
< | < | ||
- | adb devices | + | fastboot help |
- | List of devices | + | fastboot |
- | 574524d99913 | + | fastboot boot recovery-3.2.1-2-oreo.img |
+ | fastboot flash boot_b boot_b.img | ||
+ | fastboot oem unlock | ||
+ | fastboot set_active b | ||
+ | fastboot reboot | ||
</ | </ | ||
Line 259: | Line 283: | ||
- Once rebooted in normal system, install **MagiskManager-v7.4.0.apk** from the file manager of your choice (it will require the permission //System// => //App// => <File manager> => //Unknown sources//). | - Once rebooted in normal system, install **MagiskManager-v7.4.0.apk** from the file manager of your choice (it will require the permission //System// => //App// => <File manager> => //Unknown sources//). | ||
- | FIXME Write how to complete | + | ==== Upgrading the Operating System ==== |
+ | |||
+ | The phone automatically warns about the availability of an **OTA (On The Air) Upgrade**. You can also check for upgrades availability by tapping // | ||
+ | |||
+ | If you allow downloading and installing the upgrade, a check will be performed about the **integrity** of the **boot image** and the **system image**, before the actual install. The check will fail and the upgrade will be aborted if one or both of these two conditions is true: | ||
+ | |||
+ | - You have installed **Magisk SU** or **TWRP Recovery**. These software are installed into the boot partition, either **boot_a** or **boot_b** partition. The installation of Magisk patches only the active boot partition, whereas TWRP will patches (install itself) both boot partitions. | ||
+ | - You have used **su** to modify the **/system** partition. If you have **re-mounted** /system in **read/ | ||
+ | |||
+ | The upgrade process will fail with a warning message **Couldn’t update - Installation problem** (in Italian: // | ||
+ | |||
+ | To escape from the first condition, it is sufficient to **restore the boot partition** from the original backup. You will loose root and TWRP Recovery, but you can reinstall them after the upgrade. If you have just installed Magisk, uninstalling it should be sufficient and rather simple. Start the Magisk Manager app, disable and uninstall all the modules (if any) and reboot. Then run Magisk Manager again and choose to uninstall it completely. But if you have installed also TWRP you have to recover from a backup image. This is the recipe to run from a PC command line (supposing that **active partition is B** and that you have the original **boot_b.img** dump): | ||
+ | |||
+ | < | ||
+ | adb reboot bootloader | ||
+ | fastboot flash boot_b boot_b.img | ||
+ | fastboot reboot | ||
+ | </ | ||
+ | |||
+ | Allowing automatic OTA upgrade after **tampering the /system partition** is more painful: you have to **restore system partition** by flashing it in fastboot mode. Obviously you need the original **system.img** file, either from your own backup or from factory ROM archive. Fortunately enough Xiaomi provides full stock ROM archives of the various versions. Look at this **[[https:// | ||
+ | |||
+ | Once you extracted | ||
+ | |||
+ | < | ||
+ | fastboot flash system_b system.img | ||
+ | fastboot reboot | ||
+ | </ | ||
+ | ==== The OTA Update ==== | ||
+ | |||
+ | When the phone downloads an OTA upgrade, it will save it into the **/ | ||
+ | |||
+ | The file is actualy a Jar archive. The jar executable is provided by the Debian package **openjdk-8-jdk-headless** (or whatever version of Java you have), and you can use it in this way: | ||
+ | |||
+ | < | ||
+ | mkdir update | ||
+ | cd update | ||
+ | jar -xf ../ | ||
+ | </ | ||
+ | |||
+ | The main content is a **payload.bin**, | ||
+ | |||
+ | ===== March 2020 security update ===== | ||
+ | |||
+ | In March 2020 Xiaomi released a new security update, according to this post **[[https:// | ||
+ | |||
+ | I performed the upgrade re-installing **TWRP** and **Magisk** afterward. The starting conditions were: | ||
+ | |||
+ | * A/B System Updates status: **Current Slot: B** (checked via TWRP => Reboot screen). | ||
+ | * Bootloader is **unlocked**. | ||
+ | * Installed O.S.: Android: 9, Build number: **PKQ1.180917.001.V10.0.14.0.PDHMIXM** (check from Impostazioni => Sistema => Informazioni sul telefono). | ||
+ | * From // | ||
+ | * **Magisk** v20.1 and **TWRP** 3.3.0 were installed into **boot partition** (Slot B). | ||
+ | * **System partition** was the stock one: root privileges were never used to tamper the **/system** hierarchy. | ||
+ | |||
+ | The system upgrade will **verify** the **boot** and the **system** partitions before attempting the installation, | ||
+ | |||
+ | I restored the stock **boot_b.img** image (saved before TWRP and Magisk), using the ADB commands from a connected PC: | ||
+ | |||
+ | < | ||
+ | adb reboot bootloader | ||
+ | fastboot flash boot_b boot_b.img | ||
+ | fastboot reboot | ||
+ | </ | ||
+ | |||
+ | **I got a problem** during this step: may be the **boot_b.img** was not the current one, but one of two versions before! Luckily the only negative effect was that **the WiFi was not working**. This is a **logcat** excerpt: | ||
+ | |||
+ | < | ||
+ | android.hardware.wifi@1.0-service: | ||
+ | android.hardware.wifi@1.0-service: | ||
+ | android.hardware.wifi@1.0-service: | ||
+ | android.hardware.wifi@1.0-service: | ||
+ | </ | ||
- | * Backup **boot_a** | + | I proceeded with the standard procedure, trusting that the boot partition would be recognized as original |
- | * Allow the system to **update**. FIXME Does it complete or will fail? May be it detects that the system was rooted and it will refuse. | + | |
- | | + | |
- | | + | |
===== Web References ===== | ===== Web References ===== | ||
Line 270: | Line 362: | ||
* [[https:// | * [[https:// | ||
* [[https:// | * [[https:// | ||
+ | * [[https:// | ||
* [[https:// | * [[https:// | ||
* [[https:// | * [[https:// |
doc/appunti/hardware/xiaomi_mi_a1.txt · Last modified: 2020/09/23 17:06 by niccolo