2. Modify
and recompile the kernel, uboot, and the file system
2.1 How to modify Yocto after the source
code of kernel or uboot is modified?
When we recompile in Yocto after the source
code of kernel or uboot is modified, we need to modify commit ID of the kernel
or uboot.
-
How
to get the commit ID of the kernel or uboot?
In the
directory of the kernel or uboot:
git add . (commit all the modification)
git config - -gobal user.email “your Email address”
(commit the email address of the modifier)
git config - - global user.name “your name” (commit the
name of the modifier)
git commit -m “comment”(add comment)
git log (get the commit ID)
-
If
the kernel is modified, we need to modify the “SRCREV” under below address:
/home/roy/MYD-Y6ULX-devel/04-Source/fsl-release-Yocto/sources/meta-myir-imx6ulx/recipes-kernel/linux/linux-mys6ulx_4.1.15.bb
Example
code:
# Copyright (C) 2013-2016 Freescale Semiconductor
# Released under the MIT license (see COPYING.MIT for the
terms)
SUMMARY = "Linux Kernel for MYiR MYS6ULx board"
DESCRIPTION = "Linux Kernel provided and supported
by Freescale with focus on \
i.MX Family Reference Boards. It includes support for
many IPs such as GPU, VPU and IPU."
require recipes-kernel/linux/linux-imx.inc
require recipes-kernel/linux/linux-dtb.inc
DEPENDS += "lzop-native bc-native"
LOCALVERSION = "-1.2.0"
SRCREV =
"d87b5be6bfc5a78cd45d8efa044fddcd7f4b2ac1"
SRCBRANCH = "mys-6ulx"
SRC_URI =
"git:///${HOME}/MYiR-iMX-Linux;protocol=file;branch=${SRCBRANCH} \
file://defconfig \
"
DEFAULT_PREFERENCE = "1"
COMPATIBLE_MACHINE = "(mx6ull|mx6ul)"
-
In
Yocto, the directory to modify the commit ID of uboot:
/home/roy/MYD-Y6ULX-devel/04-Source/fsl-release-Yocto/sources/meta-myir-imx6ulx/recipes-bsp/u-boot/u-boot-mys6ulx_2016.03.bb
2.2 How to tailor “make menuconfig“
of kernel? How to add new device?
Below is how to configure the kernel and how
to add new device.
-
3 ways to configure the kernel:
1. make config
2. make menuconfig
3. make xconfig (QT is needed)
Either of above 3 ways works, “make menuconfig”
is recommended.
Input this command in the terminal for VM to
open the kernel configuration interface: make menuconfig.
-
How to operate the kernel configuration interface:
1. Pressing
y to select.
2. Pressing
n not to select.
3. Pressing
m to make it a module.
4. Press
Esc to back to upper level page.
5. Press
the arrow keys to select.
6. [*]
means already selected.
7. [ ]
means not selected yet.
Generally, we tailor the kernel according to
actual demand. We introduce some necessary items here.
“General setup-->System V IPC (IPC: Inter
Process Communication)” is necessary.
After all the necessary items have been
configured, press Esc to quit, choose Yes to save.
After setting up the cross-compiler, input the
command in the terminal: make. Then wait for a long period of time. After the
compilation is completed, “zlmage” would be generated under directory “. /arch/arm/boot/”.
-
Add
new device in the kernel (take LED driver for example)
Create a LED directory under “kernel\drivers\char\”,
put the LED driver code in this directory.
Modify the “Makefile” in “kernel\drivers\char\”
to include the LED directory: add “obj-y += led/” in the “Makefile”.
-
obj-y
means get “foo.o” from compiling “xx.c” or “foo.s” file and connect “foo.o” to
the kernel.
-
obj-m
means to compile this file as a module.
Object files except “y” and “m” won’t be
compiled.
Add “Makefile” file and “Kconfig” file to LED
directory, then add below contents to these 2 files:
“Makefile” file:
obj-$(CONFIG_MY_LED_DRIVER) += my-led.o
“Kconfig” file:
config MY_LED_DRIVER
bool "my led driver"
default y
help
compile for leddriver, y for kernel, m for module.
The needed knowledge in practice is far more
than we have introduced here, to read relevant books or contents online is
suggested.
2.3 After compiling the kernel or
uboot separately we get many files, which one to use?
“zlmage” file under directory “~/MYiR-imx-Linux/arch/arm/boot/”
is from compiling kernel.
“u-boot.imx” file under directory “~/MYiR-iMX-uboot/”
is from compiling uboot.
2.4 How to find “myd-y6ull-boot-mmc0-tftp.txt”?
How to use?
When we boot Linux from SD card using u-boot,
the system would check the file “boot.scr”. When creating SD card booting file,
if nand flash is used on the board, “boot.scr” is not needed. If eMMC flash is
used on the board, “boot.scr” is needed.
Generally, the content of “boot.scr” won’t be
modified. The content of “boot.scr” is not included in the CDs which MYIR delivers
with MYD-Y6UL & 6ULL development boards, you may edit it by yourself as
below.
setenv mmcroot '/dev/mmcblk0p2 rootwait rw rootdelay=5
mem=256M'
run mmcargs
tftpboot 0x83000000 zImage
tftpboot 0x84000000 myd-y6ull-gpmi-weim.dtb
bootz 0x83000000 - 0x84000000
|