From patchwork Wed Feb 18 22:53:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dileep Katta X-Patchwork-Id: 44802 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f71.google.com (mail-ee0-f71.google.com [74.125.83.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0443921573 for ; Wed, 18 Feb 2015 22:54:24 +0000 (UTC) Received: by mail-ee0-f71.google.com with SMTP id d17sf3267027eek.2 for ; Wed, 18 Feb 2015 14:54:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:cc:subject :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=Tx45z9NTfGGeYPZWxSfE1S3kHE70jwZeDO9tPj/P69U=; b=dfpg2sZPEUCUrn3BmPu1wyScjO/kofkfJm85sJrBdJYaZ1zMvQv5l+7ivwwR4t+Bdn vGBo71Uf+Gcv3PLXqjEOCyJ0jXKzjQi5xiu4RqsUPOf9eE7UNu99iUv9JRmEsis6mSwx 0NASSe2jj6axsEKT+4PyZULm4/7tq/IPbyZsgkIU7Hm9AwNFQG0lD5X9SwZeIXrUyNlC NrtkIMfjyVOi+V0msLbyY6uOyqJjRucYCWAhbNr6iJaTNQ/0aTKnIHa18e6fU5hE4rFQ cuDs5flv9ZJqeKZDchPjLrIcGdvJpneGAwSFEJL8dvYLgmkEKtziR5RwBjSebKWFnJWf AA9A== X-Gm-Message-State: ALoCoQmgDwM/zVMgGzoUL3QxlPKteUKoBKLD1hVHV+Fi4qV0Mtxu1cnf03VBLrEPuzhtJmYPnBIG X-Received: by 10.152.43.166 with SMTP id x6mr202440lal.3.1424300063238; Wed, 18 Feb 2015 14:54:23 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.4.71 with SMTP id i7ls83461lai.44.gmail; Wed, 18 Feb 2015 14:54:21 -0800 (PST) X-Received: by 10.152.37.166 with SMTP id z6mr1449764laj.98.1424300061962; Wed, 18 Feb 2015 14:54:21 -0800 (PST) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id a4si15943441lbg.132.2015.02.18.14.54.21 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Feb 2015 14:54:21 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by labms9 with SMTP id ms9so4332140lab.10 for ; Wed, 18 Feb 2015 14:54:21 -0800 (PST) X-Received: by 10.112.64.193 with SMTP id q1mr432529lbs.88.1424300061838; Wed, 18 Feb 2015 14:54:21 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp132590lbj; Wed, 18 Feb 2015 14:54:21 -0800 (PST) X-Received: by 10.180.83.129 with SMTP id q1mr7405449wiy.46.1424300061181; Wed, 18 Feb 2015 14:54:21 -0800 (PST) Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id i4si37844338wjw.15.2015.02.18.14.54.20; Wed, 18 Feb 2015 14:54:21 -0800 (PST) Received-SPF: none (google.com: u-boot-bounces@lists.denx.de does not designate permitted sender hosts) client-ip=85.214.87.163; Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9D1594B65A; Wed, 18 Feb 2015 23:54:19 +0100 (CET) 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 kOHKegck6avp; Wed, 18 Feb 2015 23:54:19 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id EE98B4B652; Wed, 18 Feb 2015 23:54:18 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id AA00A4B652 for ; Wed, 18 Feb 2015 23:54:14 +0100 (CET) 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 xIiLqe8kLOyj for ; Wed, 18 Feb 2015 23:54:14 +0100 (CET) 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-pa0-f50.google.com (mail-pa0-f50.google.com [209.85.220.50]) by theia.denx.de (Postfix) with ESMTPS id 2B7094B639 for ; Wed, 18 Feb 2015 23:54:12 +0100 (CET) Received: by pablf10 with SMTP id lf10so4652692pab.6 for ; Wed, 18 Feb 2015 14:54:10 -0800 (PST) X-Received: by 10.67.30.34 with SMTP id kb2mr2302196pad.137.1424300050637; Wed, 18 Feb 2015 14:54:10 -0800 (PST) Received: from localhost.localdomain ([106.51.142.94]) by mx.google.com with ESMTPSA id qz3sm21951560pab.13.2015.02.18.14.54.07 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 18 Feb 2015 14:54:09 -0800 (PST) From: Dileep Katta To: u-boot@lists.denx.de, robherring2@gmail.com, trini@ti.com, rob.herring@linaro.org, srae@broadcom.com, l.majewski@samsung.com, angelabaker@ti.com Date: Thu, 19 Feb 2015 04:23:54 +0530 Message-Id: <1424300035-19634-1-git-send-email-dileep.katta@linaro.org> X-Mailer: git-send-email 1.8.3.2 Cc: Dileep Katta Subject: [U-Boot] [PATCH v1 1/2] fastboot: Add support to flash u-boot and MLO to QSPI X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: 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" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: dileep.katta@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 This adds the functionality to flash u-boot and MLO images to QSPI using fastboot Signed-off-by: Dileep Katta --- Note: This is on top of Rob Herring patches submitted to support oem format command drivers/usb/gadget/f_fastboot.c | 75 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index f7d84bf..a170eea 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -492,10 +492,23 @@ static void cb_continue(struct usb_ep *ep, struct usb_request *req) } #ifdef CONFIG_FASTBOOT_FLASH +#ifdef CONFIG_SPL_SPI_SUPPORT +int boot_from_spi = 0; +#endif + static void cb_flash(struct usb_ep *ep, struct usb_request *req) { char *cmd = req->buf; char response[RESPONSE_LEN]; +#ifdef CONFIG_SPL_SPI_SUPPORT + char source[32]; + int status = 0; + char *sf_probe[3] = {"sf", "probe", "0"}; + char *sf_write_xloader[5] = {"sf", "write", NULL, "0", "20000"}; + char *sf_update_xloader[5] = {"sf", "update", NULL, "0", "20000"}; + char *sf_write_bl[5] = {"sf", "write", NULL, "80000", "80000"}; + char *sf_update_bl[5] = {"sf", "update", NULL, "80000", "80000"}; +#endif strsep(&cmd, ":"); if (!cmd) { @@ -505,6 +518,68 @@ static void cb_flash(struct usb_ep *ep, struct usb_request *req) } strcpy(response, "FAILno flash device defined"); +#ifdef CONFIG_SPL_SPI_SUPPORT + /* + * Check if this is for xloader or bootloader. + * Also, check if we have to flash to SPI + */ + if (strcmp(cmd, "xloader") == 0 && boot_from_spi) { + printf("Flashing %s to SPI\n", cmd); + status = do_spi_flash(NULL, 0, 3, sf_probe); + if (status) { + fastboot_tx_write_str("FAILcould not probe SPI"); + return; + } + sf_write_xloader[2] = source; + sf_update_xloader[2] = source; + sprintf(source, "0x%x", + (unsigned int)CONFIG_USB_FASTBOOT_BUF_ADDR); + + printf("Updating X-LOADER to SPI\n"); + status = do_spi_flash(NULL, 0, 5, sf_update_xloader); + if (status) { + fastboot_tx_write_str("FAILupdate xloader failed"); + return; + } + + printf("Writing X-LOADER to SPI\n"); + status = do_spi_flash(NULL, 0, 5, sf_write_xloader); + if (status) { + fastboot_tx_write_str("FAILwrite xloader failed"); + return; + } + printf("Writing xloader DONE\n"); + fastboot_tx_write_str("OKAY"); + return; + } + if (strcmp(cmd, "bootloader") == 0 && boot_from_spi) { + printf("Flashing %s to SPI\n", cmd); + status = do_spi_flash(NULL, 0, 3, sf_probe); + if (status) { + fastboot_tx_write_str("FAILcould not probe SPI"); + return; + } + sf_write_bl[2] = source; + sf_update_bl[2] = source; + sprintf(source, "0x%x", + (unsigned int)CONFIG_USB_FASTBOOT_BUF_ADDR); + printf("Updating bootloader to SPI\n"); + status = do_spi_flash(NULL, 0, 5, sf_update_bl); + if (status) { + fastboot_tx_write_str("FAILupdate bootloader failed"); + return; + } + printf("Writing bootloader to SPI\n"); + status = do_spi_flash(NULL, 0, 5, sf_write_bl); + if (status) { + fastboot_tx_write_str("FAILwrite bootloader failed"); + return; + } + printf("Writing bootloader DONE\n"); + fastboot_tx_write_str("OKAY"); + return; + } +#endif #ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV fb_mmc_flash_write(cmd, (void *)CONFIG_USB_FASTBOOT_BUF_ADDR, download_bytes, response);