Partition size is calculated as block count times a block size of 512
for DeviceType 2 and 4096 for DeviceType 8.
Flashing stock android on some devices fail due to some partitions
being too small for the corresponding file. This is the case on
klimtlte (and other exynos5420 devices), where sboot.bin does not fit
into the BOOTLOADER partition.
Tests done:
* Flash stock android (A500FXXS1CSB2) to a5lte, works fine
* Flash stock android (I9300XXUGPE1) to i9300, works fine
* Flash stock android (I9505XXUPQG1) to i9505, works fine
* Flash stock android (G930FXXU8ETI2) to herolte (with block
size 4096), works fine
* Flash stock android (T705XXU1CPL1) to klimtlte, fails due to
BOOTLOADER partition being smaller than sboot.bin, the file has a
size of 1148160, and the partition 2046*512=1047552
The unknown string is "COM_TAR2" in all devices I have access to. The
last unknown 4 bytes might be some sort of version, in old devices it
is 0000, in Galaxy S6 0003, in Galaxy S7 and S8 0004 and in Galaxy S9
and tab S6 lite 0005.
The CPU/bootloader string looks something like:
* LSI5410 - Seen in Exynos 5420, 5433 devices (and perhaps others)
* LSI7420 - Seen in Exynos 7420, 8890, 8895 devices (and perhaps others)
* LSI7880 - Seen in a5y17lte (exynos 7880)
* LSI9610 - Seen in gta4xl (exynos 9611)
* LSI9810 - Seen in star2lte (exynos 9810)
* Mx - Seen in Galaxy S3 (device codename is m0/m3)
* MSM8916 - Seen in MSM8916 devices
* MSM8960 - Seen in jflte (and probably in others, jflte has a APQ8064AB CPU)
Carrying around this (now outdated) driver in the repo seems
unnecessary. Windows users can download latest from
https://zadig.akeo.ie/downloads/ instead.
Testing on 32bit arm have weird issues where the build failed if
run/continued without configuring again.
With these scripts we also require less files, no .c files in cmake/.
One downside is that we now require at least Visual Studio
2005 (MSVCR80) for compiling on windows (and there's no check for this
currently).
We should only need to define it for old versions of MSVC. On linux
it seems that defining nullptr does not really have any downsides, but
on android we get some obscure compiler errors due to how nullptr is
defined. Fix nullptr check and thereby make heimdall compile on
android.
Error message looked something like:
[ 6%] Building CXX object libpit/CMakeFiles/pit.dir/source/libpit.cpp.o
In file included from /data/data/com.termux/files/home/Heimdall/libpit/source/libpit.cpp:22:
In file included from /data/data/com.termux/files/home/Heimdall/libpit/source/libpit.h:38:
In file included from /data/data/com.termux/files/usr/include/c++/v1/string:504:
In file included from /data/data/com.termux/files/usr/include/c++/v1/string_view:175:
In file included from /data/data/com.termux/files/usr/include/c++/v1/__string:57:
In file included from /data/data/com.termux/files/usr/include/c++/v1/algorithm:643:
/data/data/com.termux/files/usr/include/c++/v1/memory:2268:9: error: cannot initialize a member subobject of type 'libpit::PitEntry **' with an rvalue of type 'int'
: __value_(_VSTD::forward<_Up>(__u))
^ ~~~~~~~~~~~~~~~~~~~~~~~~
/data/data/com.termux/files/usr/include/c++/v1/memory:2353:9: note: in instantiation of function template specialization 'std::__compressed_pair_elem<libpit::PitEntry **, 0, false>::__compressed_pair_elem<int, void>' requested here
: _Base1(std::forward<_U1>(__t1)), _Base2(std::forward<_U2>(__t2)) {}
^
/data/data/com.termux/files/usr/include/c++/v1/vector:436:7: note: in instantiation of function template specialization 'std::__compressed_pair<libpit::PitEntry **, std::allocator<libpit::PitEntry *>>::__compressed_pair<int, std::__default_init_tag>' requested here
__end_cap_(nullptr, __default_init_tag())
^
/data/data/com.termux/files/usr/include/c++/v1/vector:495:5: note: in instantiation of member function 'std::__vector_base<libpit::PitEntry *, std::allocator<libpit::PitEntry *>>::__vector_base' requested here
vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
^
/data/data/com.termux/files/home/projects/Heimdall/libpit/source/libpit.cpp:65:10: note: in instantiation of member function 'std::vector<libpit::PitEntry *>::vector' requested here
PitData::PitData()
^
Some (older) devices seem to have a problem with this:
https://github.com/Benjamin-Dobell/Heimdall/issues/497
As far as I can see from logs, alt_setting is always 0, so with this
change libusb_set_interface_alt_setting will probably never be run.
tests: flash and boot recovery onto SM-G955
Heimdall fails to handshake with device on my Linux installation:
Initialising protocol...
ERROR: libusb error -7 whilst sending bulk transfer. Retrying...
ERROR: libusb error -7 whilst sending bulk transfer. Retrying...
ERROR: libusb error -7 whilst sending bulk transfer. Retrying...
ERROR: libusb error -7 whilst sending bulk transfer. Retrying...
ERROR: libusb error -7 whilst sending bulk transfer. Retrying...
ERROR: libusb error -7 whilst sending bulk transfer.
ERROR: Failed to send handshake!
ERROR: Failed to receive handshake response. Result: -7
ERROR: Protocol initialisation failed!
However, with the same USB cable, port and device, Heimdall
successfully handshake with the device on Windows via WinUSB.
This indicates handling of USB devices of host (AMD X570) on
Linux might lead to undesired results. Though, without further
testing, the interference from userspace (Ubuntu 20.04, KDE) can
not be ruled out.
Thus, this patch calls libusb_reset_device to ensure
the USB port is in a clean state before we send the data.
Fixes issues with newer devices and hosts.
Signed-off-by: Jesse Chan <jc@linux.com>
Use QRandomGenerator instead. Fixes compilation warning:
/home/grimler/Heimdall/heimdall-frontend/source/Packaging.cpp: In static member function ‘static QString HeimdallFrontend::Packaging::ClashlessFilename(const QList<HeimdallFrontend::FileInfo>&, const QString&)’:
/home/grimler/Heimdall/heimdall-frontend/source/Packaging.cpp:910:34: warning: ‘int qrand()’ is deprecated: use QRandomGenerator instead [-Wdeprecated-declarations]
910 | filename.append(QChar(qrand() % ('Z' - 'A' + 1) + 'A'));
| ^
In file included from /usr/include/qt/QtCore/qchar.h:43,
from /usr/include/qt/QtCore/qstring.h:49,
from /usr/include/qt/QtCore/qdatetime.h:44,
from /usr/include/qt/QtCore/QDateTime:1,
from /home/grimler/Heimdall/heimdall-frontend/source/Packaging.cpp:32:
/usr/include/qt/QtCore/qglobal.h:1274:80: note: declared here
1274 | Q_CORE_EXPORT QT_DEPRECATED_VERSION_X_5_15("use QRandomGenerator instead") int qrand();
| ^~~~~
Use QString::asprintf instead. Fixes compilation warning:
/home/grimler/Heimdall/heimdall-frontend/source/mainwindow.cpp: In member function ‘void HeimdallFrontend::MainWindow::StartFlash()’:
/home/grimler/Heimdall/heimdall-frontend/source/mainwindow.cpp:925:53: warning: ‘QString& QString::sprintf(const char*, ...)’ is deprecated: Use asprintf(), arg() or QTextStream instead [-Wdeprecated-declarations]
925 | flag.sprintf("--%u", fileInfos[i].GetPartitionId());
| ^
In file included from /usr/include/qt/QtCore/qcoreapplication.h:44,
from /usr/include/qt/QtCore/QCoreApplication:1,
from /home/grimler/Heimdall/heimdall-frontend/source/mainwindow.cpp:22:
/usr/include/qt/QtCore/qstring.h:393:14: note: declared here
393 | QString &sprintf(const char *format, ...) Q_ATTRIBUTE_FORMAT_PRINTF(2, 3);
|
The former is deprecated. Fixes compilation warning:
/home/grimler/Heimdall/heimdall/source/BridgeManager.cpp: In member function ‘bool Heimdall::BridgeManager::DetectDevice()’:
/home/grimler/Heimdall/heimdall/source/BridgeManager.cpp:402:57: warning: ‘void libusb_set_debug(libusb_context*, int)’ is deprecated: Use libusb_set_option instead [-Wdeprecated-declarations]
402 | libusb_set_debug(libusbContext, LIBUSB_LOG_LEVEL_NONE);
| ^
In file included from /home/grimler/Heimdall/heimdall/source/BridgeManager.cpp:25:
/usr/include/libusb-1.0/libusb.h:1352:18: note: declared here
1352 | void LIBUSB_CALL libusb_set_debug(libusb_context *ctx, int level);
| ^~~~~~~~~~~~~~~~
Revert "Updated README.md so the README[.txt] links point to the gitlab version, rather than the broken gituser links they were pointing to."
This reverts commit af5b574042.