* [meta-fsl-arm][PATCHv2] mx28-bcb: add utility to generate Boot Control Block
@ 2013-08-22 14:41 Alexandre Belloni
2013-08-22 17:03 ` Otavio Salvador
0 siblings, 1 reply; 9+ messages in thread
From: Alexandre Belloni @ 2013-08-22 14:41 UTC (permalink / raw)
To: meta-freescale; +Cc: Maxime Ripard, jimwall, brian
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@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
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [meta-fsl-arm][PATCHv2] mx28-bcb: add utility to generate Boot Control Block
2013-08-22 14:41 [meta-fsl-arm][PATCHv2] mx28-bcb: add utility to generate Boot Control Block Alexandre Belloni
@ 2013-08-22 17:03 ` Otavio Salvador
2013-08-23 3:15 ` Marek Vasut
0 siblings, 1 reply; 9+ messages in thread
From: Otavio Salvador @ 2013-08-22 17:03 UTC (permalink / raw)
To: Alexandre Belloni
Cc: meta-freescale@yoctoproject.org, Maxime Ripard, jimwall, brian
On Thu, Aug 22, 2013 at 11:41 AM, Alexandre Belloni
<alexandre.belloni@free-electrons.com> wrote:
> 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@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 @@
I'd put your copyright here as well.
--
Otavio Salvador O.S. Systems
http://www.ossystems.com.br http://code.ossystems.com.br
Mobile: +55 (53) 9981-7854 Mobile: +1 (347) 903-9750
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [meta-fsl-arm][PATCHv2] mx28-bcb: add utility to generate Boot Control Block
2013-08-22 17:03 ` Otavio Salvador
@ 2013-08-23 3:15 ` Marek Vasut
2013-08-23 9:23 ` Alexandre Belloni
0 siblings, 1 reply; 9+ messages in thread
From: Marek Vasut @ 2013-08-23 3:15 UTC (permalink / raw)
To: meta-freescale; +Cc: brian, Maxime Ripard, jimwall, Otavio Salvador
Dear Otavio Salvador,
> On Thu, Aug 22, 2013 at 11:41 AM, Alexandre Belloni
>
> <alexandre.belloni@free-electrons.com> wrote:
> > 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@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 @@
>
> I'd put your copyright here as well.
Why do you not use mxsboot tool from U-Boot instead of re-inventing the wheel?
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [meta-fsl-arm][PATCHv2] mx28-bcb: add utility to generate Boot Control Block
2013-08-23 3:15 ` Marek Vasut
@ 2013-08-23 9:23 ` Alexandre Belloni
2013-08-23 10:41 ` Marek Vasut
0 siblings, 1 reply; 9+ messages in thread
From: Alexandre Belloni @ 2013-08-23 9:23 UTC (permalink / raw)
To: Marek Vasut
Cc: meta-freescale, brian, Maxime Ripard, jimwall, Otavio Salvador
On 23/08/2013 05:15, Marek Vasut wrote:
> Why do you not use mxsboot tool from U-Boot instead of re-inventing the wheel?
I'm not sure we really want to download the u-boot sources for something
that simple. Also, I simply didn't know about it.
--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [meta-fsl-arm][PATCHv2] mx28-bcb: add utility to generate Boot Control Block
2013-08-23 9:23 ` Alexandre Belloni
@ 2013-08-23 10:41 ` Marek Vasut
2013-08-23 11:02 ` Alexandre Belloni
2013-08-23 11:02 ` Eric Bénard
0 siblings, 2 replies; 9+ messages in thread
From: Marek Vasut @ 2013-08-23 10:41 UTC (permalink / raw)
To: Alexandre Belloni
Cc: meta-freescale, brian, Maxime Ripard, jimwall, Otavio Salvador
Dear Alexandre Belloni,
> On 23/08/2013 05:15, Marek Vasut wrote:
> > Why do you not use mxsboot tool from U-Boot instead of re-inventing the
> > wheel?
>
> I'm not sure we really want to download the u-boot sources for something
> that simple. Also, I simply didn't know about it.
You can always pull it out or create a package of u-boot tools (maybe that's
already in Yocto, Otavio?). I don't see a point in duplicating effort instead of
focusing on common goal.
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [meta-fsl-arm][PATCHv2] mx28-bcb: add utility to generate Boot Control Block
2013-08-23 10:41 ` Marek Vasut
@ 2013-08-23 11:02 ` Alexandre Belloni
2013-08-23 11:02 ` Eric Bénard
1 sibling, 0 replies; 9+ messages in thread
From: Alexandre Belloni @ 2013-08-23 11:02 UTC (permalink / raw)
To: Marek Vasut
Cc: meta-freescale, brian, Maxime Ripard, jimwall, Otavio Salvador
Hi,
On 23/08/2013 12:41, Marek Vasut wrote:
> Dear Alexandre Belloni,
>
>> On 23/08/2013 05:15, Marek Vasut wrote:
>>> Why do you not use mxsboot tool from U-Boot instead of re-inventing the
>>> wheel?
>> I'm not sure we really want to download the u-boot sources for something
>> that simple. Also, I simply didn't know about it.
> You can always pull it out or create a package of u-boot tools (maybe that's
> already in Yocto, Otavio?). I don't see a point in duplicating effort instead of
> focusing on common goal.
Yeah, that's what I'm doing. It is was not so simple to find the correct
option compile it standalone ;)
--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [meta-fsl-arm][PATCHv2] mx28-bcb: add utility to generate Boot Control Block
2013-08-23 10:41 ` Marek Vasut
2013-08-23 11:02 ` Alexandre Belloni
@ 2013-08-23 11:02 ` Eric Bénard
2013-08-23 11:04 ` Alexandre Belloni
1 sibling, 1 reply; 9+ messages in thread
From: Eric Bénard @ 2013-08-23 11:02 UTC (permalink / raw)
To: Marek Vasut
Cc: Otavio Salvador, brian, jimwall, meta-freescale, Maxime Ripard
Hi Marek,
Le Fri, 23 Aug 2013 12:41:16 +0200,
Marek Vasut <marex@denx.de> a écrit :
> Dear Alexandre Belloni,
>
> > On 23/08/2013 05:15, Marek Vasut wrote:
> > > Why do you not use mxsboot tool from U-Boot instead of re-inventing the
> > > wheel?
> >
> > I'm not sure we really want to download the u-boot sources for something
> > that simple. Also, I simply didn't know about it.
>
> You can always pull it out or create a package of u-boot tools (maybe that's
> already in Yocto, Otavio?). I don't see a point in duplicating effort instead of
> focusing on common goal.
>
you're right, it's already in meta-fsl-arm :
recipes-bsp/u-boot/u-boot-mxsboot_2013.07.bb
Eric
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [meta-fsl-arm][PATCHv2] mx28-bcb: add utility to generate Boot Control Block
2013-08-23 11:02 ` Eric Bénard
@ 2013-08-23 11:04 ` Alexandre Belloni
2013-08-23 11:26 ` Marek Vasut
0 siblings, 1 reply; 9+ messages in thread
From: Alexandre Belloni @ 2013-08-23 11:04 UTC (permalink / raw)
To: Eric Bénard
Cc: Marek Vasut, brian, Otavio Salvador, jimwall, meta-freescale,
Maxime Ripard
On 23/08/2013 13:02, Eric Bénard wrote:
> Hi Marek,
>
> Le Fri, 23 Aug 2013 12:41:16 +0200,
> Marek Vasut <marex@denx.de> a écrit :
>
>> Dear Alexandre Belloni,
>>
>>> On 23/08/2013 05:15, Marek Vasut wrote:
>>>> Why do you not use mxsboot tool from U-Boot instead of re-inventing the
>>>> wheel?
>>> I'm not sure we really want to download the u-boot sources for something
>>> that simple. Also, I simply didn't know about it.
>> You can always pull it out or create a package of u-boot tools (maybe that's
>> already in Yocto, Otavio?). I don't see a point in duplicating effort instead of
>> focusing on common goal.
>>
> you're right, it's already in meta-fsl-arm :
> recipes-bsp/u-boot/u-boot-mxsboot_2013.07.bb
Right... I'll use that one :) Thanks everyone.
--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [meta-fsl-arm][PATCHv2] mx28-bcb: add utility to generate Boot Control Block
2013-08-23 11:04 ` Alexandre Belloni
@ 2013-08-23 11:26 ` Marek Vasut
0 siblings, 0 replies; 9+ messages in thread
From: Marek Vasut @ 2013-08-23 11:26 UTC (permalink / raw)
To: meta-freescale; +Cc: Otavio Salvador, brian, jimwall, Maxime Ripard
Dear Alexandre Belloni,
> On 23/08/2013 13:02, Eric Bénard wrote:
> > Hi Marek,
> >
> > Le Fri, 23 Aug 2013 12:41:16 +0200,
> >
> > Marek Vasut <marex@denx.de> a écrit :
> >> Dear Alexandre Belloni,
> >>
> >>> On 23/08/2013 05:15, Marek Vasut wrote:
> >>>> Why do you not use mxsboot tool from U-Boot instead of re-inventing
> >>>> the wheel?
> >>>
> >>> I'm not sure we really want to download the u-boot sources for
> >>> something that simple. Also, I simply didn't know about it.
> >>
> >> You can always pull it out or create a package of u-boot tools (maybe
> >> that's already in Yocto, Otavio?). I don't see a point in duplicating
> >> effort instead of focusing on common goal.
> >
> > you're right, it's already in meta-fsl-arm :
> > recipes-bsp/u-boot/u-boot-mxsboot_2013.07.bb
>
> Right... I'll use that one :) Thanks everyone.
Wow, I didn't know. Sorry you had to write your own thing, I know this portion
can be ugly :-(
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2013-08-23 11:26 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-22 14:41 [meta-fsl-arm][PATCHv2] mx28-bcb: add utility to generate Boot Control Block Alexandre Belloni
2013-08-22 17:03 ` Otavio Salvador
2013-08-23 3:15 ` Marek Vasut
2013-08-23 9:23 ` Alexandre Belloni
2013-08-23 10:41 ` Marek Vasut
2013-08-23 11:02 ` Alexandre Belloni
2013-08-23 11:02 ` Eric Bénard
2013-08-23 11:04 ` Alexandre Belloni
2013-08-23 11:26 ` Marek Vasut
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.