Commit graph

547 commits

Author SHA1 Message Date
David Anderson
38b3c7a122 fastbootd: Add an update-super command to sync the super partition.
This change introduces an "update-super" command to the fastboot
protocol. Unlike the "flash" command, which copies raw or sparse data to
a partition, the "update-super" command requires the data to be a super
image generated by lpmake.

If the super partition is not yet formatted (or is corrupt), then it
will be formatted using the given image. Otherwise, "update-super" will
preserve the existing partition layout, and only ensure that logical
partition entries exist for all the new partitions in the given image.
All new partitions added this way will have a zero size, and it is the
host's responsibility to size them as needed afterwards with the
"resize-logical-partition" command.

In addition, the "update-super" command supports a "wipe" argument,
which will force the super partition to be reformatted with the given
image, overwriting any existing partition tables.

Bug: 78793464
Test: fastboot flashall with a super partition
Change-Id: If37d839a03e396e11b6c08a9c32984106613d1dc
2018-08-22 15:05:03 -07:00
Chris Fries
1572771495 Merge "Add support to fastboot_driver for sending sparse images with CRC check" 2018-08-22 18:39:16 +00:00
Aaron Wisner
9812b58fc4 Add support to fastboot_driver for sending sparse images with CRC check
The default argument will prevent anything from breaking

Test: Build on glinux
Change-Id: Ib427ab210476db1ec1c69c0a3238d0653e98b79a
2018-08-22 11:02:47 -05:00
Dario Freni
ab5583b585 s/product-services/product_services/g
Attempting to reduce the number of different spellings we have for
"product services" partition in the codebase.

Bug: 112431447
Test: m
Change-Id: I1a87d7e040a8b1f91f973ac7d90d6360b5b54f71
Merged-In: I1a87d7e040a8b1f91f973ac7d90d6360b5b54f71
2018-08-20 17:46:42 +00:00
David Anderson
79ab0e3e98 fastbootd: Complete the implementation of getvar has-slot.
Bug: 78793464
Test: fastboot getvar has-slot:super returns "no"
Change-Id: I80f171df062c008718b810bbe12070834d4aa3fb
2018-08-14 16:24:07 -07:00
David Anderson
3195e6edc3 Allow C++17 in fastboot.
Bug: N/A
Test: fastboot builds
Change-Id: Ife120dbe4f45e8aa83225978ea9d5e88bbb58b9e
2018-08-13 13:18:02 -07:00
Chris Fries
3b984c7efe Merge "Increase fastboot timeout to 30 seconds" 2018-08-13 14:58:34 +00:00
Aaron Wisner
50acca7226 Increase fastboot timeout to 30 seconds
Some OEM commands can take quite a while.
The current 10 second timeout is too small.

Test: fastboot tool
Change-Id: Icf59615919c92dc85807abe3ec5793504cf7a162
2018-08-10 17:44:28 -05:00
David Anderson
d9ba061e77 fastbootd: Add is-userspace variable.
Bug: 78793464
Test: fastboot getvar is-userspace
          returns true for fastbootd
      fastboot getvar is-userspace
          returns false or error for bootloader fastboot.

Change-Id: I80e1ef6dcf3922e4f555cb2e409e3e098c16fbbc
2018-08-09 15:06:53 -07:00
David Anderson
0d4277d7b3 fastbootd: Add commands for logical partitions.
This patch adds the following new commands to fastbootd:

    getvar is_logical:<partition>
    create-logical-logical-partition <partition> <size>
    delete-logical-partition <partition>
    resize-logicallogical-partition <partition> <size>

All of these commands operate on logical partitions only, and require a
properly configured "super" partition to operate.

Bug: 78793464
Test: fastboot create-logical-partition example 4096
      fastboot create-logical-partition example 4096 returns error
      fastboot getvar is-logical:example returns "yes"
      fastboot getvar partition-size:example returns "1000"
      fastboot resize-logicalpartition example 8000
      fastboot getvar partition-size:example returns "2000"
      fastboot delete-logical-partition example
      fastboot getvar is-logical:example returns error
      fastboot getvar is-logical:system_a returns "no"

