Merge lp:~mabac/linaro-image-tools/hwpacks-v2-samsung into lp:linaro-image-tools/11.11

Proposed by Mattias Backman
Status: Merged
Approved by: James Westby
Approved revision: 436
Merged at revision: 429
Proposed branch: lp:~mabac/linaro-image-tools/hwpacks-v2-samsung
Merge into: lp:linaro-image-tools/11.11
Diff against target: 502 lines (+215/-66)
6 files modified
linaro_image_tools/hwpack/builder.py (+4/-0)
linaro_image_tools/hwpack/config.py (+96/-0)
linaro_image_tools/hwpack/hardwarepack.py (+23/-2)
linaro_image_tools/media_create/android_boards.py (+2/-5)
linaro_image_tools/media_create/boards.py (+86/-53)
linaro_image_tools/media_create/tests/test_media_create.py (+4/-6)
To merge this branch: bzr merge lp:~mabac/linaro-image-tools/hwpacks-v2-samsung
Reviewer Review Type Date Requested Status
James Westby (community) Approve
Review via email: mp+73051@code.launchpad.net

Description of the change

Hi,

This branch adds hwpacks V2 support for Samsung boards. The additions are the parameters for start and lengths for boot files (BL1, BL2 and ENV) as well as for specifying which spl file to pull from the u-boot package.

To avoid cluttering the BoardConfig set_metadata I put the Samsung specific code in the SamsungConfig class. Perhaps this is a bad thing to do since we would like to only have a BoardConfig class in the end without any overloading.

Hwpack config for testing: lp:~mabac/+junk/hwpack.natty.linaro-lt-origen

Thanks,

Mattias

To post a comment you must log in.
433. By Mattias Backman

Add samsung fields to hwpack metadata.

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

Yep, I think it's a mistake to have the SamsungConfig class involved here.

If the code is too long on BoardConfig then let's look for ways to shrink it
or split it up, rather than doing this.

