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
=== modified file 'linaro_image_tools/hwpack/builder.py'
--- linaro_image_tools/hwpack/builder.py 2011-08-02 16:46:24 +0000
+++ linaro_image_tools/hwpack/builder.py 2011-08-29 12:19:23 +0000
@@ -149,6 +149,10 @@
149 hwpack.metadata.u_boot = self.add_file_to_hwpack(149 hwpack.metadata.u_boot = self.add_file_to_hwpack(
150 u_boot_package, self.config.u_boot_file,150 u_boot_package, self.config.u_boot_file,
151 package_unpacker, hwpack, hwpack.U_BOOT_DIR)151 package_unpacker, hwpack, hwpack.U_BOOT_DIR)
152 if self.config.spl_file is not None:
153 hwpack.metadata.spl = self.add_file_to_hwpack(
154 u_boot_package, self.config.spl_file,
155 package_unpacker, hwpack, hwpack.U_BOOT_DIR)
152156
153 if self.config.x_loader_package is not None:157 if self.config.x_loader_package is not None:
154 x_loader_package = self.find_fetched_package(158 x_loader_package = self.find_fetched_package(
155159
=== modified file 'linaro_image_tools/hwpack/config.py'
--- linaro_image_tools/hwpack/config.py 2011-08-18 15:46:52 +0000
+++ linaro_image_tools/hwpack/config.py 2011-08-29 12:19:23 +0000
@@ -51,6 +51,7 @@
51 ASSUME_INSTALLED_KEY = "assume-installed"51 ASSUME_INSTALLED_KEY = "assume-installed"
52 U_BOOT_PACKAGE_KEY = "u_boot_package"52 U_BOOT_PACKAGE_KEY = "u_boot_package"
53 U_BOOT_FILE_KEY = "u_boot_file"53 U_BOOT_FILE_KEY = "u_boot_file"
54 SPL_FILE_KEY = "spl_file"
54 SERIAL_TTY_KEY = "serial_tty"55 SERIAL_TTY_KEY = "serial_tty"
55 KERNEL_ADDR_KEY = "kernel_addr"56 KERNEL_ADDR_KEY = "kernel_addr"
56 INITRD_ADDR_KEY = "initrd_addr"57 INITRD_ADDR_KEY = "initrd_addr"
@@ -73,6 +74,11 @@
73 BOOT_SCRIPT_KEY = 'boot_script'74 BOOT_SCRIPT_KEY = 'boot_script'
74 UBOOT_IN_BOOT_PART_KEY = 'u_boot_in_boot_part'75 UBOOT_IN_BOOT_PART_KEY = 'u_boot_in_boot_part'
75 EXTRA_SERIAL_OPTS_KEY = 'extra_serial_options'76 EXTRA_SERIAL_OPTS_KEY = 'extra_serial_options'
77 SAMSUNG_BL1_START_KEY = 'samsung_bl1_start'
78 SAMSUNG_BL1_LEN_KEY = 'samsung_bl1_len'
79 SAMSUNG_ENV_LEN_KEY = 'samsung_env_len'
80 SAMSUNG_BL2_LEN_KEY = 'samsung_bl2_len'
81
7682
77 DEFINED_PARTITION_LAYOUTS = [83 DEFINED_PARTITION_LAYOUTS = [
78 'bootfs16_rootfs',84 'bootfs16_rootfs',
@@ -128,6 +134,10 @@
128 self._validate_boot_script()134 self._validate_boot_script()
129 self._validate_uboot_in_boot_part()135 self._validate_uboot_in_boot_part()
130 self._validate_extra_serial_opts()136 self._validate_extra_serial_opts()
137 self._validate_samsung_bl1_start()
138 self._validate_samsung_bl1_len()
139 self._validate_samsung_env_len()
140 self._validate_samsung_bl2_len()
131141
132 self._validate_sections()142 self._validate_sections()
133143
@@ -372,6 +382,14 @@
372 return self._get_option_from_main_section(self.U_BOOT_FILE_KEY)382 return self._get_option_from_main_section(self.U_BOOT_FILE_KEY)
373383
374 @property384 @property
385 def spl_file(self):
386 """The spl bin file that will be unpacked from the u-boot package.
387
388 A str.
389 """
390 return self._get_option_from_main_section(self.SPL_FILE_KEY)
391
392 @property
375 def x_loader_package(self):393 def x_loader_package(self):
376 """The x-loader package that contains the x-loader bin.394 """The x-loader package that contains the x-loader bin.
377395
@@ -412,6 +430,38 @@
412 return self._get_option_from_main_section(self.DTB_FILE_KEY)430 return self._get_option_from_main_section(self.DTB_FILE_KEY)
413431
414 @property432 @property
433 def samsung_bl1_start(self):
434 """BL1 start offset for Samsung boards.
435
436 A str.
437 """
438 return self._get_option_from_main_section(self.SAMSUNG_BL1_START_KEY)
439
440 @property
441 def samsung_bl1_len(self):
442 """BL1 length for Samsung boards.
443
444 A str.
445 """
446 return self._get_option_from_main_section(self.SAMSUNG_BL1_LEN_KEY)
447
448 @property
449 def samsung_env_len(self):
450 """Env length for Samsung boards.
451
452 A str.
453 """
454 return self._get_option_from_main_section(self.SAMSUNG_ENV_LEN_KEY)
455
456 @property
457 def samsung_bl2_len(self):
458 """BL2 length for Samsung boards.
459
460 A str.
461 """
462 return self._get_option_from_main_section(self.SAMSUNG_BL2_LEN_KEY)
463
464 @property
415 def architectures(self):465 def architectures(self):
416 """The architectures to build the hwpack for.466 """The architectures to build the hwpack for.
417467
@@ -471,6 +521,12 @@
471 self._assert_matches_pattern(521 self._assert_matches_pattern(
472 self.PATH_REGEX, u_boot_file, "Invalid path: %s" % u_boot_file)522 self.PATH_REGEX, u_boot_file, "Invalid path: %s" % u_boot_file)
473523
524 def _validate_spl_file(self):
525 spl_file = self.spl_file
526 if spl_file is not None:
527 self._assert_matches_pattern(
528 self.PATH_REGEX, spl_file, "Invalid path: %s" % spl_file)
529
474 def _validate_x_loader_file(self):530 def _validate_x_loader_file(self):
475 x_loader_file = self.x_loader_file531 x_loader_file = self.x_loader_file
476 if x_loader_file is not None:532 if x_loader_file is not None:
@@ -659,6 +715,46 @@
659 self.MAIN_SECTION,715 self.MAIN_SECTION,
660 x_loader_package))716 x_loader_package))
661717
718 def _validate_samsung_bl1_start(self):
719 samsung_bl1_start = self.samsung_bl1_start
720 if samsung_bl1_start is None:
721 return
722 try:
723 assert int(samsung_bl1_start) > 0
724 except:
725 raise HwpackConfigError(
726 "Invalid samsung_bl1_start %s" % (samsung_bl1_start))
727
728 def _validate_samsung_bl1_len(self):
729 samsung_bl1_len = self.samsung_bl1_len
730 if samsung_bl1_len is None:
731 return
732 try:
733 assert int(samsung_bl1_len) > 0
734 except:
735 raise HwpackConfigError(
736 "Invalid samsung_bl1_len %s" % (samsung_bl1_len))
737
738 def _validate_samsung_env_len(self):
739 samsung_env_len = self.samsung_env_len
740 if samsung_env_len is None:
741 return
742 try:
743 assert int(samsung_env_len) > 0
744 except:
745 raise HwpackConfigError(
746 "Invalid samsung_env_len %s" % (samsung_env_len))
747
748 def _validate_samsung_bl2_len(self):
749 samsung_bl2_len = self.samsung_bl2_len
750 if samsung_bl2_len is None:
751 return
752 try:
753 assert int(samsung_bl2_len) > 0
754 except:
755 raise HwpackConfigError(
756 "Invalid samsung_bl2_len %s" % (samsung_bl2_len))
757
662 def _validate_architectures(self):758 def _validate_architectures(self):
663 architectures = self.architectures759 architectures = self.architectures
664 if not architectures:760 if not architectures:
665761
=== modified file 'linaro_image_tools/hwpack/hardwarepack.py'
--- linaro_image_tools/hwpack/hardwarepack.py 2011-08-18 13:46:36 +0000
+++ linaro_image_tools/hwpack/hardwarepack.py 2011-08-29 12:19:23 +0000
@@ -84,12 +84,15 @@
84 loader_min_size=None, vmlinuz=None, initrd=None,84 loader_min_size=None, vmlinuz=None, initrd=None,
85 dtb_addr=None, extra_boot_options=None,85 dtb_addr=None, extra_boot_options=None,
86 boot_script=None, uboot_in_boot_part=None,86 boot_script=None, uboot_in_boot_part=None,
87 extra_serial_opts=None):87 extra_serial_opts=None, samsung_bl1_start=None,
88 samsung_bl1_len=None, samsung_env_len=None,
89 samsung_bl2_len=None):
88 """Add fields that are specific to the new format.90 """Add fields that are specific to the new format.
8991
90 These fields are not present in earlier config files.92 These fields are not present in earlier config files.
91 """93 """
92 self.u_boot = None94 self.u_boot = None
95 self.spl = None
93 self.serial_tty = serial_tty96 self.serial_tty = serial_tty
94 self.kernel_addr = kernel_addr97 self.kernel_addr = kernel_addr
95 self.initrd_addr = initrd_addr98 self.initrd_addr = initrd_addr
@@ -110,6 +113,10 @@
110 self.boot_script = boot_script113 self.boot_script = boot_script
111 self.uboot_in_boot_part = uboot_in_boot_part114 self.uboot_in_boot_part = uboot_in_boot_part
112 self.extra_serial_opts = extra_serial_opts115 self.extra_serial_opts = extra_serial_opts
116 self.samsung_bl1_start = samsung_bl1_start
117 self.samsung_bl1_len = samsung_bl1_len
118 self.samsung_env_len = samsung_env_len
119 self.samsung_bl2_len = samsung_bl2_len
113120
114 @classmethod121 @classmethod
115 def from_config(cls, config, version, architecture):122 def from_config(cls, config, version, architecture):
@@ -153,7 +160,11 @@
153 extra_boot_options=config.extra_boot_options,160 extra_boot_options=config.extra_boot_options,
154 boot_script=config.boot_script,161 boot_script=config.boot_script,
155 uboot_in_boot_part=config.uboot_in_boot_part,162 uboot_in_boot_part=config.uboot_in_boot_part,
156 extra_serial_opts=config.extra_serial_opts)163 extra_serial_opts=config.extra_serial_opts,
164 samsung_bl1_start=config.samsung_bl1_start,
165 samsung_bl1_len=config.samsung_bl1_len,
166 samsung_env_len=config.samsung_env_len,
167 samsung_bl2_len=config.samsung_bl2_len)
157 return metadata168 return metadata
158169
159 def __str__(self):170 def __str__(self):
@@ -173,6 +184,8 @@
173 184
174 if self.u_boot is not None:185 if self.u_boot is not None:
175 metadata += "U_BOOT=%s\n" % self.u_boot186 metadata += "U_BOOT=%s\n" % self.u_boot
187 if self.spl is not None:
188 metadata += "SPL=%s\n" % self.spl
176 if self.serial_tty is not None:189 if self.serial_tty is not None:
177 metadata += "SERIAL_TTY=%s\n" % self.serial_tty190 metadata += "SERIAL_TTY=%s\n" % self.serial_tty
178 if self.kernel_addr is not None:191 if self.kernel_addr is not None:
@@ -214,6 +227,14 @@
214 metadata += "U_BOOT_IN_BOOT_PART=%s\n" % self.uboot_in_boot_part227 metadata += "U_BOOT_IN_BOOT_PART=%s\n" % self.uboot_in_boot_part
215 if self.extra_serial_opts is not None:228 if self.extra_serial_opts is not None:
216 metadata += "EXTRA_SERIAL_OPTIONS=%s\n" % self.extra_serial_opts229 metadata += "EXTRA_SERIAL_OPTIONS=%s\n" % self.extra_serial_opts
230 if self.samsung_bl1_start is not None:
231 metadata += "SAMSUNG_BL1_START=%s\n" % self.samsung_bl1_start
232 if self.samsung_bl1_len is not None:
233 metadata += "SAMSUNG_BL1_LEN=%s\n" % self.samsung_bl1_len
234 if self.samsung_env_len is not None:
235 metadata += "SAMSUNG_ENV_LEN=%s\n" % self.samsung_env_len
236 if self.samsung_bl2_len is not None:
237 metadata += "SAMSUNG_BL2_LEN=%s\n" % self.samsung_bl2_len
217238
218 return metadata239 return metadata
219240
220241
=== modified file 'linaro_image_tools/media_create/android_boards.py'
--- linaro_image_tools/media_create/android_boards.py 2011-08-24 14:47:20 +0000
+++ linaro_image_tools/media_create/android_boards.py 2011-08-29 12:19:23 +0000
@@ -26,9 +26,6 @@
2626
27from linaro_image_tools.media_create.partitions import SECTOR_SIZE27from linaro_image_tools.media_create.partitions import SECTOR_SIZE
28from linaro_image_tools.media_create.boards import PART_ALIGN_S28from linaro_image_tools.media_create.boards import PART_ALIGN_S
29from linaro_image_tools.media_create.boards import SAMSUNG_V310_BL1_START
30from linaro_image_tools.media_create.boards import SAMSUNG_V310_BL2_START
31from linaro_image_tools.media_create.boards import SAMSUNG_V310_BL2_LEN
32from linaro_image_tools.media_create.boards import BeagleConfig29from linaro_image_tools.media_create.boards import BeagleConfig
33from linaro_image_tools.media_create.boards import PandaConfig30from linaro_image_tools.media_create.boards import PandaConfig
34from linaro_image_tools.media_create.boards import Mx53LoCoConfig31from linaro_image_tools.media_create.boards import Mx53LoCoConfig
@@ -251,8 +248,8 @@
251 @classmethod248 @classmethod
252 def get_sfdisk_cmd(cls, should_align_boot_part=False):249 def get_sfdisk_cmd(cls, should_align_boot_part=False):
253 loaders_min_len = (250 loaders_min_len = (
254 SAMSUNG_V310_BL2_START + SAMSUNG_V310_BL2_LEN -251 cls.SAMSUNG_V310_BL2_START + cls.SAMSUNG_V310_BL2_LEN -
255 SAMSUNG_V310_BL1_START)252 cls.SAMSUNG_V310_BL1_START)
256253
257 loader_start, loader_end, loader_len = align_partition(254 loader_start, loader_end, loader_len = align_partition(
258 1, loaders_min_len, 1, PART_ALIGN_S)255 1, loaders_min_len, 1, PART_ALIGN_S)
259256
=== modified file 'linaro_image_tools/media_create/boards.py'
--- linaro_image_tools/media_create/boards.py 2011-08-25 09:57:46 +0000
+++ linaro_image_tools/media_create/boards.py 2011-08-29 12:19:23 +0000
@@ -69,38 +69,6 @@
69 """Round value to the next multiple of align."""69 """Round value to the next multiple of align."""
70 return (value + align - 1) / align * align70 return (value + align - 1) / align * align
7171
72# Samsung v310 implementation notes and terminology
73#
74# * BL0, BL1 etc. are the various bootloaders in order of execution
75# * BL0 is the first stage bootloader, located in ROM; it loads a 32s long BL1
76# from MMC offset +1s and runs it
77# * BL1 is the secondary program loader (SPL), a small (< 14k) version of
78# U-Boot with a checksum; it inits DRAM and loads a 1024s long BL2 to DRAM
79# from MMC offset +65s
80# * BL2 is U-Boot; it loads its 32s (16 KiB) long environment from MMC offset
81# +33s which tells it to load a boot.scr from the first FAT partition of the
82# MMC
83#
84# Layout:
85# +0s: part table / MBR, 1s long
86# +1s: BL1/SPL, 32s long
87# +33s: U-Boot environment, 32s long
88# +65s: U-Boot, 1024s long
89# >= +1089s: FAT partition with boot script (boot.scr), kernel (uImage) and
90# initrd (uInitrd)
91SAMSUNG_V310_BL1_START = 1
92SAMSUNG_V310_BL1_LEN = 32
93SAMSUNG_V310_ENV_START = SAMSUNG_V310_BL1_START + SAMSUNG_V310_BL1_LEN
94SAMSUNG_V310_ENV_LEN = 32
95assert SAMSUNG_V310_ENV_START == 33, "BL1 expects u-boot environment at +33s"
96assert SAMSUNG_V310_ENV_LEN * SECTOR_SIZE == 16 * 1024, (
97 "BL1 expects u-boot environment to be 16 KiB")
98SAMSUNG_V310_BL2_START = SAMSUNG_V310_ENV_START + SAMSUNG_V310_ENV_LEN
99SAMSUNG_V310_BL2_LEN = 1024
100assert SAMSUNG_V310_BL2_LEN * SECTOR_SIZE == 512 * 1024, (
101 "BL1 expects BL2 (u-boot) to be 512 KiB")
102
103
104def align_partition(min_start, min_length, start_alignment, end_alignment):72def align_partition(min_start, min_length, start_alignment, end_alignment):
105 """Compute partition start and end offsets based on specified constraints.73 """Compute partition start and end offsets based on specified constraints.
10674
@@ -254,6 +222,37 @@
254 vmlinuz = None222 vmlinuz = None
255 initrd = None223 initrd = None
256224
225 # Samsung v310 implementation notes and terminology
226 #
227 # * BL0, BL1 etc. are the various bootloaders in order of execution
228 # * BL0 is the first stage bootloader, located in ROM; it loads a 32s long BL1
229 # from MMC offset +1s and runs it
230 # * BL1 is the secondary program loader (SPL), a small (< 14k) version of
231 # U-Boot with a checksum; it inits DRAM and loads a 1024s long BL2 to DRAM
232 # from MMC offset +65s
233 # * BL2 is U-Boot; it loads its 32s (16 KiB) long environment from MMC offset
234 # +33s which tells it to load a boot.scr from the first FAT partition of the
235 # MMC
236 #
237 # Layout:
238 # +0s: part table / MBR, 1s long
239 # +1s: BL1/SPL, 32s long
240 # +33s: U-Boot environment, 32s long
241 # +65s: U-Boot, 1024s long
242 # >= +1089s: FAT partition with boot script (boot.scr), kernel (uImage) and
243 # initrd (uInitrd)
244 SAMSUNG_V310_BL1_START = 1
245 SAMSUNG_V310_BL1_LEN = 32
246 SAMSUNG_V310_ENV_START = SAMSUNG_V310_BL1_START + SAMSUNG_V310_BL1_LEN
247 SAMSUNG_V310_ENV_LEN = 32
248 assert SAMSUNG_V310_ENV_START == 33, "BL1 expects u-boot environment at +33s"
249 assert SAMSUNG_V310_ENV_LEN * SECTOR_SIZE == 16 * 1024, (
250 "BL1 expects u-boot environment to be 16 KiB")
251 SAMSUNG_V310_BL2_START = SAMSUNG_V310_ENV_START + SAMSUNG_V310_ENV_LEN
252 SAMSUNG_V310_BL2_LEN = 1024
253 assert SAMSUNG_V310_BL2_LEN * SECTOR_SIZE == 512 * 1024, (
254 "BL1 expects BL2 (u-boot) to be 512 KiB")
255
257 hardwarepack_handler = None256 hardwarepack_handler = None
258257
259 @classmethod258 @classmethod
@@ -285,6 +284,12 @@
285 cls.extra_boot_args_options = None284 cls.extra_boot_args_options = None
286 cls.boot_script = None285 cls.boot_script = None
287 cls.kernel_flavors = None286 cls.kernel_flavors = None
287 cls.SAMSUNG_V310_BL1_START = None
288 cls.SAMSUNG_V310_BL1_LEN = None
289 cls.SAMSUNG_V310_ENV_START = None
290 cls.SAMSUNG_V310_ENV_LEN = None
291 cls.SAMSUNG_V310_BL2_START = None
292 cls.SAMSUNG_V310_BL2_LEN = None
288293
289 # Set new values from metadata.294 # Set new values from metadata.
290 cls.kernel_addr = cls.get_metadata_field('kernel_addr')295 cls.kernel_addr = cls.get_metadata_field('kernel_addr')
@@ -332,6 +337,32 @@
332 elif string.lower(uboot_in_boot_part) == 'no':337 elif string.lower(uboot_in_boot_part) == 'no':
333 cls.uboot_in_boot_part = False338 cls.uboot_in_boot_part = False
334339
340 samsung_bl1_start = cls.get_metadata_field('samsung_bl1_start')
341 if samsung_bl1_start is not None:
342 cls.SAMSUNG_V310_BL1_START = int(samsung_bl1_start)
343 samsung_bl1_len = cls.get_metadata_field('samsung_bl1_len')
344 if samsung_bl1_len is not None:
345 cls.SAMSUNG_V310_BL1_LEN = int(samsung_bl1_len)
346 samsung_env_len = cls.get_metadata_field('samsung_env_len')
347 if samsung_env_len is not None:
348 cls.SAMSUNG_V310_ENV_LEN = int(samsung_env_len)
349 assert cls.SAMSUNG_V310_ENV_LEN * SECTOR_SIZE == 16 * 1024, (
350 "BL1 expects u-boot environment to be 16 KiB")
351 samsung_bl2_len = cls.get_metadata_field('samsung_bl2_len')
352 if samsung_bl2_len is not None:
353 cls.SAMSUNG_V310_BL2_LEN = int(samsung_bl2_len)
354 assert cls.SAMSUNG_V310_BL2_LEN * SECTOR_SIZE == 512 * 1024, (
355 "BL1 expects BL2 (u-boot) to be 512 KiB")
356
357 if (cls.SAMSUNG_V310_BL1_START and cls.SAMSUNG_V310_BL1_LEN):
358 cls.SAMSUNG_V310_ENV_START = (cls.SAMSUNG_V310_BL1_START +
359 cls.SAMSUNG_V310_BL1_LEN)
360 assert cls.SAMSUNG_V310_ENV_START == 33, (
361 "BL1 expects u-boot environment at +33s")
362 if (cls.SAMSUNG_V310_ENV_START and cls.SAMSUNG_V310_ENV_LEN):
363 cls.SAMSUNG_V310_BL2_START = (cls.SAMSUNG_V310_ENV_START +
364 cls.SAMSUNG_V310_ENV_LEN)
365
335 @classmethod366 @classmethod
336 def get_file(cls, file_alias, default=None):367 def get_file(cls, file_alias, default=None):
337 file_in_hwpack = cls.hardwarepack_handler.get_file(file_alias)368 file_in_hwpack = cls.hardwarepack_handler.get_file(file_alias)
@@ -1023,8 +1054,8 @@
1023 def get_sfdisk_cmd(cls, should_align_boot_part=False):1054 def get_sfdisk_cmd(cls, should_align_boot_part=False):
1024 # bootloaders partition needs to hold BL1, U-Boot environment, and BL21055 # bootloaders partition needs to hold BL1, U-Boot environment, and BL2
1025 loaders_min_len = (1056 loaders_min_len = (
1026 SAMSUNG_V310_BL2_START + SAMSUNG_V310_BL2_LEN -1057 cls.SAMSUNG_V310_BL2_START + cls.SAMSUNG_V310_BL2_LEN -
1027 SAMSUNG_V310_BL1_START)1058 cls.SAMSUNG_V310_BL1_START)
10281059
1029 # bootloaders partition1060 # bootloaders partition
1030 loaders_start, loaders_end, loaders_len = align_partition(1061 loaders_start, loaders_end, loaders_len = align_partition(
@@ -1049,9 +1080,9 @@
1049 boot_device_or_file, k_img_data, i_img_data,1080 boot_device_or_file, k_img_data, i_img_data,
1050 d_img_data):1081 d_img_data):
1051 cls.install_samsung_boot_loader(chroot_dir, boot_device_or_file)1082 cls.install_samsung_boot_loader(chroot_dir, boot_device_or_file)
1052 env_size = SAMSUNG_V310_ENV_LEN * SECTOR_SIZE1083 env_size = cls.SAMSUNG_V310_ENV_LEN * SECTOR_SIZE
1053 env_file = make_flashable_env(boot_env, env_size)1084 env_file = make_flashable_env(boot_env, env_size)
1054 _dd(env_file, boot_device_or_file, seek=SAMSUNG_V310_ENV_START)1085 _dd(env_file, boot_device_or_file, seek=cls.SAMSUNG_V310_ENV_START)
10551086
1056 make_uImage(cls.load_addr, k_img_data, boot_dir)1087 make_uImage(cls.load_addr, k_img_data, boot_dir)
1057 make_uInitrd(i_img_data, boot_dir)1088 make_uInitrd(i_img_data, boot_dir)
@@ -1086,38 +1117,40 @@
1086 'u-boot.bin')1117 'u-boot.bin')
1087 return uboot_file1118 return uboot_file
10881119
1089
1090 @classmethod1120 @classmethod
1091 def populate_raw_partition(cls, chroot_dir, boot_device_or_file):1121 def populate_raw_partition(cls, chroot_dir, boot_device_or_file):
1092 # Zero the env so that the boot_script will get loaded1122 # Zero the env so that the boot_script will get loaded
1093 _dd("/dev/zero", boot_device_or_file, count=SAMSUNG_V310_ENV_LEN,1123 _dd("/dev/zero", boot_device_or_file, count=cls.SAMSUNG_V310_ENV_LEN,
1094 seek=SAMSUNG_V310_ENV_START)1124 seek=cls.SAMSUNG_V310_ENV_START)
1095 # Populate created raw partition with BL1 and u-boot1125 # Populate created raw partition with BL1 and u-boot
1096 spl_file = os.path.join(chroot_dir, 'boot', 'u-boot-mmc-spl.bin')1126 spl_file = os.path.join(chroot_dir, 'boot', 'u-boot-mmc-spl.bin')
1097 assert os.path.getsize(spl_file) <= (SAMSUNG_V310_BL1_LEN * SECTOR_SIZE), (1127 assert os.path.getsize(spl_file) <= (cls.SAMSUNG_V310_BL1_LEN * SECTOR_SIZE), (
1098 "%s is larger than SAMSUNG_V310_BL1_LEN" % spl_file)1128 "%s is larger than SAMSUNG_V310_BL1_LEN" % spl_file)
1099 _dd(spl_file, boot_device_or_file, seek=SAMSUNG_V310_BL1_START)1129 _dd(spl_file, boot_device_or_file, seek=cls.SAMSUNG_V310_BL1_START)
1100 uboot_file = os.path.join(chroot_dir, 'boot', 'u-boot.bin')1130 uboot_file = os.path.join(chroot_dir, 'boot', 'u-boot.bin')
1101 assert os.path.getsize(uboot_file) <= (SAMSUNG_V310_BL2_LEN * SECTOR_SIZE), (1131 assert os.path.getsize(uboot_file) <= (cls.SAMSUNG_V310_BL2_LEN * SECTOR_SIZE), (
1102 "%s is larger than SAMSUNG_V310_BL2_LEN" % uboot_file)1132 "%s is larger than SAMSUNG_V310_BL2_LEN" % uboot_file)
1103 _dd(uboot_file, boot_device_or_file, seek=SAMSUNG_V310_BL2_START)1133 _dd(uboot_file, boot_device_or_file, seek=cls.SAMSUNG_V310_BL2_START)
11041134
11051135
1106 @classmethod1136 @classmethod
1107 def install_samsung_boot_loader(cls, chroot_dir, boot_device_or_file):1137 def install_samsung_boot_loader(cls, chroot_dir, boot_device_or_file):
1108 spl_file = cls._get_samsung_spl(chroot_dir)
1109 bl1_max_size = SAMSUNG_V310_BL1_LEN * SECTOR_SIZE
1110 assert os.path.getsize(spl_file) <= bl1_max_size, (
1111 "%s is larger than %s" % (spl_file, bl1_max_size))
1112 _dd(spl_file, boot_device_or_file, seek=SAMSUNG_V310_BL1_START)
1113
1114 with cls.hardwarepack_handler:1138 with cls.hardwarepack_handler:
1139 try:
1140 default = cls._get_samsung_spl(chroot_dir)
1141 except AssertionError:
1142 default = None
1143 spl_file = cls.get_file('spl', default=default)
1144 bl1_max_size = cls.SAMSUNG_V310_BL1_LEN * SECTOR_SIZE
1145 assert os.path.getsize(spl_file) <= bl1_max_size, (
1146 "%s is larger than %s" % (spl_file, bl1_max_size))
1147 _dd(spl_file, boot_device_or_file, seek=cls.SAMSUNG_V310_BL1_START)
1115 uboot_file = cls.get_file(1148 uboot_file = cls.get_file(
1116 'u_boot', default=cls._get_samsung_uboot(chroot_dir))1149 'u_boot', default=cls._get_samsung_uboot(chroot_dir))
1117 bl2_max_size = SAMSUNG_V310_BL2_LEN * SECTOR_SIZE1150 bl2_max_size = cls.SAMSUNG_V310_BL2_LEN * SECTOR_SIZE
1118 assert os.path.getsize(uboot_file) <= bl2_max_size, (1151 assert os.path.getsize(uboot_file) <= bl2_max_size, (
1119 "%s is larger than %s" % (uboot_file, bl2_max_size))1152 "%s is larger than %s" % (uboot_file, bl2_max_size))
1120 _dd(uboot_file, boot_device_or_file, seek=SAMSUNG_V310_BL2_START)1153 _dd(uboot_file, boot_device_or_file, seek=cls.SAMSUNG_V310_BL2_START)
11211154
11221155
1123class SMDKV310Config(SamsungConfig):1156class SMDKV310Config(SamsungConfig):
11241157
=== modified file 'linaro_image_tools/media_create/tests/test_media_create.py'
--- linaro_image_tools/media_create/tests/test_media_create.py 2011-08-25 09:57:46 +0000
+++ linaro_image_tools/media_create/tests/test_media_create.py 2011-08-29 12:19:23 +0000
@@ -44,8 +44,6 @@
44 android_boards,44 android_boards,
45 )45 )
46from linaro_image_tools.media_create.boards import (46from linaro_image_tools.media_create.boards import (
47 SAMSUNG_V310_BL1_START,
48 SAMSUNG_V310_BL2_START,
49 SECTOR_SIZE,47 SECTOR_SIZE,
50 align_up,48 align_up,
51 align_partition,49 align_partition,
@@ -1505,9 +1503,9 @@
1505 "chroot_dir", "boot_disk")1503 "chroot_dir", "boot_disk")
1506 expected = [1504 expected = [
1507 '%s dd if=chroot_dir/%s/SPL of=boot_disk bs=512 conv=notrunc '1505 '%s dd if=chroot_dir/%s/SPL of=boot_disk bs=512 conv=notrunc '
1508 'seek=%d' % (sudo_args, uboot_flavor, SAMSUNG_V310_BL1_START),1506 'seek=%d' % (sudo_args, uboot_flavor, boards.SMDKV310Config.SAMSUNG_V310_BL1_START),
1509 '%s dd if=chroot_dir/%s/uboot of=boot_disk bs=512 conv=notrunc '1507 '%s dd if=chroot_dir/%s/uboot of=boot_disk bs=512 conv=notrunc '
1510 'seek=%d' % (sudo_args, uboot_flavor, SAMSUNG_V310_BL2_START)]1508 'seek=%d' % (sudo_args, uboot_flavor, boards.SMDKV310Config.SAMSUNG_V310_BL2_START)]
1511 self.assertEqual(expected, fixture.mock.commands_executed)1509 self.assertEqual(expected, fixture.mock.commands_executed)
15121510
1513 def test_install_origen_u_boot(self):1511 def test_install_origen_u_boot(self):
@@ -1531,9 +1529,9 @@
1531 "chroot_dir", "boot_disk")1529 "chroot_dir", "boot_disk")
1532 expected = [1530 expected = [
1533 '%s dd if=chroot_dir/%s/SPL of=boot_disk bs=512 conv=notrunc '1531 '%s dd if=chroot_dir/%s/SPL of=boot_disk bs=512 conv=notrunc '
1534 'seek=%d' % (sudo_args, uboot_flavor, SAMSUNG_V310_BL1_START),1532 'seek=%d' % (sudo_args, uboot_flavor, boards.OrigenConfig.SAMSUNG_V310_BL1_START),
1535 '%s dd if=chroot_dir/%s/uboot of=boot_disk bs=512 conv=notrunc '1533 '%s dd if=chroot_dir/%s/uboot of=boot_disk bs=512 conv=notrunc '
1536 'seek=%d' % (sudo_args, uboot_flavor, SAMSUNG_V310_BL2_START)]1534 'seek=%d' % (sudo_args, uboot_flavor, boards.OrigenConfig.SAMSUNG_V310_BL2_START)]
1537 self.assertEqual(expected, fixture.mock.commands_executed)1535 self.assertEqual(expected, fixture.mock.commands_executed)
15381536
1539 def test_get_plain_boot_script_contents(self):1537 def test_get_plain_boot_script_contents(self):

Subscribers

People subscribed via source and target branches