-
Notifications
You must be signed in to change notification settings - Fork 110
For linux msm/spinor #146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
For linux msm/spinor #146
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -299,9 +299,17 @@ static int firehose_configure_response_parser(xmlNode *node, void *data, bool *r | |
| } | ||
|
|
||
| static int firehose_send_configure(struct qdl_device *qdl, size_t payload_size, | ||
| bool skip_storage_init, const char *storage, | ||
| bool skip_storage_init, | ||
| enum qdl_storage_type storage, | ||
| size_t *max_payload_size) | ||
| { | ||
| static const char * const memory_names[] = { | ||
| [QDL_STORAGE_EMMC] = "emmc", | ||
| [QDL_STORAGE_NAND] = "nand", | ||
| [QDL_STORAGE_UFS] = "ufs", | ||
| [QDL_STORAGE_NVME] = "nvme", | ||
| [QDL_STORAGE_SPINOR] = "spinor", | ||
| }; | ||
| xmlNode *root; | ||
| xmlNode *node; | ||
| xmlDoc *doc; | ||
|
|
@@ -311,7 +319,7 @@ static int firehose_send_configure(struct qdl_device *qdl, size_t payload_size, | |
| xmlDocSetRootElement(doc, root); | ||
|
|
||
| node = xmlNewChild(root, NULL, (xmlChar *)"configure", NULL); | ||
| xml_setpropf(node, "MemoryName", storage); | ||
| xml_setpropf(node, "MemoryName", memory_names[storage]); | ||
| xml_setpropf(node, "MaxPayloadSizeToTargetInBytes", "%lu", payload_size); | ||
| xml_setpropf(node, "verbose", "%d", 0); | ||
| xml_setpropf(node, "ZLPAwareHost", "%d", 1); | ||
|
|
@@ -324,7 +332,7 @@ static int firehose_send_configure(struct qdl_device *qdl, size_t payload_size, | |
| } | ||
|
|
||
| static int firehose_try_configure(struct qdl_device *qdl, bool skip_storage_init, | ||
| const char *storage) | ||
| enum qdl_storage_type storage) | ||
| { | ||
| size_t max_sector_size; | ||
| size_t sector_sizes[] = { 512, 4096 }; | ||
|
|
@@ -359,7 +367,7 @@ static int firehose_try_configure(struct qdl_device *qdl, bool skip_storage_init | |
|
|
||
| ux_debug("accepted max payload size: %zu\n", qdl->max_payload_size); | ||
|
|
||
| if (strcmp(storage, "nand")) { | ||
| if (storage != QDL_STORAGE_NAND) { | ||
| max_sector_size = sector_sizes[ARRAY_SIZE(sector_sizes) - 1]; | ||
| buf = malloc(max_sector_size); | ||
| memset(&op, 0, sizeof(op)); | ||
|
|
@@ -429,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) | ||
| { | ||
| unsigned int num_sectors; | ||
| unsigned int sector_size; | ||
| unsigned int zlp_timeout = 10000; | ||
| struct stat sb; | ||
| size_t chunk_size; | ||
| xmlNode *root; | ||
|
|
@@ -446,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; | ||
|
|
||
|
|
@@ -560,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, 10000); | ||
| n = qdl_write(qdl, buf, chunk_size * sector_size, zlp_timeout); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The actual increase to 30s occurred in the previous commit
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
|
|
@@ -929,7 +946,7 @@ static int firehose_reset(struct qdl_device *qdl) | |
|
|
||
| static int firehose_detect_and_configure(struct qdl_device *qdl, | ||
| bool skip_storage_init, | ||
| const char *storage, | ||
| enum qdl_storage_type storage, | ||
| unsigned int timeout_s) | ||
| { | ||
| struct timeval timeout = { .tv_sec = timeout_s }; | ||
|
|
@@ -962,7 +979,7 @@ int firehose_provision(struct qdl_device *qdl) | |
| { | ||
| int ret; | ||
|
|
||
| ret = firehose_detect_and_configure(qdl, true, "ufs", 5); | ||
| ret = firehose_detect_and_configure(qdl, true, QDL_STORAGE_UFS, 5); | ||
| if (ret) | ||
| return ret; | ||
|
|
||
|
|
@@ -980,7 +997,7 @@ int firehose_provision(struct qdl_device *qdl) | |
|
|
||
| } | ||
|
|
||
| int firehose_run(struct qdl_device *qdl, const char *storage) | ||
| int firehose_run(struct qdl_device *qdl, enum qdl_storage_type storage) | ||
| { | ||
| bool multiple; | ||
| int bootable; | ||
|
|
@@ -1004,7 +1021,7 @@ int firehose_run(struct qdl_device *qdl, const char *storage) | |
| if (ret) | ||
| return ret; | ||
|
|
||
| ret = program_execute(qdl, firehose_program); | ||
| ret = program_execute(qdl, firehose_program, storage); | ||
| if (ret) | ||
| return ret; | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considering that
struct qdl_devicealready has some storage-related fields likesize_t sector_size, why not includeqdl_storage_typeinto this structure as well?This will remove the need to pass one more param to functions like this
There was a problem hiding this comment.
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.