pengutronix / genimage

tool to generate multiple filesystem and flash images from a tree
GNU General Public License v2.0
305 stars 110 forks source link

Automatically update default offset #180

Closed rossburton closed 2 years ago

rossburton commented 2 years ago

If I want to build a disk image without a partition table which is several pieces of data glued together without a partition table I need to maintain the offsets for every partition by hand. This is because the offset automatically being the end of the previous partition only works for partitions which are in the partition table.

Can this auto-offset logic work for all images, and not just ones with a partition table?

michaelolbrich commented 2 years ago

If you set partition-table-type to none then you could just pretend that all partitions are in the partition table (which does not exist, so it doesn't matter). Then the offset will be calculated automatically. If you don't want any gaps at all, then you should also set align to 1.

rossburton commented 2 years ago

Like this?

image pack.img {
    hdimage {
        partition-table-type = "none"
    }
    partition 1 {
        image = "1"
    }
    partition 2 {
        image = "2"
    }
    partition 3 {
        image = "3"
    }
}
ERROR: hdimage(pack.img): partition 2 (offset 0x0, size 0xc) overlaps previous partition 1 (offset 0x0, size 0xc)

(new to genimage, may be doing something dumb)

michaelolbrich commented 2 years ago

Ah, we overwrite the in-partition-table flag when there is no partition table: https://github.com/pengutronix/genimage/blob/master/image-hd.c#L680

And I suppose that's correct that way: The default alignment for in-partition-table = true only makes sense on regular disk image with a normal sector size. When you use it for something else then a default alignment doesn't make sense.

So I'm not sure what the best way to fix this is. Probably just do auto offset for all partitions when no partition table is generated.