Simple process and notes for updating Android recovery
Summary of recovery updates:
1. General recovery upgrade process:
① Compile: Execute make otapackage
②. In the main systemformat, rename the upgrade package as update.zip and download it to the/cache directory.
③. Create a file/cache/recovery/command and write it to the command: -- update_package =/cache/update.zip
④ The terminal executes the reboot recovery to enter the recovery mode. You can also call the android_reboot function through the android upper layer and set the code to enter the recovery mode.
⑤. The system restarts, enters the recovery mode, and starts the recovery process. This process detects/cache/recovery/commands and then upgrades update.zip.
2. command file/cache/recovery/command: stores the command line from Mainsystem to Recovery. Each line is a command and supports several combinations.
-- Send_intent = anystring // write the text out to recovery/intent at the end of the Recovery, the intent string defined in the finish_recovery function is passed as a parameter, and write it to/cache/recovery/intent.
-- Update_package = root: path // verify install an OTA package file Main packages.
-- Wipe_data // erase user data (and cache), then reboot. Erase user data. The cache partition must be erased when the data partition is erased.
-- Wipe_cache // wipecache (but not user data), then reboot. Erase the cache partition.
3. The rediscovery time zone must be consistent with the partition number in the system main mode.
Location: bootable/bootloader/uboot-imx/include/autoconf. mk
CONFIG_ANDROID_CACHE_PARTITION_MMC = 12
CONFIG_ANDROID_RECOVERY_PARTITION_MMC = 6
CONFIG_ANDROID_SYSTEM_PARTITION_MMC = 5
Config_android_recovery_pai_file = "/recovery/command"
4. Modify bootable/recovery. c.
# LOCAL_MODULE_TAGS: = eng
If this line is opened, only the copy to/system/bin action will be available in the eng software.
5. build/core/Makefile Modification
$ (INTERNAL_OTA_PACKAGE_TARGET): $ (BUILT_TARGET_FILES_PACKAGE) $ (DISTTOOLS)
@ Echo "Package OTA: $ @"
$ (Hide)./build/tools/releasetools/ota_from_target_files-v \
-P $ (HOST_OUT )\
-K $ (KEY_CERT_PAIR )\
-N \
-W \
-N: whether the timestamp is not checked during the upgrade. By default, the timestamp must be checked. That is, the upgrade can only be performed based on the old version.
-W: whether to clear the userdata Partition
Note: If the following error occurs in/cache/recovery/last_log, the upgrade package is older and the execution is terminated. You can add the-n items mentioned above.
Assert failed :! Less_than_int (1397801920, getprop ("ro. build. date. utc "))
6. Store the recovery log file in/cache/recovery/
Last_install
Last_locale: the language used for the last recovery, such as the prompt language displayed on the interface during the update.
Last_log: log
7. Check whether the command file/cache/recovery/command function is int check_recovery_assist_file (void) defined in the following file:
"Bootable/bootloader/uboot-imx/board/freescale/mx6q_sabresd/mx6q_sabresd.c"
8. The recovery upgrade is performed by executing the updater-script. Below are some comments for your reference.
- Assert (getprop ("ro. product. device") = "sabresd_6dq" |
- Getprop ("ro. build. product") = "sabresd_6dq ");
- // Show_progress (frac, sec): frac indicates the progress completed value, and sec indicates the total number of seconds of the entire process. It mainly uses and displays the progress bar on the UI.
- Show_progress (0.500000, 0 );
- // Format (fs_type, partition_type, location): fs_type, file system type. The value is generally "yaffs2" or "ext4 ". Partition_type: partition type. Generally, the value is "MTD" or "EMMC ". It is mainly used to format a specified file system.
- Format ("ext4", "EMMC", "/dev/block/mmcblk0p5", "0", "/system ");
- // Mount a file system/system to the specified mount point mmcblk0p5
- Mount ("ext4", "EMMC", "/dev/block/mmcblk0p5", "/system ");
- // Package_extract_dir (src_path, destination_path): src_path, the directory to be extracted, and the destination directory of destination_path. Purpose: extract the directory from the update package to the specified location.
- Package_extract_dir ("recovery", "/system"); // extract recovery
- Package_extract_dir ("system", "/system"); // extract system
- // Create a symbolic link
- Symlink ("Roboto-Bold.ttf", "/system/fonts/DroidSans-Bold.ttf ");
- Symlink ("Roboto-Regular.ttf", "/system/fonts/DroidSans. ttf ");
- Symlink ("mksh", "/system/bin/sh ");
- Symlink ("toolbox", "/system/bin/cat", "/system/bin/chmod ",
- "/System/bin/chown", "/system/bin/cmp", "/system/bin/cp ",
- "/System/bin/date", "/system/bin/dd", "/system/bin/df ",
- "/System/bin/dmesg", "/system/bin/du", "/system/bin/getevent ",
- "/System/bin/getprop", "/system/bin/grep", "/system/bin/hd ",
- "/System/bin/id", "/system/bin/ifconfig", "/system/bin/iftop ",
- "/System/bin/insmod", "/system/bin/ioctl", "/system/bin/ionice ",
- "/System/bin/kill", "/system/bin/ln", "/system/bin/log ",
- "/System/bin/ls", "/system/bin/lsmod", "/system/bin/lsof ",
- "/System/bin/md5", "/system/bin/mkdir", "/system/bin/mount ",
- "/System/bin/mv", "/system/bin/nandread", "/system/bin/netstat ",
- "/System/bin/newfs_msdos", "/system/bin/Y", "/system/bin/printenv ",
- "/System/bin/ps", "/system/bin/reboot", "/system/bin/renice ",
- "/System/bin/rm", "/system/bin/rmdir", "/system/bin/rmmod ",
- "/System/bin/route", "/system/bin/schedtop", "/system/bin/sendevent ",
- "/System/bin/setconsole", "/system/bin/setprop", "/system/bin/sleep ",
- "/System/bin/smd", "/system/bin/start", "/system/bin/stop ",
- "/System/bin/sync", "/system/bin/top", "/system/bin/touch ",
- "/System/bin/umount", "/system/bin/uptime", "/system/bin/vmstat ",
- "/System/bin/watchprops ",
- "/System/bin/wipe ");
- // Set file or directory permissions
- Set_perm_recursive (0, 0, 0755,064 4, "/system ");
- Set_perm_recursive (0, 2000,075 5, 0755, "/system/bin ");
- Set_perm (0, 3003,027 50, "/system/bin/netcfg ");
- Set_perm (0, 3004,027 55, "/system/bin/ping ");
- Set_perm (0, 2000,067 50, "/system/bin/run-");
- Set_perm (1002,100 2, 0440, "/system/etc/limits. conf ");
- Set_perm (1014,200 0, 0550, "/system/etc/dhcpcd-run-hooks ");
- Set_perm (0, 2000,055 0, "/system/etc/init. goldfish. sh ");
- Set_perm (0, 0, 0544, "/system/etc/install-recovery.sh ");
- Set_perm_recursive (0, 0, 0755,055 5, "/system/etc/ppp ");
- Set_perm_recursive (0, 2000,075 5, 0644, "/system/vendor ");
- Set_perm (0, 0, 0644, "/system/vendor/etc/audio_effects.conf ");
- Set_perm_recursive (0, 2000,075 5, 0755, "/system/xbin ");
- Show_progress (0.200000, 0 );
- Show_progress (0.200000, 10 );
- // Write the boot. imgfile in the upgrade package to/dev/block/mmcblk0p1
- Package_extract_file ("boot. img", "/dev/block/mmcblk0p1 ");
- Show_progress (0.100000, 0 );
- Unmount ("/system ");
9. The updater-script is generated from python script build/tools/releasetools/ota_from_target_files.
10. The updated image is displayed under/android4.2-imx6/bootable/recovery/res/images.
11. In Android recovery mode, the text displayed on the interface is read from png text images. The directory is also in/android4.2-imx6/bootable/recovery/res/images
To display text, you must pass the locale variable from the upper layer. If you do not set it or do not know how to set it (I do not know), you can directly modify the locale definition in the bootable/recovery. cpp file to assign the initial value.
Char * locale = "en_GB"