Closed Bug 858188 Opened 11 years ago Closed 11 years ago

FOTA updates fail to apply when downloaded to the sdcard (regression)

Categories

(Firefox OS Graveyard :: General, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(blocking-b2g:koi+)

RESOLVED WORKSFORME
blocking-b2g koi+

People

(Reporter: dhylands, Assigned: dhylands)

References

Details

Attachments

(1 obsolete file)

I was adding steps to reproduce to bug 838924 comment 10 and when it went to install the update, I saw:

UpdatePrompt: Rebooting into recovery to apply FOTA update: /mnt/sdcard/updates/fota/update.zip

as the very last entry in logcat, but it just rebooted the phone. It didn't reboot into recovery to apply the update.

I was testing on my unagi
If no sdcard is present, then it seems to reboot into recovery fine. It passes the path:

  /data/local/updates/fota/update.zip

to the bootloader. However, if an sdcard is present, then it passes in:

  /mnt/sdcard/updates/fota/update.zip

In 1.0.1, I belive it used to pass in /sdcard/updates/fota/update.zip.
I verified that if I modify UpdatePrompt.js by applying the following patch:

diff --git a/b2g/components/UpdatePrompt.js b/b2g/components/UpdatePrompt.js
index 9c9b30b..ba93480 100644
--- a/b2g/components/UpdatePrompt.js
+++ b/b2g/components/UpdatePrompt.js
@@ -374,6 +374,10 @@ UpdatePrompt.prototype = {
   },
 
   finishOSUpdate: function UP_finishOSUpdate(aOsUpdatePath) {
+    if (aOsUpdatePath.substring(0,12) == "/mnt/sdcard/") {
+      // Convert /mnt/sdcard/ into /sdcard/
+      aOsUpdatePath = aOsUpdatePath.substring(4);
+    }
     log("Rebooting into recovery to apply FOTA update: " + aOsUpdatePath);
 
     try {

that the FOTA update was applied properly. I consider this patch a proof of concept patch. I think a better way to do this would be to have a preference which provides translations, and I'll work on a patch based on this.

I'm also nominating this for koi? since it impacts FOTA updates.
Assignee: nobody → dhylands
blocking-b2g: --- → koi?
Blocks: 916098
It seems that editing librecovery/device/unagi.mk and changing:

RECOVERY_EXTERNAL_STORAGE := /sdcard

to be:

RECOVERY_EXTERNAL_STORAGE := /mnt/sdcard

It looks like all of the device makefiles need to be edited.
Attachment #808444 - Flags: review?(schien)
Comment on attachment 808444 [details] [diff] [review]
Change external location from /sdcard to /mnt/sdcard

This is a patch for librecovery
Summary: FOTA updates don't boot into recovery (regression) → FOTA updates fail to apply when downloaded to the sdcard (regression)
I did some test yesterday, finally it does work.

Add a makefile with RECOVERY_EXTERNAL_STORAGE for device under "librecovery/device" is needed. 

And "RECOVERY_EXTERNAL_STORAGE" should be the mount path where sdcard is mounted in recovery.img.
Comment on attachment 808444 [details] [diff] [review]
Change external location from /sdcard to /mnt/sdcard

Review of attachment 808444 [details] [diff] [review]:
-----------------------------------------------------------------

RECOVERY_EXTERNAL_STORAGE should be matched with the mount point of sdcard in recovery mode. Does it means all these three devices are mounting sdcard under /mnt/sdcard/ in recovery mode?
So I know for sure that on the unagi, RECOVERY_EXTERNAL_STORAGE set to /sdcard fails to apply the update, and set to /mnt/sdcard works (I tested 1.1).

I'm not sure about the others. I guess I'll have to experiment and find out. I'll fire off some builds tomorrow morning and test them (I have an otoro and a hamachi, so it should be easy enough to do).
Your email suggested a mapping. So what exactly is being mapped?

Or should I be looking for /mnt/sdcard and replacing it with whatever RECOVERY_EXTERNAL_STORAGE is set to?

I may have misinterpreted your email.
Or perhaps the question I should ask is what should UpdatePrompt do to determine the correct path to pass down to librecvovery?
Hi, Dave, 

I just finished test on mako device. 

To make the update work in recovery mode, RECOVERY_EXTERNAL_STORAGE must be set to "/data/media/0". 

I found that "/sdcard" in normal boot is an emulated one, and it is mapping to "/data/media/0".

In this case, update in recovery mode will not work if RECOVERY_EXTERNAL_STORAGE set to /sdcard.
The file path translation from normal boot to recovery boot is already done by librecovery [1]. The file path in sdcard passed to librecovery should be like {EXTERNAL_STORAGE}/fota/update.zip and will be replace to {RECOVERY_EXTERNAL_STORAGE}/fota/update.zip while writing as a command for recovery mode.

[1] https://github.com/mozilla-b2g/librecovery/blob/master/librecovery.c#L142
I think we can also reference to Bug 915981 comment #7, if so we will not maintain the makefile for each device under "librecovery/device".
@mwu, do you know the mount point of sdcard for otoro, unagi, and hamachi?
Flags: needinfo?(mwu)
Should be /mnt/sdcard.
Flags: needinfo?(mwu)
@mwu, does the mount point still be /mnt/sdcard in recovery mode?
Flags: needinfo?(mwu)
I think we can know the mount point in recovery mode of each device from "recovery.fstab" of them. But I don't know where to get the "recovery.fstab" of otoro, unagi, and hamachi.
+ing for FOTA update uplift
blocking-b2g: koi? → koi+
Attachment #808444 - Attachment is obsolete: true
Attachment #808444 - Flags: review?(schien)
OK - I was able to verify that /sdcard is, in fact, the mount point for the sdcard for otoro, unagi, and hamachi

I was able to get FOTA working on my unagi. I think I was using some stale libraries and wasn't getting the new librecovery when I experienced the problem in comment 8.

I also discovered that we don't flash our librecovery.so onto the hamachi, and even when I have the correct librecovery.so, the update fails due to signature problems.

So I'm going to close this bug as WORKSFORME since the FOTA for unagi is working properly.

This is what I saw in /cache/recovery/last_log for the hamachi:

mtd: successfully wrote block at 0
Finding update package...
I:Update location: /sdcard/updates/fota/update.zip
Opening update package...
I:1 key(s) loaded from /res/keys
Verifying update package...
I:comment is 1738 bytes; signature 1720 bytes from end
E:failed to verify whole-file signature
I:verify_file returned 1
E:signature verification failed
Installation aborted.
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → WORKSFORME
Flags: needinfo?(mwu)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: