From patchwork Fri May 20 13:45:36 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mattias Backman X-Patchwork-Id: 1559 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:53:04 -0000 Delivered-To: patches@linaro.org Received: by 10.224.54.134 with SMTP id q6cs161345qag; Fri, 20 May 2011 06:45:38 -0700 (PDT) Received: by 10.216.14.199 with SMTP id d49mr4025161wed.65.1305899137483; Fri, 20 May 2011 06:45:37 -0700 (PDT) Received: from adelie.canonical.com (adelie.canonical.com [91.189.90.139]) by mx.google.com with ESMTP id w9si6998451weo.134.2011.05.20.06.45.37; Fri, 20 May 2011 06:45:37 -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 1QNQ1I-00027Q-T6 for ; Fri, 20 May 2011 13:45:36 +0000 Received: from loganberry.canonical.com (localhost [127.0.0.1]) by loganberry.canonical.com (Postfix) with ESMTP id D9FC32E8014 for ; Fri, 20 May 2011 13:45:36 +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: 339 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-image-tools/linaro-image-tools/trunk] Rev 339: Initial support for ST-Ericsson Snowball based on an implementation by Tony Mansson and Hans Odeb... Message-Id: <20110520134536.21036.13864.launchpad@loganberry.canonical.com> Date: Fri, 20 May 2011 13:45:36 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="13085"; Instance="initZopeless config overlay" X-Launchpad-Hash: fdddfa11cfe357cb6851d7435a717403cf3eedf3 Merge authors: Mattias Backman (mabac) Tony Mansson (tony-mansson) Related merge proposals: https://code.launchpad.net/~mabac/linaro-image-tools/snowball-support/+merge/61582 proposed by: Mattias Backman (mabac) review: Approve - Tony Mansson (tony-mansson) review: Approve - Hans Odeberg (hans-odeberg) review: Approve - Loïc Minier (lool) https://code.launchpad.net/~tony-mansson/linaro-image-tools/snowball-support/+merge/60924 proposed by: Loïc Minier (lool) ------------------------------------------------------------ revno: 339 [merge] committer: Mattias Backman branch nick: linaro-image-tools timestamp: Fri 2011-05-20 15:37:53 +0200 message: Initial support for ST-Ericsson Snowball based on an implementation by Tony Mansson and Hans Odeberg. This adds the BoardConfig classes SnowballSdConfig and SnowballEmmcConfig. Start files for the Snowball boot loader partition is contained in the hwpack along with a startfiles.cfg files which describes them. 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 2011-04-26 16:37:19 +0000 +++ linaro_image_tools/media_create/boards.py 2011-05-20 07:51:46 +0000 @@ -495,6 +495,150 @@ make_boot_script(boot_env, boot_script_path) +class SnowballSdConfig(Ux500Config): + '''Use only with --mmc option. Creates the standard vfat and ext2 + partitions for kernel and rootfs on an SD card. + Note that the Snowball board needs a loader partition on the + internal eMMC flash to boot. That partition is created with + the SnowballConfigImage configuration.''' + + @classmethod + def _make_boot_files(cls, boot_env, chroot_dir, boot_dir, + boot_device_or_file, k_img_data, i_img_data, + d_img_data): + make_uImage(cls.load_addr, k_img_data, boot_dir) + boot_script_path = os.path.join(boot_dir, cls.boot_script) + make_boot_script(boot_env, boot_script_path) + + +class SnowballEmmcConfig(SnowballSdConfig): + '''Use only with --image option. Creates a raw image which contains an + additional (raw) loader partition, containing some boot stages + and u-boot.''' + # Boot ROM looks for a boot table of contents (TOC) at 0x20000 + # Actually, it first looks at address 0, but that's where l-m-c + # puts the MBR, so the boot loader skips that address. + SNOWBALL_LOADER_START_S = (128 * 1024) / SECTOR_SIZE + SNOWBALL_STARTUP_FILES_CONFIG = 'startfiles.cfg' + TOC_SIZE = 512 + + @classmethod + def get_sfdisk_cmd(cls, should_align_boot_part=None): + """Return the sfdisk command to partition the media. + + :param should_align_boot_part: Ignored. + + The Snowball partitioning scheme depends on whether the target is + a raw image or an SD card. Both targets have the normal + FAT 32 boot partition and EXT? root partition. + The raw image prepends these two partitions with a raw loader partition, + containing HW-dependent boot stages up to and including u-boot. + This is done since the boot rom always boots off the internal memory; + there simply is no point to having a loader partition on SD card. + """ + # boot ROM expects bootloader at 0x20000, which is sector 0x100 + # with the usual SECTOR_SIZE of 0x200. + # (sector 0 is MBR / partition table) + loader_start, loader_end, loader_len = align_partition( + SnowballEmmcConfig.SNOWBALL_LOADER_START_S, + LOADER_MIN_SIZE_S, 1, PART_ALIGN_S) + + boot_start, boot_end, boot_len = align_partition( + loader_end + 1, BOOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) + # we ignore _root_end / _root_len and return an sfdisk command to + # instruct the use of all remaining space; XXX if we had some root size + # config, we could do something more sensible + root_start, _root_end, _root_len = align_partition( + 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) + + @classmethod + def _make_boot_files(cls, boot_env, chroot_dir, boot_dir, + boot_device_or_file, k_img_data, i_img_data, + d_img_data): + make_uImage(cls.load_addr, k_img_data, boot_dir) + boot_script_path = os.path.join(boot_dir, cls.boot_script) + make_boot_script(boot_env, boot_script_path) + _, toc_filename = tempfile.mkstemp() + atexit.register(os.unlink, toc_filename) + config_files_path = os.path.join(chroot_dir, 'boot') + new_files = cls.get_file_info(config_files_path) + with open(toc_filename, 'wb') as toc: + cls.create_toc(toc, new_files) + cls.install_snowball_boot_loader(toc_filename, new_files, + boot_device_or_file, + cls.SNOWBALL_LOADER_START_S) + + @classmethod + def install_snowball_boot_loader(cls, toc_file_name, files, + boot_device_or_file, start_sector): + ''' Copies TOC and boot files into the boot partition. + A sector size of 1 is used for some files, as they do not + necessarily start on an even address. ''' + assert os.path.getsize(toc_file_name) <= cls.TOC_SIZE + _dd(toc_file_name, boot_device_or_file, seek=start_sector) + + for file in files: + # XXX We need checks that these files do not overwrite each + # other. This code assumes that offset and file sizes are ok. + if (file['offset'] % SECTOR_SIZE) != 0: + seek_bytes = start_sector * SECTOR_SIZE + file['offset'] + _dd(file['filename'], boot_device_or_file, block_size=1, + seek=seek_bytes) + else: + seek_sectors = start_sector + file['offset']/SECTOR_SIZE + _dd(file['filename'], boot_device_or_file, seek=seek_sectors) + + @classmethod + def create_toc(cls, f, files): + ''' Writes a table of contents of the boot binaries. + Boot rom searches this table to find the binaries.''' + for file in files: + # Format string means: < little endian, + # I; unsigned int; offset, + # I; unsigned int; size, + # I; unsigned int; flags, + # i; int; align, + # i; int; load_address, + # 12s; string of char; name + # http://igloocommunity.org/support/index.php/ConfigPartitionOverview + flags = 0 + load_adress = file['align'] + data = struct.pack('