If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

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

RESOLVED WORKSFORME

Status

Firefox OS
General
RESOLVED WORKSFORME
5 years ago
4 years ago

People

(Reporter: dhylands, Assigned: dhylands)

Tracking

(Blocks: 1 bug)

unspecified
ARM
Gonk (Firefox OS)
Dependency tree / graph

Firefox Tracking Flags

(blocking-b2g:koi+)

Details

Attachments

(1 obsolete attachment)

(Assignee)

Description

5 years ago
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
(Assignee)

Comment 1

4 years ago
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.
(Assignee)

Comment 2

4 years ago
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?
(Assignee)

Updated

4 years ago
Blocks: 916098
(Assignee)

Comment 3

4 years ago
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.
(Assignee)

Comment 4

4 years ago
Created attachment 808444 [details] [diff] [review]
Change external location from /sdcard to /mnt/sdcard
(Assignee)

Updated

4 years ago
Attachment #808444 - Flags: review?(schien)
(Assignee)

Comment 5

4 years ago
Comment on attachment 808444 [details] [diff] [review]
Change external location from /sdcard to /mnt/sdcard

This is a patch for librecovery
(Assignee)

Updated

4 years ago
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?
(Assignee)

Comment 8

4 years ago
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).
(Assignee)

Comment 9

4 years ago
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.
(Assignee)

Comment 10

4 years ago
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)

Comment 15

4 years ago
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+
(Assignee)

Updated

4 years ago
Attachment #808444 - Attachment is obsolete: true
Attachment #808444 - Flags: review?(schien)
(Assignee)

Comment 19

4 years ago
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
Last Resolved: 4 years ago
Resolution: --- → WORKSFORME

Updated

4 years ago
Flags: needinfo?(mwu)
You need to log in before you can comment on or make changes to this bug.