Skip to main content

Customization of U-Boot and Linux

U-Boot

Most projects can use the Embedded Artists U-Boot with little or no modification. The most common modification is to change the default .dtb file that will be loaded. Some projects might need additional early initialization of hardware and will put this in the board specific file of the U-Boot.

Board specific files

If modification is needed it can in most cases be limited to changes in the board specific file which is located in a sub-directory to <uboot-dir>/board/embeddedartists. The table below lists board specific files for the different COM boards.

https://github.com/embeddedartists/uboot-imx/tree/ea_v2018.03/board/embeddedartists

BoardBoard specific file
iMX6 UltraLite COMmx6ulea-com/mx6ulea-com.c
iMX6 SoloX COMmx6sxea-com/mx6sxea-com.c
iMX6 Quad COMmx6qea-com/mx6qea-com.c
iMX6 DualLite COMmx6qea-com/mx6qea-com.c
iMX7 Dual COMmx7dea-com/mx7dea-com.c
iMX7 Dual uCOMmx7dea-com/mx7dea-com.c
iMX7ULP uCOMmx7ulpea-ucom/mx7ulpea-ucom.c
iMX8M Nano uCOMmx8mnea-ucom/mx8mnea-ucom.c
iMX8M Mini uCOMmx8mmea-ucom/mx8mmea-ucom.c
iMX8M Quad COMmx8mqea-com/mx8mqea-com.c
iMX93 uCOMmx93ea-ucom/imx93ea-ucom.c

Device tree files

The U-Boot is also utilizing device tree files like the Linux kernel. The support for device trees is however (for version 2018.03) not as extensive as it is for the Linux kernel. Not all drivers have full support for device trees. If you need to change initialization of a peripheral or add a new peripheral that should be initialized in the U-Boot you might also need to modify the device tree file used in the U-Boot.

Device tree files are located in the directory <uboot-dir>/arch/arm/dts.

https://github.com/embeddedartists/uboot-imx/tree/ea_v2018.03/arch/arm/dts

The table below lists the device trees used for Embedded Artists COM boards.

BoardDevice tree file
iMX6 UltraLite COMimx6ulea-com-kit.dts
iMX6 SoloX COMimx6sxea-com-kit.dts
iMX6 Quad COMimx6qea-com-kit.dts
iMX6 DualLite COMimx6dlea-com-kit.dts
iMX7 Dual COMimx7dea-com-kit.dts
iMX7 Dual uCOMimx7dea-ucom-kit.dts
iMX7ULP uCOMimx7ulpea-ucom-kit_v2.dts
iMX8M Nano uCOMfsl-imx8mn-ea-ucom-kit_v2.dts
iMX8M Mini uCOMfsl-imx8mm-ea-ucom-kit_v2.dts
iMX8M Quad COMfsl-imx8mq-ea-com-kit_v2.dts
iMX93 uCOMimx93-ea-ucom-kit.dts

Configuration files

The configuration of a U-Boot is divided into two files. Historically it used to be an include file that contained all configurations, but more and more are moved to a defconfig file utilizing the same kind of configuration infrastructure (Kconfig) as in the Linux kernel. You will typically modify the defconfig file if you would like to add support for more U-Boot commands or drivers. Defconfig files are located in <uboot-dir>/configs/, see the table below for the files that are used by Embedded Artists COM boards.

Follow the link below to see the defconfig file for the iMX8M Mini uCOM board.

https://github.com/embeddedartists/uboot-imx/blob/ea_v2018.03/configs/mx8mmea-ucom_defconfig

BoardDevice tree file
iMX6 UltraLite COMconfigs/mx6ulea-com_defconfig
iMX6 SoloX COMconfigs/mx6sxea-com_defconfig
iMX6 Quad COMconfigs/mx6qea-com_defconfig
iMX6 DualLite COMconfigs/mx6dlea-com_defconfig
iMX7 Dual COMconfigs/mx7dea-com_defconfig
iMX7 Dual uCOMconfigs/mx7dea-ucom_defconfig
iMX7ULP uCOMconfigs/mx7ulpea-ucom_defconfig
iMX8M Nano uCOMconfigs/mx8mnea-ucom_defconfig
iMX8M Mini uCOMconfigs/mx8mmea-ucom_defconfig
iMX8M Quad COMconfigs/mx8mqea-com_defconfig
iMX93 uCOMconfigs/mx93ea-ucom_defconfig

If you instead want to modify for example the default U-Boot environment, such as change the default dtb file that is loaded, you need to do this change in the include file which is located in <uboot-dir>/include/configs/. See the table below for a list of all files used with Embedded Artists COM boards.

Follow the link below to see how the dtb file is defined in the U-Boot environment for the iMX8M Mini uCOM board.

