前回、前々回に続いて、KLIB、KLIB_BUILDという環境変数の設定に苦戦中。一度Makefileを解析してみることにした。

【関連記事】
【組込ボードで無線LAN】②(無線LANカードN-6300を組込ボードに接続するには?)
【組込ボードで無線LAN】⑧(iwのビルド:後編-1)【組込ボードで無線LAN】⑰(QCA9377-5を挿してみた)
【組込ボードで無線LAN】㉓(backportをビルドしてみる‐2)
  • Makefileを解析する前に単純ミスをみつけた
1つ間違えに気づいた。CROSS_COMPILEのパスが間違ってるので直した。但し今回のエラーはKLIB、KLIB_BUILDのパス設定に問題があるのでそれ以前のエラー。(KLIB、KLIB_BUILDが通った後に発生したハズ。
(修正前)
CROSS_COMPILE=/opt/poky/1.8.2/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi-
(修正版)
CROSS_COMPILE=/opt/poky/1.8.2/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-
  • Makefileを解析する
まず全体を貼っつけた。緑字の部分はデバッグ用に足した。
#
# Makefile for the output source package
#

ifeq ($(KERNELRELEASE),)

MAKEFLAGS += --no-print-directory
SHELL := /bin/bash
BACKPORT_DIR := $(shell pwd)

KMODDIR ?= updates
ifneq ($(origin KLIB), undefined)
KMODPATH_ARG := "INSTALL_MOD_PATH=$(KLIB)"
else
KLIB := /lib/modules/$(shell uname -r)/
KMODPATH_ARG :=
endif
KLIB_BUILD ?= $(KLIB)/build/
KERNEL_CONFIG := $(KLIB_BUILD)/.config
KERNEL_MAKEFILE := $(KLIB_BUILD)/Makefile
CONFIG_MD5 := $(shell md5sum $(KERNEL_CONFIG) 2>/dev/null | sed 's/\s.*//')

export KLIB KLIB_BUILD BACKPORT_DIR KMODDIR KMODPATH_ARG

# disable built-in rules for this file
.SUFFIXES:

.PHONY: default
default:
        @echo "KERNELRELEASE=" $(KERNELRELEASE)
        @echo "MAKEFLAGS=" $(MAKEFLAGS)
        @echo "SHELL=" $(SHELL)
        @echo "BACKPORT_DIR" $(BACKPORT_DIR)
        @echo "KMODDIR=" $(KMODDIR)
        @echo "KLIB=" $(KLIB)
        @echo "KLIB_BUILD=" $(KLIB_BUILD)
        @echo "KMODPATH_ARG=" $(KMODPATH_ARG)
        @echo "KERNEL_CONFIG=" $(KERNEL_CONFIG)
        @echo "KERNEL_MAKEFILE=" $(KERNEL_MAKEFILE)
        @echo "CONFIG_MDS=" $(CONFIG_MD5)
        @$(MAKE) modules

.PHONY: mrproper
        @test -f .config && $(MAKE) clean || true
        @rm -f .config
        @rm -f .kernel_config_md5 Kconfig.versions Kconfig.kernel
        @rm -f backport-include/backport/autoconf.h

.DEFAULT:
        @set -e ; test -f local-symbols || (                                            \
        echo "/--------------"                                                          ;\
        echo "| You shouldn't run make in the backports tree, but only in"              ;\
        echo "| the generated output. This here is only the skeleton code"              ;\
        echo "| copied into the output directory. To use the backport system"           ;\
        echo "| from scratch, go into the top-level directory and run"                  ;\
        echo "| ./gentree.py /path/to/linux-next/ /tmp/output"                          ;\
        echo "| and then make menuconfig/... in the output directory. See"              ;\
        echo "| ./gentree.py --help"                                                    ;\
        echo "| for more options."                                                      ;\
        echo "\\--"                                                                     ;\
        false)
        @set -e ; test -f $(KERNEL_CONFIG) || (                                         \
        echo "/--------------"                                                          ;\
        echo "| Your kernel headers are incomplete/not installed."                      ;\
        echo "| Please install kernel headers, including a .config"                     ;\
        echo "| file or use the KLIB/KLIB_BUILD make variables to"                      ;\
        echo "| set the kernel to build against, e.g."                                  ;\
        echo "|   make KLIB=/lib/modules/3.1.7/"                                        ;\
        echo "| to compile/install for the installed kernel 3.1.7"                      ;\
        echo "| (that isn't currently running.)"                                        ;\
        echo "\\--"                                                                     ;\
        false)
        @set -e ; if [ "$$(cat .kernel_config_md5 2>/dev/null)" != "$(CONFIG_MD5)" ]    ;\
        then                                                                            \
                echo -n "Generating local configuration database from kernel ..."       ;\
                grep -v -f local-symbols $(KERNEL_CONFIG) | grep = | (                  \
                        while read l ; do                                               \
                                if [ "$${l:0:7}" != "CONFIG_" ] ; then                  \
                                        continue                                        ;\
                                fi                                                      ;\
                                l=$${l:7}                                               ;\
                                n=$${l%%=*}                                             ;\
                                v=$${l#*=}                                              ;\
                                if [ "$$v" = "m" ] ; then                               \
                                        echo config $$n                                 ;\
                                        echo '    tristate'                             ;\
                                elif [ "$$v" = "y" ] ; then                             \
                                        echo config $$n                                 ;\
                                        echo '    bool'                                 ;\
                                else                                                    \
                                        continue                                        ;\
                                fi                                                      ;\
                                echo "    default $$v"                                  ;\
                                echo ""                                                 ;\
                        done                                                            \
                ) > Kconfig.kernel                                                      ;\
                kver=$$($(MAKE) --no-print-directory -C $(KLIB_BUILD) kernelversion |   \
                        sed 's/^\(\([3-5]\|2\.6\)\.[0-9]\+\).*/\1/;t;d')                ;\
                test "$$kver" != "" || echo "Kernel version parse failed!"              ;\
                test "$$kver" != ""                                                     ;\
                kvers="$$(seq 14 39 | sed 's/^/2.6./')"                                 ;\
                kvers="$$kvers $$(seq 0 19 | sed 's/^/3./')"                            ;\
                kvers="$$kvers $$(seq 0 20 | sed 's/^/4./')"                            ;\
                kvers="$$kvers $$(seq 0 99 | sed 's/^/5./')"                            ;\
                print=0                                                                 ;\
                for v in $$kvers ; do                                                   \
                        if [ "$$print" = "1" ] ; then                                   \
                                echo config KERNEL_$$(echo $$v | tr . _)        ;\
                                echo "    def_bool y"                                   ;\
                        fi                                                              ;\
                        if [ "$$v" = "$$kver" ] ; then print=1 ; fi                     ;\
                done > Kconfig.versions                                                 ;\
                # RHEL as well, sadly we need to grep for it                            ;\
                RHEL_MAJOR=$$(grep '^RHEL_MAJOR' $(KERNEL_MAKEFILE) |                   \
                                        sed 's/.*=\s*\([0-9]*\)/\1/;t;d')               ;\
                RHEL_MINOR=$$(grep '^RHEL_MINOR' $(KERNEL_MAKEFILE) |                   \
                                        sed 's/.*=\s*\([0-9]*\)/\1/;t;d')               ;\
                for v in $$(seq 0 $$RHEL_MINOR) ; do                                    \
                        echo config BACKPORT_RHEL_KERNEL_$${RHEL_MAJOR}_$$v             ;\
                        echo "    def_bool y"                                           ;\
                done >> Kconfig.versions                                                ;\
                echo " done."                                                           ;\
        fi                                                                              ;\
        echo "$(CONFIG_MD5)" > .kernel_config_md5
        @$(MAKE) -f Makefile.real "$@"

.PHONY: defconfig-help
defconfig-help:
        @echo "Driver or subsystem configuration targets:"
        @set -e                                         ;\
                bk_configs="$$(ls defconfigs/*)"        ;\
                for cfg in $$bk_configs; do             \
                        echo "  defconfig-$${cfg##defconfigs/}" ;\
                done
        @echo ""

.PHONY: help
help: defconfig-help
        @echo "Cleaning targets:"
        @echo "  clean           - Remove most generated files but keep the config and"
        @echo "                    enough build support to build external modules"
        @echo "  mrproper        - Remove all generated files + config + various backup files"
        @echo ""
        @echo "Driver configuration help:"
        @echo "  defconfig-help  - List all prearranged defconfig-targets we have"
        @echo "                    designed for you. You can use this to find"
        @echo "                    driver specific configs in case all you really"
        @echo "                    need is to just compile one or a small group "
        @echo "                    of drivers."
        @echo ""
        @echo "Configuration targets:"
        @echo "  menuconfig      - Update current config utilising a menu based program"
        @echo "  oldconfig       - Update current config utilising a provided .config as base"
        @echo "  oldaskconfig    - ??"
        @echo "  silentoldconfig - Same as oldconfig, but quietly, additionally update deps"
        @echo "  allnoconfig     - New config where all options are answered with no"
        @echo "  allyesconfig    - New config where all options are accepted with yes"
        @echo "  allmodconfig    - New config selecting modules when possible"
        @echo "  alldefconfig    - New config with all symbols set to default"
        @echo "  randconfig      - New config with random answer to all options"
        @echo "  listnewconfig   - List new options"
        @echo "  olddefconfig    - Same as silentoldconfig but sets new symbols to their default value"
        @echo ""
        @echo "Other generic targets:"
        @echo "  all             - Build all targets marked with [*]"
        @echo "* modules         - Build all modules"
        @echo ""
        @echo "Architecture specific targets:"
        @echo "  install         - Install modules"
        @echo "  uninstall       - Uninstall modules"
        @echo ""
        @echo "Execute "make" or "make all" to build all targets marked with [*]"
else
include $(BACKPORT_DIR)/Makefile.kernel
endif
PC向けにmakeを実行するとこんな出力になる。
$ make
KERNELRELEASE=
MAKEFLAGS= --no-print-directory
SHELL= /bin/bash
BACKPORT_DIR= /home/pavement1234/backports/backports-5.2.8-1
KMODDIR= updates
KLIB= /lib/modules/4.4.0-21-generic/
KLIB_BUILD= /lib/modules/4.4.0-21-generic//build/
KMODPATH_ARG=
KERNEL_CONFIG= /lib/modules/4.4.0-21-generic//build//.config
KERNEL_MAKEFILE= /lib/modules/4.4.0-21-generic//build//Makefile
CONFIG_MD5= f38c3518d47033e59018d0b553554103
(ここからビルド開始…)
次にクロスコンパイル向けにmakeを実行してみる(冒頭に説明したCROSS_COMPILEは修正。他は1つ前の記事と同じ)。ピンク字の部分(KERNEL_CONFIGとKERNEL_MAKEFILEが所定のパスに存在しない)に問題がありそう。
(一旦ログアウト)
$ cd ~/backports/backports-5.2.8-1/
$ make clean
$ set -a
$ CROSS_COMPILE=/opt/poky/1.8.2/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-
$ ARCH=arm
$ KLIB_BUILD=/opt/poky/1.8.2/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi
$ KLIB=/opt/poky/1.8.2/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi
$ set +a
$ make
KERNELRELEASE=
MAKEFLAGS= --no-print-directory
SHELL= /bin/bash
BACKPORT_DIR= /home/pavement1234/backports/backports-5.2.8-1
KMODDIR= updates
KLIB=/opt/poky/1.8.2/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi
KLIB_BUILD= /opt/poky/1.8.2/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi
KMODPATH_ARG= INSTALL_MOD_PATH=/opt/poky/1.8.2/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi
KERNEL_CONFIG= /opt/poky/1.8.2/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/.config
KERNEL_MAKEFILE=/opt/poky/1.8.2/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi/Makefile
CONFIG_MD5=
/--------------
| Your kernel headers are incomplete/not installed.
| Please install kernel headers, including a .config
| file or use the KLIB/KLIB_BUILD make variables to
| set the kernel to build against, e.g.
|   make KLIB=/lib/modules/3.1.7/
| to compile/install for the installed kernel 3.1.7
| (that isn't currently running.)
\--
Makefile:50: ターゲット 'modules' のレシピで失敗しました
make[1]: *** [modules] エラー 1
Makefile:29: ターゲット 'default' のレシピで失敗しました
make: *** [default] エラー 2
KERNEL_CONFIGとKERNEL_MAKEFILEが所定のパスに存在しないのでYoctoのソース、Makefile、.configがあるフォルダをKLIB、KLIB_BUILDに指定してmakeしたら…。途中ワーニングっぽいメッセージが出るもののビルドできました。やはり謎のエラーが出たときはechoしてちゃんと解析しないとダメですね。
(一旦ログアウト)
$ cd ~/backports/backports-5.2.8-1/
$ make clean
$ set -a
$ CROSS_COMPILE=/opt/poky/1.8.2/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-
$ ARCH=arm
$ KLIB_BUILD=/home/pavement1234/fido/core-image-sato/tmp/work/nitrogen6x-poky-linux-gnueabi/linux-boundary/3.14.28-r0/build
$ KLIB=/home/pavement1234/fido/core-image-sato/tmp/work/nitrogen6x-poky-linux-gnueabi/linux-boundary/3.14.28-r0/build
$ set +a
$ make
ERNELRELEASE=
MAKEFLAGS= --no-print-directory
SHELL= /bin/bash
BACKPORT_DIR= /home/pavement1234/backports/backports-5.2.8-1
KMODDIR= updates
KLIB= /home/pavement1234/fido/core-image-sato/tmp/work/nitrogen6x-poky-linux-gnueabi/linux-boundary/3.14.28-r0/build
KLIB_BUILD= /home/pavement1234/fido/core-image-sato/tmp/work/nitrogen6x-poky-linux-gnueabi/linux-boundary/3.14.28-r0/build
KMODPATH_ARG= INSTALL_MOD_PATH=/home/pavement1234/fido/core-image-sato/tmp/work/nitrogen6x-poky-linux-gnueabi/linux-boundary/3.14.28-r0/build
KERNEL_CONFIG= /home/pavement1234/fido/core-image-sato/tmp/work/nitrogen6x-poky-linux-gnueabi/linux-boundary/3.14.28-r0/build/.config
KERNEL_MAKEFILE= /home/pavement1234/fido/core-image-sato/tmp/work/nitrogen6x-poky-linux-gnueabi/linux-boundary/3.14.28-r0/build/Makefile
CONFIG_MD5= f706b202afd342e26ebdbc13615bc255
Generating local configuration database from kernel ... done.
cc -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer   -c -o conf.o conf.c
cc -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer   -c -o zconf.tab.o zconf.tab.c
cc   conf.o zconf.tab.o   -o conf
boolean symbol BT tested for 'm'? test forced to 'n'
#
# configuration written to .config
#
Building backport-include/backport/autoconf.h ... done.
  CC [M]  /home/pavement1234/backports/backports-5.2.8-1/compat/main.o
  CC [M]  /home/pavement1234/backports/backports-5.2.8-1/compat/backport-3.15.o
  CC [M]  /home/pavement1234/backports/backports-5.2.8-1/compat/backport-3.17.o
(途中省略)
  Building modules, stage 2.
  MODPOST 2 modules
WARNING: "ktime_divns" [/home/pavement1234/backports/backports-5.2.8-1/compat/compat.ko] undefined!
  CC      /home/pavement1234/backports/backports-5.2.8-1/compat/compat.mod.o
  LD [M]  /home/pavement1234/backports/backports-5.2.8-1/compat/compat.ko
  CC      /home/pavement1234/backports/backports-5.2.8-1/net/wireless/cfg80211.mod.o
  LD [M]  /home/pavement1234/backports/backports-5.2.8-1/net/wireless/cfg80211.ko
  • ath10向けにビルドする
さて、前の項ではKLIB、KLIB_BUILDをデバッグするために単にmakeを実行しましたが、KLIB、KLIB_BUILDの問題が片付いたので、この項ではath10k向けにビルドするためmake defconfig-ath10kを指定してからmakeしました。...が、ath10kがビルドされませんでした。
(一旦ログアウト)
$ cd ~/backports/backports-5.2.8-1/
$ make clean
$ set -a
$ CROSS_COMPILE=/opt/poky/1.8.2/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-
$ ARCH=arm
$ KLIB_BUILD=/home/pavement1234/fido/core-image-sato/tmp/work/nitrogen6x-poky-linux-gnueabi/linux-boundary/3.14.28-r0/build
$ KLIB=/home/pavement1234/fido/core-image-sato/tmp/work/nitrogen6x-poky-linux-gnueabi/linux-boundary/3.14.28-r0/build
$ set +a
$ make defconfig-ath10k
cc -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer   -c -o conf.o conf.c
cc -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer   -c -o zconf.tab.o zconf.tab.c
cc   conf.o zconf.tab.o   -o conf
boolean symbol BT tested for 'm'? test forced to 'n'
#
# configuration written to .config
#
$ make
KERNELRELEASE=
MAKEFLAGS= --no-print-directory
SHELL= /bin/bash
BACKPORT_DIR= /home/pavement1234/backports/backports-5.2.8-1
KMODDIR= updates
KLIB= /home/pavement1234/fido/core-image-sato/tmp/work/nitrogen6x-poky-linux-gnueabi/linux-boundary/3.14.28-r0/build
KLIB_BUILD= /home/pavement1234/fido/core-image-sato/tmp/work/nitrogen6x-poky-linux-gnueabi/linux-boundary/3.14.28-r0/build
KMODPATH_ARG= INSTALL_MOD_PATH=/home/pavement1234/fido/core-image-sato/tmp/work/nitrogen6x-poky-linux-gnueabi/linux-boundary/3.14.28-r0/build
KERNEL_CONFIG= /home/pavement1234/fido/core-image-sato/tmp/work/nitrogen6x-poky-linux-gnueabi/linux-boundary/3.14.28-r0/build/.config
KERNEL_MAKEFILE= /home/pavement1234/fido/core-image-sato/tmp/work/nitrogen6x-poky-linux-gnueabi/linux-boundary/3.14.28-r0/build/Makefile
CONFIG_MD5= f706b202afd342e26ebdbc13615bc255
make[5]: 'conf' は更新済みです.
boolean symbol BT tested for 'm'? test forced to 'n'
#
# configuration written to .config
#
Building backport-include/backport/autoconf.h ... done.
  CC [M]  /home/pavement1234/backports/backports-5.2.8-1/compat/main.o
  CC [M]  /home/pavement1234/backports/backports-5.2.8-1/compat/backport-3.15.o
  CC [M]  /home/pavement1234/backports/backports-5.2.8-1/compat/backport-3.17.o
(途中省略)
  Building modules, stage 2.
  MODPOST 2 modules
WARNING: "ktime_divns" [/home/pavement1234/backports/backports-5.2.8-1/compat/compat.ko] undefined!
  CC      /home/pavement1234/backports/backports-5.2.8-1/compat/compat.mod.o
  LD [M]  /home/pavement1234/backports/backports-5.2.8-1/compat/compat.ko
  CC      /home/pavement1234/backports/backports-5.2.8-1/net/wireless/cfg80211.mod.o
  LD [M]  /home/pavement1234/backports/backports-5.2.8-1/net/wireless/cfg80211.ko
backportsの.configを見たところ、ath10kのCONFIGが全部OFFになってました。make defconfig-ath10kが効いてない感じ?
$ vi .config
#
# Automatically generated file; DO NOT EDIT.
# Backports from "Linux" "v5.2.8-0-gd36a8d2fb62c" (backports "v5.2.8-1-0-ga33d4e95")
#
CPTCFG_WIRELESS=y
CPTCFG_NET_CORE=y
CPTCFG_EXPERT=y
(途中省略)
# CPTCFG_BACKPORTED_ATH10K is not set
# CPTCFG_BACKPORTED_ATH10K_CE is not set
# CPTCFG_BACKPORTED_ATH10K_PCI is not set
# CPTCFG_BACKPORTED_ATH10K_AHB is not set
# CPTCFG_BACKPORTED_ATH10K_SDIO is not set
# CPTCFG_BACKPORTED_ATH10K_USB is not set
# CPTCFG_BACKPORTED_ATH10K_SNOC is not set
# CPTCFG_BACKPORTED_ATH10K_DEBUG is not set
# CPTCFG_BACKPORTED_ATH10K_DEBUGFS is not set
# CPTCFG_BACKPORTED_ATH10K_SPECTRAL is not set
# CPTCFG_BACKPORTED_ATH10K_TRACING is not set
# CPTCFG_BACKPORTED_ATH10K_DFS_CERTIFIED is not set
(以下省略)
まぁでも、compat.koとcfg80211.koがビルドできてるので、もう一歩だと思う。

続く
IMG_20191002_073217




スポンサードリンク