Merge lp:~cyphermox/phablet-tools/fastboot-flashing into lp:phablet-tools

Proposed by Mathieu Trudel-Lapierre
Status: Rejected
Rejected by: Sergio Schvezov
Proposed branch: lp:~cyphermox/phablet-tools/fastboot-flashing
Merge into: lp:phablet-tools
Diff against target: 156 lines (+56/-22)
1 file modified
phablet-flash (+56/-22)
To merge this branch: bzr merge lp:~cyphermox/phablet-tools/fastboot-flashing
Reviewer Review Type Date Requested Status
Sergio Schvezov Needs Information
PS Jenkins bot continuous-integration Approve
Review via email: mp+162424@code.launchpad.net

Commit message

Make phablet-flash allow flashing straight from the bootloader.

One should be able to simply reboot into the bootloader and run phablet-flash, and successfully detect the device product name and flash it with the correct image.

This slightly changes the behavior of "phablet-flash -b" to first reboot into the recovery image before pushing the image to be installed to userdata.

Description of the change

Make phablet-flash allow flashing straight from the bootloader.

One should be able to simply reboot into the bootloader and run phablet-flash, and successfully detect the device product name and flash it with the correct image.

This slightly changes the behavior of "phablet-flash -b" to first reboot into the recovery image before pushing the image to be installed to userdata.

At a minimum, this removes the requirement for an Android install to have developer settings and USB debugging enabled to be able to install the Ubuntu Touch image.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Sergio Schvezov (sergiusens) wrote :

Can't we make this the default bootstrapping method?

review: Needs Information
Revision history for this message
Sergio Schvezov (sergiusens) wrote :

also, why is the following needed?
143 + time.sleep(10)

fastboot does a wait for device on its own

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

ah, to list devices... shouldn't it be closer to where it is needed? And is 10 seconds a good number?

Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

Indeed it does, but this is in the recovery using adb.
On May 6, 2013 3:20 PM, "Sergio Schvezov" <email address hidden>
wrote:

> also, why is the following needed?
> 143 + time.sleep(10)
>
> fastboot does a wait for device on its own
> --
>
> https://code.launchpad.net/~mathieu-tl/phablet-tools/fastboot-flashing/+merge/162424
> You are the owner of lp:~mathieu-tl/phablet-tools/fastboot-flashing.
>

Unmerged revisions

87. By Mathieu Trudel-Lapierre

