Merge lp:~mabac/linaro-image-tools/make-boot-files-v2 into lp:linaro-image-tools/11.11

Proposed by Mattias Backman
Status: Merged
Merged at revision: 432
Proposed branch: lp:~mabac/linaro-image-tools/make-boot-files-v2
Merge into: lp:linaro-image-tools/11.11
Diff against target: 501 lines (+156/-62)
5 files modified
linaro-media-create (+9/-0)
linaro_image_tools/hwpack/config.py (+15/-1)
linaro_image_tools/hwpack/hardwarepack.py (+5/-0)
linaro_image_tools/media_create/boards.py (+117/-47)
linaro_image_tools/media_create/tests/test_media_create.py (+10/-14)
To merge this branch: bzr merge lp:~mabac/linaro-image-tools/make-boot-files-v2
Reviewer Review Type Date Requested Status
Ricardo Salveti Pending
linaro-image-tools maintainers Pending
Review via email: mp+75169@code.launchpad.net

Description of the change

Hi,

This branch is the final (I hope) major step needed for hwpacks v2. It pulls in all board specific _make_boot_files() methods into a single one which executes the different parts depending on the metadata fields.

If the x_loader file is found (that is x_loader_file and x_loader_package where set when creating the hwpack) then it will be copied to the boot partition. This used to happen for Omap boards, now it's available to any hwpack.

If uboot_dd is Yes in the hwpack metadata, then the uboot bin will be dd:d to the target. Only needed for imx5 today as far as I can tell.

If the spl file is set in hwpack metadata then we assume this is Samsung mode and dd uboot and the spl files using the other samsung fields for offsets etc.

We always do make_uImage/( and make_uInitrd().

If we find a dtb file we do make_dtb().

If boot_script is set we do make_boot_script() to create input to mkimage.

Here's a question: is there a problem if there is a boot.ini file for boards that don't need it? Only Omap/Igep creates that today so I might have to create yet another field for this:
    MAKE_BOOT_INI = Yes ==> run make_boot_ini()

And if snowball_startup_files_config is set we run populate_raw_partition() which currently is Snowball specific.

Thanks,

Mattias

To post a comment you must log in.
Revision history for this message
James Westby (james-w) wrote :

171 + make_uImage(cls.load_addr, k_img_data, boot_dir)
172 + make_uInitrd(i_img_data, boot_dir)
173 +
174 + if d_img_data is not None:

The comment doesn't show it, but the indentation seems off there.

Also, it would be good to extract some more code to avoid
duplication (such as the samsung offset assertions.)

We don't want to duplicate all this code, but at the same time
we want it to be clear that changing this isn't the way
to support software changes.

Lastly, but not directly related to this change, I wonder if
the meaning of all these config options are going to be clear
to everyone? Will they need some documentation of what the
effects are so they know what to set for their board?

Thanks,

James

Revision history for this message
Mattias Backman (mabac) wrote :

On Wed, Sep 14, 2011 at 4:29 AM, James Westby <email address hidden> wrote:
> 171     + make_uImage(cls.load_addr, k_img_data, boot_dir)
> 172     + make_uInitrd(i_img_data, boot_dir)
> 173     +
> 174     + if d_img_data is not None:
>
> The comment doesn't show it, but the indentation seems off there.

Do you mean for them to go inside the scope of "with
hardwarepack_handler"? These lines don't need that since they don't
rely on getting files directly from the hwpack tarball. They could go
in there of course, it wouldn't hurt. Or did you mean something else?

>
> Also, it would be good to extract some more code to avoid
> duplication (such as the samsung offset assertions.)
>
> We don't want to duplicate all this code, but at the same time
> we want it to be clear that changing this isn't the way
> to support software changes.

I extracted a _dd_file() method in BoardConfig that takes care of the
assertions and dd:ing for Samsung and imx5. I'm not sure that's
exactly what you meant? If we like it this way, I can do the same
change for the (V1) install_samsung_bootloader() method.

>
> Lastly, but not directly related to this change, I wonder if
> the meaning of all these config options are going to be clear
> to everyone? Will they need some documentation of what the
> effects are so they know what to set for their board?

You're right it won't be very clear to anyone. I've created a wiki
page https://wiki.linaro.org/HardwarePacksV2 where I can explain the
fields and merge it into the current hwpack format page when we
release it.

435. By Mattias Backman

Change kernel files glob to be relative to chroot instead of chroot/boot/ and fix get_format() bug.

436. By Mattias Backman

Extract dd_file method to assert that the file exists, that it does not exceed a maximum size and dd it to the target.

Revision history for this message
James Westby (james-w) wrote :

On Wed, 14 Sep 2011 13:04:27 -0000, Mattias Backman <email address hidden> wrote:
> On Wed, Sep 14, 2011 at 4:29 AM, James Westby <email address hidden> wrote:
> > 171     + make_uImage(cls.load_addr, k_img_data, boot_dir)
> > 172     + make_uInitrd(i_img_data, boot_dir)
> > 173     +
> > 174     + if d_img_data is not None:
> >
> > The comment doesn't show it, but the indentation seems off there.
>
> Do you mean for them to go inside the scope of "with
> hardwarepack_handler"? These lines don't need that since they don't
> rely on getting files directly from the hwpack tarball. They could go
> in there of course, it wouldn't hurt. Or did you mean something else?

It looked to me like the first two lines were indented one space more
than the last line I quoted.

I couldn't tell if they were supposed to be the same level of
indentation or four spaces indented, or even if I was really seeing that
one space indent :-)

