Bluez: removed outdated stuff so multithreaded bitbake doesn't break apps depending...
[vuplus_openembedded] / packages / linux / nslu2-kernel.inc
1 # Standard definitions for any NSLU2 Linux kernel.
2 # Include this file in a .bb which specifies, at least,
3 # PN,PV,PR for the desired kernel
4 #
5 # Define the following *before* including this file as
6 # required:
7 #
8 # N2K_PATCHES - full list of patches to apply, to add files
9 #   generate a patch against /dev/null
10 # N2K_SUFFIX - the suffix to add after 'zImage-' in the
11 #   deploy/images directory, should identify the image config
12 #
13 # DEFAULT_PREFERENCE is set automagically in this file as
14 # follows:
15 #
16 #  10  For *released* kernels
17 #   8  For mm or ac patched versions of released kernels
18 #   6  For rc patched kernels (release candidates)
19 #   4  For mm or ac patched rc (release candidate) kernels
20 #   2  For pre or bk versions
21 #   0  For mm or ac patched pre or bk versions
22 #
23 # --------------------------------------------------------------
24 #
25 # Within this file bitbake variables local to the file are
26 # named N2K_FOO
27 #
28 SECTION = "kernel"
29 DESCRIPTION = "Linux kernel for the Linksys NSLU2 device"
30 LICENSE = "GPL"
31
32 DEPENDS += "devio-native"
33
34 # Linux kernel source has the general form linux-X.Y.Z-patchP,
35 # X.Y is the major version number, Z (which may have multiple
36 # parts) is a sub-version and 'patch' is something like 'mm' or
37 # 'ac' with a patch version.  The original bz2 archive will be
38 # in a directory/file vX.Y/linux-X.Y.Z.tar.bz2.  The unpacked
39 # source will be in the directory linux-X.Y.Z and this directory
40 # name corresponds to the module directory (in /lib/modules).
41 #
42 # The corresponding .bb file should be called:
43 #
44 #       package_X.Y.Z-patchP
45 #
46 # Giving PN=package PV=X.Y.Z-patchP (and PR is set in the .bb
47 # file).  Files, including the all important defconfig, are
48 # searched for in the following directories (last one first):
49 #
50 #       nslu2-kernel/files
51 #       nslu2-kernel/X.Y
52 #       nslu2-kernel/X.Y.Z
53 #       nslu2-kernel/X.Y.Z-patch
54 #       nslu2-kernel/X.Y.Z-patchP
55 #       package-X.Y.Z-patchP
56 #
57 # This allows sharing of patch files and other useful source!
58 # To share a file or patch with an earlier version put it in
59 # the shared directory - e.g. to use foo.patch on 2.6.11.2 and
60 # 2.6.11.4 it should be in directory nslu2-kernel/2.6.11.
61 #
62 # Note that when there are multiple patches the X.Y.Z-patch form
63 # uses base-patch (e.g. 2.6.12-mm) whereas X.Y.Z-patchP has the
64 # full form, for example 2.6.12-rc3-mm1 (in the same case).
65
66 #PN=package-name
67 #PV=package-version (full)
68
69 # The patch has the general form (rcN|preN|acN|mmN|bkN)* with the
70 # separate patch items being separated by '-' characters.  The
71 # rc patch is first and has the important property that it
72 # requires the *preceding* kernel base version and that this
73 # will be the source directory name.
74 python () {
75     # The patches list may be empty.  This code starts with the base
76     # kernel version and steps through the patches.  Because the rc and
77     # pre patches actually require the *preceding* kernel version the code
78     # fixes that up appropriately.
79     pv = bb.data.getVar("PV",d,1).split('-')
80     kernel = pv[0].split('.')
81     base = pv[0]
82     name = [base]
83     major = '.'.join(name[0].split('.')[0:2])
84     minor = '.'.join(name[0].split('.')[0:3])
85     patch_uri = [ None ]
86     filedir = "${FILE_DIRNAME}/nslu2-kernel/%s"
87     # This entry will become the last one (everything is inserted before it)
88     filepath = [ filedir % "files" ]
89     pref = 10
90     mmac = 0
91     for patch in pv[1:]:
92         name.append(patch)
93         pname = '-'.join(name)
94         if patch[0:2] == "rc" or patch[0:3] == "pre":
95             patch_uri.append("ftp://ftp.kernel.org/pub/linux/kernel/v%s/testing/patch-%s.bz2;patch=1;pname=%s" % (major, pname, pname))
96             kernel[-1] = str(int(kernel[-1]) - 1)
97             if patch[0:2] == "rc" and pref == 10:
98                 pref = 6
99                 filepath[0:0] = [ filedir % name[0] ]
100                 filepath[0:0] = [ filedir % (name[0] + "-rc") ]
101             else:
102                 pref = 2
103         elif patch[0:2] == "bk" or patch[0:3] == "git":
104             patch_uri.append("ftp://ftp.kernel.org/pub/linux/kernel/v%s/snapshots/patch-%s.bz2;patch=1;pname=%s" % (major, pname, pname))
105             pref = 2
106         elif patch[0:2] == "ac":
107             patch_uri.append("ftp://ftp.kernel.org/pub/linux/kernel/people/alan/linux-%s/%s/patch-%s" % (major, base, pname))
108             mmac = 2
109             filepath[0:0] = [ filedir % (name[0] + "-ac") ]
110         elif patch[0:2] == "mm":
111             patch_uri.append("ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/%s/%s/%s/%s.bz2;patch=1;pname=%s" % (major, base, pname, pname, pname))
112             mmac = 2
113             filepath[0:0] = [ filedir % (name[0] + "-mm") ]
114         else:
115             raise bb.build.FuncFailed("nslu2-kernel: patch %s not recognized in %s" % (patch, '-'.join(pv)))
116         filepath[0:0] = [ filedir % pname ]
117         base = pname
118
119     base = '.'.join(kernel)
120     patch_uri[0] = "ftp://ftp.kernel.org/pub/linux/kernel/v%s/linux-%s.tar.bz2" % (major, base)
121     filepath[-1:-1] = [ filedir % base ]
122     if base != minor:
123             filepath[-1:-1] = [ filedir % minor ]
124     filepath[-1:-1] = [ filedir % major ]
125
126     bb.data.setVar("N2K_SRCMAJ", major, d)
127     # bb.note("N2K_SRCMAJ := %s" % major)
128     bb.data.setVar("N2K_SRCVER", base, d)
129     # bb.note("N2K_SRCVER := %s" % base)
130     bb.data.setVar("N2K_SRCURI", ' '.join(patch_uri), d)
131     # bb.note("N2K_SRCURI := %s" % ' '.join(patch_uri))
132     bb.data.setVar("N2K_FILESPATH", ':'.join(filepath), d)
133     # bb.note("N2K_FILESPATH := %s" % ' '.join(filepath))
134     bb.data.setVar("DEFAULT_PREFERENCE", pref-mmac, d)
135     # bb.note("DEFAULT_PREFERENCE := %s" % (pref-mmac))
136 }
137
138 # FILESPATH: this list is in order last-searched-first, therefore
139 # the first entry is the *latest* and/or most specific
140 FILESPATH = "${FILE_DIRNAME}/${P}:${N2K_FILESPATH}"
141
142 # The working directory will be the 'base' version (which may not be the
143 # same as implied by the PV variable because it corresponds to the prior
144 # minor version for rc and pre patched versions).
145 S = "${WORKDIR}/linux-${N2K_SRCVER}"
146
147 # N2K_PATCHES is the list of patches.
148 N2K_PATCHES ?= ""
149
150 # Image suffix - actually set in conf/machine/nslu2.conf as it is also
151 # used by anything which needs to know the name of the generated image.
152 # Should be overridden in the distro if patches or defconfig are changed.
153 N2K_SUFFIX ?= "nslu2${ARCH_BYTE_SEX}"
154
155 SRC_URI  = "${N2K_SRCURI}"
156 SRC_URI += "${N2K_PATCHES}"
157 SRC_URI += "file://defconfig"
158
159 COMPATIBLE_HOST = 'arm.*-linux'
160
161 inherit kernel
162
163 ARCH = "arm"
164 KERNEL_IMAGETYPE = "zImage"
165 # To specify the console set KERNEL_CONSOLE in the .bb file.
166 # CMDLINE_ROOT contains the boot options, CMDLINE_KERNEL_OPTIONS
167 # contains the things for a specific kernel.
168 CMDLINE_KERNEL_OPTIONS ?= "reboot=s"
169 CMDLINE_ROOT ?= "root=/dev/mtdblock4 rw rootfstype=jffs2 mem=32M@0x00000000 init=/linuxrc"
170 # Add distro specific debug (or non-debug) options to this
171 CMDLINE_DEBUG ?= ""
172 CMDLINE = "${CMDLINE_ROOT} ${CMDLINE_KERNEL_OPTIONS} ${CMDLINE_DEBUG} ${CMDLINE_CONSOLE}"
173
174 # Set EXTRAVERSION and LOCALVERSION to "" so that the kernel version
175 # remains pinned to the x.y.z form, also turn off the directory
176 # printing which provides almost all the output of an incremental build.
177 EXTRA_OEMAKE += "EXTRAVERSION="
178 EXTRA_OEMAKE += "LOCALVERSION="
179 EXTRA_OEMAKE += "MAKEFLAGS='--no-print-directory'"
180
181 # Override KERNEL_RELEASE from kernel.bbclass to match:
182 KERNEL_RELEASE = "${KERNEL_VERSION}"
183
184 addtask unpacklocal before do_patch after do_unpack
185
186 # NOTE: in MM kernel builds the config options (oldconfig, menuconfig
187 # and so on) do not allow an option to be overridden, so the following
188 # removes the options which must be changed.
189 do_configure_prepend() {
190         rm -f ${S}/.config
191         echo "CONFIG_CMDLINE=\"${CMDLINE}\"" >>'${S}/.config'
192         if test '${ARCH_BYTE_SEX}' = be
193         then
194                 echo 'CONFIG_CPU_BIG_ENDIAN=y' >>'${S}/.config'
195         fi
196         if test '${SLUGOS_IMAGESEX}' = big-endian
197         then
198                 echo 'CONFIG_JFFS2_BIG_ENDIAN=y' >>'${S}/.config'
199         fi
200         if test '${SLUGOS_IMAGESEX}' = little-endian
201         then
202                 echo 'CONFIG_JFFS2_LITTLE_ENDIAN=y' >>'${S}/.config'
203         fi
204         sed -e '/CONFIG_CPU_BIG_ENDIAN/d' -e '/CONFIG_CMDLINE=/d' \
205                 -e '/CONFIG_JFFS2_NATIVE_ENDIAN=/d' \
206                 -e '/CONFIG_JFFS2_BIG_ENDIAN=/d' \
207                 -e '/CONFIG_JFFS2_LITTLE_ENDIAN=/d' \
208                 '${WORKDIR}/defconfig' >>'${S}/.config'
209         rm -rf ${S}/include/asm-arm/arch ${S}/include/asm-arm/proc \
210                ${S}/include/asm-arm/.proc ${S}/include/asm-arm/.arch
211 }
212
213 # This function adds the required prefix to the image to deal with two
214 # problems:
215 #
216 # 1) The machine type set by RedBoot is wrong - the type for an ixdp425, not an NSLU2
217 #    e3a01c02 e3811055
218 # 2) For LE kernels it is necessary to prefix change-to-le code to the kernel image:
219 #    ee110f10 e3c00080 ee010f10
220 #    and to byte swap the (LE) image to match the BE flash layout
221 #
222 # The argument to the function is the destination directory
223 redboot_fixup_armeb() {
224         rm -f "$1".new
225         devio '<<arch/${ARCH}/boot/${KERNEL_IMAGETYPE}' >"$1".new \
226                 'wb 0xe3a01c02,4' \
227                 'wb 0xe3811055,4' \
228                 'cp$'
229         mv "$1".new "$1"
230 }
231
232 redboot_fixup_arm() {
233         rm -f "$1".new
234         devio '<<arch/${ARCH}/boot/${KERNEL_IMAGETYPE}' >"$1".new \
235                 'wb 0xe3a01c02,4' \
236                 'wb 0xe3811055,4' \
237                 'wb 0xee110f10,4' \
238                 'wb 0xe3c00080,4' \
239                 'wb 0xee010f10,4' \
240                 'xp $,4' || {
241                 echo 'ERROR: arch/${ARCH}/boot/${KERNEL_IMAGETYPE}: failed to byteswap zImage' >&2
242                 return 1
243         }
244         mv "$1".new "$1"
245 }
246
247 do_install_append() {
248         redboot_fixup '${STAGING_KERNEL_DIR}/${KERNEL_IMAGETYPE}'
249 }
250
251 do_deploy[dirs] = "${S}"
252 do_deploy() {
253         install -d ${DEPLOY_DIR_IMAGE}
254         redboot_fixup '${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${N2K_SUFFIX}'
255 }
256
257 addtask deploy before do_build after do_compile
258
259 COMPATIBLE_MACHINE = "nslu2"