Commit graph

65 commits

Author SHA1 Message Date
Ying Wang
71edfc8b9a Also archive adb.exe/fastboot.exe when building win_sdk.
On linux we archive both Linux and Windows binaries.

Bug: 27315911
Change-Id: I17d25cd1ea611a9c917f1e78b47f21a8959eea20
2016-02-29 19:27:06 -08:00
David Pursell
4601c978ca fastboot: add UDP protocol.
Implements a UDP protocol for fastboot, documented in
fastboot_protocol.txt.

This version of the protocol does not include multi-packet windowing,
which will likely be needed to achieve reasonable speeds over WiFi.
Since we don't have any WiFi use cases yet, we'd like to get this in
now and update the protocol later if it becomes necessary.

Usage:
  fastboot -s udp:<hostname>[:port] <command>

Bug: http://b/26154914
Change-Id: Ia5bbae6bcd6405671f594d7120b3994746d234d3
2016-02-10 10:21:30 -08:00
David Pursell
2ec418a4c9 fastboot: add TCP protocol.
This CL implements a TCP protocol for use with fastboot. Protocol
description is given in fastboot_protocol.txt, some examples of
expected behavior can also be found in tcp_test.cpp.

Usage is:
  fastboot -s tcp:<hostname>[:port] <command>

Bug: http://b/26558551
Change-Id: If53a514a534489c617db32c4fea8819949121282
2016-02-03 13:57:45 -08:00
David Pursell
b34e4a06ee libcutils/fastboot: improve multi-buffer write.
Fixes libcutils multi-buffer write interface to be more friendly and
hooks into it from the fastboot Socket class.

Bug: http://b/26558551
Change-Id: Ibb3a8428fc379755602de52722c1260f9e345bc0
2016-02-03 10:01:38 -08:00
David Pursell
c3a466960f fastboot: socket testing improvements.
(This code was originally part of a huge fastboot CL but has been split
out to try to make the CLs a little more manageable).

More prep for fastboot TCP and UDP implementations. This CL adds a
SocketMock class that makes it easy to mock out network behavior so we
can unit test the TCP and UDP protocols.

Also uses the new libcutils socket_get_local_port() to avoid hardcoding
a server port in unit tests.

Bug: http://b/26157893.
Change-Id: I1ba10f31e98d7349313fc15f240383d63378a8db
2016-02-02 11:29:10 -08:00
David Pursell
572bce2908 fastboot: use cutils socket functions.
Now that cutils has cross-platform socket functionality, we can
restructure fastboot to remove platform-dependent networking code.

This CL adds socket_set_receive_timeout() to libcutils and combines the
fastboot socket code into a single implementation. It also adds TCP
functionality to fastboot sockets, but nothing uses it yet except for
the unit tests. A future CL will add the TCP protocol which will use
this TCP socket implementation.

Bug: http://b/26558551

Change-Id: If613fb348f9332b31fa2c88d67fb1e839923768a
2016-01-21 09:53:11 -08:00
David Pursell
0eb8e1b706 libcutils: share Windows networking code.
This CL moves Windows networking code from fastboot to libcutils so
that it can be shared with other host programs such as adb.

Not all libcutils networking functions have been implemented for
Windows, just those necessary for fastboot. In the next CL I will do
the same for adb, adding any additional required functions.

Unit tests have also been added to test the functions using a loopback
connection.

Bug: http://b/26236380.
Change-Id: Ibc51a67030fe69a04c23512eefa9d19b055c7c12
2016-01-15 15:57:35 -08:00
David Pursell
815c7beae7 fastboot: implement UDP networking interface.
This CL creates a UdpSocket class that provides a simple unified
interface to send and receive UDP packets for all platforms. Nothing
uses this interface yet except for tests.

The eventual goal is to implement a UDP protocol for fastboot, but it
makes the code much simpler and more modular if we handle the low-level
networking here independently of our custom fastboot protocol.

Some of the Windows code is similar to adb. I'd like to create a
library to hold the common functionality, but it is going to be a
little delicate to separate out the features unique to adb (e.g. the
custom file descriptor system), and I don't want to risk breaking
something in adb before the holiday break, so I'm hoping to get this in
for now and merge them early next year.

