Skip to content

Commit d921829

Browse files
committed
qdl: add support for dry run execution
This mode assists in validating the `rawprogram_.xml` and `patch_.xml` files, as well as the Firehose commands that are expected to be sent to the Firehose programmer. Dry run implementation is also expected to be extended for the Digests Table generation required for Firehose Validated Image Programming (VIP). Example of usage: $ qdl --dry-run --serial=0AA94EFD --debug prog_firehose_ddr.elf rawprogram*.xml patch*.xml qdl version v2.1-24-g30ac3a8-dirty This is a dry-run execution of QDL. No actual flashing has been performed waiting for programmer... FIREHOSE WRITE: <?xml version="1.0"?> <data><configure MemoryName="ufs" MaxPayloadSizeToTargetInBytes="1048576" verbose="0" ZLPAwareHost="1" SkipStorageInit="0"/></data> FIREHOSE WRITE: <?xml version="1.0"?> <data><configure MemoryName="ufs" MaxPayloadSizeToTargetInBytes="0" verbose="0" ZLPAwareHost="1" SkipStorageInit="0"/></data> accepted max payload size: 0 FIREHOSE WRITE: <?xml version="1.0"?> <data><program SECTOR_SIZE_IN_BYTES="4096" num_partition_sectors="131072" physical_partition_number="0" start_sector="6" filename="efi.bin"/></data> Signed-off-by: Igor Opaniuk <[email protected]>
1 parent 2971c84 commit d921829

File tree

7 files changed

+102
-4
lines changed

7 files changed

+102
-4
lines changed

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ CFLAGS += -O2 -Wall -g `pkg-config --cflags libxml-2.0 libusb-1.0`
66
LDFLAGS += `pkg-config --libs libxml-2.0 libusb-1.0`
77
prefix := /usr/local
88

9-
QDL_SRCS := firehose.c io.c qdl.c sahara.c util.c patch.c program.c read.c ufs.c usb.c ux.c
9+
QDL_SRCS := firehose.c io.c qdl.c sahara.c util.c patch.c program.c read.c sim.c ufs.c usb.c ux.c
1010
QDL_OBJS := $(QDL_SRCS:.c=.o)
1111

12-
RAMDUMP_SRCS := ramdump.c sahara.c io.c usb.c util.c ux.c
12+
RAMDUMP_SRCS := ramdump.c sahara.c io.c sim.c usb.c util.c ux.c
1313
RAMDUMP_OBJS := $(RAMDUMP_SRCS:.c=.o)
1414

1515
KS_OUT := ks

firehose.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ static int firehose_read(struct qdl_device *qdl, int timeout_ms,
148148
gettimeofday(&now, NULL);
149149
timeradd(&now, &delta, &timeout);
150150

151+
if (qdl->dev_type == QDL_DEVICE_SIM)
152+
return 0;
153+
151154
do {
152155
n = qdl_read(qdl, buf, sizeof(buf), 100);
153156
if (n < 0) {
@@ -300,7 +303,8 @@ static int firehose_configure(struct qdl_device *qdl, bool skip_storage_init, co
300303
return -1;
301304
}
302305

303-
max_payload_size = size;
306+
if (qdl->dev_type == QDL_DEVICE_USB)
307+
max_payload_size = size;
304308
}
305309

306310
ux_debug("accepted max payload size: %zu\n", max_payload_size);

io.c

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ struct qdl_device *qdl_init(enum QDL_DEVICE_TYPE type)
3535
if (type == QDL_DEVICE_USB)
3636
return usb_init();
3737

38+
if (type == QDL_DEVICE_SIM)
39+
return sim_init();
40+
3841
return NULL;
3942
}
4043

qdl.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ static void print_usage(void)
102102
{
103103
extern const char *__progname;
104104
fprintf(stderr,
105-
"%s [--debug] [--version] [--allow-missing] [--storage <emmc|nand|ufs>] [--finalize-provisioning] [--include <PATH>] [--serial <NUM>] [--out-chunk-size <SIZE>] <prog.mbn> [<program> <patch> ...]\n",
105+
"%s [--debug] [--dry-run] [--version] [--allow-missing] [--storage <emmc|nand|ufs>] [--finalize-provisioning] [--include <PATH>] [--serial <NUM>] [--out-chunk-size <SIZE>] <prog.mbn> [<program> <patch> ...]\n",
106106
__progname);
107107
}
108108

@@ -133,6 +133,7 @@ int main(int argc, char **argv)
133133
{"serial", required_argument, 0, 'S'},
134134
{"storage", required_argument, 0, 's'},
135135
{"allow-missing", no_argument, 0, 'f'},
136+
{"dry-run", no_argument, 0, 'n'},
136137
{0, 0, 0, 0}
137138
};
138139

