Easy Installer custom image from RAW file

Before Easy Installer, we have a procedure to program brand new Apalis iMX6 boards via a ‘dd’ command to rewrite all the mmc. We have a RAW file that is the clone of the full mmc.
How can I use this file to create a custom image for Easy Installer?

I’ve made several test editing the JSON config file from the Linux LXDE image. No luck so far.
This is the last version

{
  "autoinstall": false,
  "config_format": 1,
  "name": "Custom Image",
  "description": "Custom Image",
  "version": "0.7.34.600",
  "release_date": "2018-09-06",
  "prepare_script": "prepare.sh",
  "wrapup_script": "wrapup.sh",
  "marketing": "marketing.tar",
  "icon": "toradexlinux.png",
  "supported_product_ids": [
    "0027",
    "0028",
    "0029",
    "0035"
  ],
  "blockdevs": [
    {
      "name": "mmcblk0",
      "content": {
        "filesystem_type": "raw",
        "rawfiles": [
          {
            "dd_options": "bs=10M",
            "filename": "emmc.raw",
            "size": 3776
          }
        ]
      }
    }
  ]
}

What I’m doing is dd-ing the .raw file in mmcblk0 device.
First, what I WAS doing is dd the raw file in mmcblk2 device. Using mmcblk2 I get an error from Easy Installer since mmcblk2 is not present. FYI, this is the output of lsblk on the source device (the une I used to create the .raw file)

mmcblk2boot0 179:8    0     2M  1 disk 
mmcblk2boot1 179:16   0     2M  1 disk 
mmcblk2      179:0    0   3.7G  0 disk 
`-mmcblk2p1  179:1    0   3.7G  0 part /

Since it is the full clone, I -suppose- I don’t need to actually clone the u-boot.imx file in mmc2boot0/1 partitions (tested it too, but still no luck. Also, I don’t have no SPL file).
Note, I’ve created the RAW file with this command

# dd bs=10M if=/dev/mmcblk2 of=/media/stock/emmc.raw

I run this command from a “temporary” OS run from SD.

What happens with my custom image is:

  • I get an error from Easy Installer that a couple of bytes was not written on device due to the fact that there is no space left
  • After the Easy Installer install procedure the original Apalis u-boot runs on reboot instead of mine
  • If I force bmode mmc from u-boot the system restart and then freeze

I would not recommend doing this from such a raw file as this may easily break in the future if anything changes (and things will change as the only constant is change). If you really do believe in this cloning approach please have a look at the following article on our developer website which explains how this may be done in an at least halfway sensible way.

If I still want to use Easy Installer, the steps to follow are:

  • create an archive with the current file system and copy in the Easy Installer folder
  • create an archive with kernel (uImage + DTB file) and copy in the Easy Installer folder
  • edit json config file so that file system and kernel will be put in two separate partitions

But what about u-boot? I have the .imx file, that can be put in mmcxxxxboot0. LXDE json also adds a SPL, that I don’t have. Is it mandatory? (I’ve searched about it but didn’t find a ). Loading the correct u-boot is my main concern at the moment; after every image flash tentative I’ve always had the default Apalis u-boot running…

Also, once u-boot is up and running I have to edit it so that:

  • it searches in the right mmc (0 instead of 2)
  • loads kernel from right place (no more /boot folder in filesystem but in the second partition)

Actually, I suppose I can still skip the second partition (the kernel one) and go on with kernel in the /boot folder.

If I still want to use Easy Installer, the steps to follow are:

  • create an archive with the current file system and copy in the Easy Installer folder
  • create an archive with kernel (uImage + DTB file) and copy in the Easy Installer folder
  • edit json config file so that file system and kernel will be put in two separate partitions

More or less, yes. Just what our article says basically.

But what about u-boot? I have the .imx file, that can be put in mmcxxxxboot0. LXDE json also adds a SPL, that I don’t have. Is it mandatory? (I’ve searched about it but didn’t find a ). Loading the correct u-boot is my main concern at the moment; after every image flash tentative I’ve always had the default Apalis u-boot running…

Then, you are probably using some older U-Boot version (I hope at least a stable one otherwise watch out for various boot issues). Some of this may be explained in the following article.

Also, once u-boot is up and running I have to edit it so that:

You mean edit the U-Boot environment?

That may be done via u_boot_env as explained here.

it searches in the right mmc (0 instead of 2)

loads kernel from right place (no more /boot folder in filesystem but in the second partition)

Actually, I suppose I can still skip the second partition (the kernel one) and go on with kernel in the /boot folder.

You may of course do as you please but remember to adjust resp. configuration.

Thanks for the detailed info.

I’m working with an u-boot V2.4, so yes, quite an old one. But, well, a working one… If I can go on with this version (at least for a while) I’ll be glad!

I’ve made some modifications to the JSON and now the u-boot is -almost- running. It starts but soon freezes. Here’s the output:

U-Boot 2015.04-00056-g158b428-dirty (Jul 14 2017 - 17:17:00)

CPU:   Freescale i.MX6Q rev1.5 at 792 MHz
CPU:   Serial: 0x0A1C29D4EA9ADD2D
CPU:   Temperature 27 C
Reset cause: POR
Boot:  eMMC
I2C:   ready
DRAM:  1 GiB
PMIC: device id: 0x10, revision id: 0x21
PMIC: programmed
Vendor: MYCOMP
MMC:   FSL_SDHC: 0, FSL_SDHC: 1, FSL_SDHC: 2

I’ve tried both the u-boot with default environment variables and with an u_boot_env “script” to change the mmc indexes; same result.

Any idea about what could cause such behavior?

In the meanwhile I’m gonna re-read the article you’ve linked

Thanks for the detailed info.

You are very welcome.

I’m working with an u-boot V2.4, so yes, quite an old one.

V2.4 was really only ever released as a beta version never intended for any production use and is long since unsupported as per our support strategy.

But, well, a working one… If I can go on with this version (at least for a while) I’ll be glad!

Lucky you. However, there are various known issues around that ancient version.

I’ve made some modifications to the JSON and now the u-boot is -almost- running. It starts but soon freezes. Here’s the output: …

I’ve tried both the u-boot with default environment variables and with an u_boot_env “script” to change the mmc indexes; same result.

Any idea about what could cause such behavior?

Yes, that ancient U-Boot does not like being booted from the hardware area boot partition in the so-called fast boot mode. Both concepts are further mentioned here.

Our stable BSP V2.6 switched to those concepts by default and the Toradex Easy Installer also defaults to this potentially fusing the SoC resp. re-configuring the eMMC via a wrapup script.

Basically, the eMMC aka SDHCI driver can not cope with the IP being left in fast boot mode when handed over to it during boot.

So you are really strongly advised to update to a later U-Boot version.

In the meanwhile I’m gonna re-read the article you’ve linked

I thought that this behaviour could have something to do with the fast boot mode…
For testing purpose, is there a way to disable the fast boot? So I’m sure that everything works and it’s “just” a matter of updating the u-boot. The post install script says that the fast boot enable operation is a “once-time operation” and a “non-reversible” one…

I thought that this behaviour could have something to do with the fast boot mode… For testing purpose, is there a way to disable the fast boot? So I’m sure that everything works and it’s “just” a matter of updating the u-boot. The post install script says that the fast boot enable operation is a “once-time operation” and a “non-reversible” one…

No, unfortunately, there is no way to revert using the fast boot mode.

I’ve updated the u-boot to branch 2015.04-toradex (v2.6, I suppose). Not the last one because I had too much to merge… Now I’m able to flash u-boot and rootfs correctly!

Thanks for your kind help

You are very welcome.