pengutronix / genimage

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

hdimage: Implement 'gpt-location' option to move GPT table #70

Closed thirtythreeforty closed 5 years ago

thirtythreeforty commented 5 years ago

This allows the user to specify the location of the GPT table. This is useful if a device requires that the bootloader be located in a location that conflicts with the normal location of the GPT table.

Also, this changes the calculation of the "first usable LBA" to be the first listed partition; this allows the calculation to disregard the non-listed bootloaders that make this feature useful. It is up to the user to ensure that the GPT table is in a location that does not conflict with any non-listed partition entries.

Comments welcome.

thirtythreeforty commented 5 years ago

My particular use-case for this was getting a GPT table to work with an i.MX6, which insists that its bootloader must go right in the middle of the GPT table. Normally, you can just use an MBR and forgo GPT, but in my case I am trying to use the trifecta of GPT, i.MX6, and Fastboot, which requires GPT.

Bootlin has previously run into this and resorted to patching the fastboot functionality in U-Boot, which I didn't really find appealing.

thirtythreeforty commented 5 years ago

Also for what it's worth, I ran the generated image through cgdisk's Verify function, and although it claimed it is an "exotic configuration," it found no problems.

jluebbe commented 5 years ago

This allows the user to specify the location of the GPT table. This is useful if a device requires that the bootloader be located in a location that conflicts with the normal location of the GPT table.

I wasn't aware that the GPT can be found at different locations. How is it found at runtime if it's not at the "normal" location?

thirtythreeforty commented 5 years ago

@jluebbe the header cannot be moved, it's always at LBA 1. But the header specifies which LBA the table is at. Traditionally it's at LBA 2, but you can put it anywhere you like, with the restriction that the "first usable" LBA must be after the table.

michaelolbrich commented 5 years ago

I merged this, because it just fine as it is. I've created a new pull request #72 to fix the problem I mentioned above.

thirtythreeforty commented 5 years ago

Great, thanks! Yeah I am also going to closely review the GPT images it generates because we're using them.