https://github.com/embeddedartists/uboot-imx/blob/ea_v2018.03/include/configs/mx8mmea-ucom.h#L166

BoardDevice tree file
iMX6 UltraLite COMinclude/configs/mx6ulea-com.h
iMX6 SoloX COMinclude/configs/mx6sxea-com.h
iMX6 Quad COMinclude/configs/mx6qea-com.h
iMX6 DualLite COMinclude/configs/mx6qea-com.h
iMX7 Dual COMinclude/configs/mx7dea-com.h
iMX7 Dual uCOMinclude/configs/mx7dea-com.h
iMX7ULP uCOMinclude/configs/mx7ulpea-ucom.h
iMX8M Nano uCOMinclude/configs/mx8mnea-ucom.h
iMX8M Mini uCOMinclude/configs/mx8mmea-ucom.h
iMX8M Quad COMinclude/configs/mx8mqea-com.h
iMX93 uCOMinclude/configs/mx93ea-ucom.h

Linux

Customizing Linux for your product mostly involves creating or modifying device tree files, read the Device Tree section for more information about device tree files. In some cases, you might also need to modify the kernel configuration and / or add new device drivers. Our Linux kernel repository is available at GitHub: https://github.com/embeddedartists/linux-imx.

Kernel configuration

The default Linux kernel configuration for Embedded Artists COM boards is stored in the kernel sources. There are two different files; one for iMX6 / iMX7 based COM boards and another for iMX8 based COM boards.

Board familyConfiguration file
iMX6 and iMX7<kernel-dir>/arch/arm/configs/ea_imx_defconfig
iMX8 and iMX9<kernel-dir>/arch/arm64/configs/ea_imx8_defconfig

If you need to modify the default kernel configuration it is recommended to use a tool, such as make menuconfig, to do this instead of editing the configuration file manually. Here are instruction for how to run menuconfig from within Yocto: Kernel Configuration. In the section Build Linux kernel from source code you can see how to use menuconfig when building the kernel from source code.

In the example below we want to enable dynamic printk support (CONFIG_DYNAMIC_DEBUG) in the kernel.

  1. Run the menuconfig tool.
    make menuconfig
  2. In the menu go to Kernel hacking > printk and dmesg options > Enable dynamic printk() support
  3. Click Exit a number of times and when you are asked to save the new configuration click Yes.
  4. You can now build the kernel with the new configurations to make sure there are no errors.
  5. When you are satisfied with the configuration changes, generate a new defconfig file.
    make savedefconfig
  6. The file will be called defconfig and stored in the root of the kernel sources. You can replace the current default configurations by copying this file to the location of the default configuration file as shown below (for iMX8 and iMX9).
    cp defconfig arch/arm64/configs/ea_imx8_defconfig

Device drivers

Peripherals that you need access to from Linux needs a device driver. The kernel already contains device drivers for many peripherals so the first step is to search in the kernel sources for the peripheral. Device drivers are located in <kernel-dir>/drivers.

In the example below we search for the Atmel MXT1664 touch controller and finds it in the input/touchscreen directory.

cd <kernel-dir/drivers
grep -r mxt1664 *
input/touchscreen/Kconfig:        module will be called atmel_mxt1664_ts.
input/touchscreen/Makefile:obj-$(CONFIG_TOUCHSCREEN_ATMEL_MXT1664) += atmel_mxt1664_ts.o
input/touchscreen/atmel_mxt1664_ts.c:struct mxt1664_ts {
...

If the device driver isn't available in the kernel you need to add it. It is out-of-scope for this document to describe how you develop a new device driver and it is actually not that common that you need to develop it from scratch anyways. The most common approach to add a missing device driver to the kernel is as follows.

  1. Go to the manufacturer of the peripheral and see if they have a device driver available.
  2. If the manufacturer doesn't have a device driver look in newer versions of the Linux kernel you are using. If it has been added you need to back-port it to the version of the kernel you are using.
  3. Besides looking in a newer version of the kernel you are using you could look in other kernel source repositories such as the main line kernel or NXP’s community kernel.
  4. If you find a device driver you need to add it to your kernel sources which involves several steps (the exact number of steps can be different for different types of device drivers).
    • Copy the device driver file(s).
    • Add the new file to the relevant Makefile.
    • Add a new configuration to relevant Kconfig file.
    • Make sure the new configuration is enabled by adding it to the default configuration file.
    • Make sure everything builds.

If you inspect the commit below and look for mxt1664 you can see how Atmel'’'s touch controller driver was added.

https://github.com/embeddedartists/linux-imx/commit/5549a9a2bf234fe61db2eec5f25676e7d97fe091