Change-Id: Iff323eabcf5c559fa04c7c92574650b01803eb1f
2018-08-09 15:06:52 -07:00
David Anderson
88ef0b1f25 fastbootd: Add support for flashing logical partitions.
When flashing logical partitions, we read the "super" partition metadata
corresponding to the current slot. We then temporarily create a
device-mapper device for that partition, and immediately destroy the
device after all operations are complete. We do not mount partitions
ahead of time, or keep them mounted, because a fastboot operation may
change the layout of the logical partition table (or change which slot
is current).

Bug: 78793464
Test: fastboot flash a logical partition under "super"
Change-Id: Id2a61d3592decabeebfd283c4fd6e6cbe576a18c
2018-08-09 11:15:23 -07:00
David Anderson
12211d163e fastbootd: Enable erase and flash commands for physical partitions.
Bug: 78793464
Test: adb reboot fastboot && fastboot flashall

Change-Id: Ibe802c36f6efe20111a2315616ef34d3a027950f
2018-08-09 09:58:37 -07:00
Tao Bao
075c351af2 Merge "fastboot: fastbootd uses libadbd.so." 2018-08-09 16:31:29 +00:00
David Anderson
856b7ecbb6 fastbootd: Allow returning errors from getvar handlers.
Currently a few getvar handlers will return invalid strings when an
error occurs. This change allows those handlers to instead send a proper
failure message.

Bug: 78793464
Test: N/A
Change-Id: I7ff7d036c1e6fb0a3d700ecf21b1103ab77278d2
2018-08-08 18:24:09 -07:00
Tao Bao
b71eedf912 fastboot: fastbootd uses libadbd.so.
The size of `fastbootd` goes down from 64088-byte to 38488-byte
(aosp_taimen-userdebug) after the change.

Bug: 78793464
Test: `m -j installclean && m -j fastbootd`. Check that
      $OUT/recovery/root/system/lib64/libadbd.so exists and
      $OUT/recovery/root/system/bin/fastbootd depends on that.
Change-Id: Ic36c98da1a0dda4e0d86e671f858c42578f53f90
2018-08-08 15:54:48 -07:00
Hridya Valsaraju
31d2c26409 fastbootd: Implement the getvar command.
This implements basic "fastboot getvar" support, including commands supported
by IBootControl.

Bug: 78793464
Test: fastboot getvar <fastboot variable>

Change-Id: Iee1a7b3f43dea46f80dcdf73c45034e2ffe4727d
2018-08-08 11:41:53 -07:00
Treehugger Robot
6b0ecdab15 Merge "fastboot: Fix product-services typo" 2018-08-07 18:24:10 +00:00
David Anderson
8cdea7ff0c fastboot: Fix product-services typo
The build system generates a partition name of "product_services" for
the product-services partition, so fastboot's image list must reflect
this.

Bug: 78793464
Test: fastboot flash product_services works with fastbootd
Change-Id: I348f970c9584fd3dd4369e8cded66b6e39eee2b2
2018-08-07 09:29:11 -07:00
Xin Li
fb973d34ac Merge Android Pie into master
Bug: 112104996
Change-Id: Ib0e5b2801a931b469b753806b1fbe2fabb0c1de5
2018-08-06 17:26:31 -07:00
Treehugger Robot
c4630ef445 Merge "Allow existance of partition to be checked before flashall or update" 2018-08-07 00:20:46 +00:00
Treehugger Robot
c30a75a007 Merge "Add fastbootd." 2018-08-07 00:08:18 +00:00
Hridya Valsaraju
f1f0a9c8a5 Allow existance of partition to be checked before flashall or update
Bug: 112108453
Test: fastboot flashall with super.img and product-services.img in $OUT,
fastboot update with super.img and product-services.img in image.zip.

Change-Id: I5718b5e60c546c55af74292895b3f7fe169e4f02
2018-08-06 11:05:37 -07:00
Aaron Wisner
794fb0107b Merge "Minor fixes to fastboot_driver"
am: 8cf510ff81

