=== modified file 'linaro_image_tools/hwpack/config.py'
@@ -71,7 +71,9 @@
SAMSUNG_BL1_LEN_FIELD,
SAMSUNG_BL1_START_FIELD,
SAMSUNG_BL2_LEN_FIELD,
+ SAMSUNG_BL2_START_FIELD,
SAMSUNG_ENV_LEN_FIELD,
+ SAMSUNG_ENV_START_FIELD,
SERIAL_TTY_FIELD,
SNOWBALL_STARTUP_FILES_CONFIG_FIELD,
SOURCES_FIELD,
@@ -298,7 +300,9 @@
self._validate_snowball_startup_files_config()
self._validate_samsung_bl1_start()
self._validate_samsung_bl1_len()
+ self._validate_samsung_env_start()
self._validate_samsung_env_len()
+ self._validate_samsung_bl2_start()
self._validate_samsung_bl2_len()
self._validate_sources()
@@ -867,6 +871,14 @@
return self._get_option(SAMSUNG_BL1_LEN_FIELD)
@property
+ def samsung_env_start(self):
+ """Env start offset for Samsung boards.
+
+ A str.
+ """
+ return self._get_option(SAMSUNG_ENV_START_FIELD)
+
+ @property
def samsung_env_len(self):
"""Env length for Samsung boards.
@@ -875,6 +887,14 @@
return self._get_option(SAMSUNG_ENV_LEN_FIELD)
@property
+ def samsung_bl2_start(self):
+ """BL2 start offset for Samsung boards.
+
+ A str.
+ """
+ return self._get_option(SAMSUNG_BL2_START_FIELD)
+
+ @property
def samsung_bl2_len(self):
"""BL2 length for Samsung boards.
@@ -1269,6 +1289,16 @@
raise HwpackConfigError(
"Invalid samsung_bl1_len %s" % (samsung_bl1_len))
+ def _validate_samsung_env_start(self):
+ samsung_env_start = self.samsung_env_start
+ if samsung_env_start is None:
+ return
+ try:
+ assert int(samsung_env_start) > 0
+ except:
+ raise HwpackConfigError(
+ "Invalid samsung_env_start %s" % (samsung_env_start))
+
def _validate_samsung_env_len(self):
samsung_env_len = self.samsung_env_len
if samsung_env_len is None:
@@ -1279,6 +1309,16 @@
raise HwpackConfigError(
"Invalid samsung_env_len %s" % (samsung_env_len))
+ def _validate_samsung_bl2_start(self):
+ samsung_bl2_start = self.samsung_bl2_start
+ if samsung_bl2_start is None:
+ return
+ try:
+ assert int(samsung_bl2_start) > 0
+ except:
+ raise HwpackConfigError(
+ "Invalid samsung_bl2_start %s" % (samsung_bl2_start))
+
def _validate_samsung_bl2_len(self):
samsung_bl2_len = self.samsung_bl2_len
if samsung_bl2_len is None:
=== modified file 'linaro_image_tools/hwpack/hardwarepack.py'
@@ -64,7 +64,9 @@
SAMSUNG_BL1_LEN_FIELD,
SAMSUNG_BL1_START_FIELD,
SAMSUNG_BL2_LEN_FIELD,
+ SAMSUNG_BL2_START_FIELD,
SAMSUNG_ENV_LEN_FIELD,
+ SAMSUNG_ENV_START_FIELD,
SERIAL_TTY_FIELD,
SNOWBALL_STARTUP_FILES_CONFIG_FIELD,
SUPPORT_FIELD,
@@ -129,7 +131,8 @@
extra_serial_opts=None, loader_start=None,
snowball_startup_files_config=None,
samsung_bl1_start=None, samsung_bl1_len=None,
- samsung_env_len=None, samsung_bl2_len=None):
+ samsung_env_start=None, samsung_env_len=None,
+ samsung_bl2_start=None, samsung_bl2_len=None):
"""Add fields that are specific to the new format.
These fields are not present in earlier config files.
@@ -163,7 +166,9 @@
self.snowball_startup_files_config = snowball_startup_files_config
self.samsung_bl1_start = samsung_bl1_start
self.samsung_bl1_len = samsung_bl1_len
+ self.samsung_env_start = samsung_env_start
self.samsung_env_len = samsung_env_len
+ self.samsung_bl2_start = samsung_bl2_start
self.samsung_bl2_len = samsung_bl2_len
@classmethod
@@ -224,7 +229,9 @@
samsung_bl1_len=config.samsung_bl1_len,
samsung_bl1_start=config.samsung_bl1_start,
samsung_bl2_len=config.samsung_bl2_len,
+ samsung_bl2_start=config.samsung_bl2_start,
samsung_env_len=config.samsung_env_len,
+ samsung_env_start=config.samsung_env_start,
serial_tty=config.serial_tty,
snowball_startup_files_config=snowball_startup_config,
spl_dd=config.spl_dd,
@@ -329,8 +336,12 @@
metadata += dump({SAMSUNG_BL1_START_FIELD: self.samsung_bl1_start})
if self.samsung_bl1_len is not None:
metadata += dump({SAMSUNG_BL1_LEN_FIELD: self.samsung_bl1_len})
+ if self.samsung_env_start is not None:
+ metadata += dump({SAMSUNG_ENV_START_FIELD: self.samsung_env_start})
if self.samsung_env_len is not None:
metadata += dump({SAMSUNG_ENV_LEN_FIELD: self.samsung_env_len})
+ if self.samsung_bl2_start is not None:
+ metadata += dump({SAMSUNG_BL2_START_FIELD: self.samsung_bl2_start})
if self.samsung_bl2_len is not None:
metadata += dump({SAMSUNG_BL2_LEN_FIELD: self.samsung_bl2_len})
return metadata
@@ -415,8 +426,12 @@
metadata += "SAMSUNG_BL1_START=%s\n" % self.samsung_bl1_start
if self.samsung_bl1_len is not None:
metadata += "SAMSUNG_BL1_LEN=%s\n" % self.samsung_bl1_len
+ if self.samsung_env_start is not None:
+ metadata += "SAMSUNG_ENV_START=%s\n" % self.samsung_env_start
if self.samsung_env_len is not None:
metadata += "SAMSUNG_ENV_LEN=%s\n" % self.samsung_env_len
+ if self.samsung_bl2_start is not None:
+ metadata += "SAMSUNG_BL2_START=%s\n" % self.samsung_bl2_start
if self.samsung_bl2_len is not None:
metadata += "SAMSUNG_BL2_LEN=%s\n" % self.samsung_bl2_len
return metadata
=== modified file 'linaro_image_tools/hwpack/hwpack_fields.py'
@@ -76,7 +76,9 @@
SAMSUNG_BL1_LEN_FIELD = 'samsung_bl1_len'
SAMSUNG_BL1_START_FIELD = 'samsung_bl1_start'
SAMSUNG_BL2_LEN_FIELD = 'samsung_bl2_len'
+SAMSUNG_BL2_START_FIELD = 'samsung_bl2_start'
SAMSUNG_ENV_LEN_FIELD = 'samsung_env_len'
+SAMSUNG_ENV_START_FIELD = 'samsung_env_start'
# Snowball fields
SNOWBALL_STARTUP_FILES_CONFIG_FIELD = 'snowball_startup_files_config'
@@ -142,7 +144,9 @@
SAMSUNG_BL1_LEN_FIELD: None,
SAMSUNG_BL1_START_FIELD: None,
SAMSUNG_ENV_LEN_FIELD: None,
+ SAMSUNG_ENV_START_FIELD: None,
SAMSUNG_BL2_LEN_FIELD: None,
+ SAMSUNG_BL2_START_FIELD: None,
SNOWBALL_STARTUP_FILES_CONFIG_FIELD: None,
SOURCES_FIELD: None,
BOOTLOADERS_FIELD: {
=== modified file 'linaro_image_tools/hwpack/tests/test_config_v3.py'
@@ -29,7 +29,9 @@
SAMSUNG_BL1_LEN_FIELD,
SAMSUNG_BL1_START_FIELD,
SAMSUNG_BL2_LEN_FIELD,
+ SAMSUNG_BL2_START_FIELD,
SAMSUNG_ENV_LEN_FIELD,
+ SAMSUNG_ENV_START_FIELD,
)
@@ -816,11 +818,21 @@
SAMSUNG_BL2_LEN_FIELD + ': 1\n')
self.assertEqual(None, config._validate_keys())
+ def test_valid_samsung_bl2_start_field(self):
+ config = self.get_config(self.valid_start_v3 +
+ SAMSUNG_BL2_START_FIELD + ': 1\n')
+ self.assertEqual(None, config._validate_keys())
+
def test_valid_samsung_env_len_field(self):
config = self.get_config(self.valid_start_v3 +
SAMSUNG_ENV_LEN_FIELD + ': 1\n')
self.assertEqual(None, config._validate_keys())
+ def test_valid_samsung_env_start_field(self):
+ config = self.get_config(self.valid_start_v3 +
+ SAMSUNG_ENV_START_FIELD + ': 1\n')
+ self.assertEqual(None, config._validate_keys())
+
def test_samsung_field_wrong(self):
config = self.get_config(self.valid_start_v3 +
'samsung_wrong_field: 1\n')
=== modified file 'linaro_image_tools/media_create/android_boards.py'
@@ -323,8 +323,8 @@
@classmethod
def get_sfdisk_cmd(cls, should_align_boot_part=False):
loaders_min_len = (
- cls.SAMSUNG_V310_BL2_START + cls.SAMSUNG_V310_BL2_LEN -
- cls.SAMSUNG_V310_BL1_START)
+ cls.samsung_bl1_start + cls.samsung_bl1_len + cls.samsung_bl2_len +
+ cls.samsung_env_len)
loader_start, loader_end, loader_len = align_partition(
1, loaders_min_len, 1, PART_ALIGN_S)
=== modified file 'linaro_image_tools/media_create/boards.py'
@@ -163,37 +163,26 @@
# Support for dtb_files as per hwpack v3 format.
dtb_files = None
- # Samsung v310 implementation notes and terminology
+ # Samsung Boot-loader implementation notes and terminology
#
# * BL0, BL1 etc. are the various bootloaders in order of execution
- # * BL0 is the first stage bootloader, located in ROM; it loads a 32s
- # long BL1 from MMC offset +1s and runs it
- # * BL1 is the secondary program loader (SPL), a small (< 14k) version
+ # * BL0 is the first stage bootloader, located in ROM; it loads BL1/SPL
+ # from MMC offset +1s and runs it.
+ # * BL1 is the secondary program loader (SPL), a small version
# of U-Boot with a checksum; it inits DRAM and loads a 1024s long BL2
- # to DRAM from MMC offset +65s
- # * BL2 is U-Boot; it loads its 32s (16 KiB) long environment from MMC
- # offset +33s which tells it to load a boot.scr from the first FAT
- # partition of the MMC
- #
- # Layout:
- # +0s: part table / MBR, 1s long
- # +1s: BL1/SPL, 32s long
- # +33s: U-Boot environment, 32s long
- # +65s: U-Boot, 1024s long
- # >= +1089s: FAT partition with boot script (boot.scr), kernel (uImage)
- # and initrd (uInitrd)
- SAMSUNG_V310_BL1_START = 1
- SAMSUNG_V310_BL1_LEN = 32
- SAMSUNG_V310_ENV_START = SAMSUNG_V310_BL1_START + SAMSUNG_V310_BL1_LEN
- SAMSUNG_V310_ENV_LEN = 32
- assert SAMSUNG_V310_ENV_START == 33, (
- "BL1 expects u-boot environment at +33s")
- assert SAMSUNG_V310_ENV_LEN * SECTOR_SIZE == 16 * 1024, (
- "BL1 expects u-boot environment to be 16 KiB")
- SAMSUNG_V310_BL2_START = SAMSUNG_V310_ENV_START + SAMSUNG_V310_ENV_LEN
- SAMSUNG_V310_BL2_LEN = 1024
- assert SAMSUNG_V310_BL2_LEN * SECTOR_SIZE == 512 * 1024, (
- "BL1 expects BL2 (u-boot) to be 512 KiB")
+ # from MMC and runs it.
+ # * BL2 is the U-Boot.
+ #
+ # samsung_bl1_{start,len}: Offset and maximum size for BL1
+ # samsung_bl2_{start,len}: Offset and maximum size for BL2
+ # samsung_env_{start,len}: Offset and maximum size for Environment settings
+ #
+ samsung_bl1_start = 1
+ samsung_bl1_len = 32
+ samsung_bl2_start = 65
+ samsung_bl2_len = 1024
+ samsung_env_start = 33
+ samsung_env_len = 32
hardwarepack_handler = None
@@ -231,12 +220,12 @@
cls.kernel_flavors = None
cls.mmc_option = None
cls.mmc_part_offset = None
- cls.SAMSUNG_V310_BL1_START = None
- cls.SAMSUNG_V310_BL1_LEN = None
- cls.SAMSUNG_V310_ENV_START = None
- cls.SAMSUNG_V310_ENV_LEN = None
- cls.SAMSUNG_V310_BL2_START = None
- cls.SAMSUNG_V310_BL2_LEN = None
+ cls.samsung_bl1_start = None
+ cls.samsung_bl1_len = None
+ cls.samsung_env_len = None
+ cls.samsung_bl2_len = None
+ # cls.samsung_bl2_start and cls.samsung_env_start should
+ # be initialized to default value for backward compatibility.
# Set new values from metadata.
cls.kernel_addr = cls.get_metadata_field('kernel_addr')
@@ -332,31 +321,30 @@
loader_start = cls.get_metadata_field('loader_start')
if loader_start is not None:
cls.LOADER_START_S = int(loader_start)
+
samsung_bl1_start = cls.get_metadata_field('samsung_bl1_start')
if samsung_bl1_start is not None:
- cls.SAMSUNG_V310_BL1_START = int(samsung_bl1_start)
+ cls.samsung_bl1_start = int(samsung_bl1_start)
+
samsung_bl1_len = cls.get_metadata_field('samsung_bl1_len')
if samsung_bl1_len is not None:
- cls.SAMSUNG_V310_BL1_LEN = int(samsung_bl1_len)
+ cls.samsung_bl1_len = int(samsung_bl1_len)
+
+ samsung_bl2_len = cls.get_metadata_field('samsung_bl2_len')
+ if samsung_bl2_len is not None:
+ cls.samsung_bl2_len = int(samsung_bl2_len)
+
+ samsung_bl2_start = cls.get_metadata_field('samsung_bl2_start')
+ if samsung_bl2_start is not None:
+ cls.samsung_bl2_start = int(samsung_bl2_start)
+
samsung_env_len = cls.get_metadata_field('samsung_env_len')
if samsung_env_len is not None:
- cls.SAMSUNG_V310_ENV_LEN = int(samsung_env_len)
- assert cls.SAMSUNG_V310_ENV_LEN * SECTOR_SIZE == 16 * 1024, (
- "BL1 expects u-boot environment to be 16 KiB")
- samsung_bl2_len = cls.get_metadata_field('samsung_bl2_len')
- if samsung_bl2_len is not None:
- cls.SAMSUNG_V310_BL2_LEN = int(samsung_bl2_len)
- assert cls.SAMSUNG_V310_BL2_LEN * SECTOR_SIZE == 512 * 1024, (
- "BL1 expects BL2 (u-boot) to be 512 KiB")
+ cls.samsung_env_len = int(samsung_env_len)
- if (cls.SAMSUNG_V310_BL1_START and cls.SAMSUNG_V310_BL1_LEN):
- cls.SAMSUNG_V310_ENV_START = (cls.SAMSUNG_V310_BL1_START +
- cls.SAMSUNG_V310_BL1_LEN)
- assert cls.SAMSUNG_V310_ENV_START == 33, (
- "BL1 expects u-boot environment at +33s")
- if (cls.SAMSUNG_V310_ENV_START and cls.SAMSUNG_V310_ENV_LEN):
- cls.SAMSUNG_V310_BL2_START = (cls.SAMSUNG_V310_ENV_START +
- cls.SAMSUNG_V310_ENV_LEN)
+ samsung_env_start = cls.get_metadata_field('samsung_env_start')
+ if samsung_env_start is not None:
+ cls.samsung_env_start = int(samsung_env_start)
cls.bootloader_copy_files = cls.hardwarepack_handler.get_field(
"bootloader_copy_files")[0]
@@ -660,11 +648,11 @@
def install_samsung_boot_loader(cls, samsung_spl_file, bootloader_file,
boot_device_or_file):
cls._dd_file(samsung_spl_file, boot_device_or_file,
- cls.SAMSUNG_V310_BL1_START,
- cls.SAMSUNG_V310_BL1_LEN * SECTOR_SIZE)
+ cls.samsung_bl1_start,
+ cls.samsung_bl1_len * SECTOR_SIZE)
cls._dd_file(bootloader_file, boot_device_or_file,
- cls.SAMSUNG_V310_BL2_START,
- cls.SAMSUNG_V310_BL2_LEN * SECTOR_SIZE)
+ cls.samsung_bl2_start,
+ cls.samsung_bl2_len * SECTOR_SIZE)
@classmethod
def _make_boot_files_v2(cls, boot_env, chroot_dir, boot_dir,
@@ -712,12 +700,12 @@
if cls.env_dd:
# Do we need to zero out the env before flashing it?
_dd("/dev/zero", boot_device_or_file,
- count=cls.SAMSUNG_V310_ENV_LEN,
- seek=cls.SAMSUNG_V310_ENV_START)
- env_size = cls.SAMSUNG_V310_ENV_LEN * SECTOR_SIZE
+ count=cls.samsung_env_len,
+ seek=cls.samsung_env_start)
+ env_size = cls.samsung_env_len * SECTOR_SIZE
env_file = make_flashable_env(boot_env, env_size)
cls._dd_file(env_file, boot_device_or_file,
- cls.SAMSUNG_V310_ENV_START)
+ cls.samsung_env_start)
@classmethod
def _make_boot_files(cls, boot_env, chroot_dir, boot_dir,
@@ -1415,8 +1403,8 @@
def get_v1_sfdisk_cmd(cls, should_align_boot_part=False):
# bootloaders partition needs to hold BL1, U-Boot environment, and BL2
loaders_min_len = (
- cls.SAMSUNG_V310_BL2_START + cls.SAMSUNG_V310_BL2_LEN -
- cls.SAMSUNG_V310_BL1_START)
+ cls.samsung_bl1_start + cls.samsung_bl1_len + cls.samsung_bl2_len +
+ cls.samsung_env_len)
# bootloaders partition
loaders_start, loaders_end, loaders_len = align_partition(
@@ -1444,9 +1432,9 @@
assert cls.hwpack_format == HardwarepackHandler.FORMAT_1
cls.install_samsung_boot_loader(cls._get_samsung_spl(chroot_dir),
cls._get_samsung_bootloader(chroot_dir), boot_device_or_file)
- env_size = cls.SAMSUNG_V310_ENV_LEN * SECTOR_SIZE
+ env_size = cls.samsung_env_len * SECTOR_SIZE
env_file = make_flashable_env(boot_env, env_size)
- _dd(env_file, boot_device_or_file, seek=cls.SAMSUNG_V310_ENV_START)
+ _dd(env_file, boot_device_or_file, seek=cls.samsung_env_start)
make_uImage(cls.load_addr, k_img_data, boot_dir)
make_uInitrd(i_img_data, boot_dir)
@@ -1493,19 +1481,19 @@
@classmethod
def populate_raw_partition(cls, boot_device_or_file, chroot_dir):
# Zero the env so that the boot_script will get loaded
- _dd("/dev/zero", boot_device_or_file, count=cls.SAMSUNG_V310_ENV_LEN,
- seek=cls.SAMSUNG_V310_ENV_START)
+ _dd("/dev/zero", boot_device_or_file, count=cls.samsung_env_len,
+ seek=cls.samsung_env_start)
# Populate created raw partition with BL1 and u-boot
spl_file = os.path.join(chroot_dir, 'boot', 'u-boot-mmc-spl.bin')
assert os.path.getsize(spl_file) <= (
- cls.SAMSUNG_V310_BL1_LEN * SECTOR_SIZE), (
- "%s is larger than SAMSUNG_V310_BL1_LEN" % spl_file)
- _dd(spl_file, boot_device_or_file, seek=cls.SAMSUNG_V310_BL1_START)
+ cls.samsung_bl1_len * SECTOR_SIZE), (
+ "%s is larger than Samsung BL1 size" % spl_file)
+ _dd(spl_file, boot_device_or_file, seek=cls.samsung_bl1_start)
uboot_file = os.path.join(chroot_dir, 'boot', 'u-boot.bin')
assert os.path.getsize(uboot_file) <= (
- cls.SAMSUNG_V310_BL2_LEN * SECTOR_SIZE), (
- "%s is larger than SAMSUNG_V310_BL2_LEN" % uboot_file)
- _dd(uboot_file, boot_device_or_file, seek=cls.SAMSUNG_V310_BL2_START)
+ cls.samsung_bl2_len * SECTOR_SIZE), (
+ "%s is larger than Samsung BL2 size" % uboot_file)
+ _dd(uboot_file, boot_device_or_file, seek=cls.samsung_bl2_start)
class SMDKV310Config(SamsungConfig):
=== modified file 'linaro_image_tools/media_create/tests/test_media_create.py'
@@ -1664,9 +1664,10 @@
def test_smdkv310(self):
class config(board_configs['smdkv310']):
partition_layout = 'reserved_bootfs_rootfs'
- LOADER_MIN_SIZE_S = (boards.BoardConfig.SAMSUNG_V310_BL2_START +
- boards.BoardConfig.SAMSUNG_V310_BL2_LEN -
- boards.BoardConfig.SAMSUNG_V310_BL1_START)
+ LOADER_MIN_SIZE_S = (boards.BoardConfig.samsung_bl1_start +
+ boards.BoardConfig.samsung_bl1_len +
+ boards.BoardConfig.samsung_bl2_len +
+ boards.BoardConfig.samsung_env_len)
self.assertEquals(
'1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',
config.get_sfdisk_cmd())
@@ -1674,9 +1675,10 @@
def test_origen(self):
class config(board_configs['origen']):
partition_layout = 'reserved_bootfs_rootfs'
- LOADER_MIN_SIZE_S = (boards.BoardConfig.SAMSUNG_V310_BL2_START +
- boards.BoardConfig.SAMSUNG_V310_BL2_LEN -
- boards.BoardConfig.SAMSUNG_V310_BL1_START)
+ LOADER_MIN_SIZE_S = (boards.BoardConfig.samsung_bl1_start +
+ boards.BoardConfig.samsung_bl1_len +
+ boards.BoardConfig.samsung_bl2_len +
+ boards.BoardConfig.samsung_env_len)
self.assertEquals(
'1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-',
config.get_sfdisk_cmd())
@@ -2212,10 +2214,10 @@
expected = [
'%s dd if=chroot_dir/%s/SPL of=boot_disk bs=512 conv=notrunc '
'seek=%d' % (sudo_args, bootloader_flavor,
- boards.SMDKV310Config.SAMSUNG_V310_BL1_START),
+ boards.SMDKV310Config.samsung_bl1_start),
'%s dd if=chroot_dir/%s/uboot of=boot_disk bs=512 conv=notrunc '
'seek=%d' % (sudo_args, bootloader_flavor,
- boards.SMDKV310Config.SAMSUNG_V310_BL2_START)]
+ boards.SMDKV310Config.samsung_bl2_start)]
self.assertEqual(expected, fixture.mock.commands_executed)
def test_install_origen_u_boot(self):
@@ -2242,10 +2244,10 @@
expected = [
'%s dd if=chroot_dir/%s/SPL of=boot_disk bs=512 conv=notrunc '
'seek=%d' % (sudo_args, bootloader_flavor,
- boards.OrigenConfig.SAMSUNG_V310_BL1_START),
+ boards.OrigenConfig.samsung_bl1_start),
'%s dd if=chroot_dir/%s/uboot of=boot_disk bs=512 conv=notrunc '
'seek=%d' % (sudo_args, bootloader_flavor,
- boards.OrigenConfig.SAMSUNG_V310_BL2_START)]
+ boards.OrigenConfig.samsung_bl2_start)]
self.assertEqual(expected, fixture.mock.commands_executed)
def test_get_plain_boot_script_contents(self):