Project

General

Profile

EC20 DFOTA » History » Version 8

zecke, 12/29/2016 11:26 AM

1 1 zecke
h1. EC20/EC25 Delta Firmware over the air (DFOTA) upgrades
2
3 6 zecke
An example of the DFOTA file is here: http://dfota.quectel-service.com:8088/Dfiles/EC20/EC20EQAR02A05V03-R02A09V02.zip. EC25 seems to use the stock "recovery"/"applypatch".
4 1 zecke
5 6 zecke
h2. Mechanism
6
7
It is based on the recovery.git of Android. For the EC20 the delta format (and RSA signing) has been replaced by the usage of
8
RedBend FOTA. The RedBend FOTA is used by other Qualcomm customers too and is also used on the UC20. For the EC25 it
9
seems that the stock Android/LinuxFoundation @recovery@ is used.
10
11
The general approach is:
12
13
* APN is configured for the Linux system
14
* AT+QFOTADL is handled by atfwd_daemon and starts @wget@ to write to @update.zip@
15
* @"IP_START_UPDATE" > /cache/fota/ipth_config_dfs.txt@
16
* Reboot into the recovery image
17
* recovery will apply the update.
18
19
20
21 1 zecke
h2. Start delta upgrade
22
23
<pre>
24 6 zecke
AT+QICSGP=1,1,"APN_NAME_HERE","","",1
25 1 zecke
AT+QFOTADL="http://dfota.quectel-service.com:8088/Dfiles/EC20/EC20EQAR02A05V03-R02A09V02.zip"
26
</pre>
27
28
It will start an internal connection manager to terminate data on the Linux module and then run wget to store the file to
29
"update.zip". If it worked a reboot into the recovery system will be made.
30
31
h2. Recovery image
32
33 7 zecke
The @/usr/bin/recovery@ of the recovery image will be started on boot and checks for a @update.zip@ and
34
the instructions in @ipth_config_dfs.txt@ and then apply the updates. Maintain some counters for how often
35
an upgrade was attempted and reboot into the main image.
36 1 zecke
37
38
h2. Delta format
39 6 zecke
40 7 zecke
Delta updates can update images (e.g. bootloader, kernel) and files on a mounted filesystem. The update.zip
41
contains one file per image/filesystem to update. The general format is the same for both images and filesystems
42
and the semantic comes from the partition table supplied by the recovery application to the RedBend component.
43 1 zecke
44 7 zecke
The delta update consists out of several nested parts and pointers/offsets into it.
45 6 zecke
46 7 zecke
* Part1 with actual update
47
** CRC32 + len
48
** Common header
49
** Information of decompressed size of TableOfContents (TOC), offset for info within TOC
50
** Information of different amount of updates (diffs, inserts, removals, links, etc.)
51
** Variable part depending on above information (e.g. old and new CRC32 of files, unused data for insert, unknown for other)
52
** LZMA TableOfContents (TOC) (needs to have uncompressed size in the header and no end-of-payload marker)
53
*** Starts with null terminated filenames to patch
54
*** List of file permissions (separated by 0xAF)
55
*** Information about updates (common header points to this offset). For inserts includes filesize, offset for permission, compressed size of update)
56
** LZMA of Insert (same requirement as above)
57
** Maybe some padding.. unknown about when to insert it
58 1 zecke
59 7 zecke
* Part2 with FileNamesTable
60
** CRC32 + len
61
** Common Information
62
** Len + null terminated string
63 1 zecke
64 7 zecke
65
<pre>
66
struct update_part_header {
67
   uint32_t crc32 // CRC32 of len + data
68
   uint32_t __le len; //
69
   uint8_t data[0];
70
};
71 5 zecke
</pre>
72
73 7 zecke
We have a python script to dissect the basic structure of a diff and another script to pack a file as insert in an upgrade. Image
74
updates were not studied.
75 3 zecke
76 2 zecke
h2. Kicking the recovery binary
77 1 zecke
78 8 zecke
* mount /dev/mtdblock13 /mnt..
79 2 zecke
* Place update.zip to /cache/
80
* echo "IP_START_UPDATE" > /cache/fota/ipth_config_dfs.txt  to say what to do
81
82
Was difficult to repeat, e.g. creating backup and mounting system partition failed on second/third tries
83
84
<pre>
85 7 zecke
/ # recovery 
86 2 zecke
mount: mounting none on /sys/kernel/debug failed: Device or resource busy
87
Starting recovery on Fri Oct 14 12:39:48 2016
88
recovery filesystem table
89
=========================
90
  0 /tmp ramdisk (null) (null) 0
