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
5 # Define the following *before* including this file as
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
13 # DEFAULT_PREFERENCE is set automagically in this file as
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
23 # --------------------------------------------------------------
25 # Within this file bitbake variables local to the file are
29 DESCRIPTION = "Linux kernel for the Linksys NSLU2 device"
32 DEPENDS += "devio-native"
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).
42 # The corresponding .bb file should be called:
44 # package_X.Y.Z-patchP
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):
53 # nslu2-kernel/X.Y.Z-patch
54 # nslu2-kernel/X.Y.Z-patchP
55 # package-X.Y.Z-patchP
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.
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).
67 #PV=package-version (full)
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.
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('.')
83 major = '.'.join(name[0].split('.')[0:2])
84 minor = '.'.join(name[0].split('.')[0:3])
86 filedir = "${FILE_DIRNAME}/nslu2-kernel/%s"
87 # This entry will become the last one (everything is inserted before it)
88 filepath = [ filedir % "files" ]
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:
99 filepath[0:0] = [ filedir % name[0] ]
100 filepath[0:0] = [ filedir % (name[0] + "-rc") ]
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))
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))
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))
113 filepath[0:0] = [ filedir % (name[0] + "-mm") ]
115 raise bb.build.FuncFailed("nslu2-kernel: patch %s not recognized in %s" % (patch, '-'.join(pv)))
116 filepath[0:0] = [ filedir % pname ]
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 ]
123 filepath[-1:-1] = [ filedir % minor ]
124 filepath[-1:-1] = [ filedir % major ]
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))
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}"
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}"
147 # N2K_PATCHES is the list of patches.
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}"
155 SRC_URI = "${N2K_SRCURI}"
156 SRC_URI += "${N2K_PATCHES}"
157 SRC_URI += "file://defconfig"
159 COMPATIBLE_HOST = 'arm.*-linux'
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
172 CMDLINE = "${CMDLINE_ROOT} ${CMDLINE_KERNEL_OPTIONS} ${CMDLINE_DEBUG} ${CMDLINE_CONSOLE}"
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'"
181 # Override KERNEL_RELEASE from kernel.bbclass to match:
182 KERNEL_RELEASE = "${KERNEL_VERSION}"
184 addtask unpacklocal before do_patch after do_unpack
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() {
191 echo "CONFIG_CMDLINE=\"${CMDLINE}\"" >>'${S}/.config'
192 if test '${ARCH_BYTE_SEX}' = be
194 echo 'CONFIG_CPU_BIG_ENDIAN=y' >>'${S}/.config'
196 if test '${SLUGOS_IMAGESEX}' = big-endian
198 echo 'CONFIG_JFFS2_BIG_ENDIAN=y' >>'${S}/.config'
200 if test '${SLUGOS_IMAGESEX}' = little-endian
202 echo 'CONFIG_JFFS2_LITTLE_ENDIAN=y' >>'${S}/.config'
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
213 # This function adds the required prefix to the image to deal with two
216 # 1) The machine type set by RedBoot is wrong - the type for an ixdp425, not an NSLU2
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
222 # The argument to the function is the destination directory
223 redboot_fixup_armeb() {
225 devio '<<arch/${ARCH}/boot/${KERNEL_IMAGETYPE}' >"$1".new \
232 redboot_fixup_arm() {
234 devio '<<arch/${ARCH}/boot/${KERNEL_IMAGETYPE}' >"$1".new \
241 echo 'ERROR: arch/${ARCH}/boot/${KERNEL_IMAGETYPE}: failed to byteswap zImage' >&2
247 do_install_append() {
248 redboot_fixup '${STAGING_KERNEL_DIR}/${KERNEL_IMAGETYPE}'
251 do_deploy[dirs] = "${S}"
253 install -d ${DEPLOY_DIR_IMAGE}
254 redboot_fixup '${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${N2K_SUFFIX}'
257 addtask deploy before do_build after do_compile
259 COMPATIBLE_MACHINE = "nslu2"