From patchwork Wed Apr 20 15:20:39 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: James Westby X-Patchwork-Id: 1132 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:49:25 -0000 Delivered-To: patches@linaro.org Received: by 10.224.67.148 with SMTP id r20cs117937qai; Wed, 20 Apr 2011 08:20:43 -0700 (PDT) Received: by 10.227.140.67 with SMTP id h3mr398227wbu.80.1303312843127; Wed, 20 Apr 2011 08:20:43 -0700 (PDT) Received: from adelie.canonical.com (adelie.canonical.com [91.189.90.139]) by mx.google.com with ESMTP id m9si2222715wer.130.2011.04.20.08.20.42; Wed, 20 Apr 2011 08:20:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.139 as permitted sender) client-ip=91.189.90.139; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.139 as permitted sender) smtp.mail=bounces@canonical.com Received: from loganberry.canonical.com ([91.189.90.37]) by adelie.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1QCZCq-0006ja-Jt for ; Wed, 20 Apr 2011 15:20:41 +0000 Received: from loganberry.canonical.com (localhost [127.0.0.1]) by loganberry.canonical.com (Postfix) with ESMTP id 5DF3C2E897C for ; Wed, 20 Apr 2011 15:20:39 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: linaro-image-tools X-Launchpad-Branch: ~linaro-maintainers/linaro-image-tools/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 320 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-maintainers/linaro-image-tools/trunk] Rev 320: Merge changes to s5pv310 support: Message-Id: <20110420152039.8026.63946.launchpad@loganberry.canonical.com> Date: Wed, 20 Apr 2011 15:20:39 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="12847"; Instance="initZopeless config overlay" X-Launchpad-Hash: 022c3f931cb1669f8d793c3e272b693812bcf8b3 Merge authors: Angus Ainslie (angus-akkea) Loïc Minier (lool) Loïc Minier (lool) Related merge proposals: https://code.launchpad.net/~linaro-landing-team-samsung/linaro-image-tools/linaro-image-tools/+merge/56381 proposed by: Angus Ainslie (angus-akkea) review: Approve - James Westby (james-w) review: Approve - Loïc Minier (lool) ------------------------------------------------------------ revno: 320 [merge] committer: James Westby branch nick: trunk timestamp: Wed 2011-04-20 11:17:28 -0400 message: Merge changes to s5pv310 support: - Use the new s5pv310 u-boot. - Load from the FAT partition like most other boards. modified: linaro_image_tools/media_create/boards.py linaro_image_tools/media_create/tests/test_media_create.py --- lp:linaro-image-tools https://code.launchpad.net/~linaro-maintainers/linaro-image-tools/trunk You are subscribed to branch lp:linaro-image-tools. To unsubscribe from this branch go to https://code.launchpad.net/~linaro-maintainers/linaro-image-tools/trunk/+edit-subscription === modified file 'linaro_image_tools/media_create/boards.py' --- linaro_image_tools/media_create/boards.py 2011-04-18 21:18:06 +0000 +++ linaro_image_tools/media_create/boards.py 2011-04-20 14:42:47 +0000 @@ -73,17 +73,25 @@ # root partition; at least 50 MiB; XXX this shouldn't be hardcoded ROOT_MIN_SIZE_S = align_up(50 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE -# Samsung v310 implementation notes -# * BL1 (SPL) is expected at offset +1s and is 32s long -# * BL2 (u-boot) is loaded at a raw MMC offset of +65s by BL1 which currently -# doesn't support FAT -# * the u-boot environment is at +33s and is 32s long (16 KiB) -# * currently, some hardware issues on certain boards causes u-boot to not be -# able to use FAT to load uImage and uInitrd (or boot.scr); as a temporary -# workaround, these are loaded from +1089s and +9281s respectively -# * hence we hardcode all offsets, make sure that the files aren't larger than -# their reserved spot, and create a bootloader partition from the first -# sector after MBR up to end of initrd +# Samsung v310 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 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 @@ -95,22 +103,6 @@ SAMSUNG_V310_BL2_LEN = 1024 assert SAMSUNG_V310_BL2_LEN * SECTOR_SIZE == 512 * 1024, ( "BL1 expects BL2 (u-boot) to be 512 KiB") -SAMSUNG_V310_UIMAGE_START = SAMSUNG_V310_BL2_START + SAMSUNG_V310_BL2_LEN -SAMSUNG_V310_UIMAGE_LEN = 8192 -assert SAMSUNG_V310_UIMAGE_START == 1089, ( - "BL2 (u-boot) expects uImage at +1089s") -assert SAMSUNG_V310_UIMAGE_LEN * SECTOR_SIZE == 4 * 1024 * 1024, ( - "BL2 (u-boot) expects uImage to be 4 MiB") -SAMSUNG_V310_UINITRD_START = ( - SAMSUNG_V310_UIMAGE_START + SAMSUNG_V310_UIMAGE_LEN) -SAMSUNG_V310_UINITRD_RESERVED_LEN = 204800 -SAMSUNG_V310_UINITRD_COPY_LEN = 32768 -assert SAMSUNG_V310_UINITRD_START == 9281, ( - "BL2 (u-boot) expects uInitrd at +9281s") -assert SAMSUNG_V310_UINITRD_RESERVED_LEN * SECTOR_SIZE == 100 * 1024 * 1024, ( - "BL2 (u-boot) expects uInitrd to be 100 MiB") -assert SAMSUNG_V310_UINITRD_COPY_LEN * SECTOR_SIZE == 16 * 1024 * 1024, ( - "Only copy 16MiB for a faster boot") def align_partition(min_start, min_length, start_alignment, end_alignment): """Compute partition start and end offsets based on specified constraints. @@ -176,7 +168,7 @@ BOOT_MIN_SIZE_S = align_up(50 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE ROOT_MIN_SIZE_S = align_up(50 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE - + # align on sector 63 for compatibility with broken versions of x-loader # unless align_boot_part is set boot_align = 63 @@ -243,9 +235,9 @@ _cache_end + 1, USERDATA_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) sdcard_start, _sdcard_end, _sdcard_len = align_partition( _userdata_end + 1, SDCARD_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) - + return '%s,%s,%s,*\n%s,%s,L\n%s,%s,L\n%s,-,E\n%s,%s,L\n%s,%s,L\n%s,,,-' % ( - boot_start, boot_len, partition_type, root_start, _root_len, + boot_start, boot_len, partition_type, root_start, _root_len, system_start, _system_len, cache_start, cache_start, _cache_len, userdata_start, _userdata_len, sdcard_start) @@ -658,10 +650,11 @@ make_uInitrd(i_img_data, boot_dir) class SMDKV310Config(BoardConfig): + uboot_flavor = 'smdkv310' serial_tty = 'ttySAC1' extra_serial_opts = 'console=%s,115200n8' % serial_tty kernel_addr = '0x40007000' - initrd_addr = '0x41000000' + initrd_addr = '0x42000000' load_addr = '0x40008000' kernel_flavors = ['s5pv310'] boot_script = 'boot.scr' @@ -670,19 +663,18 @@ @classmethod def get_sfdisk_cmd(cls, should_align_boot_part=False): - # bootloader partition needs to hold everything from BL1 to uInitrd - # inclusive - min_len = ( - SAMSUNG_V310_UINITRD_START + SAMSUNG_V310_UINITRD_RESERVED_LEN - + # bootloaders partition needs to hold BL1, U-Boot environment, and BL2 + loaders_min_len = ( + SAMSUNG_V310_BL2_START + SAMSUNG_V310_BL2_LEN - SAMSUNG_V310_BL1_START) - # bootloader partition - loader_start, loader_end, loader_len = align_partition( - 1, min_len, 1, PART_ALIGN_S) + # bootloaders partition + loaders_start, loaders_end, loaders_len = align_partition( + 1, loaders_min_len, 1, PART_ALIGN_S) # FAT boot partition boot_start, boot_end, boot_len = align_partition( - loader_end + 1, BOOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) + loaders_end + 1, BOOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) # root partition # we ignore _root_end / _root_len and return a sfdisk command to @@ -692,7 +684,7 @@ boot_end + 1, ROOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) return '%s,%s,0xDA\n%s,%s,0x0C,*\n%s,,,-' % ( - loader_start, loader_len, boot_start, boot_len, root_start) + loaders_start, loaders_len, boot_start, boot_len, root_start) @classmethod def _get_boot_env(cls, is_live, is_lowmem, consoles, rootfs_uuid, @@ -702,14 +694,6 @@ boot_env["ethact"] = "smc911x-0" boot_env["ethaddr"] = "00:40:5c:26:0a:5b" - # XXX fixme once FAT support is fixed in u-boot bug 727978 - boot_env["bootcmd"] = ( - "movi read kernel %(kernel_addr)s; " - "movi read rootfs %(initrd_addr)s %(rootfs_size)s; " - "bootm %(kernel_addr)s %(initrd_addr)s" % { - 'kernel_addr': cls.kernel_addr, - 'initrd_addr': cls.initrd_addr, - 'rootfs_size': hex(SAMSUNG_V310_UINITRD_COPY_LEN * SECTOR_SIZE)}) return boot_env @@ -717,23 +701,31 @@ def _make_boot_files(cls, boot_env, chroot_dir, boot_dir, boot_device_or_file, k_img_data, i_img_data, d_img_data): + spl_file = os.path.join( + chroot_dir, 'usr', 'lib', 'u-boot', cls.uboot_flavor, + 'v310_mmc_spl.bin') + # XXX need to check that the length of spl_file is smaller than + # SAMSUNG_V310_BL1_LEN + _dd(spl_file, boot_device_or_file, seek=SAMSUNG_V310_BL1_START) + uboot_file = os.path.join( - chroot_dir, 'usr', 'lib', 'u-boot', 'smdkv310', 'u-boot.v310') - install_smdkv310_boot_loader(uboot_file, boot_device_or_file) + chroot_dir, 'usr', 'lib', 'u-boot', cls.uboot_flavor, 'u-boot.bin') + # XXX need to check that the length of uboot_file is smaller than + # SAMSUNG_V310_BL2_LEN + _dd(uboot_file, boot_device_or_file, seek=SAMSUNG_V310_BL2_START) env_size = SAMSUNG_V310_ENV_LEN * SECTOR_SIZE env_file = make_flashable_env(boot_env, env_size) - install_smdkv310_boot_env(env_file, boot_device_or_file) + _dd(env_file, boot_device_or_file, seek=SAMSUNG_V310_ENV_START) - uImage_file = make_uImage(cls.load_addr, k_img_data, boot_dir) - install_smdkv310_uImage(uImage_file, boot_device_or_file) - uInitrd_file = make_uInitrd(i_img_data, boot_dir) - install_smdkv310_initrd(uInitrd_file, boot_device_or_file) + make_uImage(cls.load_addr, k_img_data, boot_dir) + make_uInitrd(i_img_data, boot_dir) + make_dtb(d_img_data, boot_dir) # unused at the moment once FAT support enabled for the # Samsung u-boot this can be used bug 727978 - #boot_script_path = os.path.join(boot_dir, cls.boot_script) - #make_boot_script(boot_env, boot_script_path) + boot_script_path = os.path.join(boot_dir, cls.boot_script) + make_boot_script(boot_env, boot_script_path) board_configs = { @@ -807,15 +799,12 @@ def make_uImage(load_addr, img_data, boot_disk): img = '%s/uImage' % boot_disk - _run_mkimage( - 'kernel', load_addr, load_addr, 'Linux', img_data, img) - return img + return _run_mkimage('kernel', load_addr, load_addr, 'Linux', img_data, img) def make_uInitrd(img_data, boot_disk): img = '%s/uInitrd' % boot_disk - _run_mkimage('ramdisk', '0', '0', 'initramfs', img_data, img) - return img + return _run_mkimage('ramdisk', '0', '0', 'initramfs', img_data, img) def make_dtb(img_data, boot_disk): @@ -918,53 +907,3 @@ as_root=True) proc.wait() - -def install_smdkv310_uImage(uImage_file, boot_device_or_file): - # the layout keeps SAMSUNG_V310_UIMAGE_LEN sectors for uImage; make sure - # uImage isn't actually larger or it would be truncated - max_size = SAMSUNG_V310_UIMAGE_LEN * SECTOR_SIZE - assert os.path.getsize(uImage_file) <= max_size, ( - "%s is larger than the allocated v310 uImage length" % uImage_file) - _dd(uImage_file, boot_device_or_file, count=SAMSUNG_V310_UIMAGE_LEN, - seek=SAMSUNG_V310_UIMAGE_START) - - -def install_smdkv310_initrd(initrd_file, boot_device_or_file): - # the layout keeps SAMSUNG_V310_UINITRD_RESERVED_LEN sectors for uInitrd - # but only SAMSUNG_V310_UINITRD_COPY_LEN sectors are loaded into memory; - # make sure uInitrd isn't actually larger or it would be truncated in - # memory - max_size = SAMSUNG_V310_UINITRD_COPY_LEN * SECTOR_SIZE - assert os.path.getsize(initrd_file) <= max_size, ( - "%s is larger than the v310 uInitrd length as used by u-boot" - % initrd_file) - _dd(initrd_file, boot_device_or_file, - count=SAMSUNG_V310_UINITRD_COPY_LEN, - seek=SAMSUNG_V310_UINITRD_START) - - -def install_smdkv310_boot_env(env_file, boot_device_or_file): - # the environment file is exactly SAMSUNG_V310_ENV_LEN as created by - # make_flashable_env(), so we don't need to check the size of env_file - _dd(env_file, boot_device_or_file, count=SAMSUNG_V310_ENV_LEN, - seek=SAMSUNG_V310_ENV_START) - - -def install_smdkv310_boot_loader(v310_file, boot_device_or_file): - """Samsung specific terminology - BL0 is the first stage bootloader, - BL1 is the SPL (secondary program loader) - v310_file is a binary with the same layout as BL1 + u-boot environment + - BL2; write BL1 (SPL) piece first (SAMSUNG_V310_BL1_LEN sectors at +0s in - the file and +SAMSUNG_V310_BL1_START on disk), then write BL2 (u-boot) - piece (rest of the file starting at +(SAMSUNG_V310_BL1_LEN + - SAMSUNG_V310_ENV_LEN)s in the file which is the same as - +(SAMSUNG_V310_BL2_START - SAMSUNG_V310_BL1_START)s) - """ - _dd(v310_file, boot_device_or_file, count=SAMSUNG_V310_BL1_LEN, - seek=SAMSUNG_V310_BL1_START) - # XXX need to check that the length of v310_file - 64s is smaller than - # SAMSUNG_V310_BL2_LEN - _dd(v310_file, boot_device_or_file, seek=SAMSUNG_V310_BL2_START, - skip=(SAMSUNG_V310_BL2_START - SAMSUNG_V310_BL1_START)) - === modified file 'linaro_image_tools/media_create/tests/test_media_create.py' --- linaro_image_tools/media_create/tests/test_media_create.py 2011-04-18 21:18:06 +0000 +++ linaro_image_tools/media_create/tests/test_media_create.py 2011-04-20 14:42:47 +0000 @@ -202,10 +202,8 @@ def test_smdkv310_steps(self): self.make_boot_files(boards.SMDKV310Config) expected = [ - 'install_smdkv310_boot_loader', 'make_flashable_env', - 'install_smdkv310_boot_env', 'make_uImage', - 'install_smdkv310_uImage', 'make_uInitrd', - 'install_smdkv310_initrd'] + '_dd', '_dd', 'make_flashable_env', '_dd', 'make_uImage', + 'make_uInitrd', 'make_boot_script'] self.assertEqual(expected, self.funcs_calls) def test_ux500_steps(self): @@ -332,7 +330,7 @@ def test_smdkv310(self): self.assertEquals( - '1,221183,0xDA\n221184,106496,0x0C,*\n327680,,,-', + '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-', board_configs['smdkv310'].get_sfdisk_cmd()) @@ -370,9 +368,9 @@ expected = { 'bootargs': 'console=ttySAC1,115200n8 root=UUID=deadbeef ' 'rootwait ro', - 'bootcmd': 'movi read kernel 0x40007000; ' - 'movi read rootfs 0x41000000 0x1000000; ' - 'bootm 0x40007000 0x41000000', + 'bootcmd': 'fatload mmc 0:2 0x40007000 uImage; ' + 'fatload mmc 0:2 0x42000000 uInitrd; ' + 'bootm 0x40007000 0x42000000', 'ethact': 'smc911x-0', 'ethaddr': '00:40:5c:26:0a:5b'} self.assertEqual(expected, boot_commands) @@ -773,7 +771,7 @@ # every time we run sfdisk it actually repartitions the device, # erasing any partitions created previously. self.assertEqual( - [('1,221183,0xDA\n221184,106496,0x0C,*\n327680,,,-', HEADS, + [('1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-', HEADS, SECTORS, '', self.media.path)], sfdisk_fixture.mock.calls) def test_create_partitions_for_beagle(self):