How behave EasyInstaller v1.4 properties w.r.t. eMMC layout?

I am fine tuning an EasyInstaller v1.4 image.json for my TK1 2GB SOM v1.2A image. I try to reproduce the exact eMMC layout I had with the exact same image but which was flashed with the now deprecated flash script. (Background information: I want to ensure backward compatibility with the eMMC layout which has already been flashed onto SOMs using the flash scripts not to break future updates.)

To implement that I am playing around with the image.json (configuration format 2) properties offset_in_sectors, want_maximised, partition_size_nominal and mkfs_options. I thought I configured the layout correctly but obviously I miss configured something: Unfortunately I get an error “Fixed partition offset too low” when I try to download the image with the EasyInstaller v1.4.

How does the EasyInstaller v1.4 property offset_in_sectors behave exactly? Does it specify an offset relative to the previous block device content or does it specify an offset absolute to the beginning of the block device?

offset_in_sectors is the offset from the start of the device. The installer starts with 4MiB* offset and then loops through all defined partitions. It adds the size of each partition (rounded up to the next 4MiB* alignment) to the current offset. If it can fulfill the requested offset_in_sectors it will move the start of that partition to the specified offset.

If want_maximised comes in to play things getting a bit complicated: The Installer will first count the number of partitions which have want_maximised set and how much space is used in total. At the end it will divide the free space available and add it to the partitions with want_maximised. So it is rather hard to predict what a valid offset_in_sectors for those situation is. I recommend to use offset_in_sectors only in partitions which do not have a preceding partition with want_maximised set.

* This is a hard coded constant: 8192 (512 bytes) sectors

Thanks, that already helps a lot…

I tried to use the following pseudo-code to get my well defined layout:

    "blockdevs": [
        {
            "name": "mmcblk0",
            "erase": true,
            "table_type": "dos",
            "content": {
                "filesystem_type": "raw",
                "rawfiles": [
                    {
                        "filename": "<file-raw-first>",
                        "dd_options": "seek=<start-sector-raw-first>",
                        "size": 1
                    },
                    {
                        "filename": "<some-file-raw-second>",
                        "dd_options": "seek=<sector-greater-end-of-raw-first>",
                        "size": 1
                    }
                ]
            },
            "partitions": [
                {
                    "want_maximised": false,
                    "offset_in_sectors": <sector-greater-end-of-raw-second>,
                    "content": {
                        "uncompressed_size": <size>,
                        "filesystem_type": <fs-type>,
                        "filename": "<name>",
                        "mkfs_options": "<sector-size-as-positional-argument>",
                        "label": "<label>"
                    }
                },
                {
                    "want_maximised": false,
                    "offset_in_sectors": <sector-greater-end-of-part-first>,
                    "active": true,
                    "content": {
                        "uncompressed_size": <size>,
                        "filesystem_type": "<fs-type>",
                        "filename": "<name>",
                        "mkfs_options": "<sector-count-part-second>",
                        "label": "<label>"
                    }
                },
                {
                    ...
                    }
                },
                {
                    ...
                    }
                }
            ]
        },
        {
            "name": "mmcblk0boot0",
            "erase": true,
            "content": {
                "filesystem_type": "raw",
                "rawfiles": [
                    {
                        "filename": "<some-file>",
                        "dd_options": "seek=0",
                        "size": <size>
                    }
                ]
            }
        }
    ]

Unfortunately I get an error

Error creating file system
mke2fs 1.43 (17-May-2016)
mkfs.ext4: Invalid blocks '/dev/mmcblk0p1' on device '<sector-size-as-positional-argument>'

...

EDIT: The “mkfs_option” properties (for options $ man mkfs.ext4) only affect the file system in the already created partition. Trying to specify "sector-size-as-positional-argument" makes no sense then.

  • Is there some way to define the
    partition size specifically?

  • What’ s your suggestion if one want’s
    to implement a very well defined
    layout?

In case it is not possible to specify the location and size of partitions and raw files yet:

Do you consider to add it as new feature in a future version of EasyInstaller? (Dependent on the effort to implement that: v1.5?)

I am not quite clear what you specify as mkfs_options. With offset_in_sectors the partition will already starting at said offset. mkfs.ext4 should already guarantee to start from there, there should be no additional argument required.

Right now I do not know if there is a way to define the exact size of a partition (in addition to the start location) in “Apalis TK1 EasyInstaller v1.4”. In addition I recognized that the start of partitions was slightly shifted in comparison to an image I flashed using the old script approach (I expected the same start location). I will check this again and let you know…

If offset_in_sectors is used, and it is a valid offset, it should be used unaltered when creating the partition using cfdisk. /var/volatile/tezi.log should partitioning sent to cfdisk.

