Pages

2017-02-22

Yocto:i.MX6ULL - Customize Kernel Modules


1) Raspberry Pi - loaded network modules for NAT
pi@T0020:~ $ lsmod

Module                  Size  Used by
iptable_filter          1245  1 
cdc_acm                16033  2 
rndis_host              5252  0 
cdc_ether               4293  1 rndis_host
ip_tables              11417  1 iptable_filter
x_tables               12611  2 ip_tables,iptable_filter
bcm2835_gpiomem         2860  0 
i2c_bcm2708             4920  0 
bcm2835_rng             1763  0 
cp210x                  8363  1 
usbserial              21779  3 cp210x
uio_pdrv_genirq         2944  0 
uio                     7753  1 uio_pdrv_genirq
snd_bcm2835            19802  0 
snd_pcm                73474  1 snd_bcm2835
snd_timer              18848  1 snd_pcm
snd                    50779  3 snd_bcm2835,snd_timer,snd_pcm
i2c_dev                 5671  2 
fuse                   80694  1 
ipv6                  338660  30


2) Yocto Kernel Build Structure

  * linux-imx
./meta-fsl-arm/recipes-kernel/linux/linux-imx-4.1.15
./meta-fsl-arm/recipes-kernel/linux/linux-imx_4.1.15.bb
./meta-fsl-arm/recipes-kernel/linux/linux-imx-mfgtool_4.1.15.bb
./meta-fsl-arm/recipes-kernel/linux/linux-imx.inc
./meta-fsl-bsp-release/imx/meta-bsp/recipes-kernel/linux/linux-imx_4.1.15.bb
./meta-fsl-bsp-release/imx/meta-bsp/recipes-kernel/linux/linux-imx-mfgtool_4.1.15.bb
./meta-fsl-bsp-release/imx/meta-bsp/recipes-kernel/linux/linux-imx_%.bbappend

  * imx_v7_defconfig
./imx6ull14x14evk-fb/tmp/work-shared/imx6ull14x14evk/kernel-source/arch/arm/configs/imx_v7_defconfig


[Before starting the next steps, Read the manual]
* http://www.yoctoproject.org/docs/1.8/kernel-manual/kernel-manual.html
* http://www.yoctoproject.org/docs/1.8/dev-manual/dev-manual.html#understanding-and-creating-layers


3) Add T0040 Layer to BitBake

  * Folder Structure
${fsl-release-bsp}/sources/meta-t0040
${fsl-release-bsp}/sources/meta-t0040/conf
${fsl-release-bsp}/sources/meta-t0040/recipes-kernel
${fsl-release-bsp}/sources/meta-t0040/recipes-kernel/linux
${fsl-release-bsp}/sources/meta-t0040/recipes-kernel/linux/files

  * ${fsl-release-bsp}/sources/meta-t0040/conf/layer.conf
 # We have a conf and classes directory, append to BBPATH
BBPATH .= ":${LAYERDIR}"

# We have a recipes directory, add to BBFILES
BBFILES += "${LAYERDIR}/recipes-*/*/*.bb ${LAYERDIR}/recipes-*/*/*.bbappend"

BBFILE_COLLECTIONS    += "t0040"
BBFILE_PATTERN_t0040  := "^${LAYERDIR}/"
BBFILE_PRIORITY_t0040  = "9"
LAYERVERSION_t0040     = "1"

  * ${fsl-release-bsp}/sources/meta-t0040/recipes-kernel/linux/linux-imx_%.bbappend
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
SRC_URI += "file://fragment-t0040.cfg"

# support for TUN / RNDIS / IP_TABLES
do_configure_prepend () {
    echo "CONFIG_NETFILTER=y"               >>  ${B}/.config
    echo "CONFIG_NETFILTER_DEBUG=y"         >>  ${B}/.config
    echo "CONFIG_NETFILTER_ADVANCED=n"      >>  ${B}/.config

    echo "CONFIG_TUN=m"                     >>  ${B}/.config

    echo "CONFIG_USB_ETH_RNDIS=m"           >>  ${B}/.config
    echo "CONFIG_USB_NET_RNDIS_HOST=m"      >>  ${B}/.config

    echo "CONFIG_NETFILTER_XTABLES=m"       >>  ${B}/.config

    echo "CONFIG_NF_CONNTRACK=m"            >>  ${B}/.config
    echo "CONFIG_NF_TABLES=m"               >>  ${B}/.config
    echo "CONFIG_NF_NAT=m"                  >>  ${B}/.config
    echo "CONFIG_NF_NAT_MASQUERADE_IPV4=m"  >>  ${B}/.config

    echo "CONFIG_IP_NF_CONNTRACK=m"         >>  ${B}/.config
    echo "CONFIG_IP_NF_NAT=m"               >>  ${B}/.config
    echo "CONFIG_IP_NF_TARGET_MASQUERADE=m" >>  ${B}/.config
}

  * ${fsl-release-bsp}/sources/meta-t0040/recipes-kernel/linux/files/fragment-t0040.cfg
- It is created by below sequence
bitbake linux-imx -c menuconfig
bitbake linux-imx -c diffconfig
- And copy the fragment in 
./imx6ull14x14evk-fb/tmp/work/imx6ull14x14evk-poky-linux-gnueabi/linux-imx/4.1.15-r0/fragment.cfg
  to the destination directory(.../recipes-kernel/linux/!!)


4) Enable T0040 Layer on the Build Configuration

  * ${fsl-release-bsp}/imx6ull14x14evk-fb/conf/bblayers.conf
LCONF_VERSION = "6"

BBPATH = "${TOPDIR}"
BSPDIR := "${@os.path.abspath(os.path.dirname(d.getVar('FILE', True)) + '/../..')}"

BBFILES ?= ""
BBLAYERS = " \
  ${BSPDIR}/sources/poky/meta \
  ${BSPDIR}/sources/poky/meta-yocto \
  \
  ${BSPDIR}/sources/meta-openembedded/meta-oe \
  ${BSPDIR}/sources/meta-openembedded/meta-multimedia \
  \
  ${BSPDIR}/sources/meta-fsl-arm \
  ${BSPDIR}/sources/meta-fsl-arm-extra \
  ${BSPDIR}/sources/meta-fsl-demos \
  ${BSPDIR}/sources/meta-t0040 \
"
##Freescale Yocto Project Release layer
BBLAYERS += " ${BSPDIR}/sources/meta-fsl-bsp-release/imx/meta-bsp "
BBLAYERS += " ${BSPDIR}/sources/meta-fsl-bsp-release/imx/meta-sdk "
BBLAYERS += " ${BSPDIR}/sources/meta-browser "
BBLAYERS += " ${BSPDIR}/sources/meta-openembedded/meta-gnome "
BBLAYERS += " ${BSPDIR}/sources/meta-openembedded/meta-networking "
BBLAYERS += " ${BSPDIR}/sources/meta-openembedded/meta-python "
BBLAYERS += " ${BSPDIR}/sources/meta-openembedded/meta-filesystems "
BBLAYERS += " ${BSPDIR}/sources/meta-qt5 "


4) Rebuild the Image!!
bitbake -c clean virtual/kernel 
bitbake fsl-image-gui


No comments:

Post a Comment