Skip to content

Commit 1ec12f6

Browse files
authored
Merge pull request #101 from monkbroc/erase-all
Allow erasing all storage types
2 parents c856721 + 33a2f15 commit 1ec12f6

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

firehose.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,10 +321,13 @@ static int firehose_erase(struct qdl_device *qdl, struct program *program)
321321
xmlDocSetRootElement(doc, root);
322322

323323
node = xmlNewChild(root, NULL, (xmlChar*)"erase", NULL);
324-
xml_setpropf(node, "PAGES_PER_BLOCK", "%d", program->pages_per_block);
325324
xml_setpropf(node, "SECTOR_SIZE_IN_BYTES", "%d", program->sector_size);
326325
xml_setpropf(node, "num_partition_sectors", "%d", program->num_sectors);
326+
xml_setpropf(node, "physical_partition_number", "%d", program->partition);
327327
xml_setpropf(node, "start_sector", "%s", program->start_sector);
328+
if (program->is_nand) {
329+
xml_setpropf(node, "PAGES_PER_BLOCK", "%d", program->pages_per_block);
330+
}
328331

329332
ret = firehose_write(qdl, doc);
330333
if (ret < 0) {

program.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,18 @@ static int load_erase_tag(xmlNode *node, bool is_nand)
4949
struct program *program;
5050
int errors = 0;
5151

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

59-
60-
program->is_nand = true;
54+
program->is_nand = is_nand;
6155
program->is_erase = true;
6256

63-
program->pages_per_block = attr_as_unsigned(node, "PAGES_PER_BLOCK", &errors);
6457
program->sector_size = attr_as_unsigned(node, "SECTOR_SIZE_IN_BYTES", &errors);
6558
program->num_sectors = attr_as_unsigned(node, "num_partition_sectors", &errors);
59+
program->partition = attr_as_unsigned(node, "physical_partition_number", &errors);
6660
program->start_sector = attr_as_string(node, "start_sector", &errors);
61+
if (is_nand) {
62+
program->pages_per_block = attr_as_unsigned(node, "PAGES_PER_BLOCK", &errors);
63+
}
6764

6865
if (errors) {
6966
ux_err("errors while parsing erase tag\n");

0 commit comments

Comments
 (0)