Skip to content

Commit 92fafa3

Browse files
quic-bjorandeandersson
authored andcommitted
firehose: Increate program timeout for SPINOR
The ZLP for SPINOR writes has been measured to take up to 15 seconds to complete, resulting in timeouts even with the new 10 second value. Pass around the storage type and provide a longer timeout (double the currently measured value) specifically for SPINOR. Signed-off-by: Bjorn Andersson <[email protected]>
1 parent 567b3e7 commit 92fafa3

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

firehose.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -437,10 +437,12 @@ static int firehose_erase(struct qdl_device *qdl, struct program *program)
437437
return ret == FIREHOSE_ACK ? 0 : -1;
438438
}
439439

440-
static int firehose_program(struct qdl_device *qdl, struct program *program, int fd)
440+
static int firehose_program(struct qdl_device *qdl, struct program *program,
441+
int fd, enum qdl_storage_type storage)
441442
{
442443
unsigned int num_sectors;
443444
unsigned int sector_size;
445+
unsigned int zlp_timeout = 10000;
444446
struct stat sb;
445447
size_t chunk_size;
446448
xmlNode *root;
@@ -454,6 +456,13 @@ static int firehose_program(struct qdl_device *qdl, struct program *program, int
454456
int n;
455457
uint32_t fill_value;
456458

459+
/*
460+
* ZLP has been measured to take up to 15 seconds on SPINOR devices,
461+
* let's double it to be on the safe side...
462+
*/
463+
if (storage == QDL_STORAGE_SPINOR)
464+
zlp_timeout = 30000;
465+
457466
num_sectors = program->num_sectors;
458467
sector_size = program->sector_size ? : qdl->sector_size;
459468

@@ -568,7 +577,7 @@ static int firehose_program(struct qdl_device *qdl, struct program *program, int
568577

569578
vip_transfer_clear_status(qdl);
570579
}
571-
n = qdl_write(qdl, buf, chunk_size * sector_size, 30000);
580+
n = qdl_write(qdl, buf, chunk_size * sector_size, zlp_timeout);
572581
if (n < 0) {
573582
ux_err("USB write failed for data chunk\n");
574583
ret = firehose_read(qdl, 30000, firehose_generic_parser, NULL);
@@ -1012,7 +1021,7 @@ int firehose_run(struct qdl_device *qdl, enum qdl_storage_type storage)
10121021
if (ret)
10131022
return ret;
10141023

1015-
ret = program_execute(qdl, firehose_program);
1024+
ret = program_execute(qdl, firehose_program, storage);
10161025
if (ret)
10171026
return ret;
10181027

program.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,12 @@ int program_load(const char *program_file, bool is_nand, bool allow_missing, con
264264
return errors;
265265
}
266266

267-
int program_execute(struct qdl_device *qdl, int (*apply)(struct qdl_device *qdl, struct program *program, int fd))
267+
int program_execute(struct qdl_device *qdl,
268+
int (*apply)(struct qdl_device *qdl,
269+
struct program *program,
270+
int fd,
271+
enum qdl_storage_type storage),
272+
enum qdl_storage_type storage)
268273
{
269274
struct program *program;
270275
int ret;
@@ -281,7 +286,7 @@ int program_execute(struct qdl_device *qdl, int (*apply)(struct qdl_device *qdl,
281286
return -1;
282287
}
283288

284-
ret = apply(qdl, program, fd);
289+
ret = apply(qdl, program, fd, storage);
285290
close(fd);
286291
if (ret)
287292
return ret;

program.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,12 @@ struct program {
3232
};
3333

3434
struct qdl_device;
35+
enum qdl_storage_type;
3536

3637
int program_load(const char *program_file, bool is_nand, bool allow_missing, const char *incdir);
37-
int program_execute(struct qdl_device *qdl, int (*apply)(struct qdl_device *qdl, struct program *program, int fd));
38+
int program_execute(struct qdl_device *qdl,
39+
int (*apply)(struct qdl_device *qdl, struct program *program, int fd, enum qdl_storage_type storage),
40+
enum qdl_storage_type storage);
3841
int erase_execute(struct qdl_device *qdl, int (*apply)(struct qdl_device *qdl, struct program *program));
3942
int program_find_bootable_partition(bool *multiple_found);
4043
int program_is_sec_partition_flashed(void);

0 commit comments

Comments
 (0)