Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions firehose.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,10 +437,12 @@ static int firehose_erase(struct qdl_device *qdl, struct program *program)
return ret == FIREHOSE_ACK ? 0 : -1;
}

static int firehose_program(struct qdl_device *qdl, struct program *program, int fd)
static int firehose_program(struct qdl_device *qdl, struct program *program,
int fd, enum qdl_storage_type storage)
Copy link
Contributor

@igoropaniuk igoropaniuk Nov 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering that struct qdl_device already has some storage-related fields like size_t sector_size, why not include qdl_storage_type into this structure as well?

This will remove the need to pass one more param to functions like this

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That does make sense, we only support flashing single-storage-type anyways, so that would keep things cleaner. Thanks.

{
unsigned int num_sectors;
unsigned int sector_size;
unsigned int zlp_timeout = 10000;
struct stat sb;
size_t chunk_size;
xmlNode *root;
Expand All @@ -454,6 +456,13 @@ static int firehose_program(struct qdl_device *qdl, struct program *program, int
int n;
uint32_t fill_value;

/*
* ZLP has been measured to take up to 15 seconds on SPINOR devices,
* let's double it to be on the safe side...
*/
if (storage == QDL_STORAGE_SPINOR)
zlp_timeout = 30000;

num_sectors = program->num_sectors;
sector_size = program->sector_size ? : qdl->sector_size;

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

vip_transfer_clear_status(qdl);
}
n = qdl_write(qdl, buf, chunk_size * sector_size, 30000);
n = qdl_write(qdl, buf, chunk_size * sector_size, zlp_timeout);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actual increase to 30s occurred in the previous commit "qdl: Be explicit about storage types". Could you rephrase the commit message to more accurately reflect the changes made in that commit, or transfer that change (s/10000/30000/g) to this commit?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching that, the timeout was not supposed to change in the previous commit.

if (n < 0) {
ux_err("USB write failed for data chunk\n");
ret = firehose_read(qdl, 30000, firehose_generic_parser, NULL);
Expand Down Expand Up @@ -1012,7 +1021,7 @@ int firehose_run(struct qdl_device *qdl, enum qdl_storage_type storage)
if (ret)
return ret;

ret = program_execute(qdl, firehose_program);
ret = program_execute(qdl, firehose_program, storage);
if (ret)
return ret;

Expand Down
9 changes: 7 additions & 2 deletions program.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,12 @@ int program_load(const char *program_file, bool is_nand, bool allow_missing, con
return errors;
}

int program_execute(struct qdl_device *qdl, int (*apply)(struct qdl_device *qdl, struct program *program, int fd))
int program_execute(struct qdl_device *qdl,
int (*apply)(struct qdl_device *qdl,
struct program *program,
int fd,
enum qdl_storage_type storage),
enum qdl_storage_type storage)
{
struct program *program;
int ret;
Expand All @@ -281,7 +286,7 @@ int program_execute(struct qdl_device *qdl, int (*apply)(struct qdl_device *qdl,
return -1;
}

ret = apply(qdl, program, fd);
ret = apply(qdl, program, fd, storage);
close(fd);
if (ret)
return ret;
Expand Down
8 changes: 7 additions & 1 deletion program.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,15 @@ struct program {
};

struct qdl_device;
enum qdl_storage_type;

int program_load(const char *program_file, bool is_nand, bool allow_missing, const char *incdir);
int program_execute(struct qdl_device *qdl, int (*apply)(struct qdl_device *qdl, struct program *program, int fd));
int program_execute(struct qdl_device *qdl,
int (*apply)(struct qdl_device *qdl,
struct program *program,
int fd,
enum qdl_storage_type storage),
enum qdl_storage_type storage);
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);
Expand Down
Loading