Tests are included in this CL to exercise this functionality using a
loopback connection.

Bug: http://b/26154763.
Tests: `fastboot_test` loopback tests on Linux, Mac, and Windows 7.
Change-Id: I81d1b7ace8d864246b99f6c80b8e29f64b8aa375
2015-12-16 16:16:08 -08:00
Elliott Hughes
1b708d368f Share the new adb USB diagnostic code with fastboot.
Bug: http://b/26134129
Change-Id: Ieaf0651c7b3f8a028760982091ec63a21a5484ba
2015-12-14 10:50:21 -08:00
David Pursell
0b15663830 fastboot: create Transport object (take 2).
(Second upload of this CL; original upload had the wrong version of
usb_windows.cpp that caused a compilation error. Fixed error and
re-tested.)

This CL creates a Transport object to provide a generic interface for
various transports. Specifically this is designed to be able to add UDP
support to fastboot in an upcoming CL without changing the main program
logic.

Also includes some minor code style fixes and replaces malloc/free
in the USB implementation files with smart pointers and std::string.

Bug: http://b/22029765
Change-Id: I1175bbce08690fbd15f51e68166be9b3e9973ea0
2015-11-16 09:31:07 -08:00
David Pursell
c0504e1873 Revert "fastboot: create Transport object."
This broke some stuff, will look into it Monday.

This reverts commit 6f233a7799.

Change-Id: I155bc85d21fda3b0ba1e5e17839059797fb15509
2015-11-14 00:15:57 +00:00
David Pursell
6f233a7799 fastboot: create Transport object.
This CL creates a Transport object to provide a generic interface for
various transports. Specifically this is designed to be able to add UDP
support to fastboot in an upcoming CL without changing the main program
logic.

Also includes some minor code style fixes and replaces malloc/free
in the USB implementation files with smart pointers and std::string.

Bug: http://b/22029765
Change-Id: I68641af0da7d13db4647f5e20a18d04d67f0b327
2015-11-13 11:08:17 -08:00
Elliott Hughes
c1fd492ac5 Revert "Revert "adb/base: fix adb push of Unicode filenames on Win32""
This reverts commit cc8cd59456.

With the dependency on libcutils (for gettid for non-bionic) removed,
this no longer breaks the build.

Change-Id: I645bd6876e2502ddc1535b69af1e645c0df9d178
2015-11-11 18:23:00 -08:00
Elliott Hughes
cc8cd59456 Revert "adb/base: fix adb push of Unicode filenames on Win32"
This reverts commit ac9514a452.

The new gettid dependency caused other breakage.

Change-Id: I74a75e40c30a45beb275f9dd38eb5c7beac15fbd
2015-11-11 18:01:12 +00:00
Spencer Low
ac9514a452 adb/base: fix adb push of Unicode filenames on Win32
ae5a6c06cd made adb push use
android::base::ReadFileToString() for small files, but that API did not
support UTF-8 filenames on Windows, until this fix which does the
following:

- Add android::base::{WideToUTF8,UTF8ToWide}() which are only available
  on Windows. The signatures are based on Chromium's APIs of the same
  name.

- Add the namespace android::base::utf8 which has versions of APIs that
  take UTF-8 strings. To use this, make sure your code is in a namespace
  and then do "using namespace android::base::utf8;". On Windows, this will
  make calls to open() call android::base::utf8::open(), and on other
  platforms, it will just call the regular ::open().

- Make ReadFileToString() and WriteStringToFile() use utf8::open() and
  utf8::unlink().

- Adapt unittests from Chromium.

- fastboot needs to link with libcutils because it links with libbase
  which depends on libcutils for gettid() for logging.

Change-Id: I1aeac40ff358331d7a1ff457ce894bfb17863904
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
2015-11-10 15:48:54 -08:00
Dan Willemsen
87a419c8b1 Remove USE_MINGW/CYGWIN; Whitelist windows modules
CYGWIN is not supported, USE_MINGW and HOST_OS==windows are being
replaced with LOCAL_..._windows variables.

