From patchwork Fri Feb 3 00:30:06 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 6581 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 2CCF423EB0 for ; Fri, 3 Feb 2012 00:30:10 +0000 (UTC) Received: from mail-tul01m020-f180.google.com (mail-tul01m020-f180.google.com [209.85.214.180]) by fiordland.canonical.com (Postfix) with ESMTP id DCCA5A1807B for ; Fri, 3 Feb 2012 00:30:09 +0000 (UTC) Received: by obbuo19 with SMTP id uo19so4707042obb.11 for ; Thu, 02 Feb 2012 16:30:09 -0800 (PST) Received: by 10.50.236.5 with SMTP id uq5mr14812753igc.13.1328229009146; Thu, 02 Feb 2012 16:30:09 -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.231.169.210 with SMTP id a18cs72181ibz; Thu, 2 Feb 2012 16:30:08 -0800 (PST) Received: by 10.213.109.11 with SMTP id h11mr429569ebp.123.1328229007311; Thu, 02 Feb 2012 16:30:07 -0800 (PST) Received: from mx2.suse.de (cantor2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id 13si2480919eea.90.2012.02.02.16.30.06 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 02 Feb 2012 16:30:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of agraf@suse.de designates 195.135.220.15 as permitted sender) client-ip=195.135.220.15; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of agraf@suse.de designates 195.135.220.15 as permitted sender) smtp.mail=agraf@suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id A75A48FC92; Fri, 3 Feb 2012 01:30:06 +0100 (CET) From: Alexander Graf To: Peter Maydell Cc: patches@linaro.org Subject: [PATCH] omap3boot: fix raw boot Date: Fri, 3 Feb 2012 01:30:06 +0100 Message-Id: <1328229006-25691-1-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.7.3.4 According to the OMAP3 spec, raw boot tries sector 0 and sector 256: In raw mode, an image can be at offset 0 or 128KB and must not be bigger than 128KB. Raw mode is detected by reading sector 0 and sector 256. Also, bdrv_pread takes byte offsets rather than sector offsets, so the loop through the sector numbers needs to offset sector sizes in. Signed-off-by: Alexander Graf --- hw/omap3_boot.c | 13 ++++++++++--- 1 files changed, 10 insertions(+), 3 deletions(-) diff --git a/hw/omap3_boot.c b/hw/omap3_boot.c index 2db81f2..eca399a 100644 --- a/hw/omap3_boot.c +++ b/hw/omap3_boot.c @@ -649,12 +649,13 @@ static int omap3_mmc_raw_boot(BlockDriverState *bs, struct omap3_boot_s *boot; uint32_t i = 0; int result = 0; - - if (bdrv_pread(bs, 0, sector, 0x200) == 0x200) { + +again: + if (bdrv_pread(bs, i * 0x200, sector, 0x200) == 0x200) { boot = omap3_boot_init(mpu, mmc1, sector, 0x200); if (boot->state == confighdr) { /* CH must be present for raw boot */ while (omap3_boot_block(sector, 0x200, boot)) { - if (bdrv_pread(bs, ++i, sector, 0x200) != 0x200) { + if (bdrv_pread(bs, ++i * 0x200, sector, 0x200) != 0x200) { TRACE("error trying to read sector %u on boot device", i); break; } @@ -663,6 +664,12 @@ static int omap3_mmc_raw_boot(BlockDriverState *bs, result = (boot->state == done); free(boot); } + + if (!result && !i) { + /* try again at 128k */ + i = 256; + goto again; + } return result; }