91
  1 / auto rootfs (null) 0
92
  2 /proc proc proc (null) 0
93
  3 /dev/pts devpts devpts (null) 0
94
  4 /proc/bus/usb usbfs usbfs (null) 0
95
  5 /dev/shm tmpfs tmpfs (null) 0
96
  6 /cache yaffs2 /dev/mtdblock9 (null) 0
97
  7 /media/card auto /dev/mmcblk0p1 (null) 0
98
  8 /system yaffs2 /dev/mtdblock14 (null) 0
99
  9 /data yaffs2 /dev/mtdblock15 (null) 0
100
  10 /misc mtd /dev/mtdblock10 (null) 0
101
102
rootfs on / type rootfs (rw)
103
/dev/root on / type yaffs2 (rw,relatime)
104
proc on /proc type proc (rw,relatime)
105
sysfs on /sys type sysfs (rw,relatime)
106
tmpfs on /dev type tmpfs (rw,relatime,size=64k,mode=755)
107
devpts on /dev/pts type devpts (rw,relatime,mode=600)
108
tmpfs on /dev/shm type tmpfs (rw,relatime,mode=777)
109
/dev/mtdblock15 on /usr type yaffs2 (rw,relatime)
110
/dev/mtdblock9 on /cache type yaffs2 (rw,relatime)
111
/dev/mtdblock13 on / type yaffs (rw,relatime)
112
tmpfs on /dev type tmpfs (rw,relatime,size=64k,mode=755)
113
/dev/mtdblock9 on /cache type yaffs2 (rw,relatime)
114
none on /sys type sysfs (rw,relatime)
115
none on /sys/kernel/debug type debugfs (rw,relatime)
116
proc on /proc type proc (rw,relatime)
117
total 3
118
lrwxrwxrwx    1 root     root            31 Jul 21 07:10 boot_hsic_composition -> /usr/bin/usb/compositions/empty
119
lrwxrwxrwx    1 root     root            30 Jul 21 07:10 boot_hsusb_composition -> /usr/bin/usb/compositions/9215
120
drwxr-xr-x    1 root     root          2048 Jul 21 07:10 compositions
121
crw--w----    1 root     root      247,   0 Jan  8  1970 /dev/ttyGS0
122
RB_Progress: fwrite "/dev/ttyGS1" fail
123
I:Checking delta update status...
124
handle_redbend_update: START_DELTA_UPDATE
125
I:Setting delta update status...
126
I:Delta update status is set to (IP_PREVIOUS_UPDATE_IN_PROGRESS 0)
127
I:Start delta update...
128
I:Setting recovery boot...
129
I:Recovery mode reached maximum retry. Clear boot message.
130
mtd: successfully wrote block at bebe0f4800000000
131
I:Set boot command ""
132
I:boot.command=
133
I:boot.recovery=
134
I:Update location: /cache/update.zip
135
I:number of files in zip is 1 
136
I:verifying file at index 0
137
I:No radio diff images found 
138
I:system.diff found 
139
E:No modem package available.
140
E:No modem update needed. returning O.K
141
mtd: successfully wrote block at bebe23a000000000
142
I:Reset FOTA cookie done.
143
start fota update (/cache/fota/system.diff)
144
redbend_fs_entry: device_name: /dev/mtdblock14
145
redbend_fs_entry: mount_point: /tmp/system
146
redbend_fs_entry: update_name: /cache/fota/system.diff
147
redbend_fs_entry: part_name: system
148
149
150
151
RB_GetDelta: offset 0x0(0), size 0x14(20)
152
RB_GetDelta: offset 0x0(0), size 0x18(24)
153
RB_GetDelta: offset 0x4(4), size 0x3508(13576)
154
RB_GetDelta: offset 0x0(0), size 0x40(64)
155
RB_GetDelta: offset 0x350c(13580), size 0x18(24)
156
RB_GetDelta: offset 0x3510(13584), size 0x27(39)
157
RB_GetDelta: offset 0x0(0), size 0x14(20)
158
RB_GetDelta: offset 0x0(0), size 0x18(24)
159
RB_GetDelta: offset 0x350c(13580), size 0x18(24)
160
RB_GetDelta: offset 0x0(0), size 0x18(24)
161
RB_GetDelta: offset 0x0(0), size 0x18(24)
162
RB_GetDelta: offset 0x350c(13580), size 0x18(24)
163
RB_GetDelta: offset 0x3524(13604), size 0x4(4)
164
RB_GetDelta: offset 0x3528(13608), size 0x4(4)
165
RB_GetDelta: offset 0x352c(13612), size 0x7(7)
166
RB_GetDelta: offset 0x0(0), size 0x40(64)
167
RB_GetDelta: offset 0x0(0), size 0x40(64)
168
RB_GetDelta: offset 0x40(64), size 0x304(772)
169
RB_GetDelta: offset 0x344(836), size 0xd(13)
170
RB_GetDelta: offset 0x351(849), size 0x4a8(1192)
171
FS partition delta dump
172
RedBend: Delta Info: delta_sig - 0x6d0d05e5
173
RedBend: Delta Info: delta_size - 13580
174
RedBend: Delta Info: ver - 82000
175
RedBend: Delta Info: scout_ver - 80000
176
RedBend: Delta Info: flags - 0x80000000
177
RedBend: Delta Info: runtype_flags - 0x280
178
RedBend: Delta Info: ram_size - 0x200c8
179
RedBend: Delta Info: sector_size - 0x40000
180
RedBend: Delta Info: dic_sz - 0xdc8
181
RedBend: Delta Info: compress_sz - 0x4b5
182
RedBend: Delta Info: min_alloc_ram_use - 0x22
183
RedBend: Delta Info: ext_info_sz - 2
184
RedBend: Delta Info: num_copy - 0
185
RedBend: Delta Info: num_diff - 95
186
RedBend: Delta Info: num_insert - 3
187
RedBend: Delta Info: num_delete - 0
188
RedBend: Delta Info: num_del_dirs - 0
189
RedBend: Delta Info: num_dirs - 0
190
RedBend: Delta Info: num_del_link - 0
191
RedBend: Delta Info: num_link - 4
192
RedBend: Delta Info: num_critical_update - 95
193
RedBend: Delta Info: num_critical_insert - 3
194
RB_CreateFolder: /cache/fota/a, mode:0x1ff
195
open file /cache/fota/a/backup
196
RB_OpenFile: Path:/cache/fota/a/backup | Mode: RDONLY 
197
 First open() with error 2
