summaryrefslogtreecommitdiffstats
path: root/meta/classes/kernel-yocto.bbclass
diff options
context:
space:
mode:
authorBruce Ashfield <bruce.ashfield@windriver.com>2010-11-18 16:09:02 -0500
committerSaul Wold <Saul.Wold@intel.com>2010-12-10 22:01:36 -0800
commit0e7d9956a0cbe95cfe2919d13fcfcac705c4b104 (patch)
treefaa2b5d6cb6cd2c1f9c27bac44986d88d074c4d8 /meta/classes/kernel-yocto.bbclass
parent3ca38b7c104e96716a89b40df797dd3277334fa8 (diff)
downloadpoky-0e7d9956a0cbe95cfe2919d13fcfcac705c4b104.tar.gz
yocto-kernel: factor common routes, update to 2.6.37 and branch renaming
In order to extend and create more kernel recipes based on the supported yocto kernel common routines need to be placed in re-usable blocks. To accomplish this meta/recipes-kernel/linux/linux-yocto_git.bb is broken into three parts: - meta/classes/kernel-yocto.bbclass: contains common routines for checking out and configuring a yocto kernel git repository. This should be inherited by recipes that need this functionality. - meta/recipes-kernel/linux/linux-yocto.inc: Contains the machine mappings, compatibility, build directives and common task definitions for a yocto kernel based recipe. This inherits kernel-yocto, and is the typical point of entry for other recipes. - meta/recipes-kernel/linux/linuux-tools.inc: tasks and function definitions for kernel recipes that want to build/export perf It also updates the linux-yocto recipe to default to 2.6.37. As part of the update to 2.6.37 the branch naming and conventions have been modified to show inheritance, and be more generic. For example: master meta yocto/base yocto/standard/arm_versatile_926ejs yocto/standard/base yocto/standard/beagleboard yocto/standard/common_pc/atom-pc yocto/standard/common_pc/base yocto/standard/common_pc_64 yocto/standard/fsl-mpc8315e-rdb yocto/standard/intel_atom_z530 yocto/standard/intel_core_qm57_pch yocto/standard/mti_malta32_be yocto/standard/preempt_rt/base yocto/standard/preempt_rt/common_pc yocto/standard/preempt_rt/common_pc_64 yocto/standard/preempt_rt/intel_atom_z530 yocto/standard/preempt_rt/intel_core_qm57_pch yocto/standard/qemu_ppc32 yocto/standard/routerstationpro In this structure: master: tracks the mainline kernel meta: meta information for the BSPs and kernel features yocto/base: baseline kernel branch yocto/standard/base: 'standard' kernel, contains features and configs for all BSPs yocto/standard/<machine>: represents a BSP with specific features or configurations The tools, tree and libc-headers have all been updated to deal with this new structure. Also in addition to dealing with the new structure, they continue to work with the existing tree and will adapt at runtime to the differences. The linux-yocto-stable_git.bb recipe continues to build the 2.6.34 based tree,and linux-yocto_git.bb builds 2.6.37. As boards are enabled for the new kernel they will move from -stable to the development kernel. As of now, only the emulated targets have moved to 2.6.37-rcX Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
Diffstat (limited to 'meta/classes/kernel-yocto.bbclass')
-rw-r--r--meta/classes/kernel-yocto.bbclass202
1 files changed, 202 insertions, 0 deletions
diff --git a/meta/classes/kernel-yocto.bbclass b/meta/classes/kernel-yocto.bbclass
new file mode 100644
index 0000000000..8e820122ec
--- /dev/null
+++ b/meta/classes/kernel-yocto.bbclass
@@ -0,0 +1,202 @@
1S = "${WORKDIR}/linux"
2
3# Determine which branch to fetch and build. Not all branches are in the
4# upstream repo (but will be locally created after the fetchers run) so
5# a fallback branch needs to be chosen.
6#
7# The default machine 'UNDEFINED'. If the machine is not set to a specific
8# branch in this recipe or in a recipe extension, then we fallback to a
9# branch that is always present 'standard'. This sets the KBRANCH variable
10# and is used in the SRC_URI. The machine is then set back to ${MACHINE},
11# since futher processing will use that to create local branches
12python __anonymous () {
13 import bb, re
14
15 version = bb.data.getVar("LINUX_VERSION", d, 1)
16 # 2.6.34 signifies the old-style tree, so we need some temporary
17 # conditional processing based on the kernel version.
18 if version == "2.6.34":
19 bb.data.setVar("KBRANCH", "${KMACHINE}-${LINUX_KERNEL_TYPE}", d)
20 bb.data.setVar("KMETA", "wrs_meta", d)
21 mach = bb.data.getVar("KMACHINE", d, 1)
22 if mach == "UNDEFINED":
23 bb.data.setVar("KBRANCH", "standard", d)
24 bb.data.setVar("KMACHINE", "${MACHINE}", d)
25 # track the global configuration on a bootstrapped BSP
26 bb.data.setVar("SRCREV_machine", "${SRCREV_meta}", d)
27 bb.data.setVar("BOOTSTRAP", "t", d)
28 else:
29 # The branch for a build is:
30 # yocto/<kernel type>/${KMACHINE} or
31 # yocto/<kernel type>/${KMACHINE}/base
32 bb.data.setVar("KBRANCH", bb.data.expand("yocto/${LINUX_KERNEL_TYPE}/${KMACHINE}",d), d)
33 bb.data.setVar("KMETA", "meta", d)
34
35 mach = bb.data.getVar("KMACHINE", d, 1)
36 # drop the "/base" if it was on the KMACHINE
37 kmachine = mach.replace('/base','')
38 # and then write KMACHINE back
39 bb.data.setVar('KMACHINE_' + bb.data.expand("${MACHINE}",d), kmachine, d)
40
41 if mach == "UNDEFINED":
42 bb.data.setVar("KBRANCH", "yocto/standard/base", d)
43 bb.data.setVar('KMACHINE_' + bb.data.expand("${MACHINE}",d), bb.data.expand("${MACHINE}",d), d)
44 bb.data.setVar("SRCREV_machine", "standard", d)
45 bb.data.setVar("BOOTSTRAP", "t", d)
46}
47
48do_patch() {
49 cd ${S}
50 if [ -f ${WORKDIR}/defconfig ]; then
51 defconfig=${WORKDIR}/defconfig
52 fi
53
54 if [ -n "${BOOTSTRAP}" ]; then
55 kbranch="yocto/${LINUX_KERNEL_TYPE}/${KMACHINE}"
56 else
57 kbranch=${KBRANCH}
58 fi
59
60 # simply ensures that a branch of the right name has been created
61 createme ${ARCH} ${kbranch} ${defconfig}
62 if [ $? -ne 0 ]; then
63 echo "ERROR. Could not create ${kbranch}"
64 exit 1
65 fi
66
67 # updates or generates the target description
68 if [ -n "${KERNEL_FEATURES}" ]; then
69 addon_features="--features ${KERNEL_FEATURES}"
70 fi
71 updateme ${addon_features} ${ARCH} ${WORKDIR}
72 if [ $? -ne 0 ]; then
73 echo "ERROR. Could not update ${kbranch}"
74 exit 1
75 fi
76
77 # executes and modifies the source tree as required
78 patchme ${kbranch}
79 if [ $? -ne 0 ]; then
80 echo "ERROR. Could not modify ${kbranch}"
81 exit 1
82 fi
83}
84
85do_kernel_checkout() {
86 if [ -d ${WORKDIR}/.git/refs/remotes/origin ]; then
87 echo "Fixing up git directory for ${LINUX_KERNEL_TYPE}/${KMACHINE}"
88 rm -rf ${S}
89 mkdir ${S}
90 mv ${WORKDIR}/.git ${S}
91
92 if [ -e ${S}/.git/packed-refs ]; then
93 cd ${S}
94 rm -f .git/refs/remotes/origin/HEAD
95IFS='
96';
97 for r in `git show-ref | grep remotes`; do
98 ref=`echo $r | cut -d' ' -f1`;
99 b=`echo $r | cut -d' ' -f2 | sed 's%refs/remotes/origin/%%'`;
100 dir=`dirname $b`
101 mkdir -p .git/refs/heads/$dir
102 echo $ref > .git/refs/heads/$b
103 done
104 cd ..
105 else
106 cp -r ${S}/.git/refs/remotes/origin/* ${S}/.git/refs/heads
107 rmdir ${S}/.git/refs/remotes/origin
108 fi
109 fi
110 cd ${S}
111
112 # checkout and clobber and unimportant files
113 git checkout -f ${KBRANCH}
114}
115do_kernel_checkout[dirs] = "${S}"
116
117addtask kernel_checkout before do_patch after do_unpack
118
119do_kernel_configme() {
120 echo "[INFO] doing kernel configme"
121
122 cd ${S}
123 configme --reconfig
124 if [ $? -ne 0 ]; then
125 echo "ERROR. Could not configure ${KMACHINE}-${LINUX_KERNEL_TYPE}"
126 exit 1
127 fi
128
129 echo "# Global settings from linux recipe" >> ${B}/.config
130 echo "CONFIG_LOCALVERSION="\"${LINUX_VERSION_EXTENSION}\" >> ${B}/.config
131}
132
133do_kernel_configcheck() {
134 echo "[INFO] validating kernel configuration"
135 cd ${B}/..
136 kconf_check ${B}/.config ${B} ${S} ${B} ${LINUX_VERSION} ${KMACHINE}-${LINUX_KERNEL_TYPE}
137}
138
139
140# Ensure that the branches (BSP and meta) are on the locatios specified by
141# their SRCREV values. If they are NOT on the right commits, the branches
142# are reset to the correct commit.
143do_validate_branches() {
144 cd ${S}
145 branch_head=`git show-ref -s --heads ${KBRANCH}`
146 meta_head=`git show-ref -s --heads ${KMETA}`
147 target_branch_head="${SRCREV_machine}"
148 target_meta_head="${SRCREV_meta}"
149
150 # nothing to do if bootstrapping
151 if [ -n "${BOOTSTRAP}" ]; then
152 return
153 fi
154
155 current=`git branch |grep \*|sed 's/^\* //'`
156 if [ -n "$target_branch_head" ] && [ "$branch_head" != "$target_branch_head" ]; then
157 if [ -n "${KERNEL_REVISION_CHECKING}" ]; then
158 git show ${target_branch_head} > /dev/null 2>&1
159 if [ $? -eq 0 ]; then
160 echo "Forcing branch $current to ${target_branch_head}"
161 git branch -m $current $current-orig
162 git checkout -b $current ${target_branch_head}
163 else
164 echo "ERROR ${target_branch_head} is not a valid commit ID."
165 echo "The kernel source tree may be out of sync"
166 exit 1
167 fi
168 fi
169 fi
170
171 if [ "$meta_head" != "$target_meta_head" ]; then
172 if [ -n "${KERNEL_REVISION_CHECKING}" ]; then
173 git show ${target_meta_head} > /dev/null 2>&1
174 if [ $? -eq 0 ]; then
175 echo "Forcing branch meta to ${target_meta_head}"
176 git branch -m ${KMETA} ${KMETA}-orig
177 git checkout -b ${KMETA} ${target_meta_head}
178 else
179 echo "ERROR ${target_meta_head} is not a valid commit ID"
180 echo "The kernel source tree may be out of sync"
181 exit 1
182 fi
183 fi
184 fi
185
186 # restore the branch for builds
187 git checkout -f ${KBRANCH}
188}
189
190# Many scripts want to look in arch/$arch/boot for the bootable
191# image. This poses a problem for vmlinux based booting. This
192# task arranges to have vmlinux appear in the normalized directory
193# location.
194do_kernel_link_vmlinux() {
195 if [ ! -d "${B}/arch/${ARCH}/boot" ]; then
196 mkdir ${B}/arch/${ARCH}/boot
197 fi
198 cd ${B}/arch/${ARCH}/boot
199 ln -sf ../../../vmlinux
200}
201
202