Bug: 23566667
Change-Id: I3e4a1e4097dc994cf5abdce6939e83a91758fd75
2015-09-02 17:10:35 -07:00
Elliott Hughes
75d47421d0 Merge "Move fastboot's Windows code to C++." 2015-06-24 19:30:58 +00:00
Elliott Hughes
20750ad823 Move fastboot's Mac OS code to C++.
Change-Id: I4f452860a401a115b6e8349237923949f2f476d1
2015-06-24 11:17:28 -07:00
Elliott Hughes
c636b64e31 Move fastboot's Windows code to C++.
Change-Id: I92414594cbdbc1896402c6d950d890042f8df6cf
2015-06-24 10:48:43 -07:00
Elliott Hughes
b3748de33f Move fastboot to C++.
Minimal conversion.

Change-Id: I32cbf125be481a8757720d10fa303c38a7fd5e38
2015-06-23 20:56:01 -07:00
Narayan Kamath
f6e9ffbc73 Fix file descriptor leak when opening invalid archives.
Also add -Wunreachable-code to the set of compiler flags, otherwise
noreturn becomes considerably less useful.

bug: https://code.google.com/p/android/issues/detail?id=171099
Change-Id: I9a95d45633c731c7046d4e4a39844d9cebfd1718
(cherrypick of 241bcf05e0e394bbf2681f359f52646dd6c707f6.)
2015-06-03 12:16:43 -07:00
Elliott Hughes
379646b2ca Add "fastboot --version".
So bug reporters can actually tell us what they're running.

Bug: http://b/21583225
Change-Id: If2a4ae97b4792aa321566603ce2c354a72d32307
2015-06-02 13:50:00 -07:00
Narayan Kamath
e97e66ea7c Use base::WriteFully in zip_archive.
We're already linking against libbase but we'll have to add
a libbase dependency to every target that includes libziparchive
as a STATIC_LIBRARY dependency, given that there's no way to
express that what we want (except by adding a LOCAL_WHOLE_STATIC_LIBRARY
dependency on libbase to libziparchive but that seems bad too)

Change-Id: I294ad389a9c61a1134a7bc323da25b0004a8f1e0
2015-04-29 14:31:45 +00:00
Colin Cross
dc1e482b20 Fix windows adb build
libc++ is not available on windows yet, but it already defaults to
static libstdc++.

Change-Id: I85a766ead84f71fe1f2f59be6ac739b0b833b6db
2015-04-20 12:43:02 -07:00
Colin Cross
55bf5f0017 statically link adb and fastboot against libc++
libc++.so is not widely available on the host, so we compile against
one built as part of the platform.  This causes problems for adb and
fastboot, which are distributed through a number of channels - the
sdk, distro packages, downloaded from the build server, or manually
copied.  Instead of forcing all users to handle libc++.so too,
statically link against libc++.

Change-Id: I51b75258653a23558c8b598802005f6c1166a439
2015-04-16 17:09:46 -07:00
Elliott Hughes
d30ad8a2ee Switch fastboot to libziparchive.
Bug: 19765860
Change-Id: I83ea56e3b317893995d7106852b65584f99c0e64
2015-03-18 23:23:11 -07:00
Elliott Hughes
253c18d2fb Prepare for switching to libziparchive.
Bug: 19765860
Change-Id: I58249d28fbc4975428d0dcac5107d1994c35676c
2015-03-18 22:47:54 -07:00
Yabin Cui
71a968602d kill libunz
Bug: 18571533
Change-Id: I4214f9236f80629152d969a6ee9fce489079cefa
2014-12-09 22:24:07 -08:00
Stephen Hines
1e95e0b19c am 64f44b84: Merge "Remove obsolete reference to ddk; Fixes for -Werror" into lmp-dev
* commit '64f44b8444dabd69cf391d42e10d44e8e926a79d':
  Remove obsolete reference to ddk; Fixes for -Werror
2014-10-01 23:21:09 +00:00
Andrew Hsieh
b75d6f1429 Remove obsolete reference to ddk; Fixes for -Werror
Bug: 14416410