198
open file /tmp/system/etc/version
199
RB_OpenFile: Path:/tmp/system/etc/version | Mode: RDONLY 
200
 First open() with error 2
201
open file /tmp/system/etc/version
202
RB_OpenFile: Path:/tmp/system/etc/version | Mode: RDONLY 
203
 First open() with error 2
204
RedBend: Error in scout, file signature mismatch in file /tmp/system/etc/version
205
umount: can't umount /tmp/system: No such file or directory
206
fota update fail (/cache/fota/system.diff)
207
I:fs:/cache/update.zip update err
208
mtd: successfully wrote block at bebe23a000000000
209
I:Reset FOTA cookie done.
210
mtd: successfully wrote block at bebe0f3800000000
211
I:Set boot command ""
212
I:Setting delta update status...
213
I:Delta update status is set to (IP_PREVIOUS_UPDATE_FAILED 500)
214
handle_redbend_update: DELTA_UPDATE_IN_PROGRESS
215
I:Setting delta update status...
216
I:Delta update status is set to (IP_PREVIOUS_UPDATE_IN_PROGRESS 0)
217
I:Start delta update...
218
I:Setting recovery boot...
219
I:Error opening recovery count file. Ignore.
220
mtd: successfully wrote block at bebe0f4800000000
221
I:Set boot command "boot-recovery"
222
I:boot.command=boot-recovery
223
I:boot.recovery=recovery
224
225
I:Update location: /cache/update.zip
226
E:Can't open /cache/update.zip
227
(No such file or directory)
228
mtd: successfully wrote block at bebe0f3800000000
229
I:Set boot command ""
230
I:Setting delta update status...
231
I:Delta update status is set to (IP_PREVIOUS_UPDATE_FAILED 410)
232
mtd: successfully wrote block at bebe23a000000000
233
I:Reset FOTA cookie done.
234
RB_Progress: fwrite "/dev/ttyGS1" fail
235
precent:0 total:1 cur:1
236
Rebooting after recovery
237
I:Rebooting at the end of recovery module.
238
mtd: successfully wrote block at bebe0f8000000000
239
I:Set boot command ""
240
</pre>
Add picture from clipboard (Maximum size: 48.8 MB)