Skip to content

Commit 4bbad4a

Browse files
committed
Allow erasing all storage types
Erase operations are currently only supported on devices using NAND storage. With this change, erase operations also work on devices with UFS storage. Signed-off-by: Julien Vanier <[email protected]>
1 parent 30ac3a8 commit 4bbad4a

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

firehose.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -323,10 +323,13 @@ static int firehose_erase(struct qdl_device *qdl, struct program *program)
323323
xmlDocSetRootElement(doc, root);
324324

325325
node = xmlNewChild(root, NULL, (xmlChar*)"erase", NULL);
326-
xml_setpropf(node, "PAGES_PER_BLOCK", "%d", program->pages_per_block);
327326
xml_setpropf(node, "SECTOR_SIZE_IN_BYTES", "%d", program->sector_size);
328327
xml_setpropf(node, "num_partition_sectors", "%d", program->num_sectors);
328+
xml_setpropf(node, "physical_partition_number", "%d", program->partition);
329329
xml_setpropf(node, "start_sector", "%s", program->start_sector);
330+
if (program->is_nand) {
331+
xml_setpropf(node, "PAGES_PER_BLOCK", "%d", program->pages_per_block);
332+
}
330333

331334
ret = firehose_write(qdl, doc);
332335
if (ret < 0) {

program.c

+5-8
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,18 @@ static int load_erase_tag(xmlNode *node, bool is_nand)
4747
struct program *program;
4848
int errors = 0;
4949

50-
if (!is_nand) {
51-
ux_err("found \"erase\" tag for non-NAND storage\n");
52-
return -EINVAL;
53-
}
54-
5550
program = calloc(1, sizeof(struct program));
5651

57-
58-
program->is_nand = true;
52+
program->is_nand = is_nand;
5953
program->is_erase = true;
6054

61-
program->pages_per_block = attr_as_unsigned(node, "PAGES_PER_BLOCK", &errors);
6255
program->sector_size = attr_as_unsigned(node, "SECTOR_SIZE_IN_BYTES", &errors);
6356
program->num_sectors = attr_as_unsigned(node, "num_partition_sectors", &errors);
57+
program->partition = attr_as_unsigned(node, "physical_partition_number", &errors);
6458
program->start_sector = attr_as_string(node, "start_sector", &errors);
59+
if (is_nand) {
60+
program->pages_per_block = attr_as_unsigned(node, "PAGES_PER_BLOCK", &errors);
61+
}
6562

6663
if (errors) {
6764
ux_err("errors while parsing erase tag\n");

0 commit comments

Comments
 (0)