269 Commits

Author SHA1 Message Date
Steve Moskovchenko
6eeb866b15 vip: Fix integer underflow in digest count
If no table(s) of digests have been found, we'll hit an
integer underflow while trying to clean up n-1 table
entries. Fix that.

Signed-off-by: Steve Moskovchenko <stevemo@skydio.com>
Signed-off-by: Jerry Zhang <Jerry@skydio.com>
v2.4
2025-12-18 18:52:57 -08:00
Bjorn Andersson
b4030fabe6 usb: Fix checkpatch warning about unnecessary parenthesis
Checkpatch was warning about unnecessary parenthesis in the change to
the ZLP handling, but Github apparently doesn't highlight warnings.

Fix this to avoid leaving the building with broken windows.

Fixes: b9ad4ceaf8 ("firehose/usb: Explicitly handle ZLP on USB read transfers")
Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
2025-12-16 16:37:59 -08:00
Bjorn Andersson
a10cf7f5da firehose: Increase image write timeout to 60 seconds
The somewhat arbitrary timeout of 30 seconds was chosen by observing a
worst case time of ~15 seconds when flashing Hamoa and Nord. But, as
reported, flashing SAIL on Nord sometimes needs this timeout to be ~35
seconds.

While the relationship between the different factors and the needed
timeout isn't fully understood, bump the value to 60 seconds to make it
work for this case as well.

Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
2025-12-16 16:31:36 -08:00
Bjorn Andersson
e033f0f205 github: Resolve liblzma-related failure in Windows builds
The Windows builds suddenly fails with:
  Cannot find path 'C:\a\_temp\msys64\mingw64\bin\liblzma-5.dll' because it does not exist.

The internet indicates that this is caused by the lack of
mingw-w64-x86_64-xz, so let's introduce this.

Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
2025-12-16 16:05:57 -08:00
Loic Poulain
b9ad4ceaf8 firehose/usb: Explicitly handle ZLP on USB read transfers
The assumption that every other Firehose read transfer is null is
incorrect. A Zero-Length Packet (ZLP) is only sent when the received
transfer size is a multiple of the USB IN endpoint's Max Packet Size.
This is a way for the device to indicated end-of-transfer.

Unconditionally expecting an empty packet was not an issue with USB 2.0,
where the typical 512-byte sector size matches the bulk IN endpoint's
Max Packet Size. However, with USB SuperSpeed (Max Packet Size = 1024),
attempting to read an empty packet after a 512/1024-byte transfer is
unnecessary and fails (timeout), resulting in errors during storage
device sector size discovery:
```
waiting for programmer...
qdl: failed to read: Resource temporarily unavailable
```

Fix and move ZLP handling to bus-specific code (usb.c).

Reported-by: Danilo Leo <d.leo@arduino.cc>
Signed-off-by: Loic Poulain <loic.poulain@oss.qualcomm.com>
2025-12-16 14:20:22 -08:00
Bjorn Andersson
516a75ff89 Merge pull request #156 from ykaire-qti/empty-filename
Check for empty patch filenames.
2025-12-03 14:57:17 -06:00
Bjorn Andersson
a88edc58ed Merge pull request #158 from jcreedon/add_slot
firehose: Add slot flag
2025-11-27 11:49:33 -06:00
Bjorn Andersson
bd656a50a0 Merge pull request #160 from igoropaniuk/sign-compare
Address more -Wsign-compare issues
2025-11-27 11:48:49 -06:00
Igor Opaniuk
a3f6c1a569 Address more -Wsign-compare issues
Address more signedness/unsignedness issues, like:

../sahara.c: In function ‘sahara_debug64_one’:
../qdl.h:20:12: warning: comparison of integer expressions of different
   signedness: ‘long unsigned int’ and ‘int’ [-Wsign-compare]
   20 |         _x < _y ? _x : _y;      \
      |            ^
../sahara.c:286:26: note: in expansion of macro ‘MIN’
  286 |                 remain = MIN((uint64_t)(region.length - chunk), DEBUG_BLOCK_SIZE);
      |                          ^~~
../qdl.h:20:24: warning: operand of ‘?:’ changes signedness from ‘int’ to
  ‘long unsigned int’ due to unsignedness of other operand [-Wsign-compare]
   20 |         _x < _y ? _x : _y;      \

../gpt.c: In function ‘gpt_find_by_name’:
../gpt.c:255:65: warning: comparison of integer expressions of different
  signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
  255 |                 if (*phys_partition >= 0 && gpt_part->partition != *phys_partition)

Now tools are built without any warnings when -Wsign-compare is enabled.

Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
2025-11-27 15:26:26 +01:00
Yvonne Kaire
a3436e2b0a Ignore patches with empty filenames.
Some device builds include patches with empty filenames. This change adds a check to ignore those patches and prevent segmentation faults.
This approach ensures consistency with other Qualcomm tools, which also ignore such patches.

Signed-off-by: Yvonne Kaire <ykaire@qti.qualcomm.com>
2025-11-26 11:10:29 -08:00
Jacob Creedon
a3ec7fd90b firehose: Add slot flag
For SoCs that support multiple UFS devices, firehose allows the slot property. This adds a flag to set the slot parameter.

