一区二区三区三上|欧美在线视频五区|国产午夜无码在线观看视频|亚洲国产裸体网站|无码成年人影视|亚洲AV亚洲AV|成人开心激情五月|欧美性爱内射视频|超碰人人干人人上|一区二区无码三区亚洲人区久久精品

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

RZ/G2L Linux系統(tǒng)如何添加新的內(nèi)核模塊

瑞薩MCU小百科 ? 來源:瑞薩MCU小百科 ? 2024-01-04 12:19 ? 次閱讀
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

RZ/G2L Linux系統(tǒng)的鏡像基于yocto構(gòu)建,本篇介紹如何添加新的內(nèi)核模塊。

方式1:內(nèi)核源碼外添加

方式2:內(nèi)核源碼中添加

需要提前已按照文檔構(gòu)建好開發(fā)環(huán)境和安裝SDK,本篇依據(jù)G2L VLP3.0.3。

方式1示例

A. bitbake編譯模塊方式

目錄和內(nèi)容參考:

左右滑動查看完整內(nèi)容

rzg2l_vlp_v3.0.3$ tree meta-renesas/meta-rz-common/recipes-kernel/kernel-module-helloworld/
meta-renesas/meta-rz-common/recipes-kernel/kernel-module-helloworld/
├── files
│  ├── helloworld.c
│  └── Makefile
└── kernel-module-helloworld.bb

helloworld.c

左右滑動查看完整內(nèi)容

