Linux Device Driver Development Cookbook
上QQ阅读APP看书,第一时间看更新

Getting ready

Since we need to add our code to the Linux sources, let's go into the directory where all sources are located. On my system, I use the Projects/ldddc/linux/ path located in my home directory. Here is what the kernel sources look like:

$ cd Projects/ldddc/linux/
$ ls
arch Documentation Kbuild mm scripts virt
block drivers Kconfig modules.builtin security vmlinux
built-in.a firmware kernel modules.order sound vmlinux.o
certs fs lib Module.symvers stNXtP40
COPYING include LICENSES net System.map
CREDITS init MAINTAINERS README tools
crypto ipc Makefile samples usr

Now, we need to set the environment variables, ARCH and CROSS_COMPILE, as follows in order to be able to cross-compile code for the ESPRESSObin:

$ export ARCH=arm64
$ export CROSS_COMPILE=aarch64-linux-gnu-

So, if we try to execute a make command as follows, the system should start compiling the kernel as usual:

$ make Image dtbs modules
CALL scripts/checksyscalls.sh
...
Note that you may avoid exporting preceding variables by just specifying them on the following command line:
$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- \
Image dtbs modules

At this point, kernel sources and the compiling environment are ready.