partition_size_nominal can be used to specify the partition size. However, sub-megabyte is not possible currently…

If offset_in_sectors is not set the Toradex Easy Installer tries to align to a 4MB byte boundary. A higher order alignment is (likely) helpful for the underlying wear leveling algorithm.

I cannot figure out why an exact specification of the layout does not work. Could you provide an example of exact layout specification with pseudo code and layout please? (Just to make sure I am not biases too much already and that I didn’t miss-understand you.)

The below layout works for me on 1.4:

{
    "config_format": 2,
    "autoinstall": false,
    "name": "Toradex Embedded Linux Demo with LXDE Complex",
    "description": "Toradex Embedded Linux Demo with LXDE with advanced Partition Layout.",
    "version": "2.8b2.97",
    "release_date": "2018-03-31",
    "u_boot_env": "uEnv.txt",
    "prepare_script": "prepare.sh",
    "wrapup_script": "wrapup.sh",
    "marketing": "marketing.tar",
    "icon": "toradexlinux.png",
    "supported_product_ids": [
        "0027",
        "0028",
        "0029",
        "0035"
    ],
    "blockdevs": [
        {
            "name": "mmcblk0",
            "erase": true,
            "table_type": "dos",
             "content": {
                 "filesystem_type": "raw",
                 "rawfiles": [
                     {
                         "filename": "marketing.tar",
                         "dd_options": "seek=8192",
                         "size": 1
                     },
                     {
                         "filename": "marketing.tar",
                         "dd_options": "seek=16384",
                         "size": 1
                     }
                 ]
             },
            "partitions": [
                {
                    "content": {
                        "filename": "Apalis-iMX6_LXDE-Image.bootfs.tar.xz",
                        "label": "BOOT",
                        "mkfs_options": "",
                        "uncompressed_size": 5.28125,
                        "filesystem_type": "FAT"
                    },
                    "want_maximised": false,
                    "offset_in_sectors": 24576,
                    "partition_size_nominal": 16
                },
                {
                    "content": {
                        "filename": "Apalis-iMX6_LXDE-Image.rootfs.tar.xz",
                        "label": "RFS",
                        "mkfs_options": "-E nodiscard",
                        "uncompressed_size": 514.1171875,
                        "filesystem_type": "ext4"
                    },
                    "want_maximised": false,
                    "partition_size_nominal": 1024
                },
                {
                    "content": {
                        "label": "DATA",
                        "mkfs_options": "-E nodiscard",
                        "filesystem_type": "ext4"
                    },
                    "want_maximised": true,
                    "partition_size_nominal": 1024
                }
            ]
        },
        {
            "name": "mmcblk0boot0",
            "content": {
                "rawfiles": [
                    {
                        "filename": "SPL",
                        "dd_options": "seek=2"
                    },
                    {
                        "filename": "u-boot.img",
                        "dd_options": "seek=138"
                    }
                ],
                "filesystem_type": "raw"
            }
        }
    ]
}

This leads to the following layout (according to /var/volatile/tezi.log):

Device         Boot   Start     End Sectors  Size Id Type
/dev/mmcblk0p1        24576   57343   32768   16M  c W95 FAT32 (LBA)
/dev/mmcblk0p2        57344 2154495 2097152    1G 83 Linux
/dev/mmcblk0p3      2154496 7733247 5578752  2.7G 83 Linux

When adding offset_in_sectors of 57344 explicitly to the RFS partition it leads to “Fixed partition offset too low” due to #35416.

@stefan.tx The EasyInstaller v1.4 docs state that partition_size_nominal is the “The minimal size of the partition in megabyte” which does not imply a maximal upper sector bound for me. However if I can use offset_in_sectors to define the start sector of a partition and offset_in_sectors + partition_size_nominal to define the end sector of a partition I am totally fine with that.

For raw files I probably do not need to define a specific end sector in case the end sector results from the file size implicitly. However I am not sure about that right now. In case I would need to define the end sector specifically: Is there a dd option which is known to work?

When adding offset_in_sectors of 57344 explicitly to the RFS partition it leads to “Fixed partition offset too low” due to #35416.

Thanks, did not notice that issue so far.

In your layout example the partitions are following each other without spacing (end sector 57343 of /dev/mmcblk0p1 is immediately followed by start sector 57344 of partition /dev/mmcblk0p2 and so on). What I was looking for is a way to define a layout with explicit end sectors, let’s say /dev/mmcblk0p1 with 57300 and /dev/mmcblk0p2 with start sector 57344.

@stefan.tx I found the issue. It was a plain MB vs. MiB issue which lead to the slightly shifted and miss spaced partitions. The layout including the end sectors can be defined just fine! Thanks for the help.

Glad you found the issue! You are welcome!