1. The new mingw-w64 toolchain x86_64-w64-mingw32-4.8 has ddk
   in x86_64-w64-mingw32/include/ddk
2. Add -Wno-error=cpp to suppress a warning that turns into error
   thanks to -Werror:

      Please include winsock2.h before windows.h
3. Cast GetLastError() return type DWORD to "int"
4. Include direct.h for _mkdir
5. Include stdint.h for uint8_t on Windows

Change-Id: I4bec0587f6573692f08c760da6c98ae551b8b5eb
2014-09-30 02:24:07 -07:00
Tim Murray
b2e13ae4fe am 3a5f3db2: am c894ced1: Merge "Fix fastboot for Darwin."
* commit '3a5f3db2aa5324518eb71c69cd1fb3e2125cbd43':
  Fix fastboot for Darwin.
2014-07-25 02:38:02 +00:00
Tim Murray
bd87944805 Fix fastboot for Darwin.
bug 16172793

Change-Id: Ib58446effc13a6e465d176da141b025d36841b8f
2014-07-24 19:27:37 -07:00
JP Abgrall
188fdd1c0f Merge "fastboot: Allow searching for needed dynamic libs in '.' (F2FS)" 2014-06-19 20:37:59 +00:00
JP Abgrall
436abebf8c fastboot: Allow searching for needed dynamic libs in '.' (F2FS)
Currently the default rpath includes $ORIGIN/../lib
So we throw in '.' which should help distributions of fastboot.

readelf -d $(which fastboot)|grep RPATH
 0x0000000f (RPATH) Library rpath: [$ORIGIN/../lib:.]

Bug: 15731906
Change-Id: I2f4345d178e5b3c87f6f159faf105ae30f3b52eb
Signed-off-by: JP Abgrall <jpa@google.com>
2014-06-19 14:47:19 -07:00
Ying Wang
6b048ce839 Store libf2fs_fmt_host_dyn on the build server.
It will be dynamically loaded by fastboot.

Bug: 15731906
Change-Id: Iff6f2b745b4ffd2c5fe343160b3efb8dcd5702fa
2014-06-19 14:44:23 -07:00
JP Abgrall
64c0ff21e4 fastboot: correctly set dependency on f2fs dynamic lib
In the past it would incorrectly also link against the dlopen()'d lib.

Now it clearly does not care about it.

ldd $(which fastboot)
        linux-gate.so.1 =>  (0xf7735000)
        libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xf76d9000)
        libstdc++.so.6 => /usr/lib/i386-linux-gnu/libstdc++.so.6 (0xf75f4000)
        libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xf75c7000)
        libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1 (0xf75a9000)
        libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xf73ff000)
        /lib/ld-linux.so.2 (0xf7736000)

Bug: 15717498
Change-Id: I5465e97a445b17f5493a1f590e181ef98a382451
Signed-off-by: JP Abgrall <jpa@google.com>
2014-06-18 11:13:05 -07:00
Torne (Richard Coles)
11d8ac2afb Only try and use f2fs on linux.
F2FS was already disabled on windows, but the library doesn't build for
mac either, so only try and use it on Linux hosts.

