ks (short for kickstart) is a utility which uses sahara to load images
from the host to a device. This is intended for "flashless boot"
devices like the Qualcomm Cloud AI 100 which rely on obtaining the
runtime firmware from the host instead of storing it on device.
While ks uses sahara, like qdl, it is different enough that a separate
utility is justified. ks does not need USB support, instead opting for
simple open()/read()/write() operations. ks does not need firehose.
The set of program arguments that ks needs is vastly different than the
set that qdl supports.
This initial implementation of ks defines two arguments. Both are
required, but the image specifier argument can be specified more than
one.
A sample invocation -
ks -p /dev/mhi0_QAIC_SAHARA -s 1:/opt/qti-aic/firmware/fw1.bin -s 2:/opt/qti-aic/firmware/fw2.bin
In this example, ks is instructed to use the /dev/mhi0_QAIC_SAHARA
device node file as the "port" which the device is using for the sahara
protocol. /opt/qti-aic/firmware/fw1.bin is mapped to id 1, and
/opt/qti-aic/firmware/fw2.bin is mapped to id 2. If the device requests
image id 1, ks will attempt to open and read
/opt/qti-aic/firmware/fw1.bin to send to the device. Note that
/opt/qti-aic/firmware/fw1.bin does not need to exist on the filesystem.
If ks cannot access the file (perhaps because it does not exist), then
the device will determine the next action. This is useful for setting
up a single command in a udev rule that can handle multiple
configurations, such as an optional DDR training process.
Signed-off-by: Jeffrey Hugo <quic_jhugo@quicinc.com>
It is possible for a device to request multiple images over the sahara
protocol. When the device issues the done response packet, the status
field indicates if the device expects to request additional images. If
so, the protocol goes back to the start and exchanges hello messages
again. Also, some images may be optional. The device may be able to
proceed if the host is unable to satisfy the request.
To support this, we need several changes.
First, we need to use the done response packet status field to decide
if we are done with sahara instead of assuming that based on having
transfered a single image.
Second, we need to reference the image id that the device is requesting
and operate on the correct file. This is a field in the read data
packet. Since the device could request more than one image, we need
a mapping of ids to files. Since different devices could have different
mappings, abstract this mapping into the qdl struct. When we get a read
request from the device, we need to open the correct file, seek to the
required offset, and provide the requested segment. The implementation
for this chooses simplicity over performance by avoiding the need to
maintain state of what image is currently requested, and if that has
been accessed before, thus we have an open fd to use which needs to be
cleaned up later.
Since the qdl struct is larger with the mapping table, move it off the
stack and instead make it a static global. We expect to only need one
instance of it, and this gives us the benifit of zero initializing the
struct for free. We also move the qdl struct definition into the qdl
header so that it can be shared with a similar implementation in a
future development.
Signed-off-by: Jeffrey Hugo <quic_jhugo@quicinc.com>
Without libudev installed you'll get the following build error:
qdl.c:43:10: fatal error: libudev.h: No such file or directory
43 | #include <libudev.h>
| ^~~~~~~~~~~
compilation terminated.
make: *** [<builtin>: qdl.o] Error 1
Mention the ubuntu package that brings it in as well similar to how
libxml2 is mentioned.
Signed-off-by: Andrew Halaney <ajhalaney@gmail.com>
Per user request, use pkg-config instead of xml2-config when generating
cflags and ldflags.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
The byte offset value for lseek can easily exceed 4GB, cast as off_t to
avoid overflow when converting sectors to bytes for lseek.
(and define _FILE_OFFSET_BITS=64 to fix 32-bit builds too)
Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Reset will only complete after all logs have been read.
Note this will result in an expected "qdl: firehose operation timed out"
error when draining the logs.
Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Assumed to be a remnant of early development lead to a recent transition
of "start_sector" from being represented as a string to an integer. But
it turns out that "start_sector" might be an expression, e.g. to write
something at the end of the disk.
So transition back to carry "start_sector" as a string.
Fixes: b6e0ea31d7 ("program: Make start_sector unsigned in")
Reported-by: Julien Robin
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
dc61f8f79e broke ufs provisioning by requiring base 10 for unsigned
attributes (provisioning xml have some values in hexadecimal). strtoul()
would return 0 for these values and provisioning would fail strangely.
Signed-off-by: Jonathan Marek <jonathan@marek.ca>
On db410c writes sometimes fails becasue the device had more log entries
to read after the <response> and refuses writes until these are drained.
Deal with this by attempting a read when write fails with a timeout.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
WIth the transition from qcserial to USBFS we no longer receive multiple
messages in a single read, so we can remove the code that decode the
buffer piecemeal.
While reworking this, also introduce a mechanism so that the parsers can
pass values back to the caller of the read.
And modify the timeout handling so that the caller always has to pass a
timeout, and bump the timeouts slightly, as they are all fatal anyways.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
qdl_write() is always called with eot=true, so drop the parameter.
As a length of 0 means we're not entering the loop and we're now always
entering the conditonal block at the end we can remove the first chunk.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
NAND based devices comes with a few minor tweaks to the program tag and
an additional erase tag, split the program code and add the handling of
the erase tag.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Remove the dummy sleep and reliance on USB read timeout while waiting
for the firehose payload to launch by rolling our own timeout handling
in firehose_read. While at it extend the firehose program timeouts, to
avoid issues seen when these operations for some reason takes a little
bit longer to return.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
The SDX55 shows up with bInterfaceProtocol of 17, so allow this to get
past the USB filtering routine.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
The downstream tool has a 3 second delay to allow the firehose payload
to boot. Adding the same makes db820c successfully enter firehose mode.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Upon booting the firehose payload some platforms will issue log messages
others won't. Rather than waiting for 10 seconds on the ones that
doesn't wait only for a second.
Hopefully this is long enough, but the firmware synchronization and
handling of incoming log messages should be reviewed further.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
It's perfectly normal to "poll" for incoming messages, so silence the
warning printout in the usb accessor functions.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>