fw_env: add redundant env support for MTD_ABSENT
PATCH v2 1/2 fw_env: add redundant env support for MTD_ABSENT
From: Oliver Metz <[email protected]>
Signed-off-by Oliver Metz <[email protected]>
Tested-by Luka Perkov <[email protected]>
---
v1 -> v2:
* correct spelling of redundant
tools/env/fw_env.c | 3 +++ 1 file changed, 3 insertions(+)
tools/env/fw_env.c +3 -0
@@ -1136,6 +1136,9 @@ int fw_env_open(void) }else if (DEVTYPE (dev_current) ==MTD_UBIVOLUME &&DEVTYPE (!dev_current) ==MTD_UBIVOLUME ) { environment.flag_scheme =FLAG_INCREMENTAL ; + }else if (DEVTYPE (dev_current) ==MTD_ABSENT && +DEVTYPE (!dev_current) ==MTD_ABSENT ) { + environment.flag_scheme =FLAG_INCREMENTAL ; }else {fprintf (stderr,"Incompatible flash types!\n" );return -1 ;
Signature · 1 line
1.8.4
PATCH v2 2/2 fw_env: fix writing environment for mtd devices
From: Oliver Metz <[email protected]>
Signed-off-by Oliver Metz <[email protected]>
Tested-by Luka Perkov <[email protected]>
---
v1 -> v2:
* fix checkpatch.pl warnings
tools/env/fw_env.c | 70 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 42 insertions(+), 28 deletions(-)
tools/env/fw_env.c +42 -28
@@ -727,27 +727,39 @@ static int flash_write_buf (int dev, int fd, void *buf, size_t count,MEMGETBADBLOCK needs 64 bits */ int rc; - blocklen =DEVESIZE (dev); +/* +* For mtd devices only offset and size of the environment do matter +*/ +if (mtd_type ==MTD_ABSENT ) { + blocklen = count; + top_of_range = offset + count; + erase_len = blocklen; + blockstart = offset; + block_seek =0 ; + write_total = blocklen; + }else { + blocklen =DEVESIZE (dev); - top_of_range = ((DEVOFFSET (dev) / blocklen) + -ENVSECTORS (dev)) * blocklen; + top_of_range = ((DEVOFFSET (dev) / blocklen) + +ENVSECTORS (dev)) * blocklen; - erase_offset = (offset / blocklen) * blocklen; + erase_offset = (offset / blocklen) * blocklen; -/* Maximum area we may use */ - erase_len = top_of_range - erase_offset; +/* Maximum area we may use */ + erase_len = top_of_range - erase_offset; - blockstart = erase_offset; -/* Offset inside a block */ - block_seek = offset - erase_offset; + blockstart = erase_offset; +/* Offset inside a block */ + block_seek = offset - erase_offset; -/* -* Data size we actually have to write: from the start of the block -* to the start of the data, then count bytes of data, and to the -* end of the block -*/ - write_total = ((block_seek + count + blocklen -1 ) / - blocklen) * blocklen; +/* +* Data size we actually write: from the start of the block +* to the start of the data, then count bytes of data, and +* to the end of the block +*/ + write_total = ((block_seek + count + blocklen -1 ) / + blocklen) * blocklen; + }/* * Support data anywhere within erase sectors: read out the complete
@@ -818,17 +830,18 @@ static int flash_write_buf (int dev, int fd, void *buf, size_t count,continue ; } - erase.start = blockstart; -ioctl (fd,MEMUNLOCK , &erase); -/* These do not need an explicit erase cycle */ -if (mtd_type !=MTD_ABSENT && - mtd_type !=MTD_DATAFLASH ) -if (ioctl (fd,MEMERASE , &erase) !=0 ) { -fprintf (stderr,"MTD erase error on %s: %s\n" , -DEVNAME (dev), -strerror (errno)); -return -1 ; - } +if (mtd_type !=MTD_ABSENT ) { + erase.start = blockstart; +ioctl (fd,MEMUNLOCK , &erase); +/* These do not need an explicit erase cycle */ +if (mtd_type !=MTD_DATAFLASH ) +if (ioctl (fd,MEMERASE , &erase) !=0 ) { +fprintf (stderr, +"MTD erase error on %s: %s\n" , +DEVNAME (dev),strerror (errno)); +return -1 ; + } + }if (lseek (fd, blockstart,SEEK_SET ) ==-1 ) { fprintf (stderr,
@@ -847,7 +860,8 @@ static int flash_write_buf (int dev, int fd, void *buf, size_t count,return -1 ; } -ioctl (fd,MEMLOCK , &erase); +if (mtd_type !=MTD_ABSENT ) +ioctl (fd,MEMLOCK , &erase); processed += blocklen; block_seek =0 ;
Signature · 1 line
1.8.4
PATCH v2 1/2 fw_env: add redundant env support for MTD_ABSENT
In reply to Luka PerkovQuoted 4 lines · Luka Perkov
From: Oliver Metz <[email protected]>
Signed-off-by Oliver Metz <[email protected]>Tested-by Luka Perkov <[email protected]>
Applied to u-boot/master along with 2/2, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130906/866de4f9/attachment.pgp>