[meta-freescale] [meta-fsl-arm][PATCHv2] mx28-bcb: add utility to generate Boot Control Block
Alexandre Belloni
alexandre.belloni at free-electrons.com
Thu Aug 22 07:41:54 PDT 2013
>From chapter 12.11.1 of the i.MX28 Applications Processor Reference
Manual, Rev. 1, 2010, a Boot Control Block is needed when booting from
an SD/MMC card. The mx28_bcb.py utility will generate and write the BCB
to a file, it will also write the provided bootstream.
Signed-off-by: Alexandre Belloni <alexandre.belloni at free-electrons.com>
---
recipes-bsp/mx28-bcb/files/mx28_bcb.py | 56 ++++++++++++++++++++++++++++++++++
recipes-bsp/mx28-bcb/mx28-bcb_1.0.bb | 20 ++++++++++++
2 files changed, 76 insertions(+)
create mode 100755 recipes-bsp/mx28-bcb/files/mx28_bcb.py
create mode 100644 recipes-bsp/mx28-bcb/mx28-bcb_1.0.bb
diff --git a/recipes-bsp/mx28-bcb/files/mx28_bcb.py b/recipes-bsp/mx28-bcb/files/mx28_bcb.py
new file mode 100755
index 0000000..ea2038b
--- /dev/null
+++ b/recipes-bsp/mx28-bcb/files/mx28_bcb.py
@@ -0,0 +1,56 @@
+#!/usr/bin/env python2
+
+#import os
+import struct
+#import subprocess
+#import sys
+#import tarfile
+#import tempfile
+
+def generate_bootstream_headers(num_bootstream, start_sector):
+ return struct.pack("<I" # Magic
+ "4x" # Primary Tag (unused)
+ "4x" # Secondary Tag (unused)
+ "I" # Number of Boot Stream blocks
+ "8x" # Padding
+ "4x" # Primary Tag (unused)
+ "I" # Base offset of the first bootstream block
+ "4x", # Padding
+ 0x00112233,
+ num_bootstream,
+ start_sector + 1)
+
+def write_bootstream_partition(device_file, start, bootstream):
+ with open(device_file, 'r+') as partition:
+ partition.seek(start*512)
+ partition.write(generate_bootstream_headers(1, start))
+
+ # Fill the rest of the first 512 bytes with 0
+ current = partition.tell()
+ partition.write(struct.pack("%dx" % (512 - current + (start*512))))
+
+ # Copy the bootstream image
+ with open(bootstream, 'r') as image:
+ partition.write(image.read())
+
+def main():
+ import argparse
+
+ parser = argparse.ArgumentParser(
+ description='Flash a SD Card at format expected by iMX28 SoCs')
+ parser.add_argument("device", help="Path to the SD Card's device file")
+ parser.add_argument("--bootstream", "-b",
+ help="Path to the boostream image", required=True)
+ parser.add_argument("--start", "-s",
+ help="Start of the bootlets partion (in sectors)",
+ type=int, required=True)
+
+ args = parser.parse_args()
+
+ write_bootstream_partition(args.device, args.start, args.bootstream)
+
+
+if __name__ == "__main__":
+ main()
+
+
diff --git a/recipes-bsp/mx28-bcb/mx28-bcb_1.0.bb b/recipes-bsp/mx28-bcb/mx28-bcb_1.0.bb
new file mode 100644
index 0000000..ea9f7cd
--- /dev/null
+++ b/recipes-bsp/mx28-bcb/mx28-bcb_1.0.bb
@@ -0,0 +1,20 @@
+# Copyright (C) 2013 Free Electrons
+# Released under the GPLv2 license
+
+DESCRIPTION = "Utility to generate the Boot Control Block for freescale mx28 platforms"
+
+LICENSE = "GPLv2"
+LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6"
+
+SECTION = "bootloader"
+PR = "r1"
+BBCLASSEXTEND = "native nativesdk"
+
+SRC_URI = "file://mx28_bcb.py"
+
+S = "${WORKDIR}"
+
+do_install() {
+ install -d ${D}${bindir}
+ install ${WORKDIR}/mx28_bcb.py ${D}${bindir}
+}
--
1.8.1.2
More information about the meta-freescale
mailing list