Add support for flashing from fastboot and recovery; make bootstrap reboot to recovery before pushing images.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'phablet-flash'
2--- phablet-flash 2013-04-24 19:09:49 +0000
3+++ phablet-flash 2013-05-03 17:27:25 +0000
4@@ -22,6 +22,7 @@
5 import requests
6 import subprocess
7 import tempfile
8+import time
9 from os import path
10 from phabletutils.adb import AndroidBridge
11 from phabletutils.downloads import DownloadManager
12@@ -62,6 +63,11 @@
13 use fastboot and are unlocked.''',
14 action='store_true',
15 )
16+ parser.add_argument('-f',
17+ '--fastboot',
18+ help='Specifies that the device should be flashed via fastboot.',
19+ action='store_true',
20+ )
21 group.add_argument('-D',
22 '--download-only',
23 help='''Download image only, but do not flash device.
24@@ -235,15 +241,30 @@
25
26
27 @adb_errors
28-def detect_device(adb, device=None):
29+def detect_device(adb, device=None, in_fastboot=False):
30 '''If no argument passed determine them from the connected device.'''
31- # Check CyanogenMod property
32- if not device:
33- device = adb.getprop('ro.cm.device').strip()
34- # Check Android property
35- if not device:
36- device = adb.getprop('ro.product.device').strip()
37- log.info('Device detected as %s' % device)
38+
39+ if in_fastboot:
40+ devices = subprocess.check_output('sudo fastboot devices',
41+ stderr=subprocess.STDOUT,
42+ shell=True)
43+ if devices == "":
44+ print ("No device connected in fastboot mode.")
45+ exit(1)
46+
47+ product_var = subprocess.check_output('sudo fastboot getvar product',
48+ stderr=subprocess.STDOUT,
49+ shell=True)
50+ device = product_var.split('\n')[0].split(' ')[1]
51+ else:
52+ # Check CyanogenMod property
53+ if not device:
54+ device = adb.getprop('ro.cm.device').strip()
55+ # Check Android property
56+ if not device:
57+ device = adb.getprop('ro.product.device').strip()
58+ log.info('Device detected as %s' % device)
59+
60 # property may not exist or we may not map it yet
61 if device not in settings.supported_devices:
62 log.error('Unsupported device, autodetect fails device')
63@@ -252,13 +273,14 @@
64
65
66 @adb_errors
67-def bootstrap(adb, files):
68+def bootstrap(adb, files, in_fastboot):
69 '''
70 Deploys device file using fastboot and launches recovery for ubuntu
71 deployment.
72 '''
73- adb.reboot(bootloader=True)
74- log.warning('The device needs to be unlocked for the following to work')
75+ if not in_fastboot:
76+ adb.reboot(bootloader=True)
77+ log.warning('The device needs to be unlocked for the following to work')
78
79 recovery_file = ''
80 for img in files.keys():
81@@ -277,7 +299,6 @@
82
83 log.info('Booting into recovery')
84 subprocess.check_call('sudo fastboot boot %s' % recovery_file, shell=True)
85- log.info('Once completed the device should reboot into Ubuntu')
86
87
88 def get_jenkins_build_id(uri):
89@@ -303,14 +324,21 @@
90
91
92 @adb_errors
93-def validate_device(adb):
94+def validate_device(adb, in_recovery):
95 '''
96 Validates if the image would be installable on the target
97 '''
98- df = adb.shell('df').split('\n')
99+ if in_recovery:
100+ df = adb.shell('df -h').split('\n')
101+ else:
102+ df = adb.shell('df').split('\n')
103 try:
104- free_data = map(str.split,
105- filter(lambda s: s.startswith('/data '), df))[0][3]
106+ if in_recovery:
107+ free_data = map(str.split,
108+ filter(lambda s: s.endswith(' /data\r'), df))[0][2]
109+ else:
110+ free_data = map(str.split,
111+ filter(lambda s: s.startswith('/data '), df))[0][3]
112 except IndexError:
113 log.error('Cannot find /data mountpoint')
114 exit(1)
115@@ -353,7 +381,7 @@
116 adb = AndroidBridge()
117 # Initializes the adb server if it is not running
118 adb.start()
119- device = detect_device(adb, args.device)
120+ device = detect_device(adb, args.device, args.fastboot)
121 if not args.series:
122 series = getattr(settings, 'default_series', None)
123 # Determine uri to download from
124@@ -386,7 +414,7 @@
125 ubuntu_img = string_format_img('ubuntu_file', series)
126 device_img = string_format_img('device_file', series, device)
127 download_list = [ubuntu_img]
128- if args.bootstrap:
129+ if args.bootstrap or args.fastboot:
130 for attr in ('device_file_img', 'recovery_file_img', 'boot_file_img'):
131 download_list.append(string_format_img(attr, series, device))
132 else:
133@@ -403,13 +431,19 @@
134 log.error('Error while downloading, ensure connection')
135 exit(1)
136 if not args.download_only:
137- if settings.validate_device:
138- validate_device(adb)
139- if args.bootstrap:
140+ if args.bootstrap or args.fastboot:
141+ bootstrap(adb, download_mgr.files, args.fastboot)
142+ log.info('Please wait while restarting into recovery...')
143+ time.sleep(10)
144+ if settings.validate_device:
145+ validate_device(adb, True)
146 push_for_autodeploy(adb,
147 download_mgr.files.get(ubuntu_img))
148- bootstrap(adb, download_mgr.files)
149+ adb.shell('/sbin/recovery')
150+ log.info('Once completed the device should reboot into Ubuntu')
151 else:
152+ if settings.validate_device:
153+ validate_device(adb, False)
154 recovery_file = create_recovery_file(adb,
155 download_mgr.files[device_img],
156 download_mgr.files[ubuntu_img],)

Subscribers

People subscribed via source and target branches