1. 指定SRCREV的例子
#kernel-module-m8887-wlan.bb DESCRIPTION = "Marvell M8887 Wifi kernel module" require include/rcar-gen3-modules-common.inc LICENSE = "GPLv2 & MIT" LIC_FILES_CHKSUM = " file://m8887/wlan/gpl-2.0.txt;md5=ab04ac0f249af12befccb94447c08b77 " inherit module DEPENDS = "linux-renesas" PV = "15.44" PR = "r4" MARVELL_M8887_URL = "git://xxx/wireless.git" BRANCH = "master" BRANCH_board1 = "board1/master" BRANCH_board2 = "board2/master" # 若使用SRCREV=${AUTOREV} 使用AUTOREV不能编译旧版本的软件! (也就是checkout回去后,${AUTOREV}还是目前最新版的软件!) # 使用externalsrc来直接编译源码目录下的代码,也可以不用每次都烦着更改SRCREV的值 SRCREV = "57341238a98b2752546b4de461f442dc4161f578" SRC_URI += "${MARVELL_M8887_URL};protocol=ssh;branch=${BRANCH}" S = "${WORKDIR}/git" WLAN_SRCDIR = "${S}/m8887/wlan" module_do_compile() { # make marvell build-sys happy cd ${WLAN_SRCDIR} make } module_do_install() { install -d ${D}/lib/modules/${KERNEL_VERSION}/extra/ install -d ${D}/etc/modprobe.d/ install -m 644 ${WLAN_SRCDIR}/wlan.conf ${D}/etc/modprobe.d/wlan.conf install -m 644 ${WLAN_SRCDIR}/mlan.ko ${D}/lib/modules/${KERNEL_VERSION}/extra/ install -m 644 ${WLAN_SRCDIR}/sd8xxx.ko ${D}/lib/modules/${KERNEL_VERSION}/extra/ } PACKAGES += "kernel-module-mlan kernel-module-sd8xxx" RDEPENDS_kernel-module-mlan_append = " marvell-m8887-fw-cal" RDEPENDS_kernel-module-sd8xxx_append = " marvell-m8887-fw-cal" FILES_${PN} += " /etc/modprobe.d/ "
2. 使用externalsrc时刻编译最新代码,又不会影响编译旧版本软件
inherit externalsrc # a dummy local SRC_URI entry, it is used to cheat kernel.class to prepare # STAGING_KERNEL_DIR so building out-of-tree kernel module runs smoothly SRC_URI_append = " file://foo" EXTERNALSRC = "${TOPDIR}/../source_code/linux" EXTERNALSRC_BUILD = "${WORKDIR}/build"
3.externalsrc编译软件来避免bb文件时刻由于git hash值与源文件保持同步
SUMMARY = "Marvell M8887 BT Kernel module" require include/rcar-gen3-modules-common.inc LICENSE = "MIT" LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f402" inherit module externalsrc DEPENDS = "linux-renesas" PV = "15.44" PR = "r4" EXTERNALSRC = "${TOPDIR}/../source/wireless/m8887/muart_bt" #这个就是S目录 EXTERNALSRC_BUILD = "${WORKDIR}/build" #这个就是B目录,编译时(run.compile中)首先cd到这个目录下然后进行编译! EXTRA_OEMAKE += "BOARD=${MACHINE}" do_compile() { cp -r ${B}/* ${WORKDIR}/build/ # 也可以写成 cp -r $(S)/* $(B) module_do_compile } do_install() { install -d ${D}/lib/modules/${KERNEL_VERSION}/extra/ #D目录是文件系统的根目录 install -m 644 ${B}/hci_uart.ko ${D}/lib/modules/${KERNEL_VERSION}/extra/ }
4.bb文件中的EXTRA_OEMAKE = "BOARD_NAME=g8s" 会以宏BOARD=g8s的方式传给Makefile
5.有时bitbake时报elf文件"No GNU Hash",使用下面忽略 INSANE_SKIP_${PN} = "ldflags" INSANE_SKIP_${PN}-dev = "ldflags"
6.kernel-module-m8887-bt/15.44-r4/temp/run.do_compile(使用file看是个shell脚本)里面导出了各种变量且写明了编译方法。 (1)可以在bb文件中重写module_do_compile(),可以修改其O指定的路径 module_do_compile() { oe_runmake xxxx O=PATH1 } (2)复写do_compile函数 do_compile() { cp -r ${S}/* ${B}/ module_do_compile } bb文件中可以复写run.do_compile中的函数
7.run.do_configure run.do_install run.do_package 这些文件在写bb文件时也可以参考。