summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorPantelis Antoniou <panto@antoniou-consulting.com>2012-11-30 08:01:11 +0000
committerMarek Vasut <marex@denx.de>2013-03-16 21:12:01 +0100
commit1b6ca18b4244756d4dbd4240510f4cc448ade0bc (patch)
tree85c05385d99705ef96d0cf947b55e767a194edac /drivers
parent80eb1bd02d1324a6fbd3b41cf72297353496bf2a (diff)
dfu: Add a partition type target
Dealing with raw block numbers with the dfu is very annoying. Introduce a partition method. Signed-off-by: Pantelis Antoniou <panto@antoniou-consulting.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/dfu/dfu_mmc.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/drivers/dfu/dfu_mmc.c b/drivers/dfu/dfu_mmc.c
index 5d504dffd1..083d74591b 100644
--- a/drivers/dfu/dfu_mmc.c
+++ b/drivers/dfu/dfu_mmc.c
@@ -21,6 +21,7 @@
#include <common.h>
#include <malloc.h>
+#include <errno.h>
#include <dfu.h>
enum dfu_mmc_op {
@@ -153,6 +154,10 @@ int dfu_read_medium_mmc(struct dfu_entity *dfu, void *buf, long *len)
int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *s)
{
+ int dev, part;
+ struct mmc *mmc;
+ block_dev_desc_t *blk_dev;
+ disk_partition_t partinfo;
char *st;
dfu->dev_type = DFU_DEV_MMC;
@@ -166,8 +171,34 @@ int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *s)
dfu->layout = DFU_FS_FAT;
} else if (!strcmp(st, "ext4")) {
dfu->layout = DFU_FS_EXT4;
+ } else if (!strcmp(st, "part")) {
+
+ dfu->layout = DFU_RAW_ADDR;
+
+ dev = simple_strtoul(s, &s, 10);
+ s++;
+ part = simple_strtoul(s, &s, 10);
+
+ mmc = find_mmc_device(dev);
+ if (mmc == NULL || mmc_init(mmc)) {
+ printf("%s: could not find mmc device #%d!\n", __func__, dev);
+ return -ENODEV;
+ }
+
+ blk_dev = &mmc->block_dev;
+ if (get_partition_info(blk_dev, part, &partinfo) != 0) {
+ printf("%s: could not find partition #%d on mmc device #%d!\n",
+ __func__, part, dev);
+ return -ENODEV;
+ }
+
+ dfu->data.mmc.lba_start = partinfo.start;
+ dfu->data.mmc.lba_size = partinfo.size;
+ dfu->data.mmc.lba_blk_size = partinfo.blksz;
+
} else {
printf("%s: Memory layout (%s) not supported!\n", __func__, st);
+ return -ENODEV;
}
if (dfu->layout == DFU_FS_EXT4 || dfu->layout == DFU_FS_FAT) {