3 # Standard definitions for any IXP4xx Linux kernel.
4 # Include this file in a .bb which specifies, at least,
5 # PN,PV,PR for the desired kernel
7 # Define the following *before* including this file as
10 # IXP4XX_PATCHES - full list of patches to apply, to add files
11 # generate a patch against /dev/null
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 # --------------------------------------------------------------
26 DESCRIPTION = "Linux kernel for the Intel IXP4xx device"
29 DEPENDS = "arm-kernel-shim devio-native"
31 # Linux kernel source has the general form linux-X.Y.Z-patchP,
32 # X.Y is the major version number, Z (which may have multiple
33 # parts) is a sub-version and 'patch' is something like 'mm' or
34 # 'ac' with a patch version. The original bz2 archive will be
35 # in a directory/file vX.Y/linux-X.Y.Z.tar.bz2. The unpacked
36 # source will be in the directory linux-X.Y.Z and this directory
37 # name corresponds to the module directory (in /lib/modules).
39 # The corresponding .bb file should be called:
41 # package_X.Y.Z-patchP
43 # Giving PN=package PV=X.Y.Z-patchP (and PR is set in the .bb
44 # file). Files, including the all important defconfig, are
45 # searched for in the following directories (last one first):
50 # ixp4xx-kernel/X.Y.Z-patch
51 # ixp4xx-kernel/X.Y.Z-patchP
52 # package-X.Y.Z-patchP
54 # This allows sharing of patch files and other useful source!
55 # To share a file or patch with an earlier version put it in
56 # the shared directory - e.g. to use foo.patch on 2.6.11.2 and
57 # 2.6.11.4 it should be in directory ixp4xx-kernel/2.6.11.
59 # Note that when there are multiple patches the X.Y.Z-patch form
60 # uses base-patch (e.g. 2.6.12-mm) whereas X.Y.Z-patchP has the
61 # full form, for example 2.6.12-rc3-mm1 (in the same case).
64 #PV=package-version (full)
66 # The patch has the general form (rcN|preN|acN|mmN|bkN)* with the
67 # separate patch items being separated by '-' characters. The
68 # rc patch is first and has the important property that it
69 # requires the *preceding* kernel base version and that this
70 # will be the source directory name.
72 # The patches list may be empty. This code starts with the base
73 # kernel version and steps through the patches. Because the rc and
74 # pre patches actually require the *preceding* kernel version the code
75 # fixes that up appropriately.
76 pv = bb.data.getVar("PV",d,1).split('-')
78 prev = pv[0].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}/ixp4xx-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("${KERNELORG_MIRROR}/pub/linux/kernel/v%s/testing/patch-%s.bz2;patch=1;pname=%s;name=rcpatch" % (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("${KERNELORG_MIRROR}/pub/linux/kernel/v%s/snapshots/patch-%s.bz2;patch=1;pname=%s;name=gitpatch" % (major, pname, pname))
106 elif patch[0:2] == "ac":
107 patch_uri.append("${KERNELORG_MIRROR}/pub/linux/kernel/people/alan/linux-%s/%s/patch-%s;name=acpatch" % (major, base, pname))
109 filepath[0:0] = [ filedir % (name[0] + "-ac") ]
110 elif patch[0:2] == "mm":
111 patch_uri.append("${KERNELORG_MIRROR}/pub/linux/kernel/people/akpm/patches/%s/%s/%s/%s.bz2;patch=1;pname=%s;name=mmpatch" % (major, base, pname, pname, pname))
113 filepath[0:0] = [ filedir % (name[0] + "-mm") ]
115 raise bb.build.FuncFailed("ixp4xx-kernel: patch %s not recognized in %s" % (patch, '-'.join(pv)))
116 filepath[0:0] = [ filedir % pname ]
119 base = '.'.join(kernel)
120 patch_uri[0] = "${KERNELORG_MIRROR}/pub/linux/kernel/v%s/linux-%s.tar.bz2;name=kernel" % (major, base)
121 filepath[-1:-1] = [ filedir % base ]
123 filepath[-1:-1] = [ filedir % minor ]
124 filepath[-1:-1] = [ filedir % major ]
126 bb.data.setVar("IXP4XX_SRCMAJ", major, d)
127 # bb.note("IXP4XX_SRCMAJ := %s" % major)
128 bb.data.setVar("IXP4XX_SRCVER", base, d)
129 # bb.note("IXP4XX_SRCVER := %s" % base)
130 bb.data.setVar("IXP4XX_SRCURI", ' '.join(patch_uri), d)
131 # bb.note("IXP4XX_SRCURI := %s" % ' '.join(patch_uri))
132 bb.data.setVar("IXP4XX_FILESPATH", ':'.join(filepath), d)
133 # bb.note("IXP4XX_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}:${IXP4XX_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-${IXP4XX_SRCVER}"
147 # IXP4XX_PATCHES is the list of patches.
150 SRC_URI = "${IXP4XX_SRCURI}"
151 SRC_URI += "${IXP4XX_PATCHES}"
153 COMPATIBLE_HOST = 'arm.*-linux.*'
154 COMPATIBLE_MACHINE = '(ixp4xx|nslu2|fsg3)'
156 inherit kernel siteinfo
160 # To specify the console set KERNEL_CONSOLE in the .bb file.
161 # CMDLINE_ROOT contains the boot options, these will be
162 # appended to the build in boot options (so it is only necessary
163 # to override stuff in the kernel source).
165 # CMDLINE_ROOT: machine specific boot options - should not be set on a
169 # CMDLINE_DEBUG: debug options such as noirqdebug, defaults to empty
170 # override in local.conf etc
173 CMDLINE = "${CMDLINE_ROOT}"
174 CMDLINE += "${CMDLINE_DEBUG}"
175 CMDLINE += "${CMDLINE_CONSOLE}"
177 # Set EXTRAVERSION and LOCALVERSION to "" so that the kernel version
178 # remains pinned to the x.y.z form, also turn off the directory
179 # printing which provides almost all the output of an incremental build.
180 EXTRA_OEMAKE += "EXTRAVERSION="
181 EXTRA_OEMAKE += "LOCALVERSION="
182 EXTRA_OEMAKE += "MAKEFLAGS='--no-print-directory'"
184 # Set the correct CONFIG_CPU_xxx_ENDIAN and CONFIG_CMDLINE at the head
185 # of the .config file and remove any settings in defconfig then append
186 # defconfig to .config
187 do_configure_prepend() {
189 echo "CONFIG_CMDLINE=\"${CMDLINE}\"" >>'${S}/.config'
190 if test '${SITEINFO_ENDIANESS}' = be
192 echo 'CONFIG_CPU_BIG_ENDIAN=y' >>'${S}/.config'
195 if [ "${TARGET_OS}" == "linux-gnueabi" -o "${TARGET_OS}" == "linux-uclibceabi" ]; then
196 echo "CONFIG_AEABI=y" >> ${S}/.config
197 echo "CONFIG_OABI_COMPAT=y" >> ${S}/.config
199 echo "# CONFIG_AEABI is not set" >> ${S}/.config
200 echo "# CONFIG_OABI_COMPAT is not set" >> ${S}/.config
203 sed -e '/CONFIG_CPU_BIG_ENDIAN/d' \
204 -e '/CONFIG_CMDLINE=/d' \
205 -e '/CONFIG_AEABI/d' \
206 -e '/CONFIG_OABI_COMPAT=/d' \
207 '${WORKDIR}/defconfig' >>'${S}/.config'
208 rm -rf ${S}/include/asm-arm/arch ${S}/include/asm-arm/proc \
209 ${S}/include/asm-arm/.proc ${S}/include/asm-arm/.arch
214 # Kernel module dependencies
216 DEPENDS += "zd1211-firmware"
217 RDEPENDS_kernel-module-zd1211rw += "zd1211-firmware"
220 # MACHID and LE handling
222 # This mach_fixup function adds the required prefix to the image to
223 # force the machine id in the kernel to be a particular value. For
224 # LE builds it also forces the CPU into LE mode - this is actually
225 # harmless even if the CPU is already in LE mode. This deals with
226 # two known problems on some boards:
228 # 1) The machine type set by the boot loader is wrong - e.g. the type
229 # for an ixdp425, not the actual board type. Prefix the code with
231 # e3a01c<hh> e38110<ll>
232 # Where the machine ID is 0xhhll
233 # 2) For LE kernels it is necessary to prefix change-to-le code to
234 # the kernel image if the boot loader runs with the CPU in BE
235 # (which is normal for IXP4XX boards):
236 # ee110f10 e3c00080 ee010f10
237 # and to byte swap the (LE) image to match the BE flash layout
239 # (2) is not required with an LE boot loader (neither the prefix
240 # nor the byte swapping) so this is controlled by a separate flag,
241 # however if the boot loader is LE it expects and LE image so the
242 # instructions written for the machine id must be LE.
244 # The argument to the function is the destination directory
246 # The generic package only includes the generic image, the other
247 # packages are made below (they are kernel-image packages but
248 # with a different ARCH).
249 FILES_kernel-image = "/boot/${KERNEL_IMAGETYPE}-${MACHINE_ARCH}-${KERNEL_VERSION}"
251 # MACHINE DEFINITIONS: one block for each machine
253 # The correct settings for the NSLU2 board:
255 PACKAGES += "kernel-image-nslu2"
256 PKG_kernel-image-nslu2 = "kernel-image-${KERNEL_VERSION}"
257 PACKAGE_ARCH_kernel-image-nslu2 = "nslu2${SITEINFO_ENDIANESS}"
258 DESCRIPTION_kernel-image-nslu2 = "Linux kernel for the LinkSys NSLU2"
259 FILES_kernel-image-nslu2 = "/${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-nslu2${SITEINFO_ENDIANESS}-${KERNEL_VERSION}"
260 pkg_postinst_kernel-image-nslu2 () {
261 update-alternatives --install /${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE} ${KERNEL_IMAGETYPE} /${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-nslu2${SITEINFO_ENDIANESS}-${KERNEL_VERSION} ${KERNEL_PRIORITY} || true
263 pkg_postrm_kernel-image-nslu2 () {
264 update-alternatives --remove ${KERNEL_IMAGETYPE} /${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-nslu2${SITEINFO_ENDIANESS}-${KERNEL_VERSION} || true
267 # The correct settings for the NAS100D board:
268 nas100d_MACHID = "865"
269 PACKAGES += "kernel-image-nas100d"
270 PKG_kernel-image-nas100d = "kernel-image-${KERNEL_VERSION}"
271 PACKAGE_ARCH_kernel-image-nas100d = "nas100d${SITEINFO_ENDIANESS}"
272 DESCRIPTION_kernel-image-nas100d = "Linux kernel for the IOMega NAS100D"
273 FILES_kernel-image-nas100d = "/${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-nas100d${SITEINFO_ENDIANESS}-${KERNEL_VERSION}"
274 pkg_postinst_kernel-image-nas100d () {
275 update-alternatives --install /${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE} ${KERNEL_IMAGETYPE} /${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-nas100d${SITEINFO_ENDIANESS}-${KERNEL_VERSION} ${KERNEL_PRIORITY} || true
277 pkg_postrm_kernel-image-nas100d () {
278 update-alternatives --remove ${KERNEL_IMAGETYPE} /${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-nas100d${SITEINFO_ENDIANESS}-${KERNEL_VERSION} || true
281 # The correct settings for the DSMG600 board:
282 dsmg600_MACHID = "964"
283 PACKAGES += "kernel-image-dsmg600"
284 PKG_kernel-image-dsmg600 = "kernel-image-${KERNEL_VERSION}"
285 PACKAGE_ARCH_kernel-image-dsmg600 = "dsmg600${SITEINFO_ENDIANESS}"
286 DESCRIPTION_kernel-image-dsmg600 = "Linux kernel for the D-Link DSM-G600"
287 FILES_kernel-image-dsmg600 = "/${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-dsmg600${SITEINFO_ENDIANESS}-${KERNEL_VERSION}"
288 pkg_postinst_kernel-image-dsmg600 () {
289 update-alternatives --install /${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE} ${KERNEL_IMAGETYPE} /${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-dsmg600${SITEINFO_ENDIANESS}-${KERNEL_VERSION} ${KERNEL_PRIORITY} || true
291 pkg_postrm_kernel-image-dsmg600 () {
292 update-alternatives --remove ${KERNEL_IMAGETYPE} /${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-dsmg600${SITEINFO_ENDIANESS}-${KERNEL_VERSION} || true
295 # The correct settings for the FSG-3 board:
297 PACKAGES += "kernel-image-fsg3"
298 PKG_kernel-image-fsg3 = "kernel-image-${KERNEL_VERSION}"
299 PACKAGE_ARCH_kernel-image-fsg3 = "fsg3${SITEINFO_ENDIANESS}"
300 DESCRIPTION_kernel-image-fsg3 = "Linux kernel for the Freecom FSG-3"
301 FILES_kernel-image-fsg3 = "/${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-fsg3${SITEINFO_ENDIANESS}-${KERNEL_VERSION}"
302 pkg_postinst_kernel-image-fsg3 () {
303 update-alternatives --install /${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE} ${KERNEL_IMAGETYPE} /${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-fsg3${SITEINFO_ENDIANESS}-${KERNEL_VERSION} ${KERNEL_PRIORITY} || true
305 pkg_postrm_kernel-image-fsg3 () {
306 update-alternatives --remove ${KERNEL_IMAGETYPE} /${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-fsg3${SITEINFO_ENDIANESS}-${KERNEL_VERSION} || true
309 BYTESWAP_armeb = "cp$"
310 BYTESWAP_arm = "xp $,4"
312 # We need the alternatives to happen in the kernel-image packages, not in
313 # the kernel package, because only the images know the name of the kernel.
314 pkg_postinst_kernel () {
316 pkg_postrm_kernel () {
319 # copy_image <dest> <machine>
320 # copy the zImage and append the appropriate shim
321 # dest: where to copy to
322 # machine: machine shim to prepend, empty for none
327 test -n "$2" && shim="${STAGING_LOADER_DIR}/arm-kernel-shim-$2.bin"
329 rm -f "$1".new "$1".shimmed
330 cat $shim ${KERNEL_OUTPUT} > "$1".shimmed
331 devio '<<'"$1"'.shimmed' >"$1".new '${BYTESWAP}' || {
332 echo 'ERROR: ${KERNEL_OUTPUT}: failed to copy zImage' >&2
340 copy_image '${D}/${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-'"$1"'-${KERNEL_VERSION}' "$2"
343 do_install_append() {
344 # Overwrite the unshimmed generic image with a shimmed one (but without
345 # any command line or machine id override).
346 rm -f '${D}/${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-${KERNEL_VERSION}'
347 install_image '${MACHINE_ARCH}'
349 # Add the machine specific images, with appropriate suffixes
350 install_image 'nslu2${SITEINFO_ENDIANESS}' 'nslu2'
351 install_image 'nas100d${SITEINFO_ENDIANESS}' 'nas100d'
352 install_image 'dsmg600${SITEINFO_ENDIANESS}' 'dsmg600'
353 install_image 'fsg3${SITEINFO_ENDIANESS}' 'fsg3'
357 copy_image '${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-'"$1" "$2"
361 install -d ${DEPLOY_DIR_IMAGE}
362 deploy_image '${MACHINE_ARCH}'
364 # And the machine specific images
365 deploy_image 'nslu2${SITEINFO_ENDIANESS}' 'nslu2'
366 deploy_image 'nas100d${SITEINFO_ENDIANESS}' 'nas100d'
367 deploy_image 'dsmg600${SITEINFO_ENDIANESS}' 'dsmg600'
368 deploy_image 'fsg3${SITEINFO_ENDIANESS}' 'fsg3'