Skip to content

Commit 353ccb2

Browse files
committed
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 <[email protected]>
1 parent 933a62b commit 353ccb2

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

program.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,27 @@ int program_find_bootable_partition(bool *multiple_found)
276276
return part;
277277
}
278278

279+
/**
280+
* program_is_sec_partition_flashed() - find if secdata partition is flashed
281+
*
282+
* Returns true if filename for secdata is set in program*.xml,
283+
* or false otherwise.
284+
*/
285+
int program_is_sec_partition_flashed(void)
286+
{
287+
struct program *program;
288+
289+
program = program_find_partition("secdata");
290+
if (!program)
291+
return false;
292+
293+
if (program->filename)
294+
return true;
295+
296+
return false;
297+
}
298+
299+
279300
void free_programs(void)
280301
{
281302
struct program *program = programes;

program.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ int program_execute(struct qdl_device *qdl, int (*apply)(struct qdl_device *qdl,
2626
const char *incdir, bool allow_missing);
2727
int erase_execute(struct qdl_device *qdl, int (*apply)(struct qdl_device *qdl, struct program *program));
2828
int program_find_bootable_partition(bool *multiple_found);
29+
int program_is_sec_partition_flashed(void);
30+
2931
void free_programs(void);
3032

3133
#endif

qdl.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
#include "qdl.h"
4343
#include "patch.h"
44+
#include "program.h"
4445
#include "ufs.h"
4546

4647
#define MAX_USBFS_BULK_SIZE (16*1024)
@@ -120,6 +121,7 @@ int main(int argc, char **argv)
120121
int ret;
121122
int opt;
122123
bool qdl_finalize_provisioning = false;
124+
bool allow_fusing = false;
123125
bool allow_missing = false;
124126
long out_chunk_size;
125127

@@ -132,6 +134,7 @@ int main(int argc, char **argv)
132134
{"serial", required_argument, 0, 'S'},
133135
{"storage", required_argument, 0, 's'},
134136
{"allow-missing", no_argument, 0, 'f'},
137+
{"allow-fusing", no_argument, 0, 'c'},
135138
{0, 0, 0, 0}
136139
};
137140

@@ -152,6 +155,9 @@ int main(int argc, char **argv)
152155
case 'l':
153156
qdl_finalize_provisioning = true;
154157
break;
158+
case 'c':
159+
allow_fusing = true;
160+
break;
155161
case OPT_OUT_CHUNK_SIZE:
156162
out_chunk_size = strtol(optarg, NULL, 10);
157163
qdl_set_out_chunk_size(&qdl, out_chunk_size);
@@ -196,6 +202,10 @@ int main(int argc, char **argv)
196202
ret = program_load(argv[optind], !strcmp(storage, "nand"));
197203
if (ret < 0)
198204
errx(1, "program_load %s failed", argv[optind]);
205+
206+
if (!allow_fusing && program_is_sec_partition_flashed())
207+
errx(1, "secdata partition to be programmed, which can lead to irreversible"
208+
" changes. Allow explicitly with --allow-fusing parameter");
199209
break;
200210
case QDL_FILE_READ:
201211
ret = read_op_load(argv[optind]);

0 commit comments

Comments
 (0)