Change-Id: I8bacfa4c01c9ee13123aef6d05d17b3f9094c765
2014-06-18 13:48:38 +01:00
JP Abgrall
6bd72beff6 fastboot: fix windows sdk build (don't do f2fs dyn load on windows)
Only do f2fs dynamic loading on linux.
Adds a stub for windows builds.

Change-Id: I7bbaaa1b2ff5992709d904b7ace40ae263d32922
Signed-off-by: JP Abgrall <jpa@google.com>
2014-06-17 23:43:18 -07:00
JP Abgrall
1235158c29 F2FS support for fastboot format and fsmgr
- Enables fsck.f2fs for partitions with type F2FS.
- Adds support for f2fs as format fs-type.
- f2fs is optional and support is dlopen()d when needed.

Needs changes in
  system/extras/f2fs_utils
  external/f2fs-tools

Change-Id: I8d141a0d4d14df9fe84d3b131484e9696fcd8870
Signed-off-by: JP Abgrall <jpa@google.com>
2014-06-17 17:01:14 -07:00
Mark Salyzyn
5957c1ffe7 fastboot: turn on -Werror
- Deal with a missing initializer issue
- Deal with some -Wunused issues
- Deal with some signed/unsigned issues
- switch to usleep from sleep to facilitate win_sdk compile

Change-Id: I64e32a5b0782aeed9582f489e866173c4df1afbf
2014-05-14 08:33:56 -07:00
Dmitry Grinberg
e6f3e9bd26 fastboot: allow format on devices with small buffers
Formatting large partitions on devices with small transfer buffers did
not work before since format used a strange path through the code to
send data. It now uses the normal path. Also cleaned up a bit. FS
code now lives in a separate file and the custom path for format is
gone.

Change-Id: If4e01cabc2e250b7c02ca7ce8c268e51d49e1529
2014-05-06 12:28:37 -07:00
Elliott Hughes
14e28d39f7 Fix a bunch of small system/core bugs.
Missing frees in:
  adb/file_sync_client.c
  fastboot/fastboot.c
  libsparse/output_file.c

Missing closedirs in:
  adb/file_sync_service.c
  cpio/mkbootfs.c
  libcutils/dir_hash.c

Potential buffer overrun in:
  gpttool/gpttool.c

Incorrect NULL check in:
  libsparse/backed_block.c

Bug: https://code.google.com/p/android/issues/detail?id=61564
Change-Id: If97838a9e73a77aef7f416c31c237ce1fca4ce21
2013-10-29 14:12:46 -07:00
Mark Wachsler
157b00171a Wait for device to disappear after reboot-bootloader.
(Linux only for now) With fastboot reading serial numbers from sysfs, it had
become possible for a fastboot command issued immediately after rebooting
the bootloader to fail, because sysfs still thought the device was online.
To prevent this, after reboot-bootloader we wait for the device to disconnect.

Also made usb_read and usb_write fail immediately if the descriptor has been
closed; this prevents an incorrect error message ("Bad file descriptor")
when errors from fb_getvar are ignored (e.g., by fb_format_supported).

Also removed unused fd param from filter_usb_device, and simplified logic
in usb_write by using do/while instead of a special case for len == 0.

Change-Id: I799b857eab411fd8ad25f5777fc61c685152ea86
2013-10-17 20:06:32 +00:00
Kenny Root
efb5e3c709 resolved conflicts for merge of 20f5daa8 to master
Change-Id: Ie3e67696d265a56dfa4d089c777506f27783a9a6
2012-10-16 18:00:29 -07:00
Kenny Root
20f5daa865 resolved conflicts for merge of 44f4f8a4 to jb-mr1-dev-plus-aosp
Change-Id: I66988d8e87a8110ca9ab3da19870b80bbaf06eba
2012-10-16 17:51:14 -07:00
Kenny Root
b83c09812f Remove HAVE_SELINUX guards
Change-Id: Idef0a784a1d237257ff4135bb1df62ff8a67ded3
2012-10-16 12:34:06 -07:00
Kenny Root
d5d6d97def Host builds: add fastboot and adb
Add fastboot and adb host utilities to debug builds for debugging
and development purposes.

Change-Id: If77699a27497b8641998930f14d4ee418b856080
2012-09-26 10:01:40 -07:00
Ying Wang
96535ba620 Dist fastboot and adb for the sdk build.
So they can be downloaded from the build page.
Bug: 7109694

Change-Id: Ibc60d0acbc5d2445c01010fd0bd4654a240b0a88
2012-09-05 10:26:43 -07:00
Joe Onorato
5069b01e21 Support for multiple modules with the same name is going away.
Change-Id: I5006b467978071f9107babe532efa71d05061580
2012-08-15 19:52:52 -07:00
Joe Onorato
2ffe3c8ac4 libext4_utils on host is now called libext4_utils_host so there is no name conflict
Change-Id: Ibc7923676925ed6942b3f672ee764cfaa98ee96e
2012-08-15 19:52:52 -07:00