Giter Site home page Giter Site logo

lkm's Introduction

Build Yocto image for i.MX6UL device and write kernel module

Product: https://variwiki.com/index.php?title=VAR-SOM-6UL

image

1. Setup Docker Clone Variscite's Docker container repository:

$ git clone https://github.com/varigit/var-host-docker-containers.git ~/var-host-docker-containers

Create folder in host(ubuntu) machine

$ mkdir ~/var-fslc-yocto

Starting a container

$ cd ~/var-host-docker-containers
$ ./run.sh -p -u 20.04 -w ~/docker-yocto-build -v ~/var-fslc-yocto

vari@abe078d0f67c:/workdir$ grep DESCRIPTION /etc/lsb-release
DISTRIB_DESCRIPTION="Ubuntu 20.04.2 LTS"

2. Build Yocto image and generate SDK

Download the latest revision

$ repo init -u https://github.com/varigit/variscite-bsp-platform.git -b kirkstone -m kirkstone-5.15.71-2.2.0.xml
$ repo sync -j$(nproc)

Build X11 GUI demo image

$ MACHINE=imx6ul-var-dart DISTRO=fslc-x11 . setup-environment build_x11

The above command is only mandatory for the very first build setup: whenever restarting a newer build session (from a different terminal or in a different time), you can skip the full setup and just run

$ source setup-environment build_x11

Use systemd instead of SysV init

Append the following to the conf/local.conf file in your Yocto build directory, to use systemd instead of SysV init in your images:

DISTRO_FEATURES:append = " virtualization"
DISTRO_FEATURES:append = " systemd"
DISTRO_FEATURES_BACKFILL_CONSIDERED:append = " sysvinit"
VIRTUAL-RUNTIME_init_manager = "systemd"
VIRTUAL-RUNTIME_initscripts = ""
IMX_DEFAULT_DISTRO_FEATURES:append = " systemd"

Append the following to the conf/local.conf file in your Yocto build directory, to add Eclipse debug support to your images:

EXTRA_IMAGE_FEATURES = " \
    eclipse-debug \
    ssh-server-openssh \
    "

Append the following to the conf/local.conf file in your Yocto build directory, to generate kernel header for kernel module compile:

TOOLCHAIN_TARGET_TASK:append = " kernel-devsrc"

Execute bitbake command to generate the Yocto image including the SDK (take couple hours)

$  bitbake -c populate_sdk fsl-image-gui

When the build step is done

image:
~/var-fslc-yocto/build_x11/tmp/deploy/images/imx6ul-var-dart/fsl-image-gui-imx6ul-var-dart-20240505161420.rootfs.wic.gz
sdk:
~/var-fslc-yocto/build_x11/tmp/deploy/sdk/fslc-x11-glibc-x86_64-fsl-image-gui-cortexa7t2hf-neon-imx6ul-var-dart-toolchain-4.0.sh

3. Flash image to SD-card

$ zcat tmp/deploy/images/imx6ul-var-dart/fsl-image-gui-imx6ul-var-dart.wic.gz | sudo dd of=/dev/sdX bs=1M && sync

Bootup device and connect via USB OTG Etherne

$ modprob g_ether
$ ifconfig usb0 192.168.6.1

image

Config your host(ubuntu) ip to 192.168.6.100

image

4. Install SDK to host(ubuntu) machine

Execute command to install SDK:

~/var-fslc-yocto/build_x11/tmp/deploy/sdk/fslc-x11-glibc-x86_64-fsl-image-gui-cortexa7t2hf-neon-imx6ul-var-dart-toolchain-4.0.sh

image

The script will install the SDK to:

/opt/fslc-x11/4.0

Build the Kernel header for kernel module development

$ cd /opt/fslc-x11/4.0/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi/lib/modules/5.15.71-imx6ul+g5ebe23fd1585/build

Copy the config folder from this repo for pre-config of kernel

https://github.com/nxp-imx/linux-imx/tree/git.kernel.org/linux-stable/linux-5.15.y/arch/arm/configs
$ sudo cp -r configs /opt/test-fslc-x11/4.0/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi/lib/modules/5.15.71-imx6ul+g5ebe23fd1585/build/arch/arm/.

Build the kernel:

$ pwd
/opt/fslc-x11/4.0/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi/lib/modules/5.15.71-imx6ul+g5ebe23fd1585
$ sudo make ARCH=arm CROSS_COMPILE=/opt/fslc-x11/4.0/sysroots/x86_64-fslcsdk-linux/usr/bin/arm-fslc-linux-gnueabi/arm-fslc-linux-gnueabi- imx_v7_defconfig

image

$ sudo make ARCH=arm CROSS_COMPILE=/opt/fslc-x11/4.0/sysroots/x86_64-fslcsdk-linux/usr/bin/arm-fslc-linux-gnueabi/arm-fslc-linux-gnueabi- scripts

image

$ sudo make ARCH=arm CROSS_COMPILE=/opt/fslc-x11/4.0/sysroots/x86_64-fslcsdk-linux/usr/bin/arm-fslc-linux-gnueabi/arm-fslc-linux-gnueabi- prepare

image

5. Build Kernel Module

$ cd hello
$ make

6. copy to target (imx)

$ scp hello1.ko hello2.ko hello5.ko [email protected]:/home/root/.

7. insert the moodule

$ insmod hello1.ko

check the module:

$ dmesg

image

lkm's People

Contributors

vult0306 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.