From 58aec28df8b749431bc217094768561c54ed5867 Mon Sep 17 00:00:00 2001 From: David-John Willis Date: Thu, 12 Apr 2012 22:21:28 +0100 Subject: bcm2835-kernel-image: Add recipe to deal with prepending the 32KB header to the kerenl image. * TODO: Clean up these recipes and merge -mkimage and -kernel-image. --- recipes-bcm/kernel-image/bcm2835-kernel-image.bb | 17 +++++++ recipes-bcm/kernel-image/bcm2835-mkimage.bb | 31 +++++++++++++ recipes-bcm/kernel-image/bcm2835-mkimage/LICENCE | 3 ++ .../bcm2835-mkimage/bcm2835-args-uncompressed.txt | 12 +++++ .../bcm2835-mkimage/bcm2835-boot-uncompressed.txt | 17 +++++++ .../bcm2835-mkimage/bcm2835-kernel-first32k.bin | Bin 0 -> 32768 bytes .../bcm2835-mkimage/bcm2835-mkimage.py | 51 +++++++++++++++++++++ 7 files changed, 131 insertions(+) create mode 100644 recipes-bcm/kernel-image/bcm2835-kernel-image.bb create mode 100644 recipes-bcm/kernel-image/bcm2835-mkimage.bb create mode 100644 recipes-bcm/kernel-image/bcm2835-mkimage/LICENCE create mode 100644 recipes-bcm/kernel-image/bcm2835-mkimage/bcm2835-args-uncompressed.txt create mode 100644 recipes-bcm/kernel-image/bcm2835-mkimage/bcm2835-boot-uncompressed.txt create mode 100644 recipes-bcm/kernel-image/bcm2835-mkimage/bcm2835-kernel-first32k.bin create mode 100644 recipes-bcm/kernel-image/bcm2835-mkimage/bcm2835-mkimage.py diff --git a/recipes-bcm/kernel-image/bcm2835-kernel-image.bb b/recipes-bcm/kernel-image/bcm2835-kernel-image.bb new file mode 100644 index 0000000..06325f8 --- /dev/null +++ b/recipes-bcm/kernel-image/bcm2835-kernel-image.bb @@ -0,0 +1,17 @@ +DESCRIPTION = "Helper recipe to make the munged kernel.img image for the RaspberryPi." +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=3f40d7994397109285ec7b81fdeb3b58" + +PR = "${MACHINE_KERNEL_PR}.0" +DEPENDS = "bcm2835-bootfiles bcm2835-mkimage-native" + +S = "${WORKDIR}" + +addtask deploy before do_package after do_install + +do_deploy() { + install -d ${DEPLOY_DIR_IMAGE}/bcm2835-bootfiles + bcm2835-mkimage.py ${DEPLOY_DIR_IMAGE}/zImage-${MACHINE}.bin ${DEPLOY_DIR_IMAGE}/bcm2835-bootfiles/kernel.img ${STAGING_BINDIR_NATIVE}/ +} + +PACKAGE_ARCH = "${MACHINE_ARCH}" diff --git a/recipes-bcm/kernel-image/bcm2835-mkimage.bb b/recipes-bcm/kernel-image/bcm2835-mkimage.bb new file mode 100644 index 0000000..5afca12 --- /dev/null +++ b/recipes-bcm/kernel-image/bcm2835-mkimage.bb @@ -0,0 +1,31 @@ +DESCRIPTION = "Tools to append 32KB binary header to kernel image." +LICENSE = "proprietary-binary" +PR = "${MACHINE_KERNEL_PR}.2" + +SECTION = "bootloader" + +LIC_FILES_CHKSUM = "file://LICENCE;md5=3d7292881293368c0a9f3bc521c2b87e" + +SRC_URI = " \ + file://LICENCE \ + file://bcm2835-args-uncompressed.txt \ + file://bcm2835-boot-uncompressed.txt \ + file://bcm2835-mkimage.py \ + file://bcm2835-kernel-first32k.bin \ +" + +S = "${WORKDIR}" + +BBCLASSEXTEND = "native nativesdk" + +do_install () { + install -d ${D}${bindir} + install -m 0755 bcm2835-mkimage.py ${D}${bindir} + install -m 0644 bcm2835-args-uncompressed.txt ${D}${bindir} + install -m 0644 bcm2835-boot-uncompressed.txt ${D}${bindir} + install -m 0644 bcm2835-kernel-first32k.bin ${D}${bindir} +} + +FILES_${PN} = " \ + ${bindir}/bcm2835-* \ +" diff --git a/recipes-bcm/kernel-image/bcm2835-mkimage/LICENCE b/recipes-bcm/kernel-image/bcm2835-mkimage/LICENCE new file mode 100644 index 0000000..c6849d9 --- /dev/null +++ b/recipes-bcm/kernel-image/bcm2835-mkimage/LICENCE @@ -0,0 +1,3 @@ +I believe this is a proprietary binary (the first32k.bin file) provided by Broadcom. + +It is distributed with the express permission of the RaspberryPi foundation. diff --git a/recipes-bcm/kernel-image/bcm2835-mkimage/bcm2835-args-uncompressed.txt b/recipes-bcm/kernel-image/bcm2835-mkimage/bcm2835-args-uncompressed.txt new file mode 100644 index 0000000..09398b4 --- /dev/null +++ b/recipes-bcm/kernel-image/bcm2835-mkimage/bcm2835-args-uncompressed.txt @@ -0,0 +1,12 @@ +; kernel args (place at 0x00000100) +0x00000005 +0x54410001 +0x00000001 +0x00001000 +0x00000000 +0x00000004 +0x54410002 +0x08000000 +0x00000000 +0x00000000 +0x00000000 diff --git a/recipes-bcm/kernel-image/bcm2835-mkimage/bcm2835-boot-uncompressed.txt b/recipes-bcm/kernel-image/bcm2835-mkimage/bcm2835-boot-uncompressed.txt new file mode 100644 index 0000000..1cf5888 --- /dev/null +++ b/recipes-bcm/kernel-image/bcm2835-mkimage/bcm2835-boot-uncompressed.txt @@ -0,0 +1,17 @@ +; bootloader (place at 0x00000000) +0xea000006 +0xe1a00000 +0xe1a00000 +0xe1a00000 +0xe1a00000 +0xe1a00000 +0xe1a00000 +0xe1a00000 + +0xe3a00000 +0xe3a01042 +0xe3811c0c +0xe59f2000 +0xe59ff000 +0x00000100 +0x00008000 diff --git a/recipes-bcm/kernel-image/bcm2835-mkimage/bcm2835-kernel-first32k.bin b/recipes-bcm/kernel-image/bcm2835-mkimage/bcm2835-kernel-first32k.bin new file mode 100644 index 0000000..ebf74be Binary files /dev/null and b/recipes-bcm/kernel-image/bcm2835-mkimage/bcm2835-kernel-first32k.bin differ diff --git a/recipes-bcm/kernel-image/bcm2835-mkimage/bcm2835-mkimage.py b/recipes-bcm/kernel-image/bcm2835-mkimage/bcm2835-mkimage.py new file mode 100644 index 0000000..6ce9231 --- /dev/null +++ b/recipes-bcm/kernel-image/bcm2835-mkimage/bcm2835-mkimage.py @@ -0,0 +1,51 @@ +#!/usr/bin/python + +import os +import re +import sys + +try: + raw_kernel = sys.argv[1] +except: + raw_kernel = "./zImage" + +try: + output_img = sys.argv[2] +except: + output_img = "./kernel.img" + +try: + supfile_loc = sys.argv[3] +except: + supfile_loc = "./" + +re_line = re.compile(r"0x(?P[0-9a-f]{8})") + +mem = [0 for i in range(32768)] + +def load_to_mem(name, addr): + f = open(name) + + for l in f.readlines(): + m = re_line.match(l) + + if m: + value = int(m.group("value"), 16) + + for i in range(4): + mem[addr] = int(value >> i * 8 & 0xff) + addr += 1 + + f.close() + +load_to_mem(""+supfile_loc+"bcm2835-boot-uncompressed.txt", 0x00000000) +load_to_mem(""+supfile_loc+"bcm2835-args-uncompressed.txt", 0x00000100) + +f = open(""+supfile_loc+"bcm2835-kernel-first32k.bin", "wb") + +for m in mem: + f.write(chr(m)) + +f.close() + +os.system("cat "+supfile_loc+"bcm2835-kernel-first32k.bin "+raw_kernel+" > "+output_img+"") -- cgit v1.2.3-54-g00ecf