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 # Linux kernel source has the general form linux-X.Y.Z-patchP,
30 # X.Y is the major version number, Z (which may have multiple
31 # parts) is a sub-version and 'patch' is something like 'mm' or
32 # 'ac' with a patch version. The original bz2 archive will be
33 # in a directory/file vX.Y/linux-X.Y.Z.tar.bz2. The unpacked
34 # source will be in the directory linux-X.Y.Z and this directory
35 # name corresponds to the module directory (in /lib/modules).
37 # The corresponding .bb file should be called:
39 # package_X.Y.Z-patchP
41 # Giving PN=package PV=X.Y.Z-patchP (and PR is set in the .bb
42 # file). Files, including the all important defconfig, are
43 # searched for in the following directories (last one first):
48 # ixp4xx-kernel/X.Y.Z-patch
49 # ixp4xx-kernel/X.Y.Z-patchP
50 # package-X.Y.Z-patchP
52 # This allows sharing of patch files and other useful source!
53 # To share a file or patch with an earlier version put it in
54 # the shared directory - e.g. to use foo.patch on 2.6.11.2 and
55 # 2.6.11.4 it should be in directory ixp4xx-kernel/2.6.11.
57 # Note that when there are multiple patches the X.Y.Z-patch form
58 # uses base-patch (e.g. 2.6.12-mm) whereas X.Y.Z-patchP has the
59 # full form, for example 2.6.12-rc3-mm1 (in the same case).
62 #PV=package-version (full)
64 # The patch has the general form (rcN|preN|acN|mmN|bkN)* with the
65 # separate patch items being separated by '-' characters. The
66 # rc patch is first and has the important property that it
67 # requires the *preceding* kernel base version and that this
68 # will be the source directory name.
70 # The patches list may be empty. This code starts with the base
71 # kernel version and steps through the patches. Because the rc and
72 # pre patches actually require the *preceding* kernel version the code
73 # fixes that up appropriately.
74 pv = bb.data.getVar("PV",d,1).split('-')
75 kernel = pv[0].split('.')
78 major = '.'.join(name[0].split('.')[0:2])
79 minor = '.'.join(name[0].split('.')[0:3])
81 filedir = "${FILE_DIRNAME}/ixp4xx-kernel/%s"
82 # This entry will become the last one (everything is inserted before it)
83 filepath = [ filedir % "files" ]
88 pname = '-'.join(name)
89 if patch[0:2] == "rc" or patch[0:3] == "pre":
90 patch_uri.append("ftp://ftp.kernel.org/pub/linux/kernel/v%s/testing/patch-%s.bz2;patch=1;pname=%s" % (major, pname, pname))
91 kernel[-1] = str(int(kernel[-1]) - 1)
92 if patch[0:2] == "rc" and pref == 10:
94 filepath[0:0] = [ filedir % name[0] ]
95 filepath[0:0] = [ filedir % (name[0] + "-rc") ]
98 elif patch[0:2] == "bk" or patch[0:3] == "git":
99 patch_uri.append("ftp://ftp.kernel.org/pub/linux/kernel/v%s/snapshots/patch-%s.bz2;patch=1;pname=%s" % (major, pname, pname))
101 elif patch[0:2] == "ac":
102 patch_uri.append("ftp://ftp.kernel.org/pub/linux/kernel/people/alan/linux-%s/%s/patch-%s" % (major, base, pname))
104 filepath[0:0] = [ filedir % (name[0] + "-ac") ]
105 elif patch[0:2] == "mm":
106 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))
108 filepath[0:0] = [ filedir % (name[0] + "-mm") ]
110 raise bb.build.FuncFailed("ixp4xx-kernel: patch %s not recognized in %s" % (patch, '-'.join(pv)))
111 filepath[0:0] = [ filedir % pname ]
114 base = '.'.join(kernel)
115 patch_uri[0] = "ftp://ftp.kernel.org/pub/linux/kernel/v%s/linux-%s.tar.bz2" % (major, base)
116 filepath[-1:-1] = [ filedir % base ]
118 filepath[-1:-1] = [ filedir % minor ]
119 filepath[-1:-1] = [ filedir % major ]
121 bb.data.setVar("IXP4XX_SRCMAJ", major, d)
122 # bb.note("IXP4XX_SRCMAJ := %s" % major)
123 bb.data.setVar("IXP4XX_SRCVER", base, d)
124 # bb.note("IXP4XX_SRCVER := %s" % base)
125 bb.data.setVar("IXP4XX_SRCURI", ' '.join(patch_uri), d)
126 # bb.note("IXP4XX_SRCURI := %s" % ' '.join(patch_uri))
127 bb.data.setVar("IXP4XX_FILESPATH", ':'.join(filepath), d)
128 # bb.note("IXP4XX_FILESPATH := %s" % ' '.join(filepath))
129 bb.data.setVar("DEFAULT_PREFERENCE", pref-mmac, d)
130 # bb.note("DEFAULT_PREFERENCE := %s" % (pref-mmac))
133 # FILESPATH: this list is in order last-searched-first, therefore
134 # the first entry is the *latest* and/or most specific
135 FILESPATH = "${FILE_DIRNAME}/${P}:${IXP4XX_FILESPATH}"
137 # The working directory will be the 'base' version (which may not be the
138 # same as implied by the PV variable because it corresponds to the prior
139 # minor version for rc and pre patched versions).
140 S = "${WORKDIR}/linux-${IXP4XX_SRCVER}"
142 # IXP4XX_PATCHES is the list of patches.
145 SRC_URI = "${IXP4XX_SRCURI}"
146 SRC_URI += "${IXP4XX_PATCHES}"
148 COMPATIBLE_HOST = 'arm.*-linux.*'
149 COMPATIBLE_MACHINE = '(ixp4xx|loft|nslu2|nas100d|dsmg600|fsg3)'
154 KERNEL_IMAGETYPE = "zImage"
156 # To specify the console set KERNEL_CONSOLE in the .bb file.
157 # CMDLINE_ROOT contains the boot options, these will be
158 # appended to the build in boot options (so it is only necessary
159 # to override stuff in the kernel source).
161 # CMDLINE_ROOT: machine specific boot options - should not be set on a
165 # CMDLINE_DEBUG: debug options such as noirqdebug, defaults to empty
166 # override in local.conf etc
169 CMDLINE = "${CMDLINE_ROOT}"
170 CMDLINE += "${CMDLINE_DEBUG}"
171 CMDLINE += "${CMDLINE_CONSOLE}"
173 # Set EXTRAVERSION and LOCALVERSION to "" so that the kernel version
174 # remains pinned to the x.y.z form, also turn off the directory
175 # printing which provides almost all the output of an incremental build.
176 EXTRA_OEMAKE += "EXTRAVERSION="
177 EXTRA_OEMAKE += "LOCALVERSION="
178 EXTRA_OEMAKE += "MAKEFLAGS='--no-print-directory'"
180 # Override KERNEL_RELEASE from kernel.bbclass to match:
181 KERNEL_RELEASE = "${KERNEL_VERSION}"
183 # Set the correct CONFIG_CPU_xxx_ENDIAN and CONFIG_CMDLINE at the head
184 # of the .config file and remove any settings in defconfig then append
185 # defconfig to .config
186 do_configure_prepend() {
188 echo "CONFIG_CMDLINE=\"${CMDLINE}\"" >>'${S}/.config'
189 if test '${ARCH_BYTE_SEX}' = be
191 echo 'CONFIG_CPU_BIG_ENDIAN=y' >>'${S}/.config'
194 if [ "${TARGET_OS}" == "linux-gnueabi" -o "${TARGET_OS}" == "linux-uclibcgnueabi" ]; then
195 echo "CONFIG_AEABI=y" >> ${S}/.config
196 echo "CONFIG_OABI_COMPAT=y" >> ${S}/.config
198 echo "# CONFIG_AEABI is not set" >> ${S}/.config
199 echo "# CONFIG_OABI_COMPAT is not set" >> ${S}/.config
202 sed -e '/CONFIG_CPU_BIG_ENDIAN/d' \
203 -e '/CONFIG_CMDLINE=/d' \
204 -e '/CONFIG_AEABI/d' \
205 -e '/CONFIG_OABI_COMPAT=/d' \
206 '${WORKDIR}/defconfig' >>'${S}/.config'
207 rm -rf ${S}/include/asm-arm/arch ${S}/include/asm-arm/proc \
208 ${S}/include/asm-arm/.proc ${S}/include/asm-arm/.arch
212 # MACHID and LE handling
214 # This mach_fixup function adds the required prefix to the image to
215 # force the machine id in the kernel to be a particular value. For
216 # LE builds it also forces the CPU into LE mode - this is actually
217 # harmless even if the CPU is already in LE mode. This deals with
218 # two known problems on some boards:
220 # 1) The machine type set by the boot loader is wrong - e.g. the type
221 # for an ixdp425, not the actual board type. Prefix the code with
223 # e3a01c<hh> e38110<ll>
224 # Where the machine ID is 0xhhll
225 # 2) For LE kernels it is necessary to prefix change-to-le code to
226 # the kernel image if the boot loader runs with the CPU in BE
227 # (which is normal for IXP4XX boards):
228 # ee110f10 e3c00080 ee010f10
229 # and to byte swap the (LE) image to match the BE flash layout
231 # (2) is not required with an LE boot loader (neither the prefix
232 # nor the byte swapping) so this is controlled by a separate flag,
233 # however if the boot loader is LE it expects and LE image so the
234 # instructions written for the machine id must be LE.
236 # The argument to the function is the destination directory
238 # The generic package only includes the generic image, the other
239 # packages are made below (they are kernel-image packages but
240 # with a different ARCH).
241 FILES_kernel-image = "/boot/${KERNEL_IMAGETYPE}-${IXP4XX_SUFFIX}-${KERNEL_RELEASE}"
243 # MACHINE DEFINITIONS: one block for each machine
245 # The correct settings for the NSLU2 board:
247 PACKAGES += "kernel-image-nslu2"
248 PKG_kernel-image-nslu2 = "kernel-image-${KERNEL_VERSION}"
249 PACKAGE_ARCH_kernel-image-nslu2 = "nslu2${ARCH_BYTE_SEX}"
250 DESCRIPTION_kernel-image-nslu2 = "Linux kernel for the LinkSys NSLU2"
251 FILES_kernel-image-nslu2 = "/${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-nslu2${ARCH_BYTE_SEX}-${KERNEL_RELEASE}"
252 pkg_postinst_kernel-image-nslu2 () {
253 update-alternatives --install /${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE} ${KERNEL_IMAGETYPE} /${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-nslu2${ARCH_BYTE_SEX}-${KERNEL_RELEASE} ${KERNEL_PRIORITY} || true
255 pkg_postrm_kernel-image-nslu2 () {
256 update-alternatives --remove ${KERNEL_IMAGETYPE} /${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-nslu2${ARCH_BYTE_SEX}-${KERNEL_RELEASE} || true
259 # The correct settings for Loft:
261 PACKAGES += "kernel-image-loft"
262 PKG_kernel-image-loft = "kernel-image-${KERNEL_VERSION}"
263 PACKAGE_ARCH_kernel-image-loft = "loft${ARCH_BYTE_SEX}"
264 DESCRIPTION_kernel-image-loft = "Linux kernel for the Giant Shoulder Inc. Loft board"
265 FILES_kernel-image-loft = "/${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-loft${ARCH_BYTE_SEX}-${KERNEL_RELEASE}"
266 pkg_postinst_kernel-image-loft () {
267 update-alternatives --install /${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE} ${KERNEL_IMAGETYPE} /${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-loft${ARCH_BYTE_SEX}-${KERNEL_RELEASE} ${KERNEL_PRIORITY} || true
269 pkg_postrm_kernel-image-loft () {
270 update-alternatives --remove ${KERNEL_IMAGETYPE} /${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-loft${ARCH_BYTE_SEX}-${KERNEL_RELEASE} || true
273 # The correct settings for the NAS100D board:
274 nas100d_MACHID = "865"
275 PACKAGES += "kernel-image-nas100d"
276 PKG_kernel-image-nas100d = "kernel-image-${KERNEL_VERSION}"
277 PACKAGE_ARCH_kernel-image-nas100d = "nas100d${ARCH_BYTE_SEX}"
278 DESCRIPTION_kernel-image-nas100d = "Linux kernel for the IOMega NAS100D"
279 FILES_kernel-image-nas100d = "/${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-nas100d${ARCH_BYTE_SEX}-${KERNEL_RELEASE}"
280 pkg_postinst_kernel-image-nas100d () {
281 update-alternatives --install /${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE} ${KERNEL_IMAGETYPE} /${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-nas100d${ARCH_BYTE_SEX}-${KERNEL_RELEASE} ${KERNEL_PRIORITY} || true
283 pkg_postrm_kernel-image-nas100d () {
284 update-alternatives --remove ${KERNEL_IMAGETYPE} /${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-nas100d${ARCH_BYTE_SEX}-${KERNEL_RELEASE} || true
287 # The correct settings for the DSMG600 board:
288 dsmg600_MACHID = "964"
289 PACKAGES += "kernel-image-dsmg600"
290 PKG_kernel-image-dsmg600 = "kernel-image-${KERNEL_VERSION}"
291 PACKAGE_ARCH_kernel-image-dsmg600 = "dsmg600${ARCH_BYTE_SEX}"
292 DESCRIPTION_kernel-image-dsmg600 = "Linux kernel for the D-Link DSM-G600"
293 FILES_kernel-image-dsmg600 = "/${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-dsmg600${ARCH_BYTE_SEX}-${KERNEL_RELEASE}"
294 pkg_postinst_kernel-image-dsmg600 () {
295 update-alternatives --install /${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE} ${KERNEL_IMAGETYPE} /${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-dsmg600${ARCH_BYTE_SEX}-${KERNEL_RELEASE} ${KERNEL_PRIORITY} || true
297 pkg_postrm_kernel-image-dsmg600 () {
298 update-alternatives --remove ${KERNEL_IMAGETYPE} /${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-dsmg600${ARCH_BYTE_SEX}-${KERNEL_RELEASE} || true
301 # The correct settings for the FSG-3 board:
303 PACKAGES += "kernel-image-fsg3"
304 PKG_kernel-image-fsg3 = "kernel-image-${KERNEL_VERSION}"
305 PACKAGE_ARCH_kernel-image-fsg3 = "fsg3${ARCH_BYTE_SEX}"
306 DESCRIPTION_kernel-image-fsg3 = "Linux kernel for the Freecom FSG-3"
307 FILES_kernel-image-fsg3 = "/${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-fsg3${ARCH_BYTE_SEX}-${KERNEL_RELEASE}"
308 pkg_postinst_kernel-image-fsg3 () {
309 update-alternatives --install /${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE} ${KERNEL_IMAGETYPE} /${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-fsg3${ARCH_BYTE_SEX}-${KERNEL_RELEASE} ${KERNEL_PRIORITY} || true
311 pkg_postrm_kernel-image-fsg3 () {
312 update-alternatives --remove ${KERNEL_IMAGETYPE} /${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-fsg3${ARCH_BYTE_SEX}-${KERNEL_RELEASE} || true
315 #FIXUP: the correct instructions to copy the kernel prepended with the le fixup
316 #FIXME: do a fixup for BE too...
318 FIXUP_arm = "wb 0xee110f10,4;wb 0xe3c00080,4;wb 0xee010f10,4;xp $,4"
320 DEPENDS += "devio-native"
322 # We need the alternatives to happen in the kernel-image packages, not in
323 # the kernel package, because only the images know the name of the kernel.
324 pkg_postinst_kernel () {
326 pkg_postrm_kernel () {
329 # copy_image <dest> <cmdline> <machine-id>
330 # copy the zImage and append the appropriate shim
331 # dest: where to copy to
332 # cmdline: command line to pass to image
333 # machine-id: decimal machine id to prepend, empty for none
338 test -n "$2" && setmach="wb $2 . 256/ 255& 0xe3a01c00+, 4; wb 255& 0xe3811000+, 4;"
341 devio '<<${KERNEL_OUTPUT}' >"$1".new "$setmach"'${FIXUP}' || {
342 echo 'ERROR: ${KERNEL_OUTPUT}: failed to copy zImage' >&2
349 copy_image '${D}/${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-'"$1"'-${KERNEL_RELEASE}' "$2"
352 do_install_append() {
353 # Overwrite the unshimmed generic image with a shimmed one (but without
354 # any command line or machine id override).
355 rm -f '${D}/${KERNEL_IMAGEDEST}/${KERNEL_IMAGETYPE}-${KERNEL_RELEASE}'
356 install_image '${IXP4XX_SUFFIX}'
358 # Add the machine specific images, with appropriate suffixes
359 install_image 'nslu2${ARCH_BYTE_SEX}' '${nslu2_MACHID}'
360 install_image 'loft${ARCH_BYTE_SEX}' '${loft_MACHID}'
361 install_image 'nas100d${ARCH_BYTE_SEX}' '${nas100d_MACHID}'
362 install_image 'dsmg600${ARCH_BYTE_SEX}' '${dsmg600_MACHID}'
363 install_image 'fsg3${ARCH_BYTE_SEX}' '${fsg3_MACHID}'
366 do_deploy[dirs] = "${S}"
369 copy_image '${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-'"$1" "$2"
373 install -d ${DEPLOY_DIR_IMAGE}
374 deploy_image '${IXP4XX_SUFFIX}'
376 # And the machine specific images
377 deploy_image 'nslu2${ARCH_BYTE_SEX}' '${nslu2_MACHID}'
378 deploy_image 'loft${ARCH_BYTE_SEX}' '${loft_MACHID}'
379 deploy_image 'nas100d${ARCH_BYTE_SEX}' '${nas100d_MACHID}'
380 deploy_image 'dsmg600${ARCH_BYTE_SEX}' '${dsmg600_MACHID}'
381 deploy_image 'fsg3${ARCH_BYTE_SEX}' '${fsg3_MACHID}'
384 addtask deploy before do_build after do_compile
387 # check for IXP4XX_SUFFIX - if not set then we don't know what to build,
388 # also sanity check the SLUGOS_IMAGESEX
389 sex = bb.data.getVar("SLUGOS_IMAGESEX", d, 1)
390 if sex != 'little-endian' and sex != 'big-endian':
391 raise bb.parse.SkipPackage("slugos kernels require SLUGOS_IMAGESEX")
392 suffix = bb.data.getVar("IXP4XX_SUFFIX", d, 1)
394 raise bb.parse.SkipPackage("slugos kernels require IXP4XX_SUFFIX")