summaryrefslogtreecommitdiffstats
path: root/patches
diff options
context:
space:
mode:
authorJan Luebbe <jlu@pengutronix.de>2013-05-09 13:00:37 +0200
committerJan Luebbe <jlu@pengutronix.de>2013-05-09 13:04:04 +0200
commit729d9dde685dcbe05b5a293ffba86638817d924f (patch)
tree42436eb1ec196e5f2a7699402dac428b87bba860 /patches
parent5609f9c3433fc3135f06ee7b5abaff7993c2d3d7 (diff)
downloadDistroKit-729d9dde685dcbe05b5a293ffba86638817d924f.tar.gz
DistroKit-729d9dde685dcbe05b5a293ffba86638817d924f.tar.xz
genimage: add patches to fix flash image generation
Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
Diffstat (limited to 'patches')
-rw-r--r--patches/genimage-5/0001-image-flash-actually-write-the-image-and-support-par.patch106
-rw-r--r--patches/genimage-5/series1
2 files changed, 107 insertions, 0 deletions
diff --git a/patches/genimage-5/0001-image-flash-actually-write-the-image-and-support-par.patch b/patches/genimage-5/0001-image-flash-actually-write-the-image-and-support-par.patch
new file mode 100644
index 0000000..d6aca3b
--- /dev/null
+++ b/patches/genimage-5/0001-image-flash-actually-write-the-image-and-support-par.patch
@@ -0,0 +1,106 @@
+From 3ee54067eece5d8f14bfbcab1cb4f2e717775920 Mon Sep 17 00:00:00 2001
+From: Jan Luebbe <jlu@pengutronix.de>
+Date: Wed, 1 May 2013 23:55:46 +0200
+Subject: [PATCH] image-flash: actually write the image and support partition offsets
+
+Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
+Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
+---
+ image-flash.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++------
+ 1 files changed, 51 insertions(+), 6 deletions(-)
+
+diff --git a/image-flash.c b/image-flash.c
+index 2939db7..f56cfa7 100644
+--- a/image-flash.c
++++ b/image-flash.c
+@@ -33,20 +33,37 @@ struct flash_image {
+ static int flash_generate(struct image *image)
+ {
+ struct partition *part;
+- struct stat s;
+- int ret;
+- const char *buf;
++ enum pad_mode mode = MODE_OVERWRITE;
++ const char *outfile = imageoutfile(image);
+
+ list_for_each_entry(part, &image->partitions, list) {
+ struct image *child;
++ const char *infile;
++ struct stat s;
++ int ret;
++
++ image_log(image, 1, "writing image partition '%s' (0x%llx@0x%llx)\n",
++ part->name, part->size, part->offset);
++
++ ret = pad_file(NULL, outfile, part->offset, 0xFF, mode);
++ if (ret) {
++ image_error(image, "failed to pad image to size %lld\n",
++ part->offset);
++ return ret;
++ }
++ mode = MODE_APPEND;
++
++ if (!part->image)
++ continue;
+
+ child = image_get(part->image);
+ if (!child) {
+ image_error(image, "could not find %s\n", part->name);
+ return -EINVAL;
+ }
+- buf = imageoutfile(child);
+- ret = stat(buf, &s);
++ infile = imageoutfile(child);
++
++ ret = stat(infile, &s);
+ if (ret)
+ return -errno;
+
+@@ -55,6 +72,13 @@ static int flash_generate(struct image *image)
+ child->file, part->name, (long long)s.st_size, part->size);
+ return -EINVAL;
+ }
++
++ ret = pad_file(infile, outfile, part->size, 0xFF, mode);
++ if (ret) {
++ image_error(image, "failed to write image partition '%s'\n",
++ part->name);
++ return ret;
++ }
+ }
+
+ return 0;
+@@ -88,8 +112,29 @@ static int flash_setup(struct image *image, cfg_t *cfg)
+ goto err_exceed;
+ part->size = flashsize - partsize;
+ }
++ if (part->size % image->flash_type->pebsize) {
++ image_error(image, "part %s size (%lld) must be a "
++ "multiple of erase block size (%i bytes)\n",
++ part->name, part->size, image->flash_type->pebsize);
++ return -EINVAL;
++ }
++ if (part->offset % image->flash_type->pebsize) {
++ image_error(image, "part %s offset (%lld) must be a"
++ "multiple of erase block size (%i bytes)\n",
++ part->name, part->offset, image->flash_type->pebsize);
++ return -EINVAL;
++ }
++ if (part->offset) {
++ if (partsize > part->offset) {
++ image_error(image, "part %s overlaps with previous partition\n",
++ part->name);
++ return -EINVAL;
++ }
++ } else {
++ part->offset = partsize;
++ }
+
+- partsize += part->size;
++ partsize = part->offset + part->size;
+ }
+
+ if (partsize > flashsize) {
+--
+1.7.2.5
+
diff --git a/patches/genimage-5/series b/patches/genimage-5/series
new file mode 100644
index 0000000..d442cae
--- /dev/null
+++ b/patches/genimage-5/series
@@ -0,0 +1 @@
+0001-image-flash-actually-write-the-image-and-support-par.patch