Search code examples
embedded-linuxdevice-tree

How to define a partition table for an e.MMC device in a device tree?


I'm working on a custom device which has a 16GB e.MMC part for mass storage. It's an embedded system, and we're using Yocto to build our kernel and other goodies.

It's my understanding that the partition table can be defined in the device tree so that I can select between two or more partition tables using either a single device tree with multiple partition tables within the device tree, or multiple device trees, each with their own partition table.

For the life of me I cannot find a single example which shows how to put the partition table for MMC devices in the device tree. Can anyone point me to a working example of an MMC/SD storage device partition that I could look at and modify for our application?


Solution

  • I may be wrong, however, I have never seen eMMC partitions being specified in device tree. The eMMC partitioning is generally part of some kind of flashing process. For example, build systems like buildroot and OpenEmbedded/Yocto can generate a compressed ext4 rootfs image and the files required for boot as per the SoC go in the first partition which generally tends to be FAT32. However, there is also distroboot, where there is only a single eMMC partition formatted as ext4 and the files required for boot are picked from /boot on that partition.

    Depending on your setup and requirements, you can have either a separate step for formatting and partitioning the eMMC from bootloader or use something like genimage tool, which generates a single .img by taking a specification of your eMMC partitioning requirements. See genimage. The .img file can be used to flash the eMMC using the simple "dd" tool.

    To use genimage, as part of Yocto build process, you would need meta-ptx layer.

    Addendum: I forgot to add how to format from u-boot. You do not mention the exact device you are using, but the eMMC flashing process from something like u-boot is pretty much the same for all SoC's. For example, have a look here. If you are using barebox as bootloader, I assume it should be pretty much the same though I cannot say for sure, since I have never used barebox.