> I extracted a _dd_file() method in BoardConfig that takes care of the
> assertions and dd:ing for Samsung and imx5. I'm not sure that's
> exactly what you meant? If we like it this way, I can do the same
> change for the (V1) install_samsung_bootloader() method.

I was just pretty sure I had seen the lines with the asserts and the _dd
calls in the v1 code, and it would be good to have one implementation
called from both the v1 and v2 code.

> >
> > Lastly, but not directly related to this change, I wonder if
> > the meaning of all these config options are going to be clear
> > to everyone? Will they need some documentation of what the
> > effects are so they know what to set for their board?
>
> You're right it won't be very clear to anyone. I've created a wiki
> page https://wiki.linaro.org/HardwarePacksV2 where I can explain the
> fields and merge it into the current hwpack format page when we
> release it.

Perfect, thanks.

James

437. By Mattias Backman

Fix glob pattern to accept leading * and fix some pep8 problems.

438. By Mattias Backman

Fix the broken get_format() fix.

Revision history for this message
Mattias Backman (mabac) wrote :

On Wed, Sep 14, 2011 at 4:34 PM, James Westby <email address hidden> wrote:
> On Wed, 14 Sep 2011 13:04:27 -0000, Mattias Backman <email address hidden> wrote:
>> On Wed, Sep 14, 2011 at 4:29 AM, James Westby <email address hidden> wrote:
>> > 171     + make_uImage(cls.load_addr, k_img_data, boot_dir)
>> > 172     + make_uInitrd(i_img_data, boot_dir)
>> > 173     +
>> > 174     + if d_img_data is not None:
>> >
>> > The comment doesn't show it, but the indentation seems off there.
>>
>> Do you mean for them to go inside the scope of "with
>> hardwarepack_handler"? These lines don't need that since they don't
>> rely on getting files directly from the hwpack tarball. They could go
>> in there of course, it wouldn't hurt. Or did you mean something else?
>
> It looked to me like the first two lines were indented one space more
> than the last line I quoted.
>
> I couldn't tell if they were supposed to be the same level of
> indentation or four spaces indented, or even if I was really seeing that
> one space indent :-)

Oh it was even worse! The last line you quoted and the following if
statement where indented with tabs. :/ Good catch!

>
>> I extracted a _dd_file() method in BoardConfig that takes care of the
>> assertions and dd:ing for Samsung and imx5. I'm not sure that's
>> exactly what you meant? If we like it this way, I can do the same
>> change for the (V1) install_samsung_bootloader() method.
>
> I was just pretty sure I had seen the lines with the asserts and the _dd
> calls in the v1 code, and it would be good to have one implementation
> called from both the v1 and v2 code.

You're right it's still there. I'll make sure that there's only one
implementation left.

439. By Mattias Backman

Save hwpack_format so we don't have to iterate over the hwpack tarballs every time we need the format version.

440. By Mattias Backman

Use the same Samsung bootloader code for both v1 and v2 code paths.

441. By Mattias Backman

