aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Android.mk3
-rw-r--r--heimdall/config.h79
-rw-r--r--heimdall/source/Android.mk38
-rw-r--r--heimdall/source/BridgeManager.cpp70
-rw-r--r--heimdall/source/BridgeManager.h8
-rw-r--r--heimdall/source/ClosePcScreenAction.cpp10
-rw-r--r--heimdall/source/DetectAction.cpp12
-rw-r--r--heimdall/source/DownloadPitAction.cpp12
-rw-r--r--heimdall/source/FlashAction.cpp12
-rw-r--r--heimdall/source/PrintPitAction.cpp12
10 files changed, 200 insertions, 56 deletions
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..ef9b4df
--- /dev/null
+++ b/Android.mk
@@ -0,0 +1,3 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(LOCAL_PATH)/heimdall/source/Android.mk
diff --git a/heimdall/config.h b/heimdall/config.h
new file mode 100644
index 0000000..2fef4fb
--- /dev/null
+++ b/heimdall/config.h
@@ -0,0 +1,79 @@
+/* config.h.in. */
+
+/* Define if building universal (internal helper macro) */
+#undef AC_APPLE_UNIVERSAL_BUILD
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#define HAVE_DLFCN_H
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H
+
+/* Define to 1 if you have the <stdint.h> header file. */
+// #undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H
+
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+ */
+#undef LT_OBJDIR
+
+/* Darwin backend */
+#if defined(__APPLE__)
+#define OS_DARWIN
+#elif defined(__linux__)
+/* Linux backend */
+#define OS_LINUX
+#else
+/* Windows backend */
+#define OS_WINDOWS
+#endif
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* Define to 1 if you have the ANSI C header files. */
+// #undef STDC_HEADERS
+
+/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
+ significant byte first (like Motorola and SPARC, unlike Intel). */
+#if defined AC_APPLE_UNIVERSAL_BUILD
+# if defined __BIG_ENDIAN__
+# define WORDS_BIGENDIAN 1
+# endif
+#else
+# ifndef WORDS_BIGENDIAN
+# undef WORDS_BIGENDIAN
+# endif
+#endif
diff --git a/heimdall/source/Android.mk b/heimdall/source/Android.mk
new file mode 100644
index 0000000..0851416
--- /dev/null
+++ b/heimdall/source/Android.mk
@@ -0,0 +1,38 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ Arguments.cpp \
+ ClosePcScreenAction.cpp \
+ DownloadPitAction.cpp \
+ FlashAction.cpp \
+ InfoAction.cpp \
+ PrintPitAction.cpp \
+ VersionAction.cpp \
+ BridgeManager.cpp \
+ DetectAction.cpp \
+ HelpAction.cpp \
+ Interface.cpp \
+ Utility.cpp \
+ main.cpp \
+ ../../libpit/Source/libpit.cpp
+
+LOCAL_C_INCLUDES := \
+ external/heimdall/libpit/Source \
+ external/libusbx/libusb
+
+LOCAL_STATIC_LIBRARIES := libusbx
+
+ifeq ($(HOST_OS),darwin)
+LOCAL_LDFLAGS := -framework CoreFoundation -framework IOKit
+endif
+
+ifeq ($(HOST_OS),linux)
+LOCAL_LDFLAGS := -lpthread -lrt
+endif
+
+LOCAL_MODULE := heimdall
+include $(BUILD_HOST_EXECUTABLE)
+
+$(call dist-for-goals,dist_files sdk,$(LOCAL_BUILT_MODULE))
diff --git a/heimdall/source/BridgeManager.cpp b/heimdall/source/BridgeManager.cpp
index b7bff3d..d9e6f06 100644
--- a/heimdall/source/BridgeManager.cpp
+++ b/heimdall/source/BridgeManager.cpp
@@ -366,7 +366,7 @@ BridgeManager::BridgeManager(bool verbose)
fileTransferPacketSize = kFileTransferPacketSizeDefault;
fileTransferSequenceTimeout = kFileTransferSequenceTimeoutDefault;
- usbLogLevel = UsbLogLevel::Default;
+ usbLogLevel = Default;
}
BridgeManager::~BridgeManager()
@@ -398,23 +398,23 @@ bool BridgeManager::DetectDevice(void)
// Setup libusb log level.
switch (usbLogLevel)
{
- case UsbLogLevel::None:
+ case None:
libusb_set_debug(libusbContext, LIBUSB_LOG_LEVEL_NONE);
break;
- case UsbLogLevel::Error:
+ case Error:
libusb_set_debug(libusbContext, LIBUSB_LOG_LEVEL_ERROR);
break;
- case UsbLogLevel::Warning:
+ case Warning:
libusb_set_debug(libusbContext, LIBUSB_LOG_LEVEL_WARNING);
break;
- case UsbLogLevel::Info:
+ case Info:
libusb_set_debug(libusbContext, LIBUSB_LOG_LEVEL_INFO);
break;
- case UsbLogLevel::Debug:
+ case Debug:
libusb_set_debug(libusbContext, LIBUSB_LOG_LEVEL_DEBUG);
break;
}
@@ -423,27 +423,51 @@ bool BridgeManager::DetectDevice(void)
struct libusb_device **devices;
int deviceCount = libusb_get_device_list(libusbContext, &devices);
+ bool detected = false;
for (int deviceIndex = 0; deviceIndex < deviceCount; deviceIndex++)
{
libusb_device_descriptor descriptor;
libusb_get_device_descriptor(devices[deviceIndex], &descriptor);
+ libusb_device *heimdallDevice = devices[deviceIndex];
+ libusb_ref_device(heimdallDevice);
+
for (int i = 0; i < BridgeManager::kSupportedDeviceCount; i++)
{
if (descriptor.idVendor == supportedDevices[i].vendorId && descriptor.idProduct == supportedDevices[i].productId)
{
- libusb_free_device_list(devices, deviceCount);
-
- Interface::Print("Device detected\n");
- return (true);
+ detected = true;
+ if (verbose)
+ {
+ unsigned char stringBuffer[128];
+ libusb_device_handle *deviceHandle;
+ int result = libusb_open(heimdallDevice, &deviceHandle);
+ if (result == LIBUSB_SUCCESS) {
+ if (libusb_get_string_descriptor_ascii(deviceHandle, descriptor.iSerialNumber,
+ stringBuffer, 128) >= 0)
+ {
+ Interface::Print("%s\n", stringBuffer);
+ }
+ else {
+ Interface::Print("unknown\n", stringBuffer);
+ }
+ libusb_close(deviceHandle);
+ }
+ }
}
}
+
+ libusb_unref_device(heimdallDevice);
}
libusb_free_device_list(devices, deviceCount);
- Interface::PrintDeviceDetectionFailed();
- return (false);
+ if (!detected)
+ Interface::PrintDeviceDetectionFailed();
+ else if (!verbose)
+ Interface::Print("Device detected\n");
+
+ return (detected);
}
int BridgeManager::Initialise(bool resume)
@@ -463,23 +487,23 @@ int BridgeManager::Initialise(bool resume)
// Setup libusb log level.
switch (usbLogLevel)
{
- case UsbLogLevel::None:
+ case None:
libusb_set_debug(libusbContext, LIBUSB_LOG_LEVEL_NONE);
break;
- case UsbLogLevel::Error:
+ case Error:
libusb_set_debug(libusbContext, LIBUSB_LOG_LEVEL_ERROR);
break;
- case UsbLogLevel::Warning:
+ case Warning:
libusb_set_debug(libusbContext, LIBUSB_LOG_LEVEL_WARNING);
break;
- case UsbLogLevel::Info:
+ case Info:
libusb_set_debug(libusbContext, LIBUSB_LOG_LEVEL_INFO);
break;
- case UsbLogLevel::Debug:
+ case Debug:
libusb_set_debug(libusbContext, LIBUSB_LOG_LEVEL_DEBUG);
break;
}
@@ -1235,7 +1259,7 @@ bool BridgeManager::SendFile(FILE *file, unsigned int destination, unsigned int
return (true);
}
-void BridgeManager::SetUsbLogLevel(UsbLogLevel usbLogLevel)
+void BridgeManager::SetUsbLogLevel(int usbLogLevel)
{
this->usbLogLevel = usbLogLevel;
@@ -1243,23 +1267,23 @@ void BridgeManager::SetUsbLogLevel(UsbLogLevel usbLogLevel)
{
switch (usbLogLevel)
{
- case UsbLogLevel::None:
+ case None:
libusb_set_debug(libusbContext, LIBUSB_LOG_LEVEL_NONE);
break;
- case UsbLogLevel::Error:
+ case Error:
libusb_set_debug(libusbContext, LIBUSB_LOG_LEVEL_ERROR);
break;
- case UsbLogLevel::Warning:
+ case Warning:
libusb_set_debug(libusbContext, LIBUSB_LOG_LEVEL_WARNING);
break;
- case UsbLogLevel::Info:
+ case Info:
libusb_set_debug(libusbContext, LIBUSB_LOG_LEVEL_INFO);
break;
- case UsbLogLevel::Debug:
+ case Debug:
libusb_set_debug(libusbContext, LIBUSB_LOG_LEVEL_DEBUG);
break;
}
diff --git a/heimdall/source/BridgeManager.h b/heimdall/source/BridgeManager.h
index 840fb5e..867bfa3 100644
--- a/heimdall/source/BridgeManager.h
+++ b/heimdall/source/BridgeManager.h
@@ -85,7 +85,7 @@ namespace Heimdall
kDefaultTimeoutEmptyTransfer = 100
};
- enum class UsbLogLevel
+ enum UsbLogLevel
{
None = 0,
Error,
@@ -131,7 +131,7 @@ namespace Heimdall
unsigned int fileTransferPacketSize;
unsigned int fileTransferSequenceTimeout;
- UsbLogLevel usbLogLevel;
+ int usbLogLevel;
int FindDeviceInterface(void);
bool ClaimDeviceInterface(void);
@@ -165,9 +165,9 @@ namespace Heimdall
bool SendFile(FILE *file, unsigned int destination, unsigned int deviceType, unsigned int fileIdentifier = 0xFFFFFFFF) const;
- void SetUsbLogLevel(UsbLogLevel usbLogLevel);
+ void SetUsbLogLevel(int usbLogLevel);
- UsbLogLevel GetUsbLogLevel(void) const
+ int GetUsbLogLevel(void) const
{
return usbLogLevel;
}
diff --git a/heimdall/source/ClosePcScreenAction.cpp b/heimdall/source/ClosePcScreenAction.cpp
index 16e30aa..a38f68c 100644
--- a/heimdall/source/ClosePcScreenAction.cpp
+++ b/heimdall/source/ClosePcScreenAction.cpp
@@ -64,23 +64,23 @@ int ClosePcScreenAction::Execute(int argc, char **argv)
if (usbLogLevelString.compare("none") == 0 || usbLogLevelString.compare("NONE") == 0)
{
- usbLogLevel = BridgeManager::UsbLogLevel::None;
+ usbLogLevel = BridgeManager::None;
}
else if (usbLogLevelString.compare("error") == 0 || usbLogLevelString.compare("ERROR") == 0)
{
- usbLogLevel = BridgeManager::UsbLogLevel::Error;
+ usbLogLevel = BridgeManager::Error;
}
else if (usbLogLevelString.compare("warning") == 0 || usbLogLevelString.compare("WARNING") == 0)
{
- usbLogLevel = BridgeManager::UsbLogLevel::Warning;
+ usbLogLevel = BridgeManager::Warning;
}
else if (usbLogLevelString.compare("info") == 0 || usbLogLevelString.compare("INFO") == 0)
{
- usbLogLevel = BridgeManager::UsbLogLevel::Info;
+ usbLogLevel = BridgeManager::Info;
}
else if (usbLogLevelString.compare("debug") == 0 || usbLogLevelString.compare("DEBUG") == 0)
{
- usbLogLevel = BridgeManager::UsbLogLevel::Debug;
+ usbLogLevel = BridgeManager::Debug;
}
else
{
diff --git a/heimdall/source/DetectAction.cpp b/heimdall/source/DetectAction.cpp
index 2139b27..a0b9e6e 100644
--- a/heimdall/source/DetectAction.cpp
+++ b/heimdall/source/DetectAction.cpp
@@ -57,7 +57,7 @@ int DetectAction::Execute(int argc, char **argv)
const StringArgument *usbLogLevelArgument = static_cast<const StringArgument *>(arguments.GetArgument("usb-log-level"));
- BridgeManager::UsbLogLevel usbLogLevel = BridgeManager::UsbLogLevel::Default;
+ BridgeManager::UsbLogLevel usbLogLevel = BridgeManager::Default;
if (usbLogLevelArgument)
{
@@ -65,23 +65,23 @@ int DetectAction::Execute(int argc, char **argv)
if (usbLogLevelString.compare("none") == 0 || usbLogLevelString.compare("NONE") == 0)
{
- usbLogLevel = BridgeManager::UsbLogLevel::None;
+ usbLogLevel = BridgeManager::None;
}
else if (usbLogLevelString.compare("error") == 0 || usbLogLevelString.compare("ERROR") == 0)
{
- usbLogLevel = BridgeManager::UsbLogLevel::Error;
+ usbLogLevel = BridgeManager::Error;
}
else if (usbLogLevelString.compare("warning") == 0 || usbLogLevelString.compare("WARNING") == 0)
{
- usbLogLevel = BridgeManager::UsbLogLevel::Warning;
+ usbLogLevel = BridgeManager::Warning;
}
else if (usbLogLevelString.compare("info") == 0 || usbLogLevelString.compare("INFO") == 0)
{
- usbLogLevel = BridgeManager::UsbLogLevel::Info;
+ usbLogLevel = BridgeManager::Info;
}
else if (usbLogLevelString.compare("debug") == 0 || usbLogLevelString.compare("DEBUG") == 0)
{
- usbLogLevel = BridgeManager::UsbLogLevel::Debug;
+ usbLogLevel = BridgeManager::Debug;
}
else
{
diff --git a/heimdall/source/DownloadPitAction.cpp b/heimdall/source/DownloadPitAction.cpp
index 841afd2..7c58b91 100644
--- a/heimdall/source/DownloadPitAction.cpp
+++ b/heimdall/source/DownloadPitAction.cpp
@@ -78,7 +78,7 @@ int DownloadPitAction::Execute(int argc, char **argv)
const StringArgument *usbLogLevelArgument = static_cast<const StringArgument *>(arguments.GetArgument("usb-log-level"));
- BridgeManager::UsbLogLevel usbLogLevel = BridgeManager::UsbLogLevel::Default;
+ BridgeManager::UsbLogLevel usbLogLevel = BridgeManager::Default;
if (usbLogLevelArgument)
{
@@ -86,23 +86,23 @@ int DownloadPitAction::Execute(int argc, char **argv)
if (usbLogLevelString.compare("none") == 0 || usbLogLevelString.compare("NONE") == 0)
{
- usbLogLevel = BridgeManager::UsbLogLevel::None;
+ usbLogLevel = BridgeManager::None;
}
else if (usbLogLevelString.compare("error") == 0 || usbLogLevelString.compare("ERROR") == 0)
{
- usbLogLevel = BridgeManager::UsbLogLevel::Error;
+ usbLogLevel = BridgeManager::Error;
}
else if (usbLogLevelString.compare("warning") == 0 || usbLogLevelString.compare("WARNING") == 0)
{
- usbLogLevel = BridgeManager::UsbLogLevel::Warning;
+ usbLogLevel = BridgeManager::Warning;
}
else if (usbLogLevelString.compare("info") == 0 || usbLogLevelString.compare("INFO") == 0)
{
- usbLogLevel = BridgeManager::UsbLogLevel::Info;
+ usbLogLevel = BridgeManager::Info;
}
else if (usbLogLevelString.compare("debug") == 0 || usbLogLevelString.compare("DEBUG") == 0)
{
- usbLogLevel = BridgeManager::UsbLogLevel::Debug;
+ usbLogLevel = BridgeManager::Debug;
}
else
{
diff --git a/heimdall/source/FlashAction.cpp b/heimdall/source/FlashAction.cpp
index d9203b0..66588da 100644
--- a/heimdall/source/FlashAction.cpp
+++ b/heimdall/source/FlashAction.cpp
@@ -426,7 +426,7 @@ int FlashAction::Execute(int argc, char **argv)
const StringArgument *usbLogLevelArgument = static_cast<const StringArgument *>(arguments.GetArgument("usb-log-level"));
- BridgeManager::UsbLogLevel usbLogLevel = BridgeManager::UsbLogLevel::Default;
+ BridgeManager::UsbLogLevel usbLogLevel = BridgeManager::Default;
if (usbLogLevelArgument)
{
@@ -434,23 +434,23 @@ int FlashAction::Execute(int argc, char **argv)
if (usbLogLevelString.compare("none") == 0 || usbLogLevelString.compare("NONE") == 0)
{
- usbLogLevel = BridgeManager::UsbLogLevel::None;
+ usbLogLevel = BridgeManager::None;
}
else if (usbLogLevelString.compare("error") == 0 || usbLogLevelString.compare("ERROR") == 0)
{
- usbLogLevel = BridgeManager::UsbLogLevel::Error;
+ usbLogLevel = BridgeManager::Error;
}
else if (usbLogLevelString.compare("warning") == 0 || usbLogLevelString.compare("WARNING") == 0)
{
- usbLogLevel = BridgeManager::UsbLogLevel::Warning;
+ usbLogLevel = BridgeManager::Warning;
}
else if (usbLogLevelString.compare("info") == 0 || usbLogLevelString.compare("INFO") == 0)
{
- usbLogLevel = BridgeManager::UsbLogLevel::Info;
+ usbLogLevel = BridgeManager::Info;
}
else if (usbLogLevelString.compare("debug") == 0 || usbLogLevelString.compare("DEBUG") == 0)
{
- usbLogLevel = BridgeManager::UsbLogLevel::Debug;
+ usbLogLevel = BridgeManager::Debug;
}
else
{
diff --git a/heimdall/source/PrintPitAction.cpp b/heimdall/source/PrintPitAction.cpp
index 7ae8e6b..8e33126 100644
--- a/heimdall/source/PrintPitAction.cpp
+++ b/heimdall/source/PrintPitAction.cpp
@@ -73,7 +73,7 @@ int PrintPitAction::Execute(int argc, char **argv)
const StringArgument *usbLogLevelArgument = static_cast<const StringArgument *>(arguments.GetArgument("usb-log-level"));
- BridgeManager::UsbLogLevel usbLogLevel = BridgeManager::UsbLogLevel::Default;
+ BridgeManager::UsbLogLevel usbLogLevel = BridgeManager::Default;
if (usbLogLevelArgument)
{
@@ -81,23 +81,23 @@ int PrintPitAction::Execute(int argc, char **argv)
if (usbLogLevelString.compare("none") == 0 || usbLogLevelString.compare("NONE") == 0)
{
- usbLogLevel = BridgeManager::UsbLogLevel::None;
+ usbLogLevel = BridgeManager::None;
}
else if (usbLogLevelString.compare("error") == 0 || usbLogLevelString.compare("ERROR") == 0)
{
- usbLogLevel = BridgeManager::UsbLogLevel::Error;
+ usbLogLevel = BridgeManager::Error;
}
else if (usbLogLevelString.compare("warning") == 0 || usbLogLevelString.compare("WARNING") == 0)
{
- usbLogLevel = BridgeManager::UsbLogLevel::Warning;
+ usbLogLevel = BridgeManager::Warning;
}
else if (usbLogLevelString.compare("info") == 0 || usbLogLevelString.compare("INFO") == 0)
{
- usbLogLevel = BridgeManager::UsbLogLevel::Info;
+ usbLogLevel = BridgeManager::Info;
}
else if (usbLogLevelString.compare("debug") == 0 || usbLogLevelString.compare("DEBUG") == 0)
{
- usbLogLevel = BridgeManager::UsbLogLevel::Debug;
+ usbLogLevel = BridgeManager::Debug;
}
else
{