Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F4197C4338F for ; Mon, 2 Aug 2021 16:38:35 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ECEAD61050 for ; Mon, 2 Aug 2021 16:38:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org ECEAD61050 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=ti.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BA3BA8296A; Mon, 2 Aug 2021 18:38:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="Nb3Z2+qP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C020F82D52; Mon, 2 Aug 2021 18:38:30 +0200 (CEST) Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id CF60381FC6 for ; Mon, 2 Aug 2021 18:38:26 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=p.yadav@ti.com Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 172GcLPS095708; Mon, 2 Aug 2021 11:38:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1627922301; bh=djdvnl/pX5/aVT0D+lM5c7+U/QUX7z7xjoJhaJ5sOwU=; h=Date:From:To:CC:Subject:References:In-Reply-To; b=Nb3Z2+qPwe5GFYXQWk3UZzbpSki/dtRnFs9IT2Bol+Utea4xDdyWxlBe/VJK16UPi F0kkyGEj0km/ifHoniGP577kLMchptCo8wCmatKY4BEz/c6JNSebwIOXnvPQ7fy2l5 xecWGHNdoqeW7WjkHOU1n9oPia2hqhONjO0eDgQI= Received: from DFLE105.ent.ti.com (dfle105.ent.ti.com [10.64.6.26]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 172GcLiU079665 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 2 Aug 2021 11:38:21 -0500 Received: from DFLE115.ent.ti.com (10.64.6.36) by DFLE105.ent.ti.com (10.64.6.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Mon, 2 Aug 2021 11:38:21 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2 via Frontend Transport; Mon, 2 Aug 2021 11:38:20 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 172GcKsF057684; Mon, 2 Aug 2021 11:38:20 -0500 Date: Mon, 2 Aug 2021 22:08:19 +0530 From: Pratyush Yadav To: Simon Glass CC: U-Boot Mailing List , Heinrich Schuchardt , Jagan Teki , Mike Frysinger Subject: Re: [PATCH v3 3/4] sf: doc: Add documentation for the 'sf' command Message-ID: <20210802163817.hee2wbtwpjc3j7ar@ti.com> References: <20210801211245.2208037-1-sjg@chromium.org> <20210801211245.2208037-4-sjg@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20210801211245.2208037-4-sjg@chromium.org> User-Agent: NeoMutt/20171215 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Hi Simon, On 01/08/21 03:12PM, Simon Glass wrote: > This command is fairly complicated so documentation is useful. > Unfortunately I an not sure how the MTD side of things works and cannot > find information about that. > > Signed-off-by: Simon Glass > --- > > (no changes since v2) > > Changes in v2: > - Many fixes as suggested by Heinrich > > doc/usage/index.rst | 1 + > doc/usage/sf.rst | 241 ++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 242 insertions(+) > create mode 100644 doc/usage/sf.rst > [...] > +Erase > +~~~~~ > + > +Use *sf erase* to erase a region of SPI flash. The erase will fail if any part > +of the region to be erased is protected or lies past the end of the flash. It > +may also fail if the start offset or length are not aligned to an erase region > +(e.g. 256 bytes). > + > + > +Update > +~~~~~~ > + > +Use *sf update* to automatically erase and update a region of SPI flash from > +memory. This works a sector at a time (typical 256 bytes or 4KB). For each Nitpick: I haven't seen any flash with a 256 bytes sector size. 256 bytes is usually the page size, not the (erase) sector size. Looking at spi-nor-ids.c, 4 KiB and 64 KiB seem to be the most common. I think it is better to use one of them to make sure readers don't confuse page size and sector size. > +sector it first checks if the sector already has the right data. If so it is > +skipped. If not, the sector is erased and the new data written. Note that if > +the length is not a multiple of the erase size, the space after the data in > +the last sector will be erased. If the offset does not start at the beginning > +of an erase block, the operation will fail. > + > +Speed statistics are shown including the number of bytes that were already > +correct. > + > + > +Protect > +~~~~~~~ > + > +SPI-flash chips often have a protection feature where the chip is split up into > +regions which can be locked or unlocked. With *sf protect* it is possible to > +change these settings, if supported by the driver. > + > +lock|unlock > + Selects whether to lock or unlock the sectors > + > + > + Start sector number to lock/unlock. This may be the byte offset or some > + other value, depending on the chip. > + > + > + Number of bytes to lock/unlock > + > + > +Test > +~~~~ > + > +A convenient and fast *sf test* subcommand provides a way to check that SPI > +flash is working as expected. This works in four stages: > + > + * erase - erases the entire region > + * check - checks that the region is erased > + * write - writes a test pattern to the region, consisting of the U-Boot code > + * read - reads back the test pattern to check that it was written correctly > + > +Memory is allocated for two buffers, each bytes in size. At typical > +size is 64KB to 1MB. The offset and size must be aligned to an erase boundary. > + > +Note that this test will fail if any part of the SPI flash is write-protected. > + > + > +Examples > +-------- > + > +This first example uses sandbox:: > + Please show the sf probe command as well here and below. Other than these comments Acked-by: Pratyush Yadav Thanks. > + => sf read 1000 1100 80000 > + device 0 offset 0x1100, size 0x80000 > + SF: 524288 bytes @ 0x1100 Read: OK > + => md 1000 > + 00001000: edfe0dd0 f33a0000 78000000 84250000 ......:....x..%. > + 00001010: 28000000 11000000 10000000 00000000 ...(............ > + 00001020: 6f050000 0c250000 00000000 00000000 ...o..%......... > + 00001030: 00000000 00000000 00000000 00000000 ................ > + 00001040: 00000000 00000000 00000000 00000000 ................ > + 00001050: 00000000 00000000 00000000 00000000 ................ > + 00001060: 00000000 00000000 00000000 00000000 ................ > + 00001070: 00000000 00000000 01000000 00000000 ................ > + 00001080: 03000000 04000000 00000000 01000000 ................ > + 00001090: 03000000 04000000 0f000000 01000000 ................ > + 000010a0: 03000000 08000000 1b000000 646e6173 ............sand > + 000010b0: 00786f62 03000000 08000000 21000000 box............! > + 000010c0: 646e6173 00786f62 01000000 61696c61 sandbox.....alia > + 000010d0: 00736573 03000000 07000000 2c000000 ses............, > + 000010e0: 6332692f 00003040 03000000 07000000 /i2c@0.......... > + 000010f0: 31000000 6963702f 00003040 03000000 ...1/pci@0...... > + => sf erase 0 80000 > + SF: 524288 bytes @ 0x0 Erased: OK > + => sf read 1000 1100 80000 > + device 0 offset 0x1100, size 0x80000 > + SF: 524288 bytes @ 0x1100 Read: OK > + => md 1000 > + 00001000: ffffffff ffffffff ffffffff ffffffff ................ > + 00001010: ffffffff ffffffff ffffffff ffffffff ................ > + 00001020: ffffffff ffffffff ffffffff ffffffff ................ > + 00001030: ffffffff ffffffff ffffffff ffffffff ................ > + 00001040: ffffffff ffffffff ffffffff ffffffff ................ > + 00001050: ffffffff ffffffff ffffffff ffffffff ................ > + 00001060: ffffffff ffffffff ffffffff ffffffff ................ > + 00001070: ffffffff ffffffff ffffffff ffffffff ................ > + 00001080: ffffffff ffffffff ffffffff ffffffff ................ > + 00001090: ffffffff ffffffff ffffffff ffffffff ................ > + 000010a0: ffffffff ffffffff ffffffff ffffffff ................ > + 000010b0: ffffffff ffffffff ffffffff ffffffff ................ > + 000010c0: ffffffff ffffffff ffffffff ffffffff ................ > + 000010d0: ffffffff ffffffff ffffffff ffffffff ................ > + 000010e0: ffffffff ffffffff ffffffff ffffffff ................ > + 000010f0: ffffffff ffffffff ffffffff ffffffff ................ > + > +This second example is running on coral, an x86 Chromebook:: > + > + => sf erase 300000 80000 > + SF: 524288 bytes @ 0x300000 Erased: OK > + => sf update 1110000 300000 80000 > + device 0 offset 0x300000, size 0x80000 > + 524288 bytes written, 0 bytes skipped in 0.457s, speed 1164578 B/s > + > + # This does nothing as the flash is already updated > + => sf update 1110000 300000 80000 > + device 0 offset 0x300000, size 0x80000 > + 0 bytes written, 524288 bytes skipped in 0.196s, speed 2684354 B/s > + => sf test 00000 80000 # try a protected region > + SPI flash test: > + Erase failed (err = -5) > + Test failed > + => sf test 800000 80000 > + SPI flash test: > + 0 erase: 18 ticks, 28444 KiB/s 227.552 Mbps > + 1 check: 192 ticks, 2666 KiB/s 21.328 Mbps > + 2 write: 227 ticks, 2255 KiB/s 18.040 Mbps > + 3 read: 189 ticks, 2708 KiB/s 21.664 Mbps > + Test passed > + 0 erase: 18 ticks, 28444 KiB/s 227.552 Mbps > + 1 check: 192 ticks, 2666 KiB/s 21.328 Mbps > + 2 write: 227 ticks, 2255 KiB/s 18.040 Mbps > + 3 read: 189 ticks, 2708 KiB/s 21.664 Mbps > + > + > +.. _SPI documentation: > + https://en.wikipedia.org/wiki/Serial_Peripheral_Interface > -- > 2.32.0.554.ge1b32706d8-goog > -- Regards, Pratyush Yadav Texas Instruments Inc.