qdl: introduce allow-fusing parameter

Introduce the --allow-fusing parameter, which must be explicitly set
if the "secdata" partition is programmed, as it will lead to irreversible
changes (fuses will be blown during the next boot).

Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
This commit is contained in:
Igor Opaniuk
2025-04-22 16:01:21 +02:00
parent 172c3c257c
commit 328e06962b
3 changed files with 33 additions and 0 deletions

View File

@@ -278,6 +278,27 @@ int program_find_bootable_partition(bool *multiple_found)
return part;
}
/**
* program_is_sec_partition_flashed() - find if secdata partition is flashed
*
* Returns true if filename for secdata is set in program*.xml,
* or false otherwise.
*/
int program_is_sec_partition_flashed(void)
{
struct program *program;
program = program_find_partition("secdata");
if (!program)
return false;
if (program->filename)
return true;
return false;
}
void free_programs(void)
{
struct program *program = programes;

View File

@@ -26,6 +26,8 @@ int program_execute(struct qdl_device *qdl, int (*apply)(struct qdl_device *qdl,
const char *incdir, bool allow_missing);
int erase_execute(struct qdl_device *qdl, int (*apply)(struct qdl_device *qdl, struct program *program));
int program_find_bootable_partition(bool *multiple_found);
int program_is_sec_partition_flashed(void);
void free_programs(void);
#endif

10
qdl.c
View File

@@ -40,6 +40,7 @@
#include "qdl.h"
#include "patch.h"
#include "program.h"
#include "ufs.h"
#include "oscompat.h"
@@ -124,6 +125,7 @@ int main(int argc, char **argv)
int ret;
int opt;
bool qdl_finalize_provisioning = false;
bool allow_fusing = false;
bool allow_missing = false;
long out_chunk_size;
@@ -136,6 +138,7 @@ int main(int argc, char **argv)
{"serial", required_argument, 0, 'S'},
{"storage", required_argument, 0, 's'},
{"allow-missing", no_argument, 0, 'f'},
{"allow-fusing", no_argument, 0, 'c'},
{0, 0, 0, 0}
};
@@ -156,6 +159,9 @@ int main(int argc, char **argv)
case 'l':
qdl_finalize_provisioning = true;
break;
case 'c':
allow_fusing = true;
break;
case OPT_OUT_CHUNK_SIZE:
out_chunk_size = strtol(optarg, NULL, 10);
qdl_set_out_chunk_size(&qdl, out_chunk_size);
@@ -200,6 +206,10 @@ int main(int argc, char **argv)
ret = program_load(argv[optind], !strcmp(storage, "nand"));
if (ret < 0)
errx(1, "program_load %s failed", argv[optind]);
if (!allow_fusing && program_is_sec_partition_flashed())
errx(1, "secdata partition to be programmed, which can lead to irreversible"
" changes. Allow explicitly with --allow-fusing parameter");
break;
case QDL_FILE_READ:
ret = read_op_load(argv[optind]);