From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gerlando Falauto Date: Tue, 3 Apr 2012 17:14:56 +0200 Subject: [U-Boot] [PATCH 0/2] SPI flash update command In-Reply-To: <4F5F9103.1030807@keymile.com> References: <4F5F9103.1030807@keymile.com> Message-ID: <1333466098-31783-1-git-send-email-gerlando.falauto@keymile.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi, this patchset allows "sf update" to erase+write a number of bytes which is not a multiple of the sector size. Start address must still be sector-aligned though. The first patch trivially makes it such it will always erase an entire sector before writing, regardless of the amount of data to write (i.e. the last sector is erased completely before writing it only partially). The second patch just makes sure that the original data at the end of the sector is written back so to apparently remain unchanged. I anticipate two potential objections already: - whether it is really worth writing back the portion of the sector which was erased but shouldn't have been overwritten (whole purpose of the second patch) - these changes make the semantics of "sf update" and "sf erase" somewhat different, in that "sf erase" needs a "+" to deal with odd lengths, whereas "sf update" does not. I think this is only partially true. After all, "sf update" is already somehow special. It's not a standard operation for a flash (erase, read, write). It combines two of those operations, and takes care of optimizing the process by removing unneeded erase/write operations. So it might as well deserve to be "special", in my opinion. Plus, it makes the command for updating u-boot as easy as sf update ${load_addr_r} 0 ${filesize} Feedback and criticism more than welcome, of course. Thank you, Gerlando Gerlando Falauto (2): cmd_sf: let "sf update" erase last sector as a whole cmd_sf: "sf update" preserve the final part of the last sector common/cmd_sf.c | 18 ++++++++++++++++-- 1 files changed, 16 insertions(+), 2 deletions(-)