Hello everyone, I am ST.
Today I will tell you how to port the u-boot.2022.10 version to the imx6ull development board.
environment
options | content |
compile host | UbuntuLTS 18.04 |
target board | ATK I.MX6ULL(512MB DDR3 + 8GB EMMC) |
u-boot version | 2022.10 |
Cross Compilation Toolchain | gcc-linaro-7.5.0-2019.12-i686_arm-linux-gnueabihf |
1. Preparation of u-boot compilation environment
1. u-boot source package download
1.1. The uboot version used this time is 2022.10 version u-boot-2022.10.tar.bz2
1.2. Download link: https://ftp.denx.de/pub/u-boot/
2. compile
2.1. Copy u-boot-2022.10.tar.bz2 to ubuntu through a shared folder or FTP service
2.2. Decompress the source code package
tar -jxvf u-boot-2022.10.tar.bz2
3. Install dependent libraries
3.1. Compiling u-boot with the default configuration reports the following error
toto@toto:~/workspace/uboot/u-boot-2022.10$ make mx6ull_14x14_evk_defconfig
YACC scripts/kconfig/zconf.tab.c
/bin/sh: 1: bison: not found
scripts/Makefile.lib:222: recipe for target 'scripts/kconfig/zconf.tab.c' failed
make[1]: *** [scripts/kconfig/zconf.tab.c] Error 127
Makefile:578: recipe for target 'mx6ull_14x14_evk_defconfig' failed
make: *** [mx6ull_14x14_evk_defconfig] Error 2
Solution:
This error is caused by the lack of some related library files. It can be compiled normally after installation. The installation command:
sudo apt install bison flex
3.2, and then continue to compile and report an error
The solution is to install the lib32z1 dependent library
sudo apt-get install lib32z1
3.3. Continue to compile make and report an error
Solution:
Continue to install the dependent library libssl-dev
sudo apt-get install libssl-dev
3.4. After the compilation is passed, all dependent libraries of u-boot have been installed
2. Add your own development board to U-Boot
Add your own development board to U-Boot NXP's official uboot defaults to NXP's own development board, although we can directly modify it on the official development board so that u-boot can run completely on our board. But from a learning point of view, we can't understand how uboot adds new platforms. Next, we will refer to NXP's official I.MX6ULL EVK development board to learn how to add our development board or development platform in u-boot.
1. Add the development board default configuration file
First create a default configuration file in the configs directory, copy mx6ull_14x14_evk_defconfig, and then rename it to mx6ull_toto_defconfig, the command is as follows:
cd configs
cp mx6ull_14x14_evk_defconfig mx6ull_toto_defconfig
Then change the contents of the file mx6ull_toto_defconfig to the following:
CONFIG_ARM=y
CONFIG_ARCH_MX6=y
CONFIG_SYS_TEXT_BASE=0x87800000
CONFIG_SYS_MALLOC_LEN=0x1000000
CONFIG_NR_DRAM_BANKS=1
CONFIG_ENV_SIZE=0x2000
CONFIG_ENV_OFFSET=0xC0000
CONFIG_MX6ULL=y
CONFIG_TARGET_MX6ULL_TOTO=y
...
It can be seen that mx6ull_toto_defconfig is basically the same as the content in mx6ull_14x14_evk_defconfig, only the ninth line has been modified
2. Add the header file corresponding to the development board
Add the header file corresponding to the I.MX6ULL-ALPHA development board under the directory include/configs , copy include/configs/mx6ullevk.h, and rename it to mx6ull_toto.h, the command is as follows:
cp include/configs/mx6ullevk.h include/configs/mx6ull_toto.h
After the copy is complete it will:
#ifndef __MX6ULLEVK_CONFIG_H
#define __MX6ULLEVK_CONFIG_H
Change to:
#ifndef __MX6ULL_TOTO_CONFIG_H
#define __MX6ULL_TOTO_CONFIG_H
There are a lot of macro definitions in mx6ull_toto.h, such as configuring uboot’s default serial port to print which uart port to use, which network port to use by default, etc. There are also some default configurations of u-boot environment variables. If we want to change the default uart and enet ports, we can modify them in mx6ull_toto.h.
3. Add the board-level folder corresponding to the development board
Each board in uboot has a corresponding folder to store board-level files, such as peripheral driver files on the development board and so on. All board-level folders of NXP's I.MX series chips are stored in the board/freescale directory. In this directory, there is a folder named mx6ullevk . This folder is the board-level folder of NXP's official I.MX6ULL EVK development board. folder. Copy mx6ullevk and rename it to mx6ull_toto, the command is as follows:
cd board/freescale
cp -r mx6ullevk/ mx6ull_toto
Enter the mx6ull_toto directory, rename the mx6ullevk.c file to mx6ull_toto.c, the command is as follows:
cd mx6ull_toto
mv mx6ullevk.c mx6ull_toto.c
We also need to make some changes to the files in the mx6ull_toto directory:
3.1. Modify the Makefile in the mx6ull_toto directory
Change the content of the Makefile file under mx6ull_alientek_emmc to the following:
# SPDX-License-Identifier: GPL-2.0+
# (C) Copyright 2016 Freescale Semiconductor, Inc.
obj-y := mx6ull_toto.o
The point is to change obj-y in line 4 to mx6ull_toto.o, so that the file mx6ull_toto.c will be compiled.
3.2. Modify the imximage.cfg file in the mx6ull_toto directory
Change the following sentence in imximage.cfg:
#ifdef CONFIG_USE_IMXIMG_PLUGIN
/*PLUGIN plugin-binary-file IRAM_FREE_START_ADDR*/
PLUGIN board/freescale/mx6ullevk/plugin.bin 0x00907000
#else
Change to:
#ifdef CONFIG_USE_IMXIMG_PLUGIN
/*PLUGIN plugin-binary-file IRAM_FREE_START_ADDR*/
PLUGIN board/freescale/mx6ull_toto/plugin.bin 0x00907000
#else
3.3. Modify the Kconfig file in the mx6ull_toto directory
Modify the Kconfig file, the modified content is as follows:
if TARGET_MX6ULL_TOTO
config SYS_BOARD
default "mx6ull_toto"
config SYS_VENDOR
default "freescale"
config SYS_CONFIG_NAME
default "mx6ull_toto"
config IMX_CONFIG
default "board/freescale/mx6ull_toto/imximage.cfg"
endif
3.4. Modify the MAINTAINERS file in the mx6ull_toto directory
Modify the MAINTAINERS file, the modified content is as follows:
MX6ULLTOTO BOARD
M: Peng Fan <[email protected]>
S: Maintained
F: board/freescale/mx6ull_toto/
F: include/configs/mx6ull_toto.h
F: configs/mx6ull_toto_defconfig
F: configs/mx6ull_14x14_evk_plugin_defconfig
F: configs/mx6ulz_14x14_evk_defconfig
4. Modify arch/arm/mach-imx/mx6/Kconfig
Modify the file arch/arm/mach-imx/mx6/Kconfig, and add the following content in line 468 :
config TARGET_MX6ULL_TOTO
bool "Support mx6ull_toto"
depends on MX6ULL
select BOARD_LATE_INIT
select DM
select DM_THERMAL
imply CMD_DM
Add the following on line 717 :
source "board/freescale/mx6ull_toto/Kconfig"
5. Other places that need to be modified
There will be a sentence "Board: MX6ULL 14x14 EVK" in the uboot startup information, that is to say, the name of the board is "MX6ULL 14x14 EVK". Then if you want to change it to the name we want, you need to open the file mx6ull_toto.c, find the function checkboard , and change it to the following:
int checkboard(void)
{
if (is_cpu_type(MXC_CPU_MX6ULZ))
puts("Board: MX6ULZ 14x14 EVK\n");
else
puts("Board: MX6ULL TOTO\n");
return 0;
}
6. Compile uboot with the newly added board configuration
Create a new shell script named build.sh in the uboot root directory, and enter the following content in this shell script:
#!/bin/bash
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- distclean
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- mx6ull_toto_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j8
build.sh adds executable permissions, the command is as follows:
chmod 777 build.sh
3. Compile, download and verify
1. Compile
./build.sh
2. Successful compilation
...
DTC arch/arm/dts/imx6ulz-bsh-smm-m2.dtb
DTC arch/arm/dts/imx6ulz-14x14-evk.dtb
DTC arch/arm/dts/imx6q-apalis-eval.dtb
DTC arch/arm/dts/imx6dl-colibri-eval-v3.dtb
SHIPPED dts/dt.dtb
CAT u-boot-dtb.bin
COPY u-boot.dtb
COPY u-boot.bin
CFGS u-boot-dtb.cfgout
MKIMAGE u-boot-dtb.imx
3. Download verification
Use imxdownload to burn the newly compiled u-boot.bin to the SD card for testing. The output of SecureCRT is as follows:
sudo ./imxdownload u-boot.bin /dev/sdb
U-Boot 2022.10-gaef9f25a-dirty (Apr 05 2023 - 17:49:18 +0800) CPU: Freescale i.MX6ULL rev1.1 792 MHz (running at 396 MHz) CPU: Industrial temperature grade (-40C to 105C) at 26C Reset cause: POR Model: Freescale i.MX6 UltraLiteLite 14x14 EVK Board Board: MX6ULL TOTO DRAM: 512 MiB Core: 65 devices, 17 uclasses, devicetree: separate MMC: FSL_SDHC: 0, FSL_SDHC: 1 Loading Environment from MMC... OK In: serial Out: serial Err: serial Net: Could not get PHY for FEC1: addr 1 Could not get PHY for FEC1: addr 1 Get shared mii bus on ethernet@2188000 Could not get PHY for FEC1: addr 2 Get shared mii bus on ethernet@2188000 Could not get PHY for FEC1: addr 2 No ethernet found. Hit any key to stop autoboot: =>
It can be seen from the output results that everything is normal except that the network is not recognized.
Network debugging under u-boot will be introduced in detail in the next article, follow me, and watch the next article in time!