[Moto E4 Questions & Answers] maurerpe:
Update unsuccessful on unlocked and rooted Moto E4 Qualcomm Perry

I have a moto e4 (qualcomm, perry) bought from Amazon (unlocked, no added) and have a CDMA trackfone-verizon sim. Phone is working fine, but the update will not apply. It gives me an error and indicates the update was unsuccessful. The bootloader is unlocked and the phone is rooted.

The issue seems to be the sha1 sum of by boot partition (see last_log below). I downloaded the stock rom for this device from https :// firmware.center/firmware/Motorola/Moto%20E4/Stock/

I believe the right one is PERRY_NPQ26.69-27_cid50_subsidy-DEFAULT_regulatory-XT1768_CFC_CANADA.xml.zip because Settings->About Phone->Build number is "NPQ26.69-27" and cat /proc/cpuinfo indicates "Device: perry". Does anybody else find it frustrating that I cannot get this file directly from motorola?

Inside that zip is a boot.img file. The sha1 sum of that file (computed with openssl sha1 boot.img) is 8f6e5f9814b84c48054bc9fd3df9f91610b85e09, which exactly matches the red text in the log file below. Also the length, 16777216, matches my current boot partition to the byte. I was hoping that simply writing this to the boot partition would fix the issue, but that was a big mistake. I copied the file to the phone and executed:

$ dd if=/dev/block/bootdevice/by-name/boot of=boot.img.orig #to save a backup of the original partition

$ dd if=boot.img of=/dev/block/bootdevice/by-name/boot

this bricked the device and it wouldn't boot. Didn't even make it to the Motorola splash screen. After some digging I was able to use fastboot on my PC to restore the boot.img.orig using:

PC$ fastboot flash:raw boot boot.img.orig

This restored the device to functioning order, but I was still not able to install the update. After this, tried to boot the stock boot image without flashing it using:

PC$ fastboot boot boot.img

This caused it to hang forever at the blue motorola splash screen. Power cycling cleared the issue as expected.

As you probably guessed by now, I am an experienced linux user, but new to android and really don't know what I am doing. [MENTION=5752019]madbat99[/MENTION] suggests that I will have to flash the complete stock rom, wiping the device. I know how to backup, both with a backup app and with twrp, so wiping won't be a huge issue. Does anybody know how to flash a full rom? I am using gentoo linux and have fastboot and adb installed and can communicate with the bootloader, I have just never flashed a phone before. Should I expect to have to relock the bootloader for the update to apply? Afterwords, I am going to have to re-unlock the bootloader, re-root the device and then restore all my backups, correct?

I really want to apply this update due to the large gaping security holes it patches.

The relevant section of /cache/recovery/last_log are: (I bolded what I think is the real error)

[ 1.687300] I:whole-file signature verified against RSA key 0

[ 1.687314] I:verify_file returned 0

[ 1.687376] Installing update...

[ 1.729707] installing gptupgrade updater extensions

[ 1.739414] file_contexts.bin is taken from /file_contexts.bin

[ 1.740818] Mount command parameters gotten in updater script

[ 1.740855] mount point :/oem location: /dev/block/bootdevice/by-name/oem , file system type :ext4

[ 1.741029] secontext for the mount point /oem is u:object_r:oemfs:s0

[ 1.744665] Source: motorola/perry/perry:7.1.1/NPQ26.69-27/31:user/release-keys

[ 1.744695] Target: motorola/perry/perry:7.1.1/NPQS26.69-27-3/3:user/release-keys

[ 1.744704] Verifying current system...

[ 2.115566] contents of partition "/dev/block/bootdevice/by-name/boot" didn't match EMMC:/dev/block/bootdevice/by-name/boot:16777216:8f6e5f9814b84c48054bc9fd3df9f91610b85e09:16777216:aa4a543db08521bc2bb6860f0d8e463d199db938

[ 2.115605] file "EMMC:/dev/block/bootdevice/by-name/boot:16777216:8f6e5f9814b84c48054bc9fd3df9f91610b85e09:16777216:aa4a543db08521bc2bb6860f0d8e463d199db938" doesn't have any of expected sha1 sums; checking cache

[ 2.115664] failed to stat "/cache/saved.file": No such file or directory

[ 2.115675] failed to load cache file

[ 2.115687] dump_badfile is failed: EMMC:/dev/block/bootdevice/by-name/boot:16777216:8f6e5f9814b84c48054bc9fd3df9f91610b85e09:16777216:aa4a543db08521bc2bb6860f0d8e463d199db938 is not present

[ 2.115720] script aborted: E3005: "EMMC:/dev/block/bootdevice/by-name/boot:16777216:8f6e5f9814b84c48054bc9fd3df9f91610b85e09:16777216:aa4a543db08521bc2bb6860f0d8e463d199db938" has unexpected contents.

[ 2.154752] E:Error in /cache/Blur_Version.26.11.31.perry.retail.en.US.zip

[ 2.154825] (Status 7)

[ 2.187583]

[ 2.209427] W:failed to read uncrypt status: No such file or directory

[ 2.209642] I:/cache/Blur_Version.26.11.31.perry.retail.en.US.zip

[ 2.209652] 0

[ 2.209660] time_total: 1

[ 2.209668] retry: 0

[ 2.209675] target_build: 3

[ 2.209682] source_build: 31

[ 2.209689] error: 3005

[ 2.209699] Installation aborted.