我正在尝试使用 Yocto SDK 构建 Linux 内核模块。但是,我遇到了编译错误,它抱怨
./include/uapi/asm-generic/int-ll64.h:12:10: fatal error: asm/bitsperlong.h: No such file or directory
#include <asm/bitsperlong.h>
Run Code Online (Sandbox Code Playgroud)
这是我的 Makefile
ARCH ?= arm
CROSS_COMPILE ?= arm-poky-linux-gnueabi-
KERNELDIR ?= /opt/poky/2.7.3/sysroots/cortexa9t2hf-neon-poky-linux-gnueabi/usr/src/kernel/
PWD := $(shell pwd)
.PHONY: build clean
build:
$(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KERNELDIR) M=$(PWD) modules
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c modules.order Module.symvers
# Incorporate modules into a multi-part driver
my-objs := hello.o
$(info Building with KERNELRELEASE = ${KERNELRELEASE})
EXTRA_CFLAGS+=-I$(PWD)/../include
obj-m := hello.o
Run Code Online (Sandbox Code Playgroud)
在调用 make 之前,我要设置源环境。
$source /opt/poky/2.7.3/environment-setup-cortexa9t2hf-neon-poky-linux-gnueabi …Run Code Online (Sandbox Code Playgroud) 我正在尝试do_compile_append通过打印消息来调试 Yocto 配方中的函数:
do_compile_append() {
for i in 1 2 3 4 5
do
echo "My yocto Looping ... number $i"
done
}
Run Code Online (Sandbox Code Playgroud)
在此示例中,我添加了一个循环来在构建期间回显一些消息。但是,当我运行bitbake构建它时,我没有看到这些消息输出到我的终端。
输出记录在哪里?
我正在尝试将数组减少为其偶数值的总和。我一直在检查 MDN 的文档 - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce
这表示,如果提供了初始值,那么它不会跳过第 0 个索引,实际上它将从索引 0 开始。我的问题是,reduce 是从索引 1 开始的。因此,我的结果是不正确的。我确信我错误地阅读了该文件或误解了它。这是我指的注释 - “注意:如果未提供initialValue,则reduce()将从索引1开始执行回调函数,跳过第一个索引。如果提供了initialValue,它将从索引0开始。”
这是我的代码。
var array = [1,2,3,4,6,100];
var initialValue = 0;
var value = array.reduce(function(accumulator, currentValue, currentIndex, array, initialValue) {
//console.log(accumulator);
if( currentValue % 2 === 0) {
accumulator += currentValue;
//return accumulator;
}
return accumulator;
});
console.log(value);
Run Code Online (Sandbox Code Playgroud)
显然,我看到的结果是 113 而不是 112。我猜,这是因为累加器的值已经是 1。因此,它最初会加 1。