#include 
static int hello_world_init(void)
{
  printk("Hello world
");
  return 0;
}
static void hello_world_exit(void)
{
  printk("Bye world
");
}
module_init(hello_world_init);
module_exit(hello_world_exit);
MODULE_LICENSE("GPL v2");

Makefile

左右滑動查看完整內(nèi)容

obj-m := helloworld.o
SRC := $(shell pwd)
all:
    make -C $(KERNELSRC) M=$(SRC) modules
install:
    make -C $(KERNELSRC) M=$(SRC) modules_install
clean:
    rm -f *.o *~ core .depend .*.cmd *.ko *.mod.c
    rm -f Module.markers Module.symvers modules.order
    rm -rf .tmp_versions Modules.symvers

kernel-module-helloworld.bb

左右滑動查看完整內(nèi)容

SRC_URI = " 
  file://helloworld.c 
  file://Makefile 
"
S = "${WORKDIR}"
EXTRA_OEMAKE = "KERNELDIR=${STAGING_KERNEL_BUILDDIR}"
EXTRA_OEMAKE += "CROSS_COMPILE=${CROSS_COMPILE}"


KERNEL_MODULE_PACKAGE_SUFFIX = ""
do_install() {
  # Create destination directory
  install -d ${D}/lib/modules/${KERNEL_VERSION}/extra/


  # Install kernel module
  install -m 644 ${S}/helloworld.ko ${D}/lib/modules/${KERNEL_VERSION}/extra/


  # Install module symbol file
  install -m 644 ${S}/Module.symvers ${STAGING_KERNEL_BUILDDIR}/helloworld.symvers
}
PACKAGES = " 
  ${PN} 
"
FILES_${PN} = " 
  /lib/modules/${KERNEL_VERSION}/extra/helloworld.ko 

編譯模塊:

左右滑動查看完整內(nèi)容

~/rzg2l_vlp_v3.0.3$ source poky/oe-init-build-env
### Shell environment set up for builds. ###


You can now run 'bitbake '


Targets are:
  core-image-minimal
  core-image-bsp
  core-image-weston
  core-image-qt
hank@rz:~/rzg2l_vlp_v3.0.3/build$ MACHINE=smarc-rzg2l bitbake -s | grep hello
go-helloworld                     :0.1-r0
kernel-module-helloworld               :1.0-r0
lib32-go-helloworld                  :0.1-r0
hank@rz:~/rzg2l_vlp_v3.0.3/build$ MACHINE=smarc-rzg2l bitbake kernel-module-helloworld
WARNING: Layer qt5-layer should set LAYERSERIES_COMPAT_qt5-layer in its conf/layer.conf file to list the core layer names it is compatible with.
WARNING: Layer qt5-layer should set LAYERSERIES_COMPAT_qt5-layer in its conf/layer.conf file to list the core layer names it is compatible with.
Loading cache: 100% 
…
NOTE: Tasks Summary: Attempted 650 tasks of which 635 didn't need to be rerun and all succeeded.

查看結(jié)果:

左右滑動查看完整內(nèi)容

build/tmp/work/smarc_rzg2l-poky-linux/kernel-module-helloworld/1.0-r0/helloworld.ko

如果想編譯到rootfs,請修改conf/local.conf追加內(nèi)容并重新編譯rootfs

左右滑動查看完整內(nèi)容

MACHINE_EXTRA_RRECOMMENDS = " kernel-module-helloworld"

庫文件包已含在rootfs內(nèi)

左右滑動查看完整內(nèi)容

build$ find ./tmp/work/smarc_rzg2l-poky-linux/ -name helloworld.ko
./tmp/work/smarc_rzg2l-poky-linux/core-image-qt/1.0-r0/rootfs/lib/modules/5.10.158-cip22-yocto-standard/extra/helloworld.ko
./tmp/work/smarc_rzg2l-poky-linux/kernel-module-helloworld/1.0-r0/helloworld.ko

B.在源碼目錄直接編譯方式

左右滑動查看完整內(nèi)容

cd /opt/poky_vlp3.0.3/sysroots/aarch64-poky-linux/lib/modules/5.10.158-cip22-yocto-standard/build
source /opt/poky_vlp3.0.3/environment-setup-aarch64-poky-linux
sudo chown -R $USER .
make scripts
make prepare
mkdir hello //并拷貝上邊的源碼文件
/opt/poky_vlp3.0.3/sysroots/aarch64-poky-linux/lib/modules/5.10.158-cip22-yocto-standard/build/hello$ ls
helloworld.c  Makefile
/opt/poky_vlp3.0.3/sysroots/aarch64-poky-linux/lib/modules/5.10.158-cip22-yocto-standard/build/hello$ make
make -C /opt/poky_vlp3.0.3/sysroots/aarch64-poky-linux/usr/src/kernel M=/opt/poky_vlp3.0.3/sysroots/aarch64-poky-linux/lib/modules/5.10.158-cip22-yocto-standard/build/hello modules
make[1]: Entering directory '/opt/poky_vlp3.0.3/sysroots/aarch64-poky-linux/lib/modules/5.10.158-cip22-yocto-standard/build'
 CC [M] /opt/poky_vlp3.0.3/sysroots/aarch64-poky-linux/lib/modules/5.10.158-cip22-yocto-standard/build/hello/helloworld.o
 MODPOST /opt/poky_vlp3.0.3/sysroots/aarch64-poky-linux/lib/modules/5.10.158-cip22-yocto-standard/build/hello/Module.symvers
 CC [M] /opt/poky_vlp3.0.3/sysroots/aarch64-poky-linux/lib/modules/5.10.158-cip22-yocto-standard/build/hello/helloworld.mod.o
 LD [M] /opt/poky_vlp3.0.3/sysroots/aarch64-poky-linux/lib/modules/5.10.158-cip22-yocto-standard/build/hello/helloworld.ko
make[1]: Leaving directory '/opt/poky_vlp3.0.3/sysroots/aarch64-poky-linux/lib/modules/5.10.158-cip22-yocto-standard/build'
hank@rz:/opt/poky_vlp3.0.3/sysroots/aarch64-poky-linux/lib/modules/5.10.158-cip22-yocto-standard/build/hello$ ls
helloworld.c helloworld.ko helloworld.mod helloworld.mod.c helloworld.mod.o helloworld.o Makefile modules.order Module.symvers

方式2示例

首先提取內(nèi)核源碼:

左右滑動查看完整內(nèi)容

~/rzg2l_vlp_v3.0.3$ source poky/oe-init-build-env
~/rzg2l_vlp_v3.0.3/build$ MACHINE=smarc-rzg2l devtool modify linux-renesas
NOTE: Starting bitbake server...
……
INFO: Adding local source files to srctree...
INFO: Copying kernel config to srctree
INFO: Source tree extracted to /home/xxx/rzg2l_vlp_v3.0.3/build/workspace/sources/linux-renesas
WARNING: SRC_URI is conditionally overridden in this recipe, thus several devtool-override-* branches have been created, one for each override that makes changes to SRC_URI. It is recommended that you make changes to the devtool branch first, then checkout and rebase each devtool-override-* branch and update any unique patches there (duplicates on those branches will be ignored by devtool finish/update-recipe)
INFO: Recipe linux-renesas now set up to build from /home/xxx/rzg2l_vlp_v3.0.3/build/workspace/sources/linux-renesas

上面最后一行就是Linux內(nèi)核源碼提取后所在目錄,即/home/xxx/rzg2l_vlp_v3.0.3/build/workspace/sources/linux-renesas, 然后去這個目錄修改代碼即可。

進(jìn)入Linux源碼目錄下找個目錄增加模塊代碼,這里使用build/workspace/sources/ linux-renesas /drivers/char目錄,在該目錄下執(zhí)行mkdir hello創(chuàng)建目錄,然后在hello目錄下創(chuàng)建以下文件。

左右滑動查看完整內(nèi)容

~/rzg2l_vlp_v3.0.3/build/workspace/sources/linux-renesas/drivers/char$ tree hello/
hello/
├── hello.c
├── Kconfig
└── Makefile

hello.c

左右滑動查看完整內(nèi)容

#include 
static int hello_world_init(void)
{
  printk("Hello world
");
  return 0;
}
static void hello_world_exit(void)
{
  printk("Bye world
");
}
module_init(hello_world_init);
module_exit(hello_world_exit);
MODULE_LICENSE("GPL v2");

Kconfig

左右滑動查看完整內(nèi)容

config HELLO
    tristate 'Create a hello module'
    default n
    help
        This is a module to print Hello World!

Makefile

obj-$(CONFIG_HELLO) += hello.o

修改build/workspace/sources/ linux-renesas /drivers/char目錄的Kconfig和Makefile:

左右滑動查看完整內(nèi)容

diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index b4e65d1ed..2b96630ab 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -508,4 +508,6 @@ config RANDOM_TRUST_BOOTLOADER
     believe its RNG facilities may be faulty. This may also be configured
     at boot time with "random.trust_bootloader=on/off".


+source "drivers/char/hello/Kconfig"
+
 endmenu
diff --git a/drivers/char/Makefile b/drivers/char/Makefile
index ffce287ef..3056303ff 100644
--- a/drivers/char/Makefile
+++ b/drivers/char/Makefile
@@ -47,3 +47,5 @@ obj-$(CONFIG_PS3_FLASH)        += ps3flash.o
 obj-$(CONFIG_XILLYBUS)     += xillybus/
 obj-$(CONFIG_POWERNV_OP_PANEL) += powernv-op-panel.o
 obj-$(CONFIG_ADI)       += adi.o
+
+obj-$(CONFIG_HELLO) += hello/

返回yocto頂層目錄,選擇內(nèi)核配置

左右滑動查看完整內(nèi)容

~/rzg2l_vlp_v3.0.3/build$ source poky/oe-init-build-env
~/rzg2l_vlp_v3.0.3/build$ MACHINE=smarc-rzg2l bitbake virtual/kernel -c menuconfig

b0390fec-aab6-11ee-8b88-92fbcf53809c.png

編譯內(nèi)核

左右滑動查看完整內(nèi)容

~/rzg2l_vlp_v3.0.3/build$ MACHINE=smarc-rzg2l devtool build linux-renesas
NOTE: Starting bitbake server...
……
NOTE: Tasks Summary: Attempted 607 tasks of which 594 didn't need to be rerun and all succeeded.

生成結(jié)果

左右滑動查看完整內(nèi)容

~/rzg2l_vlp_v3.0.3/build$ ls tmp/work/smarc_rzg2l-poky-linux/linux-renesas/5.10.158-cip22+git999-r1/linux-renesas-5.10.158-cip22+git999/drivers/char/hello/
built-in.a hello.o modules.order

最后制作補(bǔ)丁,創(chuàng)建自己的layer保存補(bǔ)丁。

左右滑動查看完整內(nèi)容

~/rzg2l_vlp_v3.0.3$ source poky/oe-init-build-env
~/rzg2l_vlp_v3.0.3/build$ bitbake-layers create-layer ../meta-mylayer
~/rzg2l_vlp_v3.0.3/build$ bitbake-layers add-layer ../meta-mylayer
hank@rz:~/rzg2l_vlp_v3.0.3/build$ tree ../meta-mylayer/
../meta-mylayer/
├── conf
│  └── layer.conf
├── COPYING.MIT
├── README
└── recipes-example
  └── example
    └── example_0.1.bb


3 directories, 4 files

再次進(jìn)入源碼目錄,提交修改,生成補(bǔ)丁

左右滑動查看完整內(nèi)容

~/rzg2l_vlp_v3.0.3/build/workspace/sources/linux-renesas$ git status .
Refresh index: 100% (70807/70807), done.
On branch devtool
Changes not staged for commit:
 (use "git add ..." to update what will be committed)
 (use "git restore ..." to discard changes in working directory)
    modified:  drivers/char/Kconfig
    modified:  drivers/char/Makefile


Untracked files:
 (use "git add ..." to include in what will be committed)
    drivers/char/hello/


no changes added to commit (use "git add" and/or "git commit -a")
~/rzg2l_vlp_v3.0.3/build/workspace/sources/linux-renesas$ git add ./*
The following paths are ignored by one of your .gitignore files:
oe-logs
oe-workdir
Use -f if you really want to add them.
~/rzg2l_vlp_v3.0.3/build/workspace/sources/linux-renesas$ git commit -m "add the hello module"
[devtool 6dc52bd44] add the hello module
 5 files changed, 25 insertions(+)
 create mode 100644 drivers/char/hello/Kconfig
 create mode 100644 drivers/char/hello/Makefile
 create mode 100644 drivers/char/hello/hello.c

切到build目錄執(zhí)行

左右滑動查看完整內(nèi)容

~/rzg2l_vlp_v3.0.3/build$ MACHINE=smarc-rzg2l devtool finish linux-renesas ../meta-mylayer/
NOTE: Starting bitbake server...
……
Parsing of 2151 .bb files complete (0 cached, 2151 parsed). 5440 targets, 887 skipped, 3 masked, 0 errors.
……
INFO: Leaving source tree /home/xxx/rzg2l_vlp_v3.0.3/build/workspace/sources/linux-renesas as-is; if you no longer need it then please delete it manually
~/rzg2l_vlp_v3.0.3/build$ tree ../meta-mylayer/
../meta-mylayer/
├── conf
│  └── layer.conf
├── COPYING.MIT
├── README
├── recipes-example
│  └── example
│    └── example_0.1.bb
└── recipes-kernel
  └── linux
    ├── linux-renesas
    │  ├── 0001-add-the-hello-module.patch
    │  └── devtool-fragment.cfg
    └── linux-renesas_%.bbappend


6 directories, 7 files

上邊patch文件就是修改的內(nèi)容了。

審核編輯:湯梓紅

聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問題,請聯(lián)系本站處理。 舉報投訴
  • 內(nèi)核
    +關(guān)注

    關(guān)注

    3

    文章

    1416

    瀏覽量

    41436
  • Linux
    +關(guān)注

    關(guān)注

    87

    文章

    11511

    瀏覽量

    213815
  • Linux系統(tǒng)
    +關(guān)注

    關(guān)注

    4

    文章

    605

    瀏覽量

    28617
  • 源碼
    +關(guān)注

    關(guān)注

    8

    文章

    671

    瀏覽量

    30334
  • SDK
    SDK
    +關(guān)注

    關(guān)注

    3

    文章

    1077

    瀏覽量

    49106

原文標(biāo)題:RZ/G2L添加新的內(nèi)核模塊

文章出處:【微信號:瑞薩MCU小百科,微信公眾號:瑞薩MCU小百科】歡迎添加關(guān)注!文章轉(zhuǎn)載請注明出處。

收藏 人收藏
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

    評論

    相關(guān)推薦
    熱點推薦

    瑞薩RZ/G2L串口SCI的使用(上)

    瑞薩RZ/G2L的串口簡稱SCI,全稱Serial Communication Interface。
    的頭像 發(fā)表于 01-17 12:19 ?2147次閱讀
    瑞薩<b class='flag-5'>RZ</b>/<b class='flag-5'>G2L</b>串口SCI的使用(上)

    RZ/G2L高速虛擬串口方案 基于瑞薩RZ/G2L SMARC開發(fā)板的虛擬(Virtual UART)實現(xiàn)方案

    UART)實現(xiàn)方案,以實現(xiàn)高速Linux UART通信,供客戶參考。 虛擬(Virtual UART)方案介紹 很多工業(yè)客戶,都有Linux下高速UART需求(1Mbps以上波特率),但是RZ/
    發(fā)表于 11-20 14:41 ?1007次閱讀
    <b class='flag-5'>RZ</b>/<b class='flag-5'>G2L</b>高速虛擬串口方案 基于瑞薩<b class='flag-5'>RZ</b>/<b class='flag-5'>G2L</b> SMARC開發(fā)板的虛擬(Virtual UART)實現(xiàn)方案

    G2L系列 核心板 -RZ/G2L 處理器簡介|框架圖|功耗|原理圖及硬件設(shè)計指南

    用戶便捷開發(fā),輕松選型。 三、RZ/G2L系列 Linux系統(tǒng)整機(jī)功耗表很多小伙伴對FET-G2LD-C核心板和OK-
    發(fā)表于 06-21 14:45

    【飛凌RZ/G2L開發(fā)板試用體驗】+01.開箱(zmj)

    ,主要應(yīng)用于各種具有視頻輸出的工控行業(yè)。2.硬件講解硬件講解:從外觀結(jié)構(gòu)上看,飛凌RZ/G2L開發(fā)板使用模塊和擴(kuò)展板的方式組成,重點是飛凌擴(kuò)展板原理圖/PCB圖免費提供,擴(kuò)展板可以更換
    發(fā)表于 08-28 19:13

    嵌入式LINUX系統(tǒng)內(nèi)核內(nèi)核模塊調(diào)試

    嵌入式LINUX系統(tǒng)內(nèi)核內(nèi)核模塊調(diào)試(嵌入式開發(fā)和硬件開發(fā))-嵌入式LINUX系統(tǒng)
    發(fā)表于 07-30 13:55 ?10次下載
    嵌入式<b class='flag-5'>LINUX</b><b class='flag-5'>系統(tǒng)</b><b class='flag-5'>內(nèi)核</b>和<b class='flag-5'>內(nèi)核模塊</b>調(diào)試

    瑞薩G2L系列核心板-RZ/G2L處理器簡介

    RZ/G2L是瑞薩在智能工控領(lǐng)域的一款高性能、超高效處理器。RZ/G2L采用Arm Cortex-A55內(nèi)核,運行頻率高達(dá)1.2GHz,內(nèi)部
    發(fā)表于 06-09 11:54 ?1155次閱讀

    RZ/G2L、RZ/V2L SMARC 模塊板用戶手冊:硬件

    RZ/G2L、RZ/V2L SMARC 模塊板用戶手冊:硬件
    發(fā)表于 01-09 19:00 ?4次下載
    <b class='flag-5'>RZ</b>/<b class='flag-5'>G2L</b>、<b class='flag-5'>RZ</b>/V<b class='flag-5'>2L</b> SMARC <b class='flag-5'>模塊</b>板用戶手冊:硬件

    RZ/G2LRZ/G2LC 用戶手冊概述

    RZ/G2L、RZ/G2LC 用戶手冊概述
    發(fā)表于 01-10 19:04 ?6次下載
    <b class='flag-5'>RZ</b>/<b class='flag-5'>G2L</b>、<b class='flag-5'>RZ</b>/<b class='flag-5'>G2</b>LC 用戶手冊概述

    RZ/G2L、RZ/V2L SMARC 模塊板用戶手冊:硬件

    RZ/G2L、RZ/V2L SMARC 模塊板用戶手冊:硬件
    發(fā)表于 06-30 18:38 ?1次下載
    <b class='flag-5'>RZ</b>/<b class='flag-5'>G2L</b>、<b class='flag-5'>RZ</b>/V<b class='flag-5'>2L</b> SMARC <b class='flag-5'>模塊</b>板用戶手冊:硬件

    RZ/G2L、RZ/G2LC 用戶手冊概述

    RZ/G2L、RZ/G2LC 用戶手冊概述
    發(fā)表于 06-30 19:47 ?6次下載
    <b class='flag-5'>RZ</b>/<b class='flag-5'>G2L</b>、<b class='flag-5'>RZ</b>/<b class='flag-5'>G2</b>LC 用戶手冊概述

    RZ/G2L核心板eMMC測試

    武漢萬象奧科RZ/G2L核心板支持eMMC存儲,可選8GB~64GB。 評估測試RZ/G2L核心板存儲在默認(rèn)8GB配置下eMMC性能(讀寫速率)。
    的頭像 發(fā)表于 03-02 17:18 ?5804次閱讀
    <b class='flag-5'>RZ</b>/<b class='flag-5'>G2L</b>核心板eMMC測試

    RZ/G2L開發(fā)板使用指南(上)

    如果需要評估RZ/G2L產(chǎn)品的各項功能,RZ/G2L評估板是最合適的平臺。
    的頭像 發(fā)表于 11-03 12:19 ?1744次閱讀
    <b class='flag-5'>RZ</b>/<b class='flag-5'>G2L</b>開發(fā)板使用指南(上)

    RZ/G2L Demo調(diào)試經(jīng)驗流程分享(1)

    r01us0553ej0107-rz-g(Release Note).pdf,r01us0556ej0102-rz-g(Board_StartUp_Guide_smarcEVK).pdf,對SMARC EVK of RZ/
    的頭像 發(fā)表于 05-06 14:25 ?1294次閱讀
    <b class='flag-5'>RZ</b>/<b class='flag-5'>G2L</b> Demo調(diào)試經(jīng)驗流程分享(1)

    RZ/G2L串口SCI的使用(上)

    RZ/G2L串口SCI的使用
    的頭像 發(fā)表于 07-25 08:06 ?863次閱讀
    <b class='flag-5'>RZ</b>/<b class='flag-5'>G2L</b>串口SCI的使用(上)

    RZ/G2L串口SCI的使用(下)

    RZ/G2L串口SCI的使用
    的頭像 發(fā)表于 08-03 08:06 ?868次閱讀
    <b class='flag-5'>RZ</b>/<b class='flag-5'>G2L</b>串口SCI的使用(下)