Change-Id: I358512c168fbe19c164bb201cf57accdb613f1a3
2018-08-02 17:49:30 -07:00
Treehugger Robot
8cf510ff81 Merge "Minor fixes to fastboot_driver" 2018-08-03 00:41:16 +00:00
Aaron Wisner
c771ae0fd4 Minor fixes to fastboot_driver
- Make RCString() static
- Add clearer error message for 0 length upload error
- Fix regex hex matching for partition-size
- Move ZLP packet checking to SparseWriteCallback()

Test: build fastboot on glinux
Change-Id: I51a040e07b9698a41f64b35a9e2baa8d575527a9
2018-08-02 17:47:38 -05:00
Hridya Valsaraju
dea91b4b53 Add fastbootd.
Fastbootd is started by recovery, and communicates
over usb with the fastboot protocol.

Add additional fastboot commands to move in and out of
fastbootd. "fastboot reboot recovery" and "fastboot reboot fastboot"

Bug: 78793464
Test: fastboot reboot recovery, fastboot reboot fastboot
Change-Id: Iffb77b2d3ceefb7335c38aa9fba7bd17821484f0
2018-08-02 09:43:23 -07:00
Hridya Valsaraju
cb10dca496 Merge "Flash super partition with fastboot flashall"
am: 10601fd512

Change-Id: Ibd1b1ba6ccd16ff82c7c050fb6bdf0121e851268
2018-08-01 13:57:11 -07:00
Treehugger Robot
10601fd512 Merge "Flash super partition with fastboot flashall" 2018-08-01 20:47:53 +00:00
Hridya Valsaraju
94943ee331 Flash super partition with fastboot flashall
Bug: 111763923
Test: fastboot flashall
Change-Id: I9b89825bac00d1237972a61715da05f933ac35ce
2018-08-01 18:30:36 +00:00
Dario Freni
586282a771 Merge "Add product-services.img for fastboot flashall."
am: 8b8d7d67f2

Change-Id: I698a75c06e6041ddf403aba2ae5e894308bce2c3
2018-07-31 19:15:00 -07:00
Treehugger Robot
8b8d7d67f2 Merge "Add product-services.img for fastboot flashall." 2018-08-01 02:00:40 +00:00
Dario Freni
c7ea1afe90 Add product-services.img for fastboot flashall.
This CL is largely and adaptation of
Ifd119650dd3316508870df0dfc770099e95ae1d1

Bug: 80741439
Test: Successfully built product-services.img with one module in it, and
flashed on device. Also successfully built image with
/system/product-services and no dedicated /product-services partition.

Change-Id: I204a831e052d018018ab124d70ad1ff1610ee007
2018-08-01 00:08:52 +01:00
David Anderson
64465fde9f Merge "fastboot: Fix hang when sparse images end in small chunks."
am: d0d7d0a6b9

Change-Id: Ia98cc2ed8f09ad99aa8d00ba7edb16553827556c
2018-07-30 16:50:32 -07:00
David Anderson
0c7bde8de6 fastboot: Fix hang when sparse images end in small chunks.
When host fastboot sends sparse blocks to the device, it tries to only
send blocks in multiples of 1024 bytes. If a block is not aligned to this
size, the excess bytes are prepended to the next write operation. This
is implemented by doing the write in two steps: first the previous
excess from the last write (plus new data up to alignment), then a
second write for the aligned remainder of the new data.

This logic has a bug if the final block plus the previous excess data
contains >= 1024 but < 2048 bytes. In this case the first write will
drain 1024 bytes from the data, and the second write will not have 1024
bytes to write. Instead of retaining this data for the next write, it
tries to write 0 chunks (and thus 0 bytes), which hangs the ioctl() call.

Bug: N/A
Test: "fastboot flash super super.img" where super.img is generated by
      lpmake, containing system and product_services partitions and
      images.

Change-Id: I9e8523c976ec84d5a57b36a28f4b1ca800edb7e7
2018-07-30 14:48:13 -07:00
Chris Fries
c6e9a94ed0 Merge "Add support for fastboot transport timeouts and USB Reset() on linux"
am: d6f97d67e0