@@ -141,6 +142,9 @@ int main(int argc, char **argv)
141142
case 'd':
142143
qdl_debug = true;
143144
break;
145+
case 'n':
146+
qdl_dev_type = QDL_DEVICE_SIM;
147+
break;
144148
case 'v':
145149
print_version();
146150
return 0;

qdl.h

+7
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
enum QDL_DEVICE_TYPE
1818
{
1919
QDL_DEVICE_USB,
20+
QDL_DEVICE_SIM,
2021
};
2122

2223
struct qdl_device
@@ -48,6 +49,11 @@ struct qdl_device_usb
4849
size_t out_chunk_size;
4950
};
5051

52+
struct qdl_device_sim
53+
{
54+
struct qdl_device base;
55+
};
56+
5157
struct qdl_device *qdl_init(enum QDL_DEVICE_TYPE type);
5258
void qdl_deinit(struct qdl_device *qdl);
5359
int qdl_open(struct qdl_device *qdl, const char *serial);
@@ -57,6 +63,7 @@ int qdl_write(struct qdl_device *qdl, const void *buf, size_t len);
5763
void qdl_set_out_chunk_size(struct qdl_device *qdl, long size);
5864

5965
struct qdl_device *usb_init(void);
66+
struct qdl_device *sim_init(void);
6067

6168
int firehose_run(struct qdl_device *qdl, const char *incdir, const char *storage, bool allow_missing);
6269
int sahara_run(struct qdl_device *qdl, char *img_arr[], bool single_image,

sahara.c

+3
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,9 @@ int sahara_run(struct qdl_device *qdl, char *img_arr[], bool single_image,
438438
bool done = false;
439439
int n;
440440

441+
if (qdl->dev_type == QDL_DEVICE_SIM)
442+
return 0;
443+
441444
if (ramdump_path) {
442445
ramdump_dir = open(ramdump_path, O_DIRECTORY);
443446
if (ramdump_dir < 0)

sim.c

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* Copyright (c) 2025, Qualcomm Innovation Center, Inc. All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions are met:
6+
*
7+
* 1. Redistributions of source code must retain the above copyright notice,
8+
* this list of conditions and the following disclaimer.
9+
*
10+
* 2. Redistributions in binary form must reproduce the above copyright notice,
11+
* this list of conditions and the following disclaimer in the documentation
12+
* and/or other materials provided with the distribution.
13+
*
14+
* 3. Neither the name of the copyright holder nor the names of its contributors
15+
* may be used to endorse or promote products derived from this software without
16+
* specific prior written permission.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28+
* POSSIBILITY OF SUCH DAMAGE.
29+
*/
30+
#include <string.h>
31+
32+
#include "qdl.h"
33+
34+
static int sim_open(struct qdl_device *qdl, const char *serial)
35+
{
36+
ux_info("This is a dry-run execution of QDL. No actual flashing has been performed\n");
37+
38+
return 0;
39+
}
40+
41+
static void sim_close(struct qdl_device *qdl)
42+
{
43+
return;
44+
}
45+
46+
static int sim_read(struct qdl_device *qdl, void *buf, size_t len, unsigned int timeout)
47+
{
48+
return len;
49+
}
50+
51+
static int sim_write(struct qdl_device *qdl, const void *buf, size_t len)
52+
{
53+
return len;
54+
}
55+
56+
static void sim_set_out_chunk_size(struct qdl_device *qdl, long size)
57+
{
58+
return;
59+
}
60+
61+
struct qdl_device *sim_init(void)
62+
{
63+
struct qdl_device *qdl = malloc(sizeof(struct qdl_device_sim));
64+
if (!qdl)
65+
return NULL;
66+
67+
memset(qdl, 0, sizeof(struct qdl_device_sim));
68+
69+
qdl->dev_type = QDL_DEVICE_SIM;
70+
qdl->open = sim_open;
71+
qdl->read = sim_read;
72+
qdl->write = sim_write;
73+
qdl->close = sim_close;
74+
qdl->set_out_chunk_size = sim_set_out_chunk_size;
75+
76+
return qdl;
77+
}

0 commit comments

Comments
 (0)