引入新的开源配方
前面介绍了如何在OpenBMC中通过新建配方引入自己的程序,也介绍了如何修改原有的程序,下面要介绍的是如何引入开源的新程序,这在OE系统上是很方便的,重点就在于引入新的配方。
OE为了方便开发者使用,提供了很多的配方,可以在OpenEmbedded Layer Index - layers找到大量的分层和配方:
比如这里想要对内存进行测试,所以需要引入memtester程序,可以在Recipes标签下进行搜索:
这样就可以找到对应的配方(除非是比较生僻的,像memtester这种常用的工具,一般都是能够找到的):
然后就可以查看这个配方:
将配方内容拷贝到本地,如果有patch也都拷贝过来(memtester有一个空的patch,也是需要的),最终得到的本地文件:
├── recipes-example
│ ├── 其它略
│ └── memtester
│ ├── files
│ │ └── Makefile.patch
│ └── memtester_4.6.0.bb
之后通过bitbake就可以查看到这个配方:
jw@HOME:~/openbmc/build$ bitbake -s | grep memtester
memtester :4.6.0-r0
尝试编译:
jw@HOME:~/openbmc/build$ bitbake memtester
Loading cache: 100% |####################################################################################| Time: 0:00:00
Loaded 4384 entries from dependency cache.
Parsing recipes: 100% |##################################################################################| Time: 0:00:00
Parsing of 2710 .bb files complete (2709 cached, 1 parsed). 4385 targets, 566 skipped, 0 masked, 0 errors.
NOTE: Resolving any missing task queue dependencies
Build Configuration:
BB_VERSION = "2.4.0"
BUILD_SYS = "x86_64-linux"
NATIVELSBSTRING = "ubuntu-20.04"
TARGET_SYS = "arm-openbmc-linux-gnueabi"
MACHINE = "beni-ast2500"
DISTRO = "openbmc-phosphor"
DISTRO_VERSION = "nodistro.0"
TUNE_FEATURES = "arm thumb arm1176jzs"
TARGET_FPU = "soft"
meta
meta-poky
meta-oe
meta-networking
meta-python
meta-phosphor
meta-aspeed = "HEAD:67c9d4e715c705cd05fd04f7c8cd4fad300a4666"
meta-beni = "master:4e26cd7e1d746483cda3dec05d602fc5406f689d"
workspace = "HEAD:67c9d4e715c705cd05fd04f7c8cd4fad300a4666"
Initialising tasks: 100% |###############################################################################| Time: 0:00:00
Sstate summary: Wanted 0 Local 0 Mirrors 0 Missed 0 Current 130 (0% match, 100% complete)
NOTE: Executing Tasks
NOTE: Tasks Summary: Attempted 530 tasks of which 530 didn't need to be rerun and all succeeded.
由于过程较快所以没有看到特别有用的信息,但是如果去build的downloads目录下,就可以看到代码已经下载来了:
jw@HOME:~/openbmc/build$ ls downloads/ | grep memtester
memtester-4.6.0.tar.gz
memtester-4.6.0.tar.gz.done
也可以看到构建的内容:
jw@HOME:~/openbmc/build$ ls tmp/work/arm1176jzs-openbmc-linux-gnueabi/memtester/4.6.0-r0/
Makefile.patch image/ pkgdata/ recipe-sysroot-native/
configure.sstate license-destdir/ pkgdata-pdata-input/ source-date-epoch/
debugsources.list memtester-4.6.0/ pkgdata-sysroot/ sysroot-destdir/
deploy-ipks/ package/ pseudo/ temp/
deploy-source-date-epoch/ packages-split/ recipe-sysroot/
所以memtester能够正常使用。下面就需要将它放到OpenBMC二进制中,还是以前的老方法,在meta-beni/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bbappend中增加memtester:
RDEPENDS:${PN}-extras:append = "webui-vue helloworld memtester"
之后通过bitbake obmc-phosphor-image
编译出整个二进制。
启动构建生成的OpenBMC二进制,在shell下就可以使用memtester程序了:
root@beni-ast2500:~# memtester
memtester version 4.6.0 (32-bit)
Copyright (C) 2001-2020 Charles Cazabon.
Licensed under the GNU General Public License version 2 (only).
pagesize is 4096
pagesizemask is 0xfffff000
need memory argument, in MB
Usage: memtester [-p physaddrbase [-d device]] <mem>[B|K|M|G] [loops]
下面是使用的一个示例:
root@beni-ast2500:~# memtester 1024K 1
memtester version 4.6.0 (32-bit)
Copyright (C) 2001-2020 Charles Cazabon.
Licensed under the GNU General Public License version 2 (only).
pagesize is 4096
pagesizemask is 0xfffff000
want 1MB (1048576 bytes)
got 1MB (1048576 bytes), trying mlock ...locked.
Loop 1/1:
Stuck Address : ok
Random Value : ok
Compare XOR : ok
Compare SUB : ok
Compare MUL : ok
Compare DIV : ok
Compare OR : ok
Compare AND : ok
Sequential Increment: ok
Solid Bits : ok
Block Sequential : ok
Checkerboard : ok
Bit Spread : ok
Bit Flip : ok
Walking Ones : ok
Walking Zeroes : ok
Done.
以上就是引入新的开源配方到OpenBMC的过程。