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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
* 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>