[Buildroot] [PATCH 1/5] Makefile: add media image generation

Vivien Didelot vivien.didelot at savoirfairelinux.com
Thu Mar 19 17:37:04 UTC 2015


Hi Yann, Thomas,

> > However, what I wonder about, is that all those defconfigs rely on
> > the image already generated by Buildroot, and I fail to see how one
> > would write a mutli-partition genimage config file.

I don't really get your point, since the defconfigs define the needed
fragment images to create (bootloader, kernel, rootfs types, etc.), then
the related genimage config file uses them to compose a final media
image. You can easily add new partition blocks in this config if you
need to.

Something like this for the Rpi:

    [...]

    image sdcard.img {
      hdimage {
      }

      partition boot {
        partition-type = 0xC
        bootable = "true"
        image = "boot.vfat"
      }

      partition rootfs {
        partition-type = 0x83
        image = "rootfs.ext4"
        size = 512M
      }

      partition data {
        partition-type = 0x83
        size = 2G
      }
    }

Then you have this final image:

$ fdisk -l output/images/sdcard.img 

    Disk output/images/sdcard.img: 522 MiB, 547357184 bytes, 1069057 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disklabel type: dos
    Disk identifier: 0x00000000

    Device                    Boot   Start     End Sectors  Size Id Type
    output/images/sdcard.img1 *          1   20480   20480   10M  c W95 FAT32 (LBA)
    output/images/sdcard.img2        20481 1069056 1048576  512M 83 Linux
    output/images/sdcard.img3      1069057 5263360 4194304    2G 83 Linux

> > Furthermore, I've read the genimage docs (a mere README, far from
> > being complete), and it does not look obvious to me.

I agree, the tool is minimalist, as its documentation. I'm working on
improving it at the same time and already upstreamed some additions to
the readme file.

> > Also, rather than letting Buildroot build the filesystem images and
> > then aggregate that with genimage, it would be meuch more
> > interesting (IMHO) to provide an example that lets genimage do the
> > filesystem. That would be a good example on how to do it.
> 
> Well, the boot.vfat image in the raspberry pi example is a good
> illustration of this: the FAT filesystem image is not created by
> Buildroot, but by genimage itself.

Exactly. Yann, I think I see where you are going, by discussing about
putting genimage as a fs option.

Looks like you see genimage simply as a tool to generate a filesystem
image (e.g., rootfs.ext2). This is possible for sure, but in the case of
Buildroot, genimage would preferably be used as a final composition tool
to create the media image (including all fragments created by
Buildroot), ready to be dumped.

That's why I find confusing to add genimage as a filesystem entry, as
you proposed in patch 1/5, since this naturally comes *after* the
generation of the fragments and the eventual post-image hook.

> > Also, in the case of multiple partitions, I wonder how /etc/fstab is
> > updated (since the current examples only use a pre-generated
> > filesystem image, they can't update fstab).
> 
> Using a post-build script ?

Indeed. Genimage also supports pre and post image hook commands, but I
would prefer to let Buildroot do this kind of customization.

> > It might even be interesting to have an example (e.g. in the manual
> > or somewhere else...) with a more complex setup, like a
> > multi-partition setup where parts are inherited from Buildroot (the
> > rootfs) and others are generated by genimage, or whatever seemingly
> > complex setup we can come up with...
> 
> Yes, I agree it would be interesting to have more complicated cases
> covered in the Buildroot manual.

Sure! For the moment I prefered to add simple genimage config files
which match exactly the setup described in the board readme files, until
we agree on this patchset. Then I'd be willing to add more complex
examples if needed.

Thomas, in the meantime, what do you think about the implementation and
what Yann suggested? Would a top directory "media/" make sense? Let me
know what needs to be changed.

Thanks guys for your time,
-v



More information about the buildroot mailing list