If for any reasons git describe does not work (git not installed, or
not running from a git workspace), set VERSION to unknown-version.
Signed-off-by: Nicolas Dechesne <nicolas.dechesne@oss.qualcomm.com>
In order to implement a proper versioning scheme, let's generate a
version.h file that defines VERSION variable built from git
workspace. The version format will be
v<MAJOR>.<MINOR>-<COMMIT##>-<SHA1>
Where:
* MAJOR and MINOR are from the most recent tag
* COMMIT## is the number of commits since last tag, to ensure
incremental numbering
* SHA1 is an abbreviated representation of the actual commit SHA.
This requires building from a git workspace, with we are effectively
calling 'git describe' during the build.
We then define print_version() utility function to be used by all
programs.
Ensure that util.c depends on version.h and that we only update
version.h timestamps when the version actually changes to avoid
unnecessary rebuilds.
Signed-off-by: Nicolas Dechesne <nicolas.dechesne@oss.qualcomm.com>
On some platforms, we support Boot LUN redundancy, with the boot
partitions duplicated on more than 1 LUN. Only 1 LUN can be boot
active at any time, but the platform can switch on reboot in case of
corruption. As such, when flashing a full system, we end up flashing
boot partition on several LUN, and the "first" LUN with SBL or XBL
will be used as the initial/primary boot device for the
setbootablestoragedrive command.
Up until this commit we displayed an error message in this situation,
but let's turn that into an ux_info() log instead, since it's not an
error.
Signed-off-by: Nicolas Dechesne <nicolas.dechesne@oss.qualcomm.com>
It is a valid use case to flash a single partition (such as CDT) with
QDL. In such a case when we are not flashing the entire image, we
effectively are not flashing any 'boot' partition (SBL, XBL, ...), and
we don't need to send the setbootablestoragedrive command to the
programmer. Currently we display the 'no boot partition found' message
which is confusing for users, as it looks like an error message even
though it's not. Let's turn this message into a debug log message
instead.
Signed-off-by: Nicolas Dechesne <nicolas.dechesne@oss.qualcomm.com>
Not providing any user feedback during flashing is not very user
friendly, in particular when, in some situations, it can take minutes to
flash very large files.
Introduce a progress bar for the flashing and patching steps to provide
such feedback to the user, when stdout is determined to be a terminal of
sufficient size (i.e. tools programmatically invoking qdl should see no
difference).
Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
QDL uses a few different styles when printing logs for the user,
with some inconsistencies, some errors, and some room for improvement.
Revisit all the ux_xyz() invocations to clean up the output from the
tool.
Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
Rather than sprinkling the user experience decisions across the
implementation with prints to stdout, stderr, conditional checks for
qdl_debug etc, consolidate these into a single set of ux wrappers.
Transition all callers of printf() and fprintf() to these new wrappers,
without changing the level of content of the printouts.
Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
Builds with multiple copies of the primary bootloader does not make
sense, but after successfully flashing all the partitions of such build
it makes more sense to make one of them bootable, at least more than
skipping the step and saying that none was found.
Pick the first found primary bootloader and warn the user about the
situation.
Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
In a few places in firehose.c the memory returned from xmlGetProp() is
leaked. Avoid this by freeing it.
Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
In the event that no ramdump_path is provided to sahara_run() the
ramdump_dir will remain -1. For good hygiene avoid calling close() on
this invalid file descriptor.
Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
Valgrind correctly reports that the write of 0x30 bytes accesses
uninitialized stack space. Pad the Sahara HELLO request and response
with the expected "reserved" entries to reach the defined 0x30 bytes to
avoid sending random stack content to the device.
Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
The XML parsing helpers turns libxml strings into standard C-types and
leaks the libxml memory. Fix this by freeing the libxml strings once
they are accessed.
Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
For each <program/> entry int he list, a scratch buffer of "max payload
size" is allocated, and lost. Free this memory instead.
Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
Continuing the journey to make QDL not leak any memory on a successful
run, introduce operations to free the program and patch objects on
exit.
Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
Every time the USB code attempts to identify and possibly open the EDL
USB device, the libusb device descriptor-object is leaked.
While at it, also introduce qdl_close() to clean up the overall state,
in order to approach not leaking memory in a clean QDL run.
Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
WriteBooster is a new feature added in UFS3.1. There are new
paramaters in the UFS header config. Trying to provision a 3.1+ device
without these parameters fail.
Also make sure that we don't send them on older devices.
Signed-off-by: Nicolas Dechesne <nicolas.dechesne@oss.qualcomm.com>
--serial and --out-chunk-size are parameters which were added recently
to qdl, but the print_usage() function was not updated accordingly.
Signed-off-by: Nicolas Dechesne <nicolas.dechesne@oss.qualcomm.com>
v2 has been deprecated for a while now, and generates a bunch of
warnings each time an action is executed.
Signed-off-by: Nicolas Dechesne <nicolas.dechesne@oss.qualcomm.com>
During the introduction of UFS provisioning, the author left behind an
additional safety measure of forcing the user to explicitly modify the
source and recompile QDL in order to be able to lock the provisioning,
to avoid users accidentally doing so.
While it does reduce the risk of irreversable mistakes, it's not
suitable when QDL is distributed as a binary - and the user already need
to set bConfigDescrLock both in provided XML files and on command line.
So, let's remove the safety net...
Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
When parsing XML files the specified binary to be flashed may not be
present. The default behaviour of QDL is to ignore missing file. This is
sometimes undesireble.
This patch changes the default behaviour. If the file to be flashed
can't be found qdl will exit with error. An optional flag --allow-missing
is introduced. It will allow to skip missing files during flashing procedure.
Default value of the flag is false.
Signed-off-by: Milosz Wasilewski <quic_mwasilew@quicinc.com>