From patchwork Thu Apr 28 09:31:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 616090 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3qwWmt0yLCz9t3c for ; Thu, 28 Apr 2016 19:31:41 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=monstr-eu.20150623.gappssmtp.com header.i=@monstr-eu.20150623.gappssmtp.com header.b=zAubSXcl; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3B05FA787F; Thu, 28 Apr 2016 11:31:37 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id y9P9fy1Ya50v; Thu, 28 Apr 2016 11:31:37 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B89C2A77ED; Thu, 28 Apr 2016 11:31:36 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8A173A77ED for ; Thu, 28 Apr 2016 11:31:33 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1jhF76VtliN8 for ; Thu, 28 Apr 2016 11:31:33 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-wm0-f42.google.com (mail-wm0-f42.google.com [74.125.82.42]) by theia.denx.de (Postfix) with ESMTPS id 53121A767E for ; Thu, 28 Apr 2016 11:31:29 +0200 (CEST) Received: by mail-wm0-f42.google.com with SMTP id g17so31004041wme.1 for ; Thu, 28 Apr 2016 02:31:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id; bh=mDHJfvDSgwU8CcE/vkXaCk0z5bfabM0By0lC8UW0qYI=; b=zAubSXcl/3VdrlMci3WGZ9Z6uSfrv1hkLvmU4pbxcuzfatNsqAJKE4UJlNtnVgQ7I6 4t3mEYZKq/B7VHm10uohDoM0gTq2kjvZx/UzcivBRRBvatK3ajtjw2LsHq2yYdkGamme pX+aPv2bckcyOrdPxkkq3va5Kni37eoWET0IgXXrsUcQ1oGEbrhq84QqddZuQ8WqqwBk NjKfbUDvt+gzXAAUG1esdnZCzykikVaHvq0aOiXX4RSbFB3R7s4+AwltJo0A2GFz+gSw u6Pfh25SXGols3aq/gjm5U12gKk+S9NgQ4b3C+9wsMXOguPHfCx56lQXuK/hbUdRV6lm 3Mvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=mDHJfvDSgwU8CcE/vkXaCk0z5bfabM0By0lC8UW0qYI=; b=Vxs5hYs0I+Bu2RAoLSXfpRyi8K4kF5Eej+K01BfGLCcRKkcpbyKKxNKgc1gXMYgkp0 8uJYr6CD+YQ7FHMNMSCUYIX1k/Bufpjq9BchuoIeLyDb+Ap3qt/aCfMiTxTS3WbXZbXN Ucyzb6ilfQTsNwR9VecSmK/Q1RL24qNcl4CaWDX6DW42dQwQI5JDbNHY+IQH07WVWKR5 4xtDmgh3d/8miUPUjiJFFSrWtMbBMrOqHNqWLXyJxnLESruWFG3AGeJSEi86cGf7bgN5 VfR8HA0F2TgzmjIAEMxxGYt3N9BlhAWHHPqtxTxXYog/m0FFnVZ622/y729gI3kjtLrY w89Q== X-Gm-Message-State: AOPr4FVqLqLIvaUbZZWG/5NGhSH9WpomQbxmefMryeDnZZi9m6LiXfw138OuVtHaCxZh3Q== X-Received: by 10.28.2.67 with SMTP id 64mr14531850wmc.70.1461835889555; Thu, 28 Apr 2016 02:31:29 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id h8sm13108040wmd.2.2016.04.28.02.31.28 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 28 Apr 2016 02:31:29 -0700 (PDT) From: Michal Simek To: Simon Glass Date: Thu, 28 Apr 2016 11:31:27 +0200 Message-Id: X-Mailer: git-send-email 1.9.1 Cc: u-boot@lists.denx.de, Stephen Warren Subject: [U-Boot] [RFC PATCH] SPL: FIT: Enable SPL_FIT_LOAD for sd bootmode for fat partions X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Support U-Boot SPL to load FIT image from fat partition. Fit image can be setup via CONFIG_SPL_FS_LOAD_KERNEL_NAME. Falcon mode is not supported. Signed-off-by: Michal Simek Reviewed-by: Simon Glass --- common/spl/spl_fat.c | 50 ++++++++++++++++++++++++++++++++++++++++++++------ fs/fat/fat.c | 4 ++-- 2 files changed, 46 insertions(+), 8 deletions(-) diff --git a/common/spl/spl_fat.c b/common/spl/spl_fat.c index d16cd540e38a..4e319c5fa470 100644 --- a/common/spl/spl_fat.c +++ b/common/spl/spl_fat.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -39,6 +40,29 @@ static int spl_register_fat_device(struct blk_desc *block_dev, int partition) return err; } +#ifdef CONFIG_SPL_LOAD_FIT +static ulong spl_fat_file_read(struct spl_load_info *load, ulong sector, + ulong count, void *buf) +{ + int err; + loff_t actread; + char *filename = (char *)load->priv; + + debug("%s: name %s, sector %lx, count %lx, buf %lx\n", + __func__, filename, sector, count, (ulong)buf); + + err = file_fat_read_at(filename, sector, buf, count, &actread); + if (err < 0) { + printf("%s: error reading image %s, err - %d\n", + __func__, filename, err); + return err; + } + + debug("actread %lx\n", (ulong)actread); + return actread; +} +#endif + int spl_load_image_fat(struct blk_desc *block_dev, int partition, const char *filename) @@ -57,16 +81,29 @@ int spl_load_image_fat(struct blk_desc *block_dev, if (err <= 0) goto end; - spl_parse_image_header(header); + if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) && + image_get_magic(header) == FDT_MAGIC) { + struct spl_load_info load; + + debug("Found FIT\n"); + load.priv = (char *)filename; + load.bl_len = 1; + load.read = spl_fat_file_read; + spl_load_simple_fit(&load, 0, header); + } else { + debug("Legacy image\n"); - err = file_fat_read(filename, (u8 *)(uintptr_t)spl_image.load_addr, 0); + spl_parse_image_header(header); + err = file_fat_read(filename, + (u8 *)(uintptr_t)spl_image.load_addr, 0); end: #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT - if (err <= 0) - printf("%s: error reading image %s, err - %d\n", - __func__, filename, err); + if (err <= 0) + printf("%s: error reading image %s, err - %d\n", + __func__, filename, err); #endif + } return (err <= 0); } @@ -81,6 +118,7 @@ int spl_load_image_fat_os(struct blk_desc *block_dev, int partition) if (err) return err; +#if !defined(CONFIG_SPL_LOAD_FIT) #if defined(CONFIG_SPL_ENV_SUPPORT) && defined(CONFIG_SPL_OS_BOOT) file = getenv("falcon_args_file"); if (file) { @@ -116,7 +154,7 @@ defaults: #endif return -1; } - +#endif return spl_load_image_fat(block_dev, partition, CONFIG_SPL_FS_LOAD_KERNEL_NAME); } diff --git a/fs/fat/fat.c b/fs/fat/fat.c index 600a90e30922..0d987e0465ee 100644 --- a/fs/fat/fat.c +++ b/fs/fat/fat.c @@ -281,9 +281,9 @@ get_cluster(fsdata *mydata, __u32 clustnum, __u8 *buffer, unsigned long size) if ((unsigned long)buffer & (ARCH_DMA_MINALIGN - 1)) { ALLOC_CACHE_ALIGN_BUFFER(__u8, tmpbuf, mydata->sect_size); - +#if !defined(CONFIG_SPL_LOAD_FIT) printf("FAT: Misaligned buffer address (%p)\n", buffer); - +#endif while (size >= mydata->sect_size) { ret = disk_read(startsect++, 1, tmpbuf); if (ret != 1) {