The reason I think it's a mistake is that there are two problems:

  1) We don't know which BoardConfig class to pick unless we use --dev, and doing that means that if Samsung release a new board that works largely like the Origen in this area, they'll either have to submit a change to l-m-c, or tell people to use --dev origen for a non-origen board.

     (I think hwpack v2 should make --dev obsolete, but I don't advocate removing it
      as we'll need it in OneHardwarePackPerSOC in order to select which board info
      to used from the hwpack)

  2) It's not how we think about the problem any more. If all the info is in the hwpack then there's only one BoardConfig (it's even the wrong name now I think), and so having multiple in the code doesn't match the mental model, and may suggest to people that it's ok to add extra stuff there that should be a hwpack extension.

The change looks good aside from that.

Thanks,

James

review: Needs Fixing
434. By Mattias Backman

Move Samsung specifics to BoardConfig.

435. By Mattias Backman

Move dd(uboot_file) into hardwarepackhandler context.

436. By Mattias Backman

Fix extra empty line.

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

> Yep, I think it's a mistake to have the SamsungConfig class involved here.
>
> If the code is too long on BoardConfig then let's look for ways to shrink it
> or split it up, rather than doing this.

It's not too long really, I was just considering aesthetics. I don't think there's a problem with having everything in BoardConfig since it will mostly be a lot of similar statements getting stuff from metadata. Also, the code can be cleaned up and shortened a lot once we stop supporting pre V2 hwpacks in l-m-c.

I have moved the Samsung fields into BoardConfig. When we don't need support for both V1 and V2 hwpacks we can refactor a bit and that might be a good time to find a better name for BoardConfig.

>
> The reason I think it's a mistake is that there are two problems:

Yes, agreed. Now we're pretty close to be able to delete the specific board classes.

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

> I have moved the Samsung fields into BoardConfig. When we don't need support
> for both V1 and V2 hwpacks we can refactor a bit and that might be a good time
> to find a better name for BoardConfig.

Great, thanks.

> >
> > The reason I think it's a mistake is that there are two problems:
>
> Yes, agreed. Now we're pretty close to be able to delete the specific board
> classes.

Excellent!

Thanks,

James

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'linaro_image_tools/hwpack/builder.py'
2--- linaro_image_tools/hwpack/builder.py 2011-08-02 16:46:24 +0000
3+++ linaro_image_tools/hwpack/builder.py 2011-08-29 12:19:23 +0000
4@@ -149,6 +149,10 @@
5 hwpack.metadata.u_boot = self.add_file_to_hwpack(
6 u_boot_package, self.config.u_boot_file,
7 package_unpacker, hwpack, hwpack.U_BOOT_DIR)
8+ if self.config.spl_file is not None:
9+ hwpack.metadata.spl = self.add_file_to_hwpack(
10+ u_boot_package, self.config.spl_file,
11+ package_unpacker, hwpack, hwpack.U_BOOT_DIR)
12
13 if self.config.x_loader_package is not None:
14 x_loader_package = self.find_fetched_package(
15
16=== modified file 'linaro_image_tools/hwpack/config.py'
17--- linaro_image_tools/hwpack/config.py 2011-08-18 15:46:52 +0000
18+++ linaro_image_tools/hwpack/config.py 2011-08-29 12:19:23 +0000
19@@ -51,6 +51,7 @@
20 ASSUME_INSTALLED_KEY = "assume-installed"
21 U_BOOT_PACKAGE_KEY = "u_boot_package"
22 U_BOOT_FILE_KEY = "u_boot_file"
23+ SPL_FILE_KEY = "spl_file"
24 SERIAL_TTY_KEY = "serial_tty"
25 KERNEL_ADDR_KEY = "kernel_addr"
26 INITRD_ADDR_KEY = "initrd_addr"
27@@ -73,6 +74,11 @@
28 BOOT_SCRIPT_KEY = 'boot_script'
29 UBOOT_IN_BOOT_PART_KEY = 'u_boot_in_boot_part'
30 EXTRA_SERIAL_OPTS_KEY = 'extra_serial_options'
31+ SAMSUNG_BL1_START_KEY = 'samsung_bl1_start'
32+ SAMSUNG_BL1_LEN_KEY = 'samsung_bl1_len'
33+ SAMSUNG_ENV_LEN_KEY = 'samsung_env_len'
34+ SAMSUNG_BL2_LEN_KEY = 'samsung_bl2_len'
35+
36
37 DEFINED_PARTITION_LAYOUTS = [
38 'bootfs16_rootfs',
39@@ -128,6 +134,10 @@
40 self._validate_boot_script()
41 self._validate_uboot_in_boot_part()
42 self._validate_extra_serial_opts()
43+ self._validate_samsung_bl1_start()
44+ self._validate_samsung_bl1_len()
45+ self._validate_samsung_env_len()
46+ self._validate_samsung_bl2_len()
47
48 self._validate_sections()
49
50@@ -372,6 +382,14 @@
51 return self._get_option_from_main_section(self.U_BOOT_FILE_KEY)
52
53 @property
54+ def spl_file(self):
55+ """The spl bin file that will be unpacked from the u-boot package.
56+
57+ A str.
58+ """
59+ return self._get_option_from_main_section(self.SPL_FILE_KEY)
60+
61+ @property
62 def x_loader_package(self):
63 """The x-loader package that contains the x-loader bin.
64
65@@ -412,6 +430,38 @@
66 return self._get_option_from_main_section(self.DTB_FILE_KEY)
67
68 @property
69+ def samsung_bl1_start(self):
70+ """BL1 start offset for Samsung boards.
71+
72+ A str.
73+ """
74+ return self._get_option_from_main_section(self.SAMSUNG_BL1_START_KEY)
75+
76+ @property
77+ def samsung_bl1_len(self):
78+ """BL1 length for Samsung boards.
79+
80+ A str.
81+ """
82+ return self._get_option_from_main_section(self.SAMSUNG_BL1_LEN_KEY)
83+
84+ @property
85+ def samsung_env_len(self):
86+ """Env length for Samsung boards.
87+
88+ A str.
89+ """
90+ return self._get_option_from_main_section(self.SAMSUNG_ENV_LEN_KEY)
91+
92+ @property
93+ def samsung_bl2_len(self):
94+ """BL2 length for Samsung boards.
95+
96+ A str.
97+ """
98+ return self._get_option_from_main_section(self.SAMSUNG_BL2_LEN_KEY)
99+
100+ @property
101 def architectures(self):
102 """The architectures to build the hwpack for.
103
104@@ -471,6 +521,12 @@
105 self._assert_matches_pattern(
106 self.PATH_REGEX, u_boot_file, "Invalid path: %s" % u_boot_file)
107
108+ def _validate_spl_file(self):
109+ spl_file = self.spl_file
110+ if spl_file is not None:
111+ self._assert_matches_pattern(
112+ self.PATH_REGEX, spl_file, "Invalid path: %s" % spl_file)
113+
114 def _validate_x_loader_file(self):
115 x_loader_file = self.x_loader_file
116 if x_loader_file is not None:
117@@ -659,6 +715,46 @@
118 self.MAIN_SECTION,
119 x_loader_package))
120
121+ def _validate_samsung_bl1_start(self):
122+ samsung_bl1_start = self.samsung_bl1_start
123+ if samsung_bl1_start is None:
124+ return
125+ try:
126+ assert int(samsung_bl1_start) > 0
127+ except:
128+ raise HwpackConfigError(
129+ "Invalid samsung_bl1_start %s" % (samsung_bl1_start))
130+
131+ def _validate_samsung_bl1_len(self):
132+ samsung_bl1_len = self.samsung_bl1_len
133+ if samsung_bl1_len is None:
134+ return
135+ try:
136+ assert int(samsung_bl1_len) > 0
137+ except:
138+ raise HwpackConfigError(
139+ "Invalid samsung_bl1_len %s" % (samsung_bl1_len))
140+
141+ def _validate_samsung_env_len(self):
142+ samsung_env_len = self.samsung_env_len
143+ if samsung_env_len is None:
144+ return
145+ try:
146+ assert int(samsung_env_len) > 0
147+ except:
148+ raise HwpackConfigError(
149+ "Invalid samsung_env_len %s" % (samsung_env_len))
150+
151+ def _validate_samsung_bl2_len(self):
152+ samsung_bl2_len = self.samsung_bl2_len
153+ if samsung_bl2_len is None:
154+ return
155+ try:
156+ assert int(samsung_bl2_len) > 0
157+ except:
158+ raise HwpackConfigError(
159+ "Invalid samsung_bl2_len %s" % (samsung_bl2_len))
160+
161 def _validate_architectures(self):
162 architectures = self.architectures
163 if not architectures:
164
165=== modified file 'linaro_image_tools/hwpack/hardwarepack.py'
166--- linaro_image_tools/hwpack/hardwarepack.py 2011-08-18 13:46:36 +0000
167+++ linaro_image_tools/hwpack/hardwarepack.py 2011-08-29 12:19:23 +0000
168@@ -84,12 +84,15 @@
169 loader_min_size=None, vmlinuz=None, initrd=None,
170 dtb_addr=None, extra_boot_options=None,
171 boot_script=None, uboot_in_boot_part=None,
172- extra_serial_opts=None):
173+ extra_serial_opts=None, samsung_bl1_start=None,
174+ samsung_bl1_len=None, samsung_env_len=None,
175+ samsung_bl2_len=None):
176 """Add fields that are specific to the new format.
177
178 These fields are not present in earlier config files.
179 """
180 self.u_boot = None
181+ self.spl = None
182 self.serial_tty = serial_tty
183 self.kernel_addr = kernel_addr
184 self.initrd_addr = initrd_addr
185@@ -110,6 +113,10 @@
186 self.boot_script = boot_script
187 self.uboot_in_boot_part = uboot_in_boot_part
188 self.extra_serial_opts = extra_serial_opts
189+ self.samsung_bl1_start = samsung_bl1_start
190+ self.samsung_bl1_len = samsung_bl1_len
191+ self.samsung_env_len = samsung_env_len
192+ self.samsung_bl2_len = samsung_bl2_len
193
194 @classmethod
195 def from_config(cls, config, version, architecture):
196@@ -153,7 +160,11 @@
197 extra_boot_options=config.extra_boot_options,
198 boot_script=config.boot_script,
199 uboot_in_boot_part=config.uboot_in_boot_part,
200- extra_serial_opts=config.extra_serial_opts)
201+ extra_serial_opts=config.extra_serial_opts,
202+ samsung_bl1_start=config.samsung_bl1_start,
203+ samsung_bl1_len=config.samsung_bl1_len,
204+ samsung_env_len=config.samsung_env_len,
205+ samsung_bl2_len=config.samsung_bl2_len)
206 return metadata
207
208 def __str__(self):
209@@ -173,6 +184,8 @@
210
211 if self.u_boot is not None:
212 metadata += "U_BOOT=%s\n" % self.u_boot
213+ if self.spl is not None:
214+ metadata += "SPL=%s\n" % self.spl
215 if self.serial_tty is not None:
216 metadata += "SERIAL_TTY=%s\n" % self.serial_tty
217 if self.kernel_addr is not None:
218@@ -214,6 +227,14 @@
219 metadata += "U_BOOT_IN_BOOT_PART=%s\n" % self.uboot_in_boot_part
220 if self.extra_serial_opts is not None:
221 metadata += "EXTRA_SERIAL_OPTIONS=%s\n" % self.extra_serial_opts
222+ if self.samsung_bl1_start is not None:
223+ metadata += "SAMSUNG_BL1_START=%s\n" % self.samsung_bl1_start
224+ if self.samsung_bl1_len is not None:
225+ metadata += "SAMSUNG_BL1_LEN=%s\n" % self.samsung_bl1_len
226+ if self.samsung_env_len is not None:
227+ metadata += "SAMSUNG_ENV_LEN=%s\n" % self.samsung_env_len
228+ if self.samsung_bl2_len is not None:
229+ metadata += "SAMSUNG_BL2_LEN=%s\n" % self.samsung_bl2_len
230
231 return metadata
232
233
234=== modified file 'linaro_image_tools/media_create/android_boards.py'
235--- linaro_image_tools/media_create/android_boards.py 2011-08-24 14:47:20 +0000
236+++ linaro_image_tools/media_create/android_boards.py 2011-08-29 12:19:23 +0000
237@@ -26,9 +26,6 @@
238
239 from linaro_image_tools.media_create.partitions import SECTOR_SIZE
240 from linaro_image_tools.media_create.boards import PART_ALIGN_S
241-from linaro_image_tools.media_create.boards import SAMSUNG_V310_BL1_START
242-from linaro_image_tools.media_create.boards import SAMSUNG_V310_BL2_START
243-from linaro_image_tools.media_create.boards import SAMSUNG_V310_BL2_LEN
244 from linaro_image_tools.media_create.boards import BeagleConfig
245 from linaro_image_tools.media_create.boards import PandaConfig
246 from linaro_image_tools.media_create.boards import Mx53LoCoConfig
247@@ -251,8 +248,8 @@
248 @classmethod
249 def get_sfdisk_cmd(cls, should_align_boot_part=False):
250 loaders_min_len = (
251- SAMSUNG_V310_BL2_START + SAMSUNG_V310_BL2_LEN -
252- SAMSUNG_V310_BL1_START)
253+ cls.SAMSUNG_V310_BL2_START + cls.SAMSUNG_V310_BL2_LEN -
254+ cls.SAMSUNG_V310_BL1_START)
255
256 loader_start, loader_end, loader_len = align_partition(
257 1, loaders_min_len, 1, PART_ALIGN_S)
258
259=== modified file 'linaro_image_tools/media_create/boards.py'
260--- linaro_image_tools/media_create/boards.py 2011-08-25 09:57:46 +0000
261+++ linaro_image_tools/media_create/boards.py 2011-08-29 12:19:23 +0000
262@@ -69,38 +69,6 @@
263 """Round value to the next multiple of align."""
264 return (value + align - 1) / align * align
265
266-# Samsung v310 implementation notes and terminology
267-#
268-# * BL0, BL1 etc. are the various bootloaders in order of execution
269-# * BL0 is the first stage bootloader, located in ROM; it loads a 32s long BL1
270-# from MMC offset +1s and runs it
271-# * BL1 is the secondary program loader (SPL), a small (< 14k) version of
272-# U-Boot with a checksum; it inits DRAM and loads a 1024s long BL2 to DRAM
273-# from MMC offset +65s
274-# * BL2 is U-Boot; it loads its 32s (16 KiB) long environment from MMC offset
275-# +33s which tells it to load a boot.scr from the first FAT partition of the
276-# MMC
277-#
278-# Layout:
279-# +0s: part table / MBR, 1s long
280-# +1s: BL1/SPL, 32s long
281-# +33s: U-Boot environment, 32s long
282-# +65s: U-Boot, 1024s long
283-# >= +1089s: FAT partition with boot script (boot.scr), kernel (uImage) and
284-# initrd (uInitrd)
285-SAMSUNG_V310_BL1_START = 1
286-SAMSUNG_V310_BL1_LEN = 32
287-SAMSUNG_V310_ENV_START = SAMSUNG_V310_BL1_START + SAMSUNG_V310_BL1_LEN
288-SAMSUNG_V310_ENV_LEN = 32
289-assert SAMSUNG_V310_ENV_START == 33, "BL1 expects u-boot environment at +33s"
290-assert SAMSUNG_V310_ENV_LEN * SECTOR_SIZE == 16 * 1024, (
291- "BL1 expects u-boot environment to be 16 KiB")
292-SAMSUNG_V310_BL2_START = SAMSUNG_V310_ENV_START + SAMSUNG_V310_ENV_LEN
293-SAMSUNG_V310_BL2_LEN = 1024
294-assert SAMSUNG_V310_BL2_LEN * SECTOR_SIZE == 512 * 1024, (
295- "BL1 expects BL2 (u-boot) to be 512 KiB")
296-
297-
298 def align_partition(min_start, min_length, start_alignment, end_alignment):
299 """Compute partition start and end offsets based on specified constraints.
300
301@@ -254,6 +222,37 @@
302 vmlinuz = None
303 initrd = None
304
305+ # Samsung v310 implementation notes and terminology
306+ #
307+ # * BL0, BL1 etc. are the various bootloaders in order of execution
308+ # * BL0 is the first stage bootloader, located in ROM; it loads a 32s long BL1
309+ # from MMC offset +1s and runs it
310+ # * BL1 is the secondary program loader (SPL), a small (< 14k) version of
311+ # U-Boot with a checksum; it inits DRAM and loads a 1024s long BL2 to DRAM
312+ # from MMC offset +65s
313+ # * BL2 is U-Boot; it loads its 32s (16 KiB) long environment from MMC offset
314+ # +33s which tells it to load a boot.scr from the first FAT partition of the
315+ # MMC
316+ #
317+ # Layout:
318+ # +0s: part table / MBR, 1s long
319+ # +1s: BL1/SPL, 32s long
320+ # +33s: U-Boot environment, 32s long
321+ # +65s: U-Boot, 1024s long
322+ # >= +1089s: FAT partition with boot script (boot.scr), kernel (uImage) and
323+ # initrd (uInitrd)
324+ SAMSUNG_V310_BL1_START = 1
325+ SAMSUNG_V310_BL1_LEN = 32
326+ SAMSUNG_V310_ENV_START = SAMSUNG_V310_BL1_START + SAMSUNG_V310_BL1_LEN
327+ SAMSUNG_V310_ENV_LEN = 32
328+ assert SAMSUNG_V310_ENV_START == 33, "BL1 expects u-boot environment at +33s"
329+ assert SAMSUNG_V310_ENV_LEN * SECTOR_SIZE == 16 * 1024, (
330+ "BL1 expects u-boot environment to be 16 KiB")
331+ SAMSUNG_V310_BL2_START = SAMSUNG_V310_ENV_START + SAMSUNG_V310_ENV_LEN
332+ SAMSUNG_V310_BL2_LEN = 1024
333+ assert SAMSUNG_V310_BL2_LEN * SECTOR_SIZE == 512 * 1024, (
334+ "BL1 expects BL2 (u-boot) to be 512 KiB")
335+
336 hardwarepack_handler = None
337
338 @classmethod
339@@ -285,6 +284,12 @@
340 cls.extra_boot_args_options = None
341 cls.boot_script = None
342 cls.kernel_flavors = None
343+ cls.SAMSUNG_V310_BL1_START = None
344+ cls.SAMSUNG_V310_BL1_LEN = None
345+ cls.SAMSUNG_V310_ENV_START = None
346+ cls.SAMSUNG_V310_ENV_LEN = None
347+ cls.SAMSUNG_V310_BL2_START = None
348+ cls.SAMSUNG_V310_BL2_LEN = None
349
350 # Set new values from metadata.
351 cls.kernel_addr = cls.get_metadata_field('kernel_addr')
352@@ -332,6 +337,32 @@
353 elif string.lower(uboot_in_boot_part) == 'no':
354 cls.uboot_in_boot_part = False
355
356+ samsung_bl1_start = cls.get_metadata_field('samsung_bl1_start')
357+ if samsung_bl1_start is not None:
358+ cls.SAMSUNG_V310_BL1_START = int(samsung_bl1_start)
359+ samsung_bl1_len = cls.get_metadata_field('samsung_bl1_len')
360+ if samsung_bl1_len is not None:
361+ cls.SAMSUNG_V310_BL1_LEN = int(samsung_bl1_len)
362+ samsung_env_len = cls.get_metadata_field('samsung_env_len')
363+ if samsung_env_len is not None:
364+ cls.SAMSUNG_V310_ENV_LEN = int(samsung_env_len)
365+ assert cls.SAMSUNG_V310_ENV_LEN * SECTOR_SIZE == 16 * 1024, (
366+ "BL1 expects u-boot environment to be 16 KiB")
367+ samsung_bl2_len = cls.get_metadata_field('samsung_bl2_len')
368+ if samsung_bl2_len is not None:
369+ cls.SAMSUNG_V310_BL2_LEN = int(samsung_bl2_len)
370+ assert cls.SAMSUNG_V310_BL2_LEN * SECTOR_SIZE == 512 * 1024, (
371+ "BL1 expects BL2 (u-boot) to be 512 KiB")
372+
373+ if (cls.SAMSUNG_V310_BL1_START and cls.SAMSUNG_V310_BL1_LEN):
374+ cls.SAMSUNG_V310_ENV_START = (cls.SAMSUNG_V310_BL1_START +
375+ cls.SAMSUNG_V310_BL1_LEN)
376+ assert cls.SAMSUNG_V310_ENV_START == 33, (
377+ "BL1 expects u-boot environment at +33s")
378+ if (cls.SAMSUNG_V310_ENV_START and cls.SAMSUNG_V310_ENV_LEN):
379+ cls.SAMSUNG_V310_BL2_START = (cls.SAMSUNG_V310_ENV_START +
380+ cls.SAMSUNG_V310_ENV_LEN)
381+
382 @classmethod
383 def get_file(cls, file_alias, default=None):
384 file_in_hwpack = cls.hardwarepack_handler.get_file(file_alias)
385@@ -1023,8 +1054,8 @@
386 def get_sfdisk_cmd(cls, should_align_boot_part=False):
387 # bootloaders partition needs to hold BL1, U-Boot environment, and BL2
388 loaders_min_len = (
389- SAMSUNG_V310_BL2_START + SAMSUNG_V310_BL2_LEN -
390- SAMSUNG_V310_BL1_START)
391+ cls.SAMSUNG_V310_BL2_START + cls.SAMSUNG_V310_BL2_LEN -
392+ cls.SAMSUNG_V310_BL1_START)
393
394 # bootloaders partition
395 loaders_start, loaders_end, loaders_len = align_partition(
396@@ -1049,9 +1080,9 @@
397 boot_device_or_file, k_img_data, i_img_data,
398 d_img_data):
399 cls.install_samsung_boot_loader(chroot_dir, boot_device_or_file)
400- env_size = SAMSUNG_V310_ENV_LEN * SECTOR_SIZE
401+ env_size = cls.SAMSUNG_V310_ENV_LEN * SECTOR_SIZE
402 env_file = make_flashable_env(boot_env, env_size)
403- _dd(env_file, boot_device_or_file, seek=SAMSUNG_V310_ENV_START)
404+ _dd(env_file, boot_device_or_file, seek=cls.SAMSUNG_V310_ENV_START)
405
406 make_uImage(cls.load_addr, k_img_data, boot_dir)
407 make_uInitrd(i_img_data, boot_dir)
408@@ -1086,38 +1117,40 @@
409 'u-boot.bin')
410 return uboot_file
411
412-
413 @classmethod
414 def populate_raw_partition(cls, chroot_dir, boot_device_or_file):
415 # Zero the env so that the boot_script will get loaded
416- _dd("/dev/zero", boot_device_or_file, count=SAMSUNG_V310_ENV_LEN,
417- seek=SAMSUNG_V310_ENV_START)
418+ _dd("/dev/zero", boot_device_or_file, count=cls.SAMSUNG_V310_ENV_LEN,
419+ seek=cls.SAMSUNG_V310_ENV_START)
420 # Populate created raw partition with BL1 and u-boot
421 spl_file = os.path.join(chroot_dir, 'boot', 'u-boot-mmc-spl.bin')
422- assert os.path.getsize(spl_file) <= (SAMSUNG_V310_BL1_LEN * SECTOR_SIZE), (
423+ assert os.path.getsize(spl_file) <= (cls.SAMSUNG_V310_BL1_LEN * SECTOR_SIZE), (
424 "%s is larger than SAMSUNG_V310_BL1_LEN" % spl_file)
425- _dd(spl_file, boot_device_or_file, seek=SAMSUNG_V310_BL1_START)
426+ _dd(spl_file, boot_device_or_file, seek=cls.SAMSUNG_V310_BL1_START)
427 uboot_file = os.path.join(chroot_dir, 'boot', 'u-boot.bin')
428- assert os.path.getsize(uboot_file) <= (SAMSUNG_V310_BL2_LEN * SECTOR_SIZE), (
429+ assert os.path.getsize(uboot_file) <= (cls.SAMSUNG_V310_BL2_LEN * SECTOR_SIZE), (
430 "%s is larger than SAMSUNG_V310_BL2_LEN" % uboot_file)
431- _dd(uboot_file, boot_device_or_file, seek=SAMSUNG_V310_BL2_START)
432+ _dd(uboot_file, boot_device_or_file, seek=cls.SAMSUNG_V310_BL2_START)
433
434
435 @classmethod
436 def install_samsung_boot_loader(cls, chroot_dir, boot_device_or_file):
437- spl_file = cls._get_samsung_spl(chroot_dir)
438- bl1_max_size = SAMSUNG_V310_BL1_LEN * SECTOR_SIZE
439- assert os.path.getsize(spl_file) <= bl1_max_size, (
440- "%s is larger than %s" % (spl_file, bl1_max_size))
441- _dd(spl_file, boot_device_or_file, seek=SAMSUNG_V310_BL1_START)
442-
443 with cls.hardwarepack_handler:
444+ try:
445+ default = cls._get_samsung_spl(chroot_dir)
446+ except AssertionError:
447+ default = None
448+ spl_file = cls.get_file('spl', default=default)
449+ bl1_max_size = cls.SAMSUNG_V310_BL1_LEN * SECTOR_SIZE
450+ assert os.path.getsize(spl_file) <= bl1_max_size, (
451+ "%s is larger than %s" % (spl_file, bl1_max_size))
452+ _dd(spl_file, boot_device_or_file, seek=cls.SAMSUNG_V310_BL1_START)
453 uboot_file = cls.get_file(
454 'u_boot', default=cls._get_samsung_uboot(chroot_dir))
455- bl2_max_size = SAMSUNG_V310_BL2_LEN * SECTOR_SIZE
456- assert os.path.getsize(uboot_file) <= bl2_max_size, (
457- "%s is larger than %s" % (uboot_file, bl2_max_size))
458- _dd(uboot_file, boot_device_or_file, seek=SAMSUNG_V310_BL2_START)
459+ bl2_max_size = cls.SAMSUNG_V310_BL2_LEN * SECTOR_SIZE
460+ assert os.path.getsize(uboot_file) <= bl2_max_size, (
461+ "%s is larger than %s" % (uboot_file, bl2_max_size))
462+ _dd(uboot_file, boot_device_or_file, seek=cls.SAMSUNG_V310_BL2_START)
463
464
465 class SMDKV310Config(SamsungConfig):
466
467=== modified file 'linaro_image_tools/media_create/tests/test_media_create.py'
468--- linaro_image_tools/media_create/tests/test_media_create.py 2011-08-25 09:57:46 +0000
469+++ linaro_image_tools/media_create/tests/test_media_create.py 2011-08-29 12:19:23 +0000
470@@ -44,8 +44,6 @@
471 android_boards,
472 )
473 from linaro_image_tools.media_create.boards import (
474- SAMSUNG_V310_BL1_START,
475- SAMSUNG_V310_BL2_START,
476 SECTOR_SIZE,
477 align_up,
478 align_partition,
479@@ -1505,9 +1503,9 @@
480 "chroot_dir", "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, SAMSUNG_V310_BL1_START),
484+ 'seek=%d' % (sudo_args, uboot_flavor, boards.SMDKV310Config.SAMSUNG_V310_BL1_START),
485 '%s dd if=chroot_dir/%s/uboot of=boot_disk bs=512 conv=notrunc '
486- 'seek=%d' % (sudo_args, uboot_flavor, SAMSUNG_V310_BL2_START)]
487+ 'seek=%d' % (sudo_args, uboot_flavor, boards.SMDKV310Config.SAMSUNG_V310_BL2_START)]
488 self.assertEqual(expected, fixture.mock.commands_executed)
489
490 def test_install_origen_u_boot(self):
491@@ -1531,9 +1529,9 @@
492 "chroot_dir", "boot_disk")
493 expected = [
494 '%s dd if=chroot_dir/%s/SPL of=boot_disk bs=512 conv=notrunc '
495- 'seek=%d' % (sudo_args, uboot_flavor, SAMSUNG_V310_BL1_START),
496+ 'seek=%d' % (sudo_args, uboot_flavor, boards.OrigenConfig.SAMSUNG_V310_BL1_START),
497 '%s dd if=chroot_dir/%s/uboot of=boot_disk bs=512 conv=notrunc '
498- 'seek=%d' % (sudo_args, uboot_flavor, SAMSUNG_V310_BL2_START)]
499+ 'seek=%d' % (sudo_args, uboot_flavor, boards.OrigenConfig.SAMSUNG_V310_BL2_START)]
500 self.assertEqual(expected, fixture.mock.commands_executed)
501
502 def test_get_plain_boot_script_contents(self):

Subscribers

People subscribed via source and target branches