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
Board | Board specific file |
---|---|
iMX6 UltraLite COM | mx6ulea-com/mx6ulea-com.c |
iMX6 SoloX COM | mx6sxea-com/mx6sxea-com.c |
iMX6 Quad COM | mx6qea-com/mx6qea-com.c |
iMX6 DualLite COM | mx6qea-com/mx6qea-com.c |
iMX7 Dual COM | mx7dea-com/mx7dea-com.c |
iMX7 Dual uCOM | mx7dea-com/mx7dea-com.c |
iMX7ULP uCOM | mx7ulpea-ucom/mx7ulpea-ucom.c |
iMX8M Nano uCOM | mx8mnea-ucom/mx8mnea-ucom.c |
iMX8M Mini uCOM | mx8mmea-ucom/mx8mmea-ucom.c |
iMX8M Quad COM | mx8mqea-com/mx8mqea-com.c |
iMX93 uCOM | mx93ea-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.
Board | Device tree file |
---|---|
iMX6 UltraLite COM | imx6ulea-com-kit.dts |
iMX6 SoloX COM | imx6sxea-com-kit.dts |
iMX6 Quad COM | imx6qea-com-kit.dts |
iMX6 DualLite COM | imx6dlea-com-kit.dts |
iMX7 Dual COM | imx7dea-com-kit.dts |
iMX7 Dual uCOM | imx7dea-ucom-kit.dts |
iMX7ULP uCOM | imx7ulpea-ucom-kit_v2.dts |
iMX8M Nano uCOM | fsl-imx8mn-ea-ucom-kit_v2.dts |
iMX8M Mini uCOM | fsl-imx8mm-ea-ucom-kit_v2.dts |
iMX8M Quad COM | fsl-imx8mq-ea-com-kit_v2.dts |
iMX93 uCOM | imx93-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
Board | Device tree file |
---|---|
iMX6 UltraLite COM | configs/mx6ulea-com_defconfig |
iMX6 SoloX COM | configs/mx6sxea-com_defconfig |
iMX6 Quad COM | configs/mx6qea-com_defconfig |
iMX6 DualLite COM | configs/mx6dlea-com_defconfig |
iMX7 Dual COM | configs/mx7dea-com_defconfig |
iMX7 Dual uCOM | configs/mx7dea-ucom_defconfig |
iMX7ULP uCOM | configs/mx7ulpea-ucom_defconfig |
iMX8M Nano uCOM | configs/mx8mnea-ucom_defconfig |
iMX8M Mini uCOM | configs/mx8mmea-ucom_defconfig |
iMX8M Quad COM | configs/mx8mqea-com_defconfig |
iMX93 uCOM | configs/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
Board | Device tree file |
---|---|
iMX6 UltraLite COM | include/configs/mx6ulea-com.h |
iMX6 SoloX COM | include/configs/mx6sxea-com.h |
iMX6 Quad COM | include/configs/mx6qea-com.h |
iMX6 DualLite COM | include/configs/mx6qea-com.h |
iMX7 Dual COM | include/configs/mx7dea-com.h |
iMX7 Dual uCOM | include/configs/mx7dea-com.h |
iMX7ULP uCOM | include/configs/mx7ulpea-ucom.h |
iMX8M Nano uCOM | include/configs/mx8mnea-ucom.h |
iMX8M Mini uCOM | include/configs/mx8mmea-ucom.h |
iMX8M Quad COM | include/configs/mx8mqea-com.h |
iMX93 uCOM | include/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 family | Configuration 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.
- Run the
menuconfig
tool.make menuconfig
- In the menu go to Kernel hacking > printk and dmesg options > Enable dynamic printk() support
- Click
Exit
a number of times and when you are asked to save the new configuration clickYes
. - You can now build the kernel with the new configurations to make sure there are no errors.
- When you are satisfied with the configuration changes, generate a new
defconfig
file.make savedefconfig
- 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.
- Go to the manufacturer of the peripheral and see if they have a device driver available.
- 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.
- 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.
- 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