with this one can do:
scripts:({
name="u-boot";
type = "copy";
mtdname = "u-boot-b";
installed-directly = true;
properties : {
copyfrom = "mtd:u-boot-a";
type = "preinstall";
chain = "raw";
}
});
Signed-off-by: Joakim Tjernlund <
joakim.t...@infinera.com>
---
handlers/copy_handler.c | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/handlers/copy_handler.c b/handlers/copy_handler.c
index bea0899e..9666bf32 100644
--- a/handlers/copy_handler.c
+++ b/handlers/copy_handler.c
@@ -30,6 +30,7 @@
#include "progress.h"
#include "handler.h"
#include "util.h"
+#include "flash.h"
#include "handler_helpers.h"
#include "installer.h"
@@ -213,7 +214,15 @@ static int copy_image_file(struct img_type *img, void *data)
script_data = data;
base_img = img;
-
+ if(strlen(img->mtdname) ){
+ int mtdnum = get_mtd_from_name(img->mtdname);
+ if (mtdnum < 0) {
+ ERROR("Wrong MTD name in description: %s",
+ img->mtdname);
+ return -1;
+ }
+ snprintf(img->device, sizeof(img->device), "/dev/mtdblock%d", mtdnum);
+ }
proplist = dict_get_list(&img->properties, "type");
if (proplist) {
entry = LIST_FIRST(proplist);
@@ -236,7 +245,17 @@ static int copy_image_file(struct img_type *img, void *data)
ERROR("Missing source device, no copyfrom property");
return -EINVAL;
}
-
+ if (!strncmp("mtd:", entry->value, 4)) {
+ int mtdnum = get_mtd_from_name(entry->value + 4);
+ if (mtdnum < 0) {
+ ERROR("Wrong MTD name in copyfrom: %s",
+ entry->value);
+ return -1;
+ }
+ free(entry->value);
+ entry->value = malloc(20+1); /* to hold "/dev/mtdblockXX */
+ snprintf(entry->value, 20, "/dev/mtdblock%d", mtdnum);
+ }
copyfrom = realpath(entry->value, NULL);
if (!copyfrom) {
ERROR("%s cannot be resolved", entry->value);
--
2.49.0