Skip to main content

Optimization - iMX8M Mini uCOM

In this chapter we explore some of the methods of reducing the boot time for the iMX8M Mini uCOM board. The process would be the same for a different COM board. For more ways to reduce the boot time you can look at the documentation mentioned in the Additional resources section.

Please note that the methods are explored in the order described below. Applying a method in a different order could also give a different reduced time for that specific method. For example, if you would disable peripherals in the device tree before silencing the kernel the amount of reduced time due to silencing the kernel would most likely be different. This is also the reason why the total reduced boot time as described in the Summary of reduced boot time section is different from the sum of all times listed in respective section.

U-Boot boot delay

By default, U-Boot has been setup with a boot delay of 2 seconds for the iMX8M Mini. The reason why the delay exists is to make it easier to enter into the U-Boot console. If you hit any key on your keyboard before the delay expires you will enter into the console.

From within the U-Boot console set the boot delay to zero using the commands below.

setenv bootdelay 0
saveenv

Reduced boot time: ~2 seconds.

note

The values specified in the table in Boot time - Summary section above already include this reduction in boot time.

Silence the kernel

The Linux kernel outputs a lot of messages to the console during boot. Outputting characters on a serial console takes time so reducing the amount will also reduce boot time. It is possible to do this by setting the kernel boot argument quiet.

From within the U-Boot console add quiet to extra_bootargs.

setenv extra_bootargs quiet
saveenv

Reduced boot time: ~3.3 seconds.

Below you can see the amount of time that has been reduced at certain time points.

  • Linux: Init process: ~1.9 seconds
  • Linux: Basic service: ~3.0 seconds
  • Linux: Login prompt: ~3.3 seconds
note

Silencing the kernel with quiet might also suppress error and warning messages.

Simplify boot command

The default boot command is quite complex and involves checking if devices and files are available. If they are not trying alternative boot methods. It also involves loading a boot script from eMMC flash. For a product where we only want to boot from eMMC the boot command can be simplified as below.

note

By doing this simplification we lose the possibility to use extra_bootargs. We can however use the variable args_from_script instead to set the kernel boot argument quiet.

setenv bootcmd 'mmc dev \${mmcdev}; if run loadimage; then run mmcboot; fi;'
setenv args_from_script quiet
saveenv

Reduced boot time: ~200 milliseconds.

Increase I2C speed in SPL

SPL is responsible for initializing the DDR RAM. The configuration data used during initialization is stored in EEPROM accessed via the I2C bus. Reading data from the EEPROM takes some time.

At the time of writing this document the default I2C speed in SPL is 100 kHz. Increasing this to 400 kHz will reduce the time of reading the configuration data.

To be able to increase the I2C speed you have to make two changes.

  • CONFIG_SYS_I2C_SPEED: Set this define to 400000 in include/configs/mx8mmea-ucom.h.
  • CONFIG_SYS_MXC_I2C1_SPEED: Set this configuration to 400000 in configs/mx8mmea-ucom_defconfig.

Reduced boot time: ~350 milliseconds.

Disable U-Boot functionality

One more way of reducing boot time is by removing functionality that you don’t need. In this example the following was removed from U-Boot.

  • Fastboot: This functionality is mainly used by the Universal Update Utility (UUU) when flashing / programming a target. You can use a separate U-Boot used by UUU that still has the fastboot functionality.
  • Video: If your product doesn’t have a display or you don’t need U-Boot to show anything on the display the video functionality can be removed.
  • Network. If you don’t need network functionality from U-Boot this can be removed.
  • MMC Env: There is a call to board_late_mmc_env_init in the board specific code that dynamically updates the mmcdev and mmcroot variables. This exists to be more flexible of choosing the mmc device used by U-Boot and Linux kernel. In most cases the device is fixed and cannot be changed so the call to this function can be removed.

The following changes was made in configs/mx8mmea-ucom_defconfig. The configurations below were previously enabled, that is, set to y.

CONFIG_FASTBOOT=n
CONFIG_USB_FUNCTION_FASTBOOT=n
CONFIG_CMD_FASTBOOT=n
CONFIG_ANDROID_BOOT_IMAGE=n
CONFIG_FASTBOOT_UUU_SUPPORT=n
CONFIG_VIDEO_IMX_SEC_DSI=n
CONFIG_DM_VIDEO=n
CONFIG_VIDEO_ADV7535=n
CONFIG_SYS_WHITE_ON_BLACK=n
CONFIG_NET=n

The following configurations were removed in include/configs/mx8mmea-ucom.h.

/*
#define CONFIG_CMD_USB_MASS_STORAGE
#define CONFIG_USB_GADGET_MASS_STORAGE
#define CONFIG_USB_FUNCTION_MASS_STORAGE
*/

Remove the call to board_late_mmc_env_init in board/embeddedartists/mx8mmea-ucom/mx8mmea-ucom.c. The call is done in the function board_late_init.

...
int board_late_init(void)
{
#ifdef CONFIG_ENV_IS_IN_MMC
// board_late_mmc_env_init();
#endif
...

Reduced boot time: ~480 milliseconds.

Disable peripherals in kernel device tree (dts)

As for the U-Boot, functionality can also be removed from the Linux kernel. The easiest way is to disable peripherals in the device tree (dts). If a peripheral is disabled the corresponding driver won’t be fully initialized and thereby reducing the boot time. We are not showing the completely modified device tree file. It was the following functionality that was disabled.

  • Audio-related
  • Display-related
  • Network interface
  • FlexSPI
  • Unused UART devices
  • Unused USDHC devices
  • PWM
  • GPIO buffer

You disable a peripheral by setting the status in the device tree node to disabled. In the excerpt below you can see how the network interface (fec1 node) is disabled.

&fec1 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_fec1>;
phy-mode = "rgmii-id";
phy-handle = <&ethphy0>;
fsl,magic-packet;
status = "disabled";

mdio {
#address-cells = <1>;
#size-cells = <0>;

ethphy0: ethernet-phy@0 {
compatible = "ethernet-phy-ieee802.3-c22";
reg = <0>;
at803x,led-act-blind-workaround;
at803x,eee-okay;
at803x,vddio-1p8v;
};
};
};

Reduced boot time: ~130 milliseconds.

Reduce kernel size

Loading the kernel from eMMC to RAM takes time. Reducing the size of the kernel can therefore reduce the boot time. This was tested by removing some functionality in the kernel. The kernel size shrunk from about 26 Mbyte to about 21 Mbyte. The reduced boot time was in this case only about 50 milliseconds. This option wasn’t further explored and is not included in the summary in the Summary of reduced boot time section below.

Summary of reduced boot time

In the table below we compare the boot time for the unmodified distribution with the one where the above described optimizations have been applied. As you can see the total boot time from reset to login prompt has been reduced with about 5.5 seconds (from almost 10.5 seconds to about 5 seconds).

Time pointUnmodifiedOptimizedReduced time
SPL: board_init_r1531530
U-Boot: board_early_init_f13641013351
U-Boot: board_init15971248349
U-Boot: Starting kernel295918961063
Linux: Init process608428023282
Linux: Basic service802135834438
Linux: Login prompt1045949275532