]> pilppa.org Git - familiar-h63xx-build.git/blob - org.handhelds.familiar/packages/linux/nslu2-kernel.inc
OE tree imported from monotone branch org.openembedded.oz354fam083 at revision 8b12e3...
[familiar-h63xx-build.git] / org.handhelds.familiar / packages / linux / nslu2-kernel.inc
1 # nslu2-kernel.inc
2 #
3 # Standard definitions for any NSLU2 Linux kernel.
4 # Include this file in a .bb which specifies, at least,
5 # PN,PV,PR for the desired kernel
6 #
7 # Define the following *before* including this file as
8 # required:
9 #
10 # N2K_EXTRA_FILES - kernel-tree path of extra files to install
11 # N2K_FILES - kernel-tree path of files to install, defaults to:
12 #   drivers/i2c/chips/x1205-rtc.c
13 #   arch/arm/mach-ixp4xx/nslu2-io.c
14 #   arch/arm/mach-ixp4xx/nslu2-setup.c
15 #   arch/arm/mach-ixp4xx/nslu2-pci.c
16 #   arch/arm/mach-ixp4xx/nslu2-part.c
17 #   include/asm-arm/arch-ixp4xx/nslu2.h
18 #   ${N2K_EXTRA_FILES}
19 #
20 # N2K_EXTRA_PATCHES - list of patches to apply (can include
21 #   patches to the files installed above)
22 # N2K_PATCHES - full list of patches to apply, defaults to:
23 #   file://nslu2_2.6.11.patch;patch=1
24 #   file://usbnet.patch;patch=1
25 #   file://ixp4xx_copy_from.patch;patch=1
26 #   file://anonymiser.patch;patch=1
27 #   file://xscale-reset.patch;patch=1
28 #   file://mtd-shutdown.patch;patch=1
29 #   ${N2K_EXTRA_PATCHES}
30 #
31 # N2K_SUFFIX - the suffix to add after 'zImage-' in the
32 #   deploy/images directory - defaults to "openslug"
33 #
34 # Notice that the N2K_PATCHES list is appropriate for
35 # openslug-kernel_2.6.11.2 and probably nothing else.
36 #
37 # DEFAULT_PREFERENCE is set automagically in this file as
38 # follows:
39 #
40 #  10  For *released* kernels
41 #   8  For mm or ac patched versions of released kernels
42 #   6  For rc patched kernels (release candidates)
43 #   4  For mm or ac patched rc (release candidate) kernels
44 #   2  For pre or bk versions
45 #   0  For mm or ac patched pre or bk versions
46 #
47 # --------------------------------------------------------------
48 #
49 # Within this file bitbake variables local to the file are
50 # named N2K_FOO
51 #
52 SECTION = "kernel"
53 DESCRIPTION = "Linux kernel for the Linksys NSLU2 device"
54 LICENSE = "GPL"
55 MAINTAINER = "John Bowler <jbowler@acm.org>"
56
57 # Linux kernel source has the general form linux-X.Y.Z-patchP,
58 # X.Y is the major version number, Z (which may have multiple
59 # parts) is a sub-version and 'patch' is something like 'mm' or
60 # 'ac' with a patch version.  The original bz2 archive will be
61 # in a directory/file vX.Y/linux-X.Y.Z.tar.bz2.  The unpacked
62 # source will be in the directory linux-X.Y.Z and this directory
63 # name corresponds to the module directory (in /lib/modules).
64 #
65 # The corresponding .bb file should be called:
66 #
67 #       package_X.Y.Z-patchP
68 #
69 # Giving PN=package PV=X.Y.Z-patchP (and PR is set in the .bb
70 # file).  Files, including the all important defconfig, are
71 # searched for in the following directories (last one first):
72 #
73 #       openslug-kernel-2.6.11.2
74 #       nslu2-kernel/files
75 #       nslu2-kernel/X.Y
76 #       nslu2-kernel/X.Y.Z
77 #       nslu2-kernel/X.Y.Z-patch
78 #       nslu2-kernel/X.Y.Z-patchP
79 #       package-X.Y.Z-patchP
80 #
81 # This allows sharing of patch files and other useful source!
82 # To share a file or patch with an earlier version put it in
83 # the shared directory - e.g. to use foo.patch on 2.6.11.2 and
84 # 2.6.11.4 it should be in directory nslu2-kernel/2.6.11.
85 #
86 # Note that when there are multiple patches the X.Y.Z-patch form
87 # uses base-patch (e.g. 2.6.12-mm) whereas X.Y.Z-patchP has the
88 # full form, for example 2.6.12-rc3-mm1 (in the same case).
89
90 #PN=package-name
91 #PV=package-version (full)
92
93 # The patch has the general form (rcN|preN|acN|mmN|bkN)* with the
94 # separate patch items being separated by '-' characters.  The
95 # rc patch is first and has the important property that it
96 # requires the *preceding* kernel base version and that this
97 # will be the source directory name.
98 python () {
99     # The patches list may be empty.  This code starts with the base
100     # kernel version and steps through the patches.  Because the rc and
101     # pre patches actually require the *preceding* kernel version the code
102     # fixes that up appropriately.
103     pv = bb.data.getVar("PV",d,1).split('-')
104     kernel = pv[0].split('.')
105     base = pv[0]
106     name = [base]
107     major = '.'.join(name[0].split('.')[0:2])
108     minor = '.'.join(name[0].split('.')[0:3])
109     patch_uri = [ None ]
110     filedir = "${FILE_DIRNAME}/nslu2-kernel/%s"
111     # This entry will become the last one (everything is inserted before it)
112     filepath = [ filedir % "files" ]
113     pref = 10
114     mmac = 0
115     for patch in pv[1:]:
116         name.append(patch)
117         pname = '-'.join(name)
118         if patch[0:2] == "rc" or patch[0:3] == "pre":
119             patch_uri.append("ftp://ftp.kernel.org/pub/linux/kernel/v%s/testing/patch-%s.bz2;patch=1;pname=%s" % (major, pname, pname))
120             kernel[-1] = str(int(kernel[-1]) - 1)
121             if patch[0:2] == "rc" and pref == 10:
122                 pref = 6
123                 filepath[0:0] = [ filedir % name[0] ]
124                 filepath[0:0] = [ filedir % (name[0] + "-rc") ]
125             else:
126                 pref = 2
127         elif patch[0:2] == "bk" or patch[0:3] == "git":
128             patch_uri.append("ftp://ftp.kernel.org/pub/linux/kernel/v%s/snapshots/patch-%s.bz2;patch=1;pname=%s" % (major, pname, pname))
129             pref = 2
130         elif patch[0:2] == "ac":
131             patch_uri.append("ftp://ftp.kernel.org/pub/linux/kernel/people/alan/linux-%s/%s/patch-%s" % (major, base, pname))
132             mmac = 2
133             filepath[0:0] = [ filedir % (name[0] + "-ac") ]
134         elif patch[0:2] == "mm":
135             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))
136             mmac = 2
137             filepath[0:0] = [ filedir % (name[0] + "-mm") ]
138         else:
139             raise bb.build.FuncFailed("nslu2-kernel: patch %s not recognized in %s" % (patch, '-'.join(pv)))
140         filepath[0:0] = [ filedir % pname ]
141         base = pname
142
143     base = '.'.join(kernel)
144     patch_uri[0] = "ftp://ftp.kernel.org/pub/linux/kernel/v%s/linux-%s.tar.bz2" % (major, base)
145     filepath[-1:-1] = [ filedir % base ]
146     if base != minor:
147             filepath[-1:-1] = [ filedir % minor ]
148     filepath[-1:-1] = [ filedir % major ]
149
150     bb.data.setVar("N2K_SRCMAJ", major, d)
151     # bb.note("N2K_SRCMAJ := %s" % major)
152     bb.data.setVar("N2K_SRCVER", base, d)
153     # bb.note("N2K_SRCVER := %s" % base)
154     bb.data.setVar("N2K_SRCURI", ' '.join(patch_uri), d)
155     # bb.note("N2K_SRCURI := %s" % ' '.join(patch_uri))
156     bb.data.setVar("N2K_FILESPATH", ':'.join(filepath), d)
157     # bb.note("N2K_FILESPATH := %s" % ' '.join(filepath))
158     bb.data.setVar("DEFAULT_PREFERENCE", pref-mmac, d)
159     # bb.note("DEFAULT_PREFERENCE := %s" % (pref-mmac))
160 }
161
162 # FILESPATH: this list is in order last-searched-first, therefore
163 # the first entry is the *latest* and/or most specific
164 FILESPATH = "${FILE_DIRNAME}/${P}:${N2K_FILESPATH}:${FILE_DIRNAME}/openslug-kernel-2.6.11.2"
165
166 # The working directory will be the 'base' version (which may not be the
167 # same as implied by the PV variable because it corresponds to the prior
168 # minor version for rc and pre patched versions).
169 S = "${WORKDIR}/linux-${N2K_SRCVER}"
170
171 # N2K_FILES is a list of additional files added to the source, these are
172 # put in place before the patches, so may themselves be patched.  The list
173 # gives the path name relative to the base of the kernel source tree, the
174 # base file name is used to *find* the file.
175 N2K_EXTRA_FILES ?=
176 N2K_FILES ?= "\
177     drivers/i2c/chips/x1205-rtc.c \
178     arch/arm/mach-ixp4xx/nslu2-io.c \
179     arch/arm/mach-ixp4xx/nslu2-setup.c \
180     arch/arm/mach-ixp4xx/nslu2-pci.c \
181     arch/arm/mach-ixp4xx/nslu2-part.c \
182     include/asm-arm/arch-ixp4xx/nslu2.h \
183     ${N2K_EXTRA_FILES}"
184
185 N2K_SRCFILES = "${@( ' '.join([ ("file://" + n2k_file.split('/')[-1]) for n2k_file in bb.data.getVar("N2K_FILES",d,1).split(None) ]) )}"
186
187 # N2K_PATCHES is a list of additional patches, the list specified
188 # here comes from the openslug-2.6.11.2 kernel, typically extra
189 # patches will be required and very often patches will need to
190 # be removed (i.e. the default is typically not very useful!)
191 N2K_EXTRA_PATCHES ?=
192 N2K_PATCHES ?= "\
193     file://nslu2_2.6.11.patch;patch=1 \
194     file://usbnet.patch;patch=1 \
195     file://ixp4xx_copy_from.patch;patch=1 \
196     file://anonymiser.patch;patch=1 \
197     file://xscale-reset.patch;patch=1 \
198     file://mtd-shutdown.patch;patch=1 \
199     ${N2K_EXTRA_PATCHES}"
200
201 N2K_SUFFIX ?= "openslug"
202
203 SRC_URI  = "${N2K_SRCURI}"
204 SRC_URI += "${N2K_SRCFILES}"
205 SRC_URI += "${N2K_PATCHES}"
206 SRC_URI += "file://defconfig"
207
208 COMPATIBLE_HOST = 'arm.*-linux'
209
210 inherit kernel
211
212 ARCH = "arm"
213 KERNEL_IMAGETYPE = "zImage"
214 # To specify the console set KERNEL_CONSOLE in the .bb file.
215 # CMDLINE_ROOT contains the boot options, CMDLINE_KERNEL_OPTIONS
216 # contains the things for a specific kernel.
217 CMDLINE_KERNEL_OPTIONS ?= "reboot=s"
218 CMDLINE_ROOT ?= "root=/dev/mtdblock4 rw rootfstype=jffs2 mem=32M@0x00000000 init=/linuxrc"
219 # Add distro specific debug (or non-debug) options to this
220 CMDLINE_DEBUG ?= ""
221 CMDLINE = "${CMDLINE_ROOT} ${CMDLINE_KERNEL_OPTIONS} ${CMDLINE_DEBUG} ${CMDLINE_CONSOLE}"
222
223 # Add the architecture compiler flags to KERNEL_CC and KERNEL_LD as
224 # required.  Notice that this has to be done for each separately built
225 # module as well!
226 KERNEL_CC += "${TARGET_CC_KERNEL_ARCH}"
227 KERNEL_LD += "${TARGET_LD_KERNEL_ARCH}"
228
229 # By putting the added files in place in a separate task before
230 # do_patch it becomes possible to patch these files.
231 do_unpacklocal() {
232         for f in ${N2K_FILES}
233         do
234                 s="$(basename "$f")"
235                 install -m 0644 "${WORKDIR}/$s" "${S}/$f"
236         done
237 }
238
239 addtask unpacklocal before do_patch after do_unpack
240
241 do_configure_prepend() {
242         install -m 0644 ${WORKDIR}/defconfig ${S}/.config
243         echo "CONFIG_CMDLINE=\"${CMDLINE}\"" >> ${S}/.config
244         rm -rf ${S}/include/asm-arm/arch ${S}/include/asm-arm/proc \
245                ${S}/include/asm-arm/.proc ${S}/include/asm-arm/.arch
246 }
247
248 do_deploy[dirs] = "${S}"
249 do_deploy() {
250         install -d ${DEPLOY_DIR}/images
251         install -m 0644 arch/${ARCH}/boot/${KERNEL_IMAGETYPE} ${DEPLOY_DIR}/images/${KERNEL_IMAGETYPE}-${N2K_SUFFIX}
252 }
253
254 addtask deploy before do_build after do_compile
255
256 python () {
257         # Don't build the kernel unless we're targeting an nslu2
258         mach = bb.data.getVar("MACHINE", d, 1)
259         if mach != 'nslu2':
260                 raise bb.parse.SkipPackage("OpenSlug only builds for the Linksys NSLU2")
261 }