Set up logging, seems to be needed to enable warn logging in partitions.py.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'linaro-media-create'
2--- linaro-media-create 2011-07-21 17:41:19 +0000
3+++ linaro-media-create 2011-09-15 12:16:52 +0000
4@@ -22,6 +22,7 @@
5 import os
6 import sys
7 import tempfile
8+import logging
9
10 from linaro_image_tools import cmd_runner
11
12@@ -95,6 +96,14 @@
13 parser = get_args_parser()
14 args = parser.parse_args()
15
16+ ch = logging.StreamHandler()
17+ ch.setLevel(logging.INFO)
18+ formatter = logging.Formatter("%(message)s")
19+ ch.setFormatter(formatter)
20+ logger = logging.getLogger("linaro_image_tools")
21+ logger.setLevel(logging.INFO)
22+ logger.addHandler(ch)
23+
24 # If --help was specified this won't execute.
25 # Create temp dir and initialize rest of path vars.
26 TMP_DIR = tempfile.mkdtemp()
27
28=== modified file 'linaro_image_tools/hwpack/config.py'
29--- linaro_image_tools/hwpack/config.py 2011-08-30 08:52:00 +0000
30+++ linaro_image_tools/hwpack/config.py 2011-09-15 12:16:52 +0000
31@@ -44,7 +44,7 @@
32 PACKAGES_KEY = "packages"
33 PACKAGE_REGEX = NAME_REGEX
34 PATH_REGEX = r"\w[\w+\-./_]+$"
35- GLOB_REGEX = r"\w[\w+\-./_\*]+$"
36+ GLOB_REGEX = r"[\w+\-./_\*]+$"
37 ORIGIN_KEY = "origin"
38 MAINTAINER_KEY = "maintainer"
39 ARCHITECTURES_KEY = "architectures"
40@@ -74,6 +74,7 @@
41 EXTRA_BOOT_OPTIONS_KEY = 'extra_boot_options'
42 BOOT_SCRIPT_KEY = 'boot_script'
43 UBOOT_IN_BOOT_PART_KEY = 'u_boot_in_boot_part'
44+ UBOOT_DD_KEY = 'u_boot_dd'
45 EXTRA_SERIAL_OPTS_KEY = 'extra_serial_options'
46 SNOWBALL_STARTUP_FILES_CONFIG_KEY = 'snowball_startup_files_config'
47 SAMSUNG_BL1_START_KEY = 'samsung_bl1_start'
48@@ -136,6 +137,7 @@
49 self._validate_extra_boot_options()
50 self._validate_boot_script()
51 self._validate_uboot_in_boot_part()
52+ self._validate_uboot_dd()
53 self._validate_extra_serial_opts()
54 self._validate_snowball_startup_files_config()
55 self._validate_samsung_bl1_start()
56@@ -187,6 +189,11 @@
57 """Whether uboot binary should be put in the boot partition. A str."""
58 return self.parser.get(self.MAIN_SECTION, self.UBOOT_IN_BOOT_PART_KEY)
59
60+ @property
61+ def uboot_dd(self):
62+ """Whether uboot binary should be dd:d to the boot partition. A str."""
63+ return self._get_option_from_main_section(self.UBOOT_DD_KEY)
64+
65 def _get_option_from_main_section(self, key):
66 """Get the value from the main section for the given key.
67
68@@ -719,6 +726,13 @@
69 "Invalid value for u_boot_in_boot_part: %s"
70 % self.parser.get("hwpack", "u_boot_in_boot_part"))
71
72+ def _validate_uboot_dd(self):
73+ uboot_dd = self.uboot_dd
74+ if uboot_dd is not None and string.lower(uboot_dd) not in ['yes', 'no']:
75+ raise HwpackConfigError(
76+ "Invalid value for u_boot_dd: %s"
77+ % self.parser.get("hwpack", "u_boot_dd"))
78+
79 def _validate_support(self):
80 support = self.support
81 if support not in (None, "supported", "unsupported"):
82
83=== modified file 'linaro_image_tools/hwpack/hardwarepack.py'
84--- linaro_image_tools/hwpack/hardwarepack.py 2011-08-30 08:52:00 +0000
85+++ linaro_image_tools/hwpack/hardwarepack.py 2011-09-15 12:16:52 +0000
86@@ -84,6 +84,7 @@
87 loader_min_size=None, vmlinuz=None, initrd=None,
88 dtb_addr=None, extra_boot_options=None,
89 boot_script=None, uboot_in_boot_part=None,
90+ uboot_dd=None,
91 extra_serial_opts=None, loader_start=None,
92 snowball_startup_files_config=None,
93 samsung_bl1_start=None, samsung_bl1_len=None,
94@@ -114,6 +115,7 @@
95 self.extra_boot_options = extra_boot_options
96 self.boot_script = boot_script
97 self.uboot_in_boot_part = uboot_in_boot_part
98+ self.uboot_dd = uboot_dd
99 self.extra_serial_opts = extra_serial_opts
100 self.snowball_startup_files_config = snowball_startup_files_config
101 self.samsung_bl1_start = samsung_bl1_start
102@@ -164,6 +166,7 @@
103 extra_boot_options=config.extra_boot_options,
104 boot_script=config.boot_script,
105 uboot_in_boot_part=config.uboot_in_boot_part,
106+ uboot_dd=config.uboot_dd,
107 extra_serial_opts=config.extra_serial_opts,
108 snowball_startup_files_config=config.snowball_startup_files_config,
109 samsung_bl1_start=config.samsung_bl1_start,
110@@ -232,6 +235,8 @@
111 metadata += "BOOT_SCRIPT=%s\n" % self.boot_script
112 if self.uboot_in_boot_part is not None:
113 metadata += "U_BOOT_IN_BOOT_PART=%s\n" % self.uboot_in_boot_part
114+ if self.uboot_dd is not None:
115+ metadata += "U_BOOT_DD=%s\n" % self.uboot_dd
116 if self.extra_serial_opts is not None:
117 metadata += "EXTRA_SERIAL_OPTIONS=%s\n" % self.extra_serial_opts
118 if self.snowball_startup_files_config is not None:
119
120=== modified file 'linaro_image_tools/media_create/boards.py'
121--- linaro_image_tools/media_create/boards.py 2011-09-12 10:58:04 +0000
122+++ linaro_image_tools/media_create/boards.py 2011-09-15 12:16:52 +0000
123@@ -35,6 +35,7 @@
124 import ConfigParser
125 import shutil
126 import string
127+import logging
128
129 from linaro_image_tools import cmd_runner
130
131@@ -69,6 +70,7 @@
132 """Round value to the next multiple of align."""
133 return (value + align - 1) / align * align
134
135+
136 def align_partition(min_start, min_length, start_alignment, end_alignment):
137 """Compute partition start and end offsets based on specified constraints.
138
139@@ -108,7 +110,7 @@
140 def __init__(self, hwpacks):
141 self.hwpacks = hwpacks
142 self.hwpack_tarfiles = []
143-
144+
145 class FakeSecHead(object):
146 """ Add a fake section header to the metadata file.
147
148@@ -147,15 +149,17 @@
149 hwpack_with_data = None
150 for hwpack_tarfile in self.hwpack_tarfiles:
151 metadata = hwpack_tarfile.extractfile(self.metadata_filename)
152- # Use RawConfigParser which does not support the magical interpolation
153- # behavior of ConfigParser so we don't mess up metadata accidentally.
154+ # Use RawConfigParser which does not support the magical
155+ # interpolation behavior of ConfigParser so we don't mess up
156+ # metadata accidentally.
157 parser = ConfigParser.RawConfigParser()
158 parser.readfp(self.FakeSecHead(metadata))
159 try:
160 new_data = parser.get(section, field)
161 if new_data is not None:
162 assert data is None, "The metadata field '%s' is set to " \
163- "'%s' and new value '%s' is found" % (field, data, new_data)
164+ "'%s' and new value '%s' is found" % (field, data,
165+ new_data)
166 data = new_data
167 hwpack_with_data = hwpack_tarfile
168 except ConfigParser.NoOptionError:
169@@ -170,8 +174,7 @@
170 format_string = format_file.read().strip()
171 if not format_string in supported_formats:
172 raise AssertionError(
173- "Format version '%s' is not supported." % \
174- format_string)
175+ "Format version '%s' is not supported." % format_string)
176 if format is None:
177 format = format_string
178 elif format != format_string:
179@@ -189,10 +192,12 @@
180
181 class BoardConfig(object):
182 """The configuration used when building an image for a board."""
183+ hwpack_format = None
184 # These attributes may not need to be redefined on some subclasses.
185 uboot_flavor = None
186 # whether to copy u-boot to the boot partition
187 uboot_in_boot_part = False
188+ uboot_dd = False
189 mmc_option = '0:1'
190 mmc_part_offset = 0
191 fat_size = 32
192@@ -200,9 +205,9 @@
193 _live_serial_opts = ''
194 extra_boot_args_options = None
195 supports_writing_to_mmc = True
196- LOADER_MIN_SIZE_S = align_up(1 * 1024**2, SECTOR_SIZE) / SECTOR_SIZE
197- BOOT_MIN_SIZE_S = align_up(50 * 1024**2, SECTOR_SIZE) / SECTOR_SIZE
198- ROOT_MIN_SIZE_S = align_up(50 * 1024**2, SECTOR_SIZE) / SECTOR_SIZE
199+ LOADER_MIN_SIZE_S = align_up(1 * 1024 ** 2, SECTOR_SIZE) / SECTOR_SIZE
200+ BOOT_MIN_SIZE_S = align_up(50 * 1024 ** 2, SECTOR_SIZE) / SECTOR_SIZE
201+ ROOT_MIN_SIZE_S = align_up(50 * 1024 ** 2, SECTOR_SIZE) / SECTOR_SIZE
202
203 # These attributes must be defined on all subclasses for backwards
204 # compatibility with hwpacks v1 format. Hwpacks v2 format allows these to
205@@ -269,12 +274,11 @@
206 def set_metadata(cls, hwpacks):
207 cls.hardwarepack_handler = HardwarepackHandler(hwpacks)
208 with cls.hardwarepack_handler:
209- if (cls.hardwarepack_handler.get_format() ==
210- cls.hardwarepack_handler.FORMAT_1):
211+ cls.hwpack_format = cls.hardwarepack_handler.get_format()
212+ if (cls.hwpack_format == cls.hardwarepack_handler.FORMAT_1):
213 return
214
215- if (cls.hardwarepack_handler.get_format() ==
216- cls.hardwarepack_handler.FORMAT_2):
217+ if (cls.hwpack_format == cls.hardwarepack_handler.FORMAT_2):
218 # Clear V1 defaults.
219 cls.kernel_addr = None
220 cls.initrd_addr = None
221@@ -325,25 +329,33 @@
222
223 boot_min_size = cls.get_metadata_field('boot_min_size')
224 if boot_min_size is not None:
225- cls.BOOT_MIN_SIZE_S = align_up(int(boot_min_size) * 1024**2,
226+ cls.BOOT_MIN_SIZE_S = align_up(int(boot_min_size) * 1024 ** 2,
227 SECTOR_SIZE) / SECTOR_SIZE
228 root_min_size = cls.get_metadata_field('root_min_size')
229 if root_min_size is not None:
230- cls.ROOT_MIN_SIZE_S = align_up(int(root_min_size) * 1024**2,
231+ cls.ROOT_MIN_SIZE_S = align_up(int(root_min_size) * 1024 ** 2,
232 SECTOR_SIZE) / SECTOR_SIZE
233 loader_min_size = cls.get_metadata_field('loader_min_size')
234 if loader_min_size is not None:
235- cls.LOADER_MIN_SIZE_S = align_up(int(loader_min_size) * 1024**2,
236+ cls.LOADER_MIN_SIZE_S = align_up(int(loader_min_size) * 1024 ** 2,
237 SECTOR_SIZE) / SECTOR_SIZE
238
239 uboot_in_boot_part = cls.get_metadata_field('u_boot_in_boot_part')
240 if uboot_in_boot_part is None:
241- cls.uboot_in_boot_part = None
242+ cls.uboot_in_boot_part = None
243 elif string.lower(uboot_in_boot_part) == 'yes':
244 cls.uboot_in_boot_part = True
245 elif string.lower(uboot_in_boot_part) == 'no':
246 cls.uboot_in_boot_part = False
247
248+ uboot_dd = cls.get_metadata_field('u_boot_dd')
249+ if uboot_dd is None:
250+ cls.uboot_dd = None
251+ elif string.lower(uboot_dd) == 'yes':
252+ cls.uboot_dd = True
253+ elif string.lower(uboot_dd) == 'no':
254+ cls.uboot_dd = False
255+
256 loader_start = cls.get_metadata_field('loader_start')
257 if loader_start is not None:
258 cls.LOADER_START_S = int(loader_start)
259@@ -492,6 +504,8 @@
260 elif cls.partition_layout in ['reserved_bootfs_rootfs']:
261 return cls.get_reserved_sfdisk_cmd(should_align_boot_part)
262 else:
263+ assert (cls.hwpack_format == HardwarepackHandler.FORMAT_1), (
264+ "Hwpack format is not 1.0 but partition_layout is unspecified.")
265 return cls.get_v1_sfdisk_cmd(should_align_boot_part)
266
267 @classmethod
268@@ -565,13 +579,84 @@
269 @classmethod
270 def make_boot_files(cls, uboot_parts_dir, is_live, is_lowmem, consoles,
271 chroot_dir, rootfs_uuid, boot_dir, boot_device_or_file):
272+ if cls.hwpack_format == HardwarepackHandler.FORMAT_1:
273+ parts_dir = uboot_parts_dir
274+ else:
275+ parts_dir = chroot_dir
276 (k_img_data, i_img_data, d_img_data) = cls._get_kflavor_files(
277- uboot_parts_dir)
278+ parts_dir)
279 boot_env = cls._get_boot_env(is_live, is_lowmem, consoles, rootfs_uuid,
280 d_img_data)
281- cls._make_boot_files(
282- boot_env, chroot_dir, boot_dir,
283- boot_device_or_file, k_img_data, i_img_data, d_img_data)
284+
285+ if cls.hwpack_format == HardwarepackHandler.FORMAT_1:
286+ cls._make_boot_files(
287+ boot_env, chroot_dir, boot_dir,
288+ boot_device_or_file, k_img_data, i_img_data, d_img_data)
289+ else:
290+ cls._make_boot_files_v2(
291+ boot_env, chroot_dir, boot_dir,
292+ boot_device_or_file, k_img_data, i_img_data, d_img_data)
293+
294+ @classmethod
295+ def _dd_file(cls, from_file, to_file, seek, max_size=None):
296+ assert from_file is not None, "No source file name given."
297+ if max_size is not None:
298+ assert os.path.getsize(from_file) <= max_size, (
299+ "'%s' is larger than %s" % (from_file, max_size))
300+ logger = logging.getLogger("linaro_image_tools")
301+ logger.info("Writing '%s' to '%s' at %s." % (from_file, to_file, seek))
302+ _dd(from_file, to_file, seek=seek)
303+
304+
305+ @classmethod
306+ def install_samsung_boot_loader(cls, samsung_spl_file, uboot_file,
307+ boot_device_or_file):
308+ cls._dd_file(samsung_spl_file, boot_device_or_file,
309+ cls.SAMSUNG_V310_BL1_START,
310+ cls.SAMSUNG_V310_BL1_LEN * SECTOR_SIZE)
311+ cls._dd_file(uboot_file, boot_device_or_file,
312+ cls.SAMSUNG_V310_BL2_START,
313+ cls.SAMSUNG_V310_BL2_LEN * SECTOR_SIZE)
314+
315+
316+ @classmethod
317+ def _make_boot_files_v2(cls, boot_env, chroot_dir, boot_dir,
318+ boot_device_or_file, k_img_data, i_img_data,
319+ d_img_data):
320+ with cls.hardwarepack_handler:
321+ x_loader_file = cls.get_file('x_loader')
322+ if x_loader_file is not None:
323+ logger = logging.getLogger("linaro_image_tools")
324+ logger.info(
325+ "Copying x-loader '%s' to boot partition." % x_loader_file)
326+ cmd_runner.run(["cp", "-v", x_loader_file, boot_dir],
327+ as_root=True).wait()
328+ # XXX: Is this really needed?
329+ cmd_runner.run(["sync"]).wait()
330+
331+ uboot_file = cls.get_file('u_boot')
332+ if cls.uboot_dd:
333+ cls._dd_file(uboot_file, boot_device_or_file, 2)
334+
335+ samsung_spl_file = cls.get_file('spl')
336+ if samsung_spl_file is not None:
337+ cls.install_samsung_boot_loader(samsung_spl_file, uboot_file,
338+ boot_device_or_file)
339+ make_uImage(cls.load_addr, k_img_data, boot_dir)
340+ make_uInitrd(i_img_data, boot_dir)
341+
342+ if d_img_data is not None:
343+ make_dtb(d_img_data, boot_dir)
344+
345+ if cls.boot_script is not None:
346+ boot_script_path = os.path.join(boot_dir, cls.boot_script)
347+ make_boot_script(boot_env, boot_script_path)
348+
349+ # Only used for Omap and Igep, will this be bad for the other boards?
350+ make_boot_ini(boot_script_path, boot_dir)
351+
352+ if cls.snowball_startup_files_config is not None:
353+ cls.populate_raw_partition(chroot_dir, boot_device_or_file)
354
355 @classmethod
356 def _make_boot_files(cls, boot_env, chroot_dir, boot_dir,
357@@ -629,10 +714,10 @@
358 return cls._get_kflavor_files_v2(path)
359
360 for flavor in cls.kernel_flavors:
361- kregex = KERNEL_GLOB % {'kernel_flavor' : flavor}
362- iregex = INITRD_GLOB % {'kernel_flavor' : flavor}
363- dregex = DTB_GLOB % {'kernel_flavor' : flavor,
364- 'dtb_name' : cls.dtb_name}
365+ kregex = KERNEL_GLOB % {'kernel_flavor': flavor}
366+ iregex = INITRD_GLOB % {'kernel_flavor': flavor}
367+ dregex = DTB_GLOB % {'kernel_flavor': flavor,
368+ 'dtb_name': cls.dtb_name}
369 kernel = _get_file_matching(os.path.join(path, kregex))
370 if kernel is not None:
371 initrd = _get_file_matching(os.path.join(path, iregex))
372@@ -657,7 +742,9 @@
373 dtb = None
374 if cls.dtb_file is not None:
375 dtb = _get_file_matching(os.path.join(path, cls.dtb_file))
376- print "Will use kernel=%s, initrd=%s, dtb=%s." % (kernel, initrd, dtb)
377+ logger = logging.getLogger("linaro_image_tools")
378+ logger.info( "Will use kernel=%s, initrd=%s, dtb=%s." % \
379+ (kernel, initrd, dtb))
380 return (kernel, initrd, dtb)
381 raise ValueError(
382 "Found kernel matching %s but no initrd matching %s" % (
383@@ -1136,6 +1223,7 @@
384 make_uImage(cls.load_addr, k_img_data, boot_dir)
385 make_uInitrd(i_img_data, boot_dir)
386
387+
388 class SamsungConfig(BoardConfig):
389 @classproperty
390 def extra_serial_opts(cls):
391@@ -1170,7 +1258,9 @@
392 def _make_boot_files(cls, boot_env, chroot_dir, boot_dir,
393 boot_device_or_file, k_img_data, i_img_data,
394 d_img_data):
395- cls.install_samsung_boot_loader(chroot_dir, boot_device_or_file)
396+ cls.install_samsung_boot_loader(cls._get_samsung_spl(chroot_dir),
397+ cls._get_samsung_uboot(chroot_dir),
398+ boot_device_or_file)
399 env_size = cls.SAMSUNG_V310_ENV_LEN * SECTOR_SIZE
400 env_file = make_flashable_env(boot_env, env_size)
401 _dd(env_file, boot_device_or_file, seek=cls.SAMSUNG_V310_ENV_START)
402@@ -1229,26 +1319,6 @@
403 _dd(uboot_file, boot_device_or_file, seek=cls.SAMSUNG_V310_BL2_START)
404
405
406- @classmethod
407- def install_samsung_boot_loader(cls, chroot_dir, boot_device_or_file):
408- with cls.hardwarepack_handler:
409- try:
410- default = cls._get_samsung_spl(chroot_dir)
411- except AssertionError:
412- default = None
413- spl_file = cls.get_file('spl', default=default)
414- bl1_max_size = cls.SAMSUNG_V310_BL1_LEN * SECTOR_SIZE
415- assert os.path.getsize(spl_file) <= bl1_max_size, (
416- "%s is larger than %s" % (spl_file, bl1_max_size))
417- _dd(spl_file, boot_device_or_file, seek=cls.SAMSUNG_V310_BL1_START)
418- uboot_file = cls.get_file(
419- 'u_boot', default=cls._get_samsung_uboot(chroot_dir))
420- bl2_max_size = cls.SAMSUNG_V310_BL2_LEN * SECTOR_SIZE
421- assert os.path.getsize(uboot_file) <= bl2_max_size, (
422- "%s is larger than %s" % (uboot_file, bl2_max_size))
423- _dd(uboot_file, boot_device_or_file, seek=cls.SAMSUNG_V310_BL2_START)
424-
425-
426 class SMDKV310Config(SamsungConfig):
427 uboot_flavor = 'smdkv310'
428 serial_tty = 'ttySAC1'
429
430=== modified file 'linaro_image_tools/media_create/tests/test_media_create.py'
431--- linaro_image_tools/media_create/tests/test_media_create.py 2011-08-30 08:52:00 +0000
432+++ linaro_image_tools/media_create/tests/test_media_create.py 2011-09-15 12:16:52 +0000
433@@ -876,6 +876,7 @@
434 super(TestBootSteps, self).setUp()
435 self.funcs_calls = []
436 self.mock_all_boards_funcs()
437+ linaro_image_tools.media_create.boards.BoardConfig.hwpack_format = '1.0'
438
439 def mock_all_boards_funcs(self):
440 """Mock functions of boards module with a call tracer."""
441@@ -938,6 +939,8 @@
442 linaro_image_tools.media_create.boards.SMDKV310Config,
443 'install_samsung_boot_loader',
444 mock_func_creator('install_samsung_boot_loader')))
445+ self.useFixture(MockSomethingFixture(os.path, 'exists',
446+ lambda file: True))
447 boards.SMDKV310Config.hardwarepack_handler = (
448 TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz'))
449 boards.SMDKV310Config.hardwarepack_handler.get_format = (
450@@ -957,6 +960,8 @@
451 linaro_image_tools.media_create.boards.OrigenConfig,
452 'install_samsung_boot_loader',
453 mock_func_creator('install_samsung_boot_loader')))
454+ self.useFixture(MockSomethingFixture(os.path, 'exists',
455+ lambda file: True))
456 boards.OrigenConfig.hardwarepack_handler = (
457 TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz'))
458 boards.OrigenConfig.hardwarepack_handler.get_format = (
459@@ -1529,22 +1534,11 @@
460 def test_install_smdk_u_boot(self):
461 fixture = self._mock_Popen()
462 uboot_flavor = boards.SMDKV310Config.uboot_flavor
463- self.useFixture(MockSomethingFixture(
464- boards.SMDKV310Config, '_get_samsung_spl',
465- classmethod(lambda cls, chroot_dir: "%s/%s/SPL" % (
466- chroot_dir, uboot_flavor))))
467- self.useFixture(MockSomethingFixture(
468- boards.SMDKV310Config, '_get_samsung_uboot',
469- classmethod(lambda cls, chroot_dir: "%s/%s/uboot" % (
470- chroot_dir, uboot_flavor))))
471- boards.SMDKV310Config.hardwarepack_handler = (
472- TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz'))
473- boards.SMDKV310Config.hardwarepack_handler.get_format = (
474- lambda: '1.0')
475 self.useFixture(MockSomethingFixture(os.path, 'getsize',
476 lambda file: 1))
477 boards.SMDKV310Config.install_samsung_boot_loader(
478- "chroot_dir", "boot_disk")
479+ "%s/%s/SPL" % ("chroot_dir", uboot_flavor),
480+ "%s/%s/uboot" % ("chroot_dir", uboot_flavor), "boot_disk")
481 expected = [
482 '%s dd if=chroot_dir/%s/SPL of=boot_disk bs=512 conv=notrunc '
483 'seek=%d' % (sudo_args, uboot_flavor, boards.SMDKV310Config.SAMSUNG_V310_BL1_START),
484@@ -1570,7 +1564,8 @@
485 self.useFixture(MockSomethingFixture(os.path, 'getsize',
486 lambda file: 1))
487 boards.OrigenConfig.install_samsung_boot_loader(
488- "chroot_dir", "boot_disk")
489+ boards.OrigenConfig._get_samsung_spl("chroot_dir"),
490+ boards.OrigenConfig._get_samsung_uboot("chroot_dir"), "boot_disk")
491 expected = [
492 '%s dd if=chroot_dir/%s/SPL of=boot_disk bs=512 conv=notrunc '
493 'seek=%d' % (sudo_args, uboot_flavor, boards.OrigenConfig.SAMSUNG_V310_BL1_START),
494@@ -1727,6 +1722,7 @@
495 # Stub time.sleep() as create_partitions() use that.
496 self.orig_sleep = time.sleep
497 time.sleep = lambda s: None
498+ linaro_image_tools.media_create.boards.BoardConfig.hwpack_format = '1.0'
499
500 def tearDown(self):
501 super(TestCreatePartitions, self).tearDown()

Subscribers

People subscribed via source and target branches