Change-Id: I3da3a3a9679c375572de0a35e40a86f9476918fa
2018-07-26 13:05:34 -07:00
Aaron Wisner
acf78d462f Add support for fastboot transport timeouts and USB Reset() on linux
USB Reset() allows simulating unplugging and replugging device.

Test: build and run fastboot on mac 10.13.3
Test: glinux build and run fastboot
Change-Id: Id924d063e549a4cca9dda03afd8f8fe266f6d2ab
2018-07-26 11:19:44 -05:00
Tobias Thierer
c526c79b37 Merge "Revert "Add derived UsbTransport class with USB reset method""
am: f6ee8fe515

Change-Id: Ia50999004b5505566051e3927daa646a2024687b
2018-07-25 08:34:14 -07:00
Tobias Thierer
f6ee8fe515 Merge "Revert "Add derived UsbTransport class with USB reset method"" 2018-07-25 15:24:54 +00:00
Tobias Thierer
ec1542f22d Revert "Add derived UsbTransport class with USB reset method"
This reverts commit ceb7cbf5fd.

Reason for revert: Broke mac builds:
system/core/fastboot/usb_osx.cpp:513:35: error: use of undeclared identifier 'USB_TRANSACTION_TIMEOUT'
USB_TRANSACTION_TIMEOUT, USB_TRANSACTION_TIMEOUT);
^

Change-Id: Ibe2f9ff2d5c63f9d33f4bd6d9ba962604cf8caeb
2018-07-25 10:41:24 +00:00
Chris Fries
34bdf4e824 Merge "Add derived UsbTransport class with USB reset method"
am: 56795ac483

Change-Id: I0203e059f415ee63600a7f55c42107c21569d96e
2018-07-24 12:41:55 -07:00
Chris Fries
56795ac483 Merge "Add derived UsbTransport class with USB reset method" 2018-07-24 19:30:02 +00:00
Aaron Wisner
ceb7cbf5fd Add derived UsbTransport class with USB reset method
For testing there needs to be a way to simulate unplugging and
replugging a device. This change adds support for a USB reset
method that does this.

Also add timeouts, so USB reads/writes don't block forever
on an unresponsive device.

Test: glinux, fastboot tool still works
Test: Reset confirmed working via wireshark Linux URB captures

Change-Id: I7213a2395d4ef1c0238810e4929ab966e78c8b55
2018-07-24 11:24:15 -05:00
Elliott Hughes
99fea016f4 Merge "fastboot: add tomcherry to OWNERS."
am: b13c49b1b0

Change-Id: I72b43f9e162a3e10fc92b9d5c7be8534ba3dfbdd
2018-07-20 17:11:09 -07:00
Treehugger Robot
b13c49b1b0 Merge "fastboot: add tomcherry to OWNERS." 2018-07-20 22:16:42 +00:00
Chris Fries
40cd9e03c9 Merge "Refactor libfastboot"
am: 767506fc5a

Change-Id: I1e20f30872969dd847fe67a23ebc5975dcb743e7
2018-07-20 14:06:46 -07:00
Chris Fries
767506fc5a Merge "Refactor libfastboot" 2018-07-20 20:52:58 +00:00
Elliott Hughes
4239aa7b75 fastboot: add tomcherry to OWNERS.
Bug: N/A
Test: N/A
Change-Id: Ie2a367b7fbf1dd5319a3506d09951d571512f438
2018-07-20 13:20:09 -07:00
Josh Gao
6a928587f8 Merge "fastboot: fix USB_TRACE, make it better."
am: a570644b7d

Change-Id: I1d88e012d14af45e5a7332a1f3f675132c1f8ed4
2018-07-20 13:10:13 -07:00
Treehugger Robot
a570644b7d Merge "fastboot: fix USB_TRACE, make it better." 2018-07-20 20:01:05 +00:00
Jim Tang
a3024ba1fa Merge "Adb and fastboot completion supports zsh users."
am: 74be24d696

Change-Id: I9cc9fdfe875479eb1f6aa2fce7b896fd9d656630
2018-07-20 03:36:23 -07:00