[PATCH] Support MTD names in copy handler

42 views
Skip to first unread message

Joakim Tjernlund

unread,
Jun 4, 2025, 3:54:41 AM6/4/25
to swup...@googlegroups.com, Joakim Tjernlund
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

Joakim Tjernlund (Nokia)

unread,
Jun 14, 2025, 8:35:33 AM6/14/25
to Joakim Tjernlund, swup...@googlegroups.com
Ping ?

On Wed, 2025-06-04 at 09:54 +0200, 'Joakim Tjernlund' via swupdate wrote:
>
> CAUTION: This is an external email. Please be very careful when clicking links or opening attachments. See the URL
> nok.it/ext for additional information.
> --
> You received this message because you are subscribed to the Google Groups "swupdate" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> swupdate+u...@googlegroups.com.
> To view this discussion visit
> https://groups.google.com/d/msgid/swupdate/20250604075427.880339-1-joakim.tjernlund%40infinera.com
> .

Joakim Tjernlund (Nokia)

unread,
Jul 25, 2025, 12:07:58 PM7/25/25
to swup...@googlegroups.com
Yet a ping ...

Stefano Babic

unread,
Jul 27, 2025, 3:00:55 AM7/27/25
to Joakim Tjernlund (Nokia), swup...@googlegroups.com
Hi Joachim,

On 25.07.25 18:07, 'Joakim Tjernlund (Nokia)' via swupdate wrote:
> Yet a ping ...
>
> On Sat, 2025-06-14 at 14:35 +0200, jocke at jocke wrote:
>> Ping ?

Even pong, but I do not know what is supposed I should do. I merged this
patch a while ago.

Best regards,
Stefano
Reply all
Reply to author
Forward
0 new messages