Commit Graph

208 Commits (60ab9bbaffe31f5072195f0dcf352d6e1037bc85)

Author SHA1 Message Date
Henrik Grimler 60ab9bbaff
FlashAction: Make sure file fit partition before flashing
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
2021-12-16 16:05:42 +01:00
Henrik Grimler e51c9119f1
libpit: describe more parts of pit header
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)
2021-12-16 16:01:18 +01:00
Henrik Grimler 31745c287a
libpit: add DeviceType = 8 entry for MMC with blksize 4096
Newer devices have an emmc with 4096 block size instead of 512.  These
seem to have DeviceType=8 instead of DeviceType=2.
2021-12-16 16:01:15 +01:00
Henrik Grimler cedfcd8c80
win32: remove zadig.exe from repo
Carrying around this (now outdated) driver in the repo seems
unnecessary. Windows users can download latest from
https://zadig.akeo.ie/downloads/ instead.
2021-12-14 11:22:04 +01:00
Henrik Grimler 6441c6a6c5
Remove some extra whitespace and convert some spaces to tabs 2021-12-10 09:46:30 +01:00
Henrik Grimler af87b7b7e4
cmake: replace LFS check with scripts from wireshark
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).
2021-12-10 09:46:24 +01:00
Henrik Grimler 761c2db4d2
cmake: set -std=c+++11 with target_compile_features instead 2021-12-10 09:46:17 +01:00
Henrik Grimler 719edaff9e
heimdall, libpit: fix (MSVC) nullptr check
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()
         ^
2021-11-25 21:26:37 +01:00
Henrik Grimler f0594beaf6
builds: test build for ubuntu 20.04 as well 2021-11-22 17:26:43 +01:00
Henrik Grimler 2ecc98020c
BridgeManager: skip libusb_set_interface_alt_setting if altsetting=0
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
2021-11-22 16:25:45 +01:00
Henrik Grimler 6317e88503 */README: replace http with https in urls 2021-06-15 11:29:49 +02:00
Henrik Grimler 74c498d61e builds: add more (build) dependencies on alpine and arch 2021-06-15 11:29:25 +02:00
Henrik Grimler f3bdacf03d CI: test build heimdall on alpine and archlinux
Using sourcehuts build service builds.sr.ht.
2021-06-15 10:46:43 +02:00
Henrik Grimler 53466cbd51 gitignore: ignore *~ as well 2021-06-15 10:46:25 +02:00
Henrik Grimler df83a4b010 CMakeLists: update usb library variable
It was renamed in the update of the Findlibusb cmake module.
2021-06-06 20:37:55 +02:00
Henrik Grimler 64bd479db6 cmake: update Findlibusb.cmake
This one adds support for more platforms (like freebsd) out of the
box, so that those distros do not need to patch the module.
2021-05-29 20:26:37 +02:00
Henrik Grimler 4fadfe9c5d heimdall: cmake: do not set libusb_USE_STATIC_LIBS
It does not have an effect, heimdall is dynamically linked in any
case.
2021-05-29 19:32:05 +02:00
Henrik Grimler 82f7241133 Use https in urls and link to libusb instead of libusbx 2021-05-29 16:54:04 +02:00
Jesse Chan 07a14d4aa8 InitialiseProtocol: reset device before handshake
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>
2021-05-03 22:38:41 +02:00
Henrik Grimler 6d17eb5178 heimdall-frontend: Remove one indentation level from Packaging
In the two variants of Packaging::ClashlessFilename.
2021-05-03 14:53:19 +02:00
Henrik Grimler 54d58b8244 README: re-format, re-phrase supported platform section
And use https for external links.
2021-05-03 14:53:19 +02:00
Romain Hunault 6ede1f1f33 Fix macOS issues
[ Taken from https://gitlab.e.foundation/e/tools/heimdall/-/tree/new_master ]
2021-05-03 14:53:19 +02:00
Henrik Grimler af3f0d6ac9 Convert all files to unix line endings
All except Win32/README.txt.
2021-05-03 14:24:06 +02:00
Henrik Grimler ccafa21e64 heimdall-frontend: fix deprecated use of qrand()
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();
      |                                                                                ^~~~~
2021-05-03 14:24:06 +02:00
Henrik Grimler 220f90a4fe heimdall-frontend: fix deprecated use of sprintf
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);
      |
