From patchwork Tue Jan 15 18:48:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fathi Boudra X-Patchwork-Id: 14076 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id CA2C523F81 for ; Tue, 15 Jan 2013 18:48:17 +0000 (UTC) Received: from mail-vb0-f41.google.com (mail-vb0-f41.google.com [209.85.212.41]) by fiordland.canonical.com (Postfix) with ESMTP id 3BBAAA196A2 for ; Tue, 15 Jan 2013 18:48:17 +0000 (UTC) Received: by mail-vb0-f41.google.com with SMTP id l22so465988vbn.14 for ; Tue, 15 Jan 2013 10:48:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:content-type:mime-version:x-launchpad-project :x-launchpad-branch:x-launchpad-message-rationale :x-launchpad-branch-revision-number:x-launchpad-notification-type:to :from:subject:message-id:date:reply-to:sender:errors-to:precedence :x-generated-by:x-launchpad-hash:x-gm-message-state; bh=LBwiIB8PD2ljOBQlAhPnOG36w748hXe2DwYtdg/ylUc=; b=paZrM90LUrC8nxIXfDcBAarsCYb144eU6Lbdl5KxH0vN7la/AU7Qk+gQqEXrfhqsrq JVtBIPoFv84ISVdILgkhHt61HcL+rhPF/vYxELTM02WwA/CcKPA8RWAirOYEm7RZN33J QfrS19CslrBdImEufWWq9HYGI8CTtlvRaUNUyywUQaNUwTeWBZBnSf7Y0JIgvPiH/jHh kmrSk2doLJTK8fppqvr7X5IPU9KT+3tKPErnYiRQ1P9Wo5mePAit4r/gqaKTvYe7Dad4 +dV3aP3PkU5+b8++r2U5Xdp8L1Pwp5xdD7DLDo3a7ThouvJyp0s3R6KgF4+8WsAVEsii 0IXA== X-Received: by 10.220.8.18 with SMTP id f18mr104411475vcf.14.1358275696330; Tue, 15 Jan 2013 10:48:16 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.145.101 with SMTP id st5csp127753veb; Tue, 15 Jan 2013 10:48:15 -0800 (PST) X-Received: by 10.194.172.228 with SMTP id bf4mr51964002wjc.38.1358275694481; Tue, 15 Jan 2013 10:48:14 -0800 (PST) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id eo18si29276820wjd.51.2013.01.15.10.48.13 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 15 Jan 2013 10:48:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) client-ip=91.189.90.7; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) smtp.mail=bounces@canonical.com Received: from ackee.canonical.com ([91.189.89.26]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1TvBYT-00038u-J8 for ; Tue, 15 Jan 2013 18:48:13 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 82903E0469 for ; Tue, 15 Jan 2013 18:48:13 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: linaro-image-tools X-Launchpad-Branch: ~linaro-image-tools/linaro-image-tools/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 600 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-image-tools/linaro-image-tools/trunk] Rev 600: * Initial support for Arndale BL1 binary (samsung_bl0_*) Message-Id: <20130115184813.2787.29651.launchpad@ackee.canonical.com> Date: Tue, 15 Jan 2013 18:48:13 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="16420"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 774c4e2ea435ed983383e6eb2e3f1464931f440a X-Gm-Message-State: ALoCoQkyObQJy6tODKNLn1AOA8IPCvuyEZoSooXiuDSigTNqsoIONmDbzTj1p1Fkd9dB+jtwQEQ5 Merge authors: Fathi Boudra (fboudra) Related merge proposals: https://code.launchpad.net/~fboudra/linaro-image-tools/initial-arndale-bl1-support/+merge/143023 proposed by: Fathi Boudra (fboudra) review: Approve - Milo Casagrande (milo) review: Resubmit - Fathi Boudra (fboudra) https://code.launchpad.net/~fboudra/linaro-image-tools/samsung-variables-init/+merge/143019 proposed by: Fathi Boudra (fboudra) review: Approve - Milo Casagrande (milo) ------------------------------------------------------------ revno: 600 [merge] committer: Fathi Boudra branch nick: linaro-image-tools timestamp: Tue 2013-01-15 20:45:34 +0200 message: * Initial support for Arndale BL1 binary (samsung_bl0_*) It assumes a pre-defined binary file. Long term, it should be a set of new keys to add in Arndale hardware pack configuration. * Add ethact/ethaddr to Arndale boot_env (LP: #1097265) Arndale board doesn't have a MAC address. To get network working out of the box, we define one in U-Boot environment. 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-image-tools/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-image-tools/linaro-image-tools/trunk/+edit-subscription === modified file 'linaro_image_tools/media_create/boards.py' --- linaro_image_tools/media_create/boards.py 2013-01-09 09:22:50 +0000 +++ linaro_image_tools/media_create/boards.py 2013-01-14 14:56:31 +0000 @@ -188,16 +188,19 @@ self.wireless_interfaces = None # 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 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 - # 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 + # BL0, BL1, BL2, BL3 are the boot loader stages in order of execution + # + # BL0 - embedded boot loader on the internal ROM + # BL1 - chip-specific boot loader provided by Samsung + # BL2 - tiny boot loader; SPL (Second Program Loader) + # BL3 - customized boot loader; U-Boot + # + # In linaro-image-tools, variables have been named samsung_blN-1 + # e.g BL1 is samsung_bl0, BL2 is samsung_bl1, BL3 is samsung_bl2 + # + # samsung_bl0_{start,len}: Offset and maximum size for BL1 + # samsung_bl1_{start,len}: Offset and maximum size for BL2 + # samsung_bl2_{start,len}: Offset and maximum size for BL3 # samsung_env_{start,len}: Offset and maximum size for settings # self.samsung_bl1_start = 1 @@ -376,25 +379,33 @@ samsung_bl1_start = self.get_metadata_field( SAMSUNG_BL1_START_FIELD) if samsung_bl1_start: - self.samsung_v310_bl1_start = int(samsung_bl1_start) - samsung_bl1_len = self.get_metadata_field(SAMSUNG_BL1_LEN_FIELD) + self.samsung_bl1_start = int(samsung_bl1_start) + + samsung_bl1_len = self.get_metadata_field( + SAMSUNG_BL1_LEN_FIELD) if samsung_bl1_len: - self.samsung_v310_bl1_len = int(samsung_bl1_len) - samsung_env_len = self.get_metadata_field(SAMSUNG_ENV_LEN_FIELD) - if samsung_env_len: - self.samsung_v310_env_len = int(samsung_env_len) - samsung_bl2_start = \ - self.get_metadata_field(SAMSUNG_BL2_START_FIELD) + self.samsung_bl1_len = int(samsung_bl1_len) + + samsung_bl2_start = self.get_metadata_field( + SAMSUNG_BL2_START_FIELD) if samsung_bl2_start: self.samsung_bl2_start = int(samsung_bl2_start) - samsung_bl2_len = self.get_metadata_field(SAMSUNG_BL2_LEN_FIELD) + + samsung_bl2_len = self.get_metadata_field( + SAMSUNG_BL2_LEN_FIELD) if samsung_bl2_len: - self.samsung_v310_bl2_len = int(samsung_bl2_len) - samsung_env_start = \ - self.get_metadata_field(SAMSUNG_ENV_START_FIELD) + self.samsung_bl2_len = int(samsung_bl2_len) + + samsung_env_start = self.get_metadata_field( + SAMSUNG_ENV_START_FIELD) if samsung_env_start is not None: self.samsung_env_start = int(samsung_env_start) + samsung_env_len = self.get_metadata_field( + SAMSUNG_ENV_LEN_FIELD) + if samsung_env_len: + self.samsung_env_len = int(samsung_env_len) + self.bootloader_copy_files = self.hardwarepack_handler.get_field( "bootloader_copy_files")[0] @@ -1563,20 +1574,81 @@ class ArndaleConfig(SamsungConfig): def __init__(self): super(ArndaleConfig, self).__init__() + self.bl0_file = 'lib/firmware/arndale/arndale-bl1.bin' self.boot_script = 'boot.scr' self.bootloader_flavor = 'arndale' - self.dtb_addr = '0x41f00000' - self.initrd_addr = '0x42000000' - self.kernel_addr = '0x40007000' self.kernel_flavors = ['arndale'] - self.load_addr = '0x40008000' self.mmc_option = '0:2' self.mmc_part_offset = 1 - self.samsung_bl1_start = 17 - self.samsung_bl2_start = 49 - self.samsung_env_start = 1073 - self.serial_tty = 'ttySAC2' - self._extra_serial_options = 'console=%s,115200n8' + self.samsung_bl0_start = 1 + self.samsung_bl0_len = 16 + + def _get_boot_env(self, is_live, is_lowmem, consoles, rootfs_id, + i_img_data, d_img_data): + boot_env = super(SamsungConfig, self)._get_boot_env( + is_live, is_lowmem, consoles, rootfs_id, i_img_data, d_img_data) + + boot_env["ethact"] = "smc911x-0" + boot_env["ethaddr"] = "00:40:5c:26:0a:5b" + + return boot_env + + def _make_boot_files_v2(self, boot_env, chroot_dir, boot_dir, + boot_device_or_file, k_img_data, i_img_data, + d_img_data): + with self.hardwarepack_handler: + bl0_file = self._get_samsung_bl0(chroot_dir) + if self.samsung_bl0_start: + self._dd_file(bl0_file, boot_device_or_file, + self.samsung_bl0_start) + + spl_file = self.get_file('spl_file') + if self.spl_in_boot_part: + assert spl_file is not None, ( + "SPL binary could not be found") + logger.info( + "Copying spl '%s' to boot partition." % spl_file) + cmd_runner.run(["cp", "-v", spl_file, boot_dir], + as_root=True).wait() + # XXX: Is this really needed? + cmd_runner.run(["sync"]).wait() + + if self.spl_dd: + self._dd_file(spl_file, boot_device_or_file, self.spl_dd) + + bootloader_file = self.get_file('bootloader_file') + if self.bootloader_dd: + self._dd_file(bootloader_file, boot_device_or_file, + self.bootloader_dd) + + make_uImage(self.load_addr, k_img_data, boot_dir) + + if i_img_data is not None: + make_uInitrd(i_img_data, boot_dir) + + if d_img_data is not None: + make_dtb(d_img_data, boot_dir) + + if self.boot_script is not None: + boot_script_path = os.path.join(boot_dir, self.boot_script) + make_boot_script(boot_env, boot_script_path) + + # Only used for Omap, will this be bad for the other boards? + make_boot_ini(boot_script_path, boot_dir) + + if self.env_dd: + # Do we need to zero out the env before flashing it? + _dd("/dev/zero", boot_device_or_file, + count=self.samsung_env_len, + seek=self.samsung_env_start) + env_size = self.samsung_env_len * SECTOR_SIZE + env_file = make_flashable_env(boot_env, env_size) + self._dd_file(env_file, boot_device_or_file, + self.samsung_env_start) + + def _get_samsung_bl0(self, chroot_dir): + bl0_file = os.path.join(chroot_dir, self.bl0_file) + return bl0_file class I386Config(BoardConfig): === modified file 'linaro_image_tools/media_create/tests/test_media_create.py' --- linaro_image_tools/media_create/tests/test_media_create.py 2013-01-09 09:22:50 +0000 +++ linaro_image_tools/media_create/tests/test_media_create.py 2013-01-15 18:45:34 +0000 @@ -31,6 +31,7 @@ import struct import tarfile import dbus +import shutil from mock import MagicMock from StringIO import StringIO @@ -805,6 +806,57 @@ config = boards.ArndaleConfig +class TestArndaleBootFiles(TestCaseWithFixtures): + def test_arndale_make_boot_files_v2(self): + popen_fixture = self.useFixture(MockCmdRunnerPopenFixture()) + board_conf = boards.ArndaleConfig() + board_conf.hwpack_format = HardwarepackHandler.FORMAT_1 + board_conf.load_addr = '0x40008000' + board_conf.boot_script = None + + board_conf.hardwarepack_handler = ( + TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz')) + + self.tempdir = self.useFixture(CreateTempDirFixture()).get_temp_dir() + self.temp_bootdir_path = os.path.join(self.tempdir, 'boot') + self.temp_bl0_path = os.path.join(self.tempdir, + 'lib', 'firmware', 'arndale') + k_img_file = os.path.join(self.tempdir, 'vmlinuz-1-arndale') + i_img_file = os.path.join(self.tempdir, 'initrd.img-1-arndale') + bl0_file = os.path.join(self.temp_bl0_path, 'arndale-bl1.bin') + os.makedirs(self.temp_bl0_path) + open(bl0_file, 'w').close() + + boot_env = {'ethact': 'smc911x-0', + 'initrd_high': '0xffffffff', + 'ethaddr': '00:40:5c:26:0a:5b', + 'fdt_high': '0xffffffff', + 'bootcmd': 'fatload mmc 0:2 None uImage; bootm None', + 'bootargs': 'root=UUID=test_boot_env_uuid rootwait ro'} + + board_conf._make_boot_files_v2( + boot_env=boot_env, + chroot_dir=self.tempdir, + boot_dir=self.temp_bootdir_path, + boot_device_or_file='boot_device_or_file', + k_img_data=k_img_file, + i_img_data=i_img_file, + d_img_data=None) + + expected_commands = [ + ('sudo -E dd if=%s of=boot_device_or_file bs=512 conv=notrunc ' + 'seek=1' % bl0_file), + ('sudo -E mkimage -A arm -O linux -T kernel -C none -a %s -e %s ' + '-n Linux -d %s %s/uImage' % (board_conf.load_addr, + board_conf.load_addr, k_img_file, self.temp_bootdir_path)), + ('sudo -E mkimage -A arm -O linux -T ramdisk -C none -a 0 -e 0 ' + '-n initramfs -d %s %s/uInitrd' % ( + i_img_file, self.temp_bootdir_path))] + self.assertEqual(expected_commands, + popen_fixture.mock.commands_executed) + shutil.rmtree(self.tempdir) + + class TestCreateToc(TestCaseWithFixtures): ''' Tests boards.SnowballEmmcConfig.create_toc()''' @@ -1977,6 +2029,22 @@ 'initrd_high': '0xffffffff'} self.assertEqual(expected, boot_commands) + def test_arndale(self): + board_conf = get_board_config('arndale') + boot_commands = board_conf._get_boot_env( + is_live=False, is_lowmem=False, consoles=[], + rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None) + expected = { + 'bootargs': 'root=UUID=deadbeef rootwait ro', + 'bootcmd': 'fatload mmc 0:2 None uImage; ' + 'fatload mmc 0:2 None uInitrd; ' + 'bootm None None', + 'ethact': 'smc911x-0', + 'ethaddr': '00:40:5c:26:0a:5b', + 'fdt_high': '0xffffffff', + 'initrd_high': '0xffffffff'} + self.assertEqual(expected, boot_commands) + def test_ux500(self): board_conf = get_board_config('ux500') boot_commands = board_conf._get_boot_env(