mirror of
https://github.com/linux-msm/qdl.git
synced 2026-02-25 13:12:25 -08:00
The Sahara implementation was written without understanding of the special meaning of image id #13. As the implementation grew support for multiple images the special casing of "single image" was introduced, and this spread to the calling bodies. Prior to the introduction of multi-programmer platforms this didn't matter, the logic was fairly simple and usage was straight forward. But when a single programmer image is provided on a multi-programmer target "single_image" is true and hence the image id is ignored on the first read, the one provided file is loaded. The typical outcome is that the following SAHARA_END_OF_IMAGE_CMD fails with a message stating "non-successful end-of-image result". Few users draws the conclusion that this is because they didn't provide the appropriate programmers. But 13 is the image id for the programmer, so it should be fine to drop the special logic. This results in a (somewhat) more helpful error message telling the user that an invalid image is being requested. Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>
100 lines
1.6 KiB
C
100 lines
1.6 KiB
C
// SPDX-License-Identifier: BSD-3-Clause
|
|
#include <getopt.h>
|
|
#include <stdbool.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#include "qdl.h"
|
|
|
|
#ifdef _WIN32
|
|
const char *__progname = "ramdump";
|
|
#endif
|
|
|
|
bool qdl_debug;
|
|
|
|
static void print_usage(FILE *out)
|
|
{
|
|
extern const char *__progname;
|
|
|
|
fprintf(out,
|
|
"%s [--debug] [-o <ramdump-path>] [segment-filter,...]\n",
|
|
__progname);
|
|
}
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
struct qdl_device *qdl;
|
|
|
|
qdl = qdl_init(QDL_DEVICE_USB);
|
|
if (!qdl)
|
|
return 1;
|
|
|
|
char *ramdump_path = ".";
|
|
char *filter = NULL;
|
|
char *serial = NULL;
|
|
int ret = 0;
|
|
int opt;
|
|
|
|
static struct option options[] = {
|
|
{"debug", no_argument, 0, 'd'},
|
|
{"version", no_argument, 0, 'v'},
|
|
{"output", required_argument, 0, 'o'},
|
|
{"serial", required_argument, 0, 'S'},
|
|
{"help", no_argument, 0, 'h'},
|
|
{0, 0, 0, 0}
|
|
};
|
|
|
|
while ((opt = getopt_long(argc, argv, "dvo:S:h", options, NULL)) != -1) {
|
|
switch (opt) {
|
|
case 'd':
|
|
qdl_debug = true;
|
|
break;
|
|
case 'v':
|
|
print_version();
|
|
ret = 0;
|
|
goto out_cleanup;
|
|
case 'o':
|
|
ramdump_path = optarg;
|
|
break;
|
|
case 'S':
|
|
serial = optarg;
|
|
break;
|
|
case 'h':
|
|
print_usage(stdout);
|
|
return 0;
|
|
default:
|
|
print_usage(stderr);
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
if (optind < argc)
|
|
filter = argv[optind++];
|
|
|
|
if (optind != argc) {
|
|
print_usage(stderr);
|
|
return 1;
|
|
}
|
|
|
|
if (qdl_debug)
|
|
print_version();
|
|
|
|
ret = qdl_open(qdl, serial);
|
|
if (ret) {
|
|
ret = 1;
|
|
goto out_cleanup;
|
|
}
|
|
|
|
ret = sahara_run(qdl, NULL, ramdump_path, filter);
|
|
if (ret < 0) {
|
|
ret = 1;
|
|
goto out_cleanup;
|
|
}
|
|
|
|
out_cleanup:
|
|
qdl_close(qdl);
|
|
qdl_deinit(qdl);
|
|
|
|
return ret;
|
|
}
|