2021-05-03 14:24:06 +02:00
Henrik Grimler 094f715c4d heimdall: BridgeManager: libusb_set_debug->libusb_set_option
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);
      |                  ^~~~~~~~~~~~~~~~
2021-05-03 14:23:40 +02:00
Henrik Grimler 9bff064d40 CMake: bump minimum version
Mostly because 2.8.4 will be deprecated in the not too far future
2021-05-03 14:07:33 +02:00
fft 92ea948323 fixup! heimdall: Fix flashing firmwares bigger than 3.5GB
Fix show progress percentage for big files.
2021-05-03 14:04:53 +02:00
Mallon Lobjakas c87f5bf210 heimdall: Fix flashing firmwares bigger than 3.5GB 2021-05-03 14:04:53 +02:00
Rudolf Tammekivi bfe1a68512 heimdall: Odin protocol version 4 support 2021-05-03 14:04:53 +02:00
Benjamin Dobell f6b618c435 Back to Github
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.
2021-05-03 13:49:24 +02:00
Benjamin Dobell a2cfdaa5ed Merge branch 'patch-1' into 'master'
Updated README.md so the README[.txt] links point to the gitlab version, rather…

See merge request BenjaminDobell/Heimdall!472
2018-07-30 04:14:51 +00:00
Kenneth Swarthout af5b574042 Updated README.md so the README[.txt] links point to the gitlab version, rather than the broken gituser links they were pointing to. 2018-07-29 05:47:06 +00:00
Benjamin Dobell 5377b6286c
Merge pull request #438 from 414n/cmake-install-targets
Added install targets
2017-11-11 01:34:24 +11:00
Alan 4a9259b477 Added install targets 2017-11-10 15:25:08 +01:00
Benjamin Dobell 9bcc42da35 Merge pull request #408 from grayed/master
Use library found instead of hardcoding compiler flag.
2017-09-20 12:05:45 +10:00
Vadim Zhukov cc44b3497d Use library found instead of hardcoding compiler flag.
Fixes build on OpenBSD.
2017-07-30 06:42:06 +03:00
Benjamin Dobell 3b4f34e2a9 Minor typo. I'm sure there are more. 2017-05-12 05:13:08 +10:00
Benjamin Dobell 699549e3c6 Bumped version to 1.4.2 2017-05-12 04:34:25 +10:00
Benjamin Dobell 663bb80f22 Merge branch 'tflash' 2017-05-12 04:34:19 +10:00
Benjamin Dobell bf891c9366 Refactor T-Flash implementation before merging. 2017-05-12 04:32:20 +10:00
Benjamin Dobell 8709370bc4 It's 2017. Where did the years go? 2017-05-12 03:47:37 +10:00
Benjamin Dobell 5b90f09625 A modern README 2017-05-12 03:47:19 +10:00
Frédéric Basse aa40b07450 allow higher timeout when switching to t-flash due to sd card initialization 2016-12-24 18:55:56 +01:00
Frédéric Basse 259f5f8973 add T-Flash option in FlashAction 2016-12-24 14:33:39 +01:00
Benjamin Dobell b6fe7f8535 Revert "Merge pull request #355 from ljani/master"
This reverts commit 9784dd2e2a, reversing
changes made to 7ebee1e877.
2016-07-20 16:11:53 +10:00
Benjamin Dobell 9784dd2e2a Merge pull request #355 from ljani/master
Use the found libusb
2016-07-18 12:28:48 +10:00
Jani d2e2f76556 Use the found libusb 2016-07-17 23:37:28 +03:00
Benjamin Dobell 7ebee1e877 Merge pull request #333 from kratz00/superfluous_semicolon
- removed superfluous semicolons from namespace definitions
2016-04-02 00:49:09 +11:00
Steffen Pankratz e8a77e6686 - removed superfluous semicolons from namespace definitions 2016-03-06 16:31:00 +01:00