Signed-off-by: Jacob Creedon <jcreedon@gmail.com>
2025-11-26 11:03:19 -08:00
Bjorn Andersson
2db10bd0c6 Merge pull request #159 from igoropaniuk/integer_issues
[housekeeping] Integer-related compiler warnings
2025-11-26 09:56:20 -06:00
Igor Opaniuk
95e2a0d3a3 Address warnings for integer expressions of different signedness
Address warnings for comparisons of integer expressions of different
signedness, for example:

../firehose.c:384:31: warning: comparison of integer expressions of
   different signedness: ‘int’ and ‘long unsigned int’ [-Wsign-compare]
  384 |                 for (i = 0; i < ARRAY_SIZE(sector_sizes); i++) {

In all places, where signed value is casted to unsigned (size_t for
instance), there is always explicitly handling of possible negative
value beforehand

Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
2025-11-25 14:09:56 +01:00
Igor Opaniuk
db8c0c8819 vip: address always false warning
Address always false warning ([-Wtype-limits]):
../vip.c:430:15: warning: comparison of unsigned expression in ‘< 0’ is
  always false [-Wtype-limits]
  430 |         if (n < 0) {
      |               ^
../vip.c:437:15: warning: comparison of unsigned expression in ‘< 0’
  is always false [-Wtype-limits]
  437 |         if (n < 0) {

Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
2025-11-25 14:09:51 +01:00
Konrad Dybcio
661ca1cba2 Merge pull request #157 from igoropaniuk/housekeeping_readme
README/CI updates/improvements
2025-11-20 13:01:02 +01:00
Igor Opaniuk
7206903f43 README: move info about man pages to a separate section
Since manual pages can be generated on all systems
(Linux, Mac, Windows(MSYS)), move this step to a separate section.

Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
2025-11-20 12:57:22 +01:00
Igor Opaniuk
b1d46164e3 github: add step for man page generation
Add a step for generating manual pages using recently added `manpages`
target in [1].

[1] commit 0a3c1175bd ("Add 'manpages' as new target to generate manpages by help2man")
Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
2025-11-20 12:39:48 +01:00
Igor Opaniuk
6b4a0adc3c README: add git to Windows build instructions
In [1] the git package is listed as a required package, add it to
the build instructions for Windows.

[1] commit 09a4f034b0 ("github: Get --version working for Windows build")
Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
2025-11-20 12:39:44 +01:00
Bjorn Andersson
80108974cf Merge pull request #154 from quic-bjorande/for-linux-msm/multi-programmer
Support for uploading multiple Sahara images to reach the Firehose stage.
2025-11-19 15:45:16 -06:00
Bjorn Andersson
57b7b56ebe README: Document the multi-image support
Document the three new mechanisms for providing multiple Sahara images
to QDL, in order to handle targets that needs to download multiple
images in order to enter Firehose mode.

Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
2025-11-18 15:10:03 -06:00
Bjorn Andersson
406ede8e14 qdl: Also support Sahara config XML documents
Flattened METAs contains the relevant programmer files, as well as a
special "sahara_config" XML file, which specifies the Sahara images and
their image ids.

Support populating the Sahara images array from this XML file as well,
to make it easy to flash this type of builds.

Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
2025-11-18 15:10:03 -06:00
Bjorn Andersson
4bdcaaec1a qdl: Support for "programmer archives"
Providing a long list of Sahara image ids and their respective payload
filename is cumbersome and error prone.

Introduce support for loading a "programmer archive", a CPIO archive
containing the list of Sahara images. The Sahara image id is read from
the filename of each file in the archive, and should be provided in the
form "<id>[:<filename>]".

Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
2025-11-18 15:10:03 -06:00
Bjorn Andersson
5b768d8be0 qdl: Allow multiple Sahara images
Some newer targets, such as Kaanapali, is requesting multiple images
from Sahara on the path to reach Firehose mode.

Extend the handling of the "programmer" argument to allow specifying a
comma-separated, colon-separated list of "<id>:<filename>" entries, to
specify the filenames for each of the image ids to be provided.

Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
2025-11-18 14:49:58 -06:00
Bjorn Andersson
ff260604e7 sahara: Load programmer at parse time
Lugging around the filename of the to-be-loaded Sahara image(s) prevents
us from (in a later patch) load the programmer payload from an archive.

So move the loading of the specified programmer image(s) to parse time
and hold each one in memory instead.

While doing this, move the "mappings" array (i.e. the list of Sahara
images) to the stack instead, as it was already being passed as a
parameter to the relevant function(s).

sahara_run() is also extended to provide debug information about which
images are being presented to the device.

Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
2025-11-18 14:49:54 -06:00
Roger Shimizu
0a3c1175bd Add 'manpages' as new target to generate manpages by help2man
* Makefile: `make manpages` generates the manpages.
* Makefile: `make clean` purges the generated manpages.
* .gitignore: Add generated manpages files.
* README.md: Add description how to make manpages for Linux.

Signed-off-by: Roger Shimizu <rosh@debian.org>
2025-11-18 14:24:02 -06:00