tools/bmap-tools.git
11 years agotests: add the base functionality test
Artem Bityutskiy [Tue, 20 Nov 2012 07:36:57 +0000 (09:36 +0200)]
tests: add the base functionality test

Change-Id: I035f71eadda2d2da83a1c8776f035cc1d5ccde12
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCreate: fix and silence pylint warnings
Artem Bityutskiy [Tue, 20 Nov 2012 13:54:15 +0000 (15:54 +0200)]
BmapCreate: fix and silence pylint warnings

Fix several pylint warnings and silence a couple.

Change-Id: If714828815ac72c026e05e022fb03f6ffed2fa6c
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy.py: fix and silence pylint warnings
Artem Bityutskiy [Tue, 20 Nov 2012 13:46:08 +0000 (15:46 +0200)]
BmapCopy.py: fix and silence pylint warnings

Fix a couple of pylint warnings and silence one.

Change-Id: I392e95b6bf0c3805e3c07cb8d80e0d0aef1b7311
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy.py: flush the destination file on exit
Artem Bityutskiy [Tue, 20 Nov 2012 13:07:44 +0000 (15:07 +0200)]
BmapCopy.py: flush the destination file on exit

Always flush the destination file on exit to make sure that if the user
opens the same file by path - he/she sees all the data.

Change-Id: I493d0c92d4818e289216925e00111128cba88db6
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy.py: open the destination file for writing
Artem Bityutskiy [Tue, 20 Nov 2012 13:06:21 +0000 (15:06 +0200)]
BmapCopy.py: open the destination file for writing

Open the destination file in write-only mode, because we only write to
this file, and never read from.

Change-Id: I5bdef84ecdb7faf38190a00bb34fb1b183fb9430
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmaptool: open the destination file in binary mode
Artem Bityutskiy [Tue, 20 Nov 2012 13:04:53 +0000 (15:04 +0200)]
bmaptool: open the destination file in binary mode

This is just a small correction - the destination file is a binary file,
so open it in binary mode.

Change-Id: I38ca25dabc38dabf65a18b6f50d8de066c8f18b1
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCreate.py: support file-like objects
Artem Bityutskiy [Tue, 20 Nov 2012 11:52:08 +0000 (13:52 +0200)]
BmapCreate.py: support file-like objects

It is very useful give BmapCreate file-like objects instead of file paths, and
this is exactly what this patch implements.

Change-Id: I6d342ea64584b8b203f62a0df33e2a6df5eb9da2
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCreate.py: stop using logger for the bmap output
Artem Bityutskiy [Tue, 20 Nov 2012 11:19:33 +0000 (13:19 +0200)]
BmapCreate.py: stop using logger for the bmap output

It is an overkill to use a logger object to output the bmap, and it is also
rather difficult for the users. Instead, make 'BmapCreate' accept a file-like
object for the output, not a logger object.

Change-Id: I7cf83dc8e0c43f762449e7fcf200b1f8b66359c5
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy.py: support file-like objects
Artem Bityutskiy [Tue, 20 Nov 2012 10:42:01 +0000 (12:42 +0200)]
BmapCopy.py: support file-like objects

It is very useful give BmapCopy file-like objects instead of file paths, and
this is exactly what this patch implements.

Change-Id: I41b40e8369743bf53e018f503b65719a1c823464
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoTODO: add an entry about interruptions
Artem Bityutskiy [Tue, 20 Nov 2012 09:28:43 +0000 (11:28 +0200)]
TODO: add an entry about interruptions

Change-Id: Icd9f43eb8b9b9c48624cfaf4553b9fa2acf5f509
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCreate: remove useless seek
Artem Bityutskiy [Tue, 20 Nov 2012 09:37:08 +0000 (11:37 +0200)]
BmapCreate: remove useless seek

We do not need to seek the image to the beginning because we do not care
about the file position - we do not read of write the file.

Change-Id: Ib5e9abd8560e77b1a095d1882594de15e97be4e7
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy.py: fix incorrect assignment
Artem Bityutskiy [Tue, 20 Nov 2012 09:11:24 +0000 (11:11 +0200)]
BmapCopy.py: fix incorrect assignment

This patch fixes the following bug:

UnboundLocalError: local variable 'last' referenced before assignment

which happens when the range consists only of one block.

Change-Id: I4d91d2abdd45408b6d2a6131e3ddd7fbbe3492f9
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapHelpers.py: introduce a 'get_block_size()' function
Artem Bityutskiy [Mon, 19 Nov 2012 15:02:40 +0000 (17:02 +0200)]
BmapHelpers.py: introduce a 'get_block_size()' function

Move the piece of code which finds out block size from 'BmapCreate.py'
to 'BmapHelpers.py' - we need this code in tests as well.

Change-Id: I1682a0cffc0348132409bdf085c9fb4fce5b4473
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy.py: save and restore block device settings
Artem Bityutskiy [Fri, 16 Nov 2012 11:31:44 +0000 (13:31 +0200)]
BmapCopy.py: save and restore block device settings

We change block device settings to improve I/O speed (e.g., switch to the
'noop' I/O scheduler). This patch also teaches the BmapCopy module to restore
the settings when the copying is done.

Change-Id: I31caddf5d86510452a7b58be3268ed973d057354
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy.py: make blkdev optimization work for partitions as wall
Artem Bityutskiy [Fri, 16 Nov 2012 10:31:56 +0000 (12:31 +0200)]
BmapCopy.py: make blkdev optimization work for partitions as wall

If we are writing to something like /dev/sdc1 instead of /dev/sdc, we should
go one level up in the sysfs hierarchy to access the block device configuration
files like 'scheduler'.

Change-Id: I845a145197aa15513a288214f0b58c7a1da3b8cf
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoPre-release version 0.4
Artem Bityutskiy [Wed, 14 Nov 2012 10:38:08 +0000 (12:38 +0200)]
Pre-release version 0.4

Change-Id: I50a735e3dedcdfd3035d58adb7edcc355994689a
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy.py: write without bmap the same way as with bmap
Artem Bityutskiy [Thu, 15 Nov 2012 09:28:10 +0000 (11:28 +0200)]
BmapCopy.py: write without bmap the same way as with bmap

Unify the code paths for the situations when we have bmap and when we do not
have it.

Change-Id: I7a8a47cf0a475077953590ea9ebbd4b905acb4ed
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCreate: generate more readable bmap
Artem Bityutskiy [Thu, 15 Nov 2012 09:00:34 +0000 (11:00 +0200)]
BmapCreate: generate more readable bmap

When the blocks rage consists of a single block (say 18282), write it
in form of <>18282</> instead of less readable <>18282-18282</> form.
'bmaptool copy' supports both.

Change-Id: I96cd97b1913227de878004fc29eb65b76f11058e
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy.py: fix another pylint complaint
Artem Bityutskiy [Thu, 15 Nov 2012 08:51:54 +0000 (10:51 +0200)]
BmapCopy.py: fix another pylint complaint

Change-Id: I526140d32b362cb7669f1ce10dbae793b8937229
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCreate.py: remove too long lines
Artem Bityutskiy [Thu, 15 Nov 2012 08:48:56 +0000 (10:48 +0200)]
BmapCreate.py: remove too long lines

Pylint complains a lot about long lines, which is fixed by this patch.

Change-Id: Ib615a44d7529ce35717cd00ac2714b6e36301e68
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy.py: handle exceptions from the reader thread
Artem Bityutskiy [Wed, 14 Nov 2012 09:59:38 +0000 (11:59 +0200)]
BmapCopy.py: handle exceptions from the reader thread

Use the batch queue to pass exceptions from the reader thread to the main
thread in case of errors, and raise the exceptions from the reader thread.

Change-Id: I02801278b76bb1b390b6e36372ee0d5b487e79c2
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy: implement threaded reader
Artem Bityutskiy [Tue, 13 Nov 2012 13:43:50 +0000 (15:43 +0200)]
BmapCopy: implement threaded reader

Read the data from a separate thread. This does not change the performance
measurably in case of uncompressed images, but does improve writing speed in
case of compressed images - Tizen.bz2 image flashing drops from 2m13s to
1m43s.

Change-Id: I3300a569042d16357fcc0920c3f03f3fff08d29d
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy.py: implement an iterator for reading the image
Artem Bityutskiy [Tue, 13 Nov 2012 12:52:26 +0000 (14:52 +0200)]
BmapCopy.py: implement an iterator for reading the image

Implement a '_get_batches()' iterator which reads batches of data from
the image file.

Change-Id: If914efc60ea6a259f8430ded8c2d4143b07adc3c
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy.py: introduce a helper iterator
Artem Bityutskiy [Tue, 13 Nov 2012 11:57:56 +0000 (13:57 +0200)]
BmapCopy.py: introduce a helper iterator

The '_copy_data()' function is a bit ugly and large. Simplify it by introducing
an iterator which splits the entire blocks range on smaller batch ranges, and
we do actual I/O in these small batches.

Change-Id: I6c6e2cb23672a6abbdb679776c82046b5706b5c8
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy.py: move chunk_size to the class level
Artem Bityutskiy [Tue, 13 Nov 2012 11:37:03 +0000 (13:37 +0200)]
BmapCopy.py: move chunk_size to the class level

We use 'chunk_size' variable in several places and hard-code it to various
values. Clean this up by introducing class-level variables for size of the
I/O operations we do. Call them 'batch_blocks' and 'batch_bytes' for the
I/O batch size in blocks and bytes.

Change-Id: I0ec6058a20e89d685e917c13268c2f70f385c053
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy.py: introduce a iterator for blocks ranges
Artem Bityutskiy [Tue, 13 Nov 2012 10:18:12 +0000 (12:18 +0200)]
BmapCopy.py: introduce a iterator for blocks ranges

Add a 'get_block_ranges()' iterator function which parses the bmap
file and returns block ranges. This makes the code a bit nicer and
modular.

Change-Id: I09270f4bc3f74b676fcf3b3f6e87c57e222c709a
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmaptool: fix a print
Artem Bityutskiy [Wed, 14 Nov 2012 13:25:05 +0000 (15:25 +0200)]
bmaptool: fix a print

We write to regular files too, not only to block devices, fix the
message correspondingly.

Change-Id: I169fc51bfd2833a01749fd30d936da4e6bd8b98e
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoFix a number of pylint warnings
Artem Bityutskiy [Wed, 14 Nov 2012 13:23:43 +0000 (15:23 +0200)]
Fix a number of pylint warnings

Change-Id: I18007ca6c50e3a733d5ee9e944636bfdaab97f45
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmaptool: pre-release version 0.3
Artem Bityutskiy [Tue, 13 Nov 2012 09:00:05 +0000 (11:00 +0200)]
bmaptool: pre-release version 0.3

Change-Id: I1dacb92a73445600497a608917367ba4a2aff295
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy.py: synchronize periodically
Artem Bityutskiy [Mon, 12 Nov 2012 13:39:48 +0000 (15:39 +0200)]
BmapCopy.py: synchronize periodically

Do not let the kernel cache too much data and run fsync() periodically. This
should impreve the Ctrl-C handling and terminate the program faster. So this
is mostly for the sake of user-friendliness, although it hurts write speed
a little bit.

Based on the idea of Patrick Ohly <patrick.ohly@intel.com>.

Change-Id: I0fa8358455623b0fc709b2a845b4753a1e25a9be
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy: move a local variable to the class level
Artem Bityutskiy [Mon, 12 Nov 2012 12:32:33 +0000 (14:32 +0200)]
BmapCopy: move a local variable to the class level

Move the 'blocks_written' local variable from the 'copy()' method to the
class lever. We'll need it in one of the next patches in other methods to find
out how much blocks has already been written.

Change-Id: I28220b85af44a39bd3643fb6d62a14804f56f9d3
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmaptool: remove stale attribute reference
Artem Bityutskiy [Mon, 12 Nov 2012 13:41:49 +0000 (15:41 +0200)]
bmaptool: remove stale attribute reference

We do not have the 'writer.target_is_block_device' attribute anymore, remove
it.

Change-Id: Id055402c5195dc10f9ced04e276610a7008fea6e
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoAdd the TODO file to store the TODO list
Artem Bityutskiy [Mon, 12 Nov 2012 12:19:24 +0000 (14:19 +0200)]
Add the TODO file to store the TODO list

Change-Id: I33e82a3882a1fc382f93e161348ab908f9ff0565
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmaptool: fix flashing speed calculation
Artem Bityutskiy [Mon, 12 Nov 2012 12:12:46 +0000 (14:12 +0200)]
bmaptool: fix flashing speed calculation

We write 'mapped_size' amount of data, not the entire image, so use the correct
variable when calculating the flashing speed.

Change-Id: I68a7eb597c3e29e4c4795ca907d13cdb466e5363
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoDebian packaging: add python 2.7 dependency
Artem Bityutskiy [Mon, 12 Nov 2012 10:29:43 +0000 (12:29 +0200)]
Debian packaging: add python 2.7 dependency

Change-Id: I3a56337c0b9006e9a86a8118b62bd96c9a664e92
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy.py: fix exeptions handling in bdev optimization
Artem Bityutskiy [Mon, 12 Nov 2012 07:25:50 +0000 (09:25 +0200)]
BmapCopy.py: fix exeptions handling in bdev optimization

The 'open()' function throws IOError exceptions, not OSError. Fix our
exception handling.

Change-Id: I13761072efa62cb96fbf01164691e114f68074de
Reported-by: Patrick Ohly <patrick.ohly@intel.com>
Reported-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCreate.py: remove junk white-space
Artem Bityutskiy [Fri, 9 Nov 2012 16:36:37 +0000 (18:36 +0200)]
BmapCreate.py: remove junk white-space

We do not need a white-space after 'sha1' attribute.

Change-Id: I4a66026d4e77309bfe2fdd092b06afa752a89b1e
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCreate.py: fix a brown-paperbag bug
Artem Bityutskiy [Fri, 9 Nov 2012 16:35:33 +0000 (18:35 +0200)]
BmapCreate.py: fix a brown-paperbag bug

We did not seek the image file, so BmapCreate calculated SHA1 incorrectly.
Fix this.

Change-Id: Ie99cf26ac3af4a319832dc79bc82ba89b7b31280
Reported-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoPre-release version 0.2
Artem Bityutskiy [Fri, 9 Nov 2012 10:22:31 +0000 (12:22 +0200)]
Pre-release version 0.2

Change-Id: Iff5a35b4a0bd9781ae160249a669b0cd7d32b53e
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy: renames to "copy"
Artem Bityutskiy [Thu, 8 Nov 2012 16:47:36 +0000 (18:47 +0200)]
BmapCopy: renames to "copy"

Rename the write() method to copy() because it matches the class name and the
idea. Similarly, rename several variables and change 'write' to 'copy' in few
comments.

Change-Id: I441eb3cdc9fc94210ed0d9e91d3fa1689edcc0ef
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy: amend comments
Artem Bityutskiy [Thu, 8 Nov 2012 16:43:03 +0000 (18:43 +0200)]
BmapCopy: amend comments

After all the rework - go through all the commentaries and docstrings and amend
them to match the current state of art.

Change-Id: I3e0de168a697795c498045414d294979f35d7efa
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy: move block device tuning to BmapBdevCopy
Artem Bityutskiy [Thu, 8 Nov 2012 16:08:43 +0000 (18:08 +0200)]
BmapCopy: move block device tuning to BmapBdevCopy

This seems to be the final piece of code which has to be moved. Now
BmapCopy is really independent of the destination file type.

Change-Id: I2a74ccea7db5984ee3940bd95a1ebfd21b6bdedb
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy: move block device capacity check to BmapBdevCopy
Artem Bityutskiy [Thu, 8 Nov 2012 15:59:41 +0000 (17:59 +0200)]
BmapCopy: move block device capacity check to BmapBdevCopy

Change-Id: Ia09788918ce5ad7a2fd27d8cd4d0c2965d4821c4
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapBdevCopy: move block device opening
Artem Bityutskiy [Thu, 8 Nov 2012 15:44:29 +0000 (17:44 +0200)]
BmapBdevCopy: move block device opening

Start moving the block device - specific stuff to the BmapBdevCopy class.
Move the open funcion first.

Change-Id: I06afd6554ec51b11f9c148a3da76dab5a9fd80f0
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy: rename 'bdev_path' to 'dest_path'
Artem Bityutskiy [Thu, 8 Nov 2012 15:37:40 +0000 (17:37 +0200)]
BmapCopy: rename 'bdev_path' to 'dest_path'

Similarly to the previous commits - rename the path attribute to 'dest_path',
because the destination does not have to be a block device.

Change-Id: I769abc160f52574aa466a71965be401d91ed243e
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCopy: rename 'f_bdev' to 'f_dest'
Artem Bityutskiy [Thu, 8 Nov 2012 15:33:39 +0000 (17:33 +0200)]
BmapCopy: rename 'f_bdev' to 'f_dest'

Just like we did in bmaptools - our destination file may be anything,
not only block device, so use 'f_dest' for the name.

Change-Id: Ia2a863238ceefbff483e025940e931b62e06e3a8
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmaptool: distinguish between block devices and regular file
Artem Bityutskiy [Thu, 8 Nov 2012 15:26:04 +0000 (17:26 +0200)]
bmaptool: distinguish between block devices and regular file

Teach bmaptool to distinguish between block devices and regular files and
use the specialized version of 'BmapCopy' in case of block devices. The
specialized version will be implemented in the 'BmapBdevCopy' class, which
is just a copy of the base class so far.

Change-Id: I444f121893dfd5d637a08300191c7a5dbc082d4e
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmaptool: rename the bdev argument to dest
Artem Bityutskiy [Thu, 8 Nov 2012 15:13:55 +0000 (17:13 +0200)]
bmaptool: rename the bdev argument to dest

Sinc the 'bmaptool copy' command is not only for block device, naming
the destination file 'bdev' is a bad idea. Let's name it 'dest' instead,
which stands for 'destination' and has the same length as 'bdev', so that
renaming is simple.

Change-Id: I7c0382446dccd569aa26a69c0e06663cd139e3ae
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoRename BmapFlash to BmapCopy
Artem Bityutskiy [Thu, 8 Nov 2012 14:52:07 +0000 (16:52 +0200)]
Rename BmapFlash to BmapCopy

Rename the module file name and the class name. There is a lot more to rename
and this is just the first step.

Change-Id: Ibee4082c783c5417401d10a41ef7787607108283
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCreate: amend comments
Artem Bityutskiy [Thu, 8 Nov 2012 14:46:25 +0000 (16:46 +0200)]
BmapCreate: amend comments

Just refresh the comments and change the identation style in docstrigs to
something I like more nowadays.

Change-Id: I430a4f8eb71c6b739b5714d84e19d723412e761e
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoRename bmap to bmaptool
Artem Bityutskiy [Thu, 8 Nov 2012 14:06:15 +0000 (16:06 +0200)]
Rename bmap to bmaptool

The word 'bmap' is already reserved for the bmap file, it is bad idea to use
it for the tool. Let's call the tool 'bmaptool' instead.

Change-Id: I0c6fb70bdf3bbdcba11985c0b646f9e5a538c872
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapFlash: fix a bunch of pylint complaints
Artem Bityutskiy [Thu, 8 Nov 2012 14:00:28 +0000 (16:00 +0200)]
BmapFlash: fix a bunch of pylint complaints

Change-Id: Ica510861824f16af29382adda47a8a2ba5675058
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCreate: fix function name
Artem Bityutskiy [Thu, 8 Nov 2012 13:56:45 +0000 (15:56 +0200)]
BmapCreate: fix function name

Function name was mis-spelled, fix it.

Change-Id: Ib3c58367a4fd757fbee4753925b69d9dc6c38a5e
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmap: remove useless warning
Artem Bityutskiy [Thu, 8 Nov 2012 13:52:18 +0000 (15:52 +0200)]
bmap: remove useless warning

No need to print a warning when copying to a regualr file, it makes little
sense and useless.

Change-Id: I77ccfe2b0a20e2ad90f97a19fdde1d8a06bd8026
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmap: rename flash to copy
Artem Bityutskiy [Thu, 8 Nov 2012 13:49:02 +0000 (15:49 +0200)]
bmap: rename flash to copy

Rename the 'flash' command to 'copy' command. Indeed, we just copy data from
the image to a destination file, which may be a block device or something else.
So let's use better naming.

Change-Id: I135668f3aa8573b9c3ce7dd571751936d47a6552
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmap: amend comments
Artem Bityutskiy [Thu, 8 Nov 2012 13:39:30 +0000 (15:39 +0200)]
bmap: amend comments

This patch changes commentaries and few messages we print.

I have a lot of changes planned, and the biggest is that I want to rename
the 'flash' command to 'copy' command. This commit is a preparation for
this change.

Change-Id: Ifc3d602d953592fba6a2892629516a08b067ec9f
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmap: correct Ctrl-C message
Artem Bityutskiy [Thu, 8 Nov 2012 13:41:20 +0000 (15:41 +0200)]
bmap: correct Ctrl-C message

The long synching we warn the user about happens only for block devices
and does not happen for regualr files. So warn only if we are writing to
a block device. Also, correct the warning spelling a bit.

Change-Id: I0b1fc3362da371b150b2ea09a9b07fe83e8b149e
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapFlash: spelling fixes
Artem Bityutskiy [Thu, 8 Nov 2012 11:47:55 +0000 (13:47 +0200)]
BmapFlash: spelling fixes

Change-Id: I95c3097563677348e3149b61aceebef58cd8f7cc
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCreate: spelling fixes
Artem Bityutskiy [Thu, 8 Nov 2012 11:45:23 +0000 (13:45 +0200)]
BmapCreate: spelling fixes

Change-Id: Iad4f07f7d15bcebf7620d8fa2380bec03f911025
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmap: a couple of spelling fixes
Artem Bityutskiy [Thu, 8 Nov 2012 11:42:34 +0000 (13:42 +0200)]
bmap: a couple of spelling fixes

Change-Id: I57ccc904fdfdebc1342fc5a401ddb73895cbfd4d
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoFix pylint warning
Artem Bityutskiy [Thu, 8 Nov 2012 11:33:41 +0000 (13:33 +0200)]
Fix pylint warning

Too long line...

Change-Id: I6c0d0b2aee94e7996db5dcac6a5513da7f47e067
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoImplement sub-commands support
Artem Bityutskiy [Thu, 8 Nov 2012 11:33:41 +0000 (13:33 +0200)]
Implement sub-commands support

Remove separate 'bmap-creator' and 'bmap-flasher' tools and instead, implement
a single 'bmap' tool with 'create' and 'flash' subcommands.

Change-Id: I6c0d0b2aee94e7996db5dcac6a5513da7f47e067
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoRename API classes
Artem Bityutskiy [Thu, 8 Nov 2012 10:16:02 +0000 (12:16 +0200)]
Rename API classes

Change API class names from BmapCreator/BmapFlasher to BmapCreate/BmapFlash.
I plan to get rid of 'bmap-creator' and 'bmap-flasher' and instead, have
a single 'bmap' tool with sub-commands: bmap create and bmap flash.

Change-Id: I5b6fbb0b75954fc27ce39ad5e4317f4957461595
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoRename API modules
Artem Bityutskiy [Thu, 8 Nov 2012 10:13:23 +0000 (12:13 +0200)]
Rename API modules

I am planning to switch to 'bmap [flash|create]' sub-commands, and this
patch is a preparation which renames API modules to match the new scheme.

Change-Id: I3ae8d726e91d8605a01d044f86a0d89b5458346d
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoRelease version 0.1.1
Artem Bityutskiy [Wed, 7 Nov 2012 09:39:53 +0000 (11:39 +0200)]
Release version 0.1.1

Change-Id: I86c186f8a8ee99cde051fd626c9e8854ae90a9cf
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agopackaging: correct dependency
Artem Bityutskiy [Wed, 7 Nov 2012 09:26:49 +0000 (11:26 +0200)]
packaging: correct dependency

Although xml.etree is part of python, Fedora and OpenSuse provide this
module in separate packages. Add the corresponding packaging requirements.

Change-Id: I705fcb091eb7f977f2d564fe0d86ede1bad295f3
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmap-flasher: act on KeyboardInterrupt
Artem Bityutskiy [Wed, 7 Nov 2012 09:09:17 +0000 (11:09 +0200)]
bmap-flasher: act on KeyboardInterrupt

When one pressess Ctrl-C, the program hands for several minutes and does
not exit. The reason is that the kernel synchronized the block device on
the last close.

Let's at least print a message to the user and tell that there is no need
to worry.

Change-Id: I61368dddf697161c2a47012c5f9e2c96b74ef273
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmap-flasher: kill the --no-sync option
Artem Bityutskiy [Wed, 7 Nov 2012 08:52:34 +0000 (10:52 +0200)]
bmap-flasher: kill the --no-sync option

The kernel sychronizes block devices on close automatically (in case of
the last reference becomes 0), so --no-sync does not work anyway.

Change-Id: Ib4783b85363a74b8d92a09c9a1a7636999569f4c
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapFlasher: improve flashing speed
Artem Bityutskiy [Tue, 6 Nov 2012 13:41:29 +0000 (15:41 +0200)]
BmapFlasher: improve flashing speed

Improve flashing speed by switching to the 'noop' I/O scheduler for the block
device we are flashing to. This gives ~20% write speed imporvement.

Also limit the write buffering in order make the flashing - we do not need that
and we better leave the memory for other applications.

Change-Id: Ideca1b4ee786c91606e91813d2ffe451380506d3
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapFlasher: error out if the image does not fit the block device
Artem Bityutskiy [Tue, 6 Nov 2012 13:21:30 +0000 (15:21 +0200)]
BmapFlasher: error out if the image does not fit the block device

I've got a bug report that the flasher tries to flash even if the block device
is too small. Let's fix this.

Change-Id: I4e7742d362fca8b6a2885b318a60fbeeb5ef1a9d
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapFlasher: provide a target_is_block_device attribute
Artem Bityutskiy [Tue, 6 Nov 2012 13:01:49 +0000 (15:01 +0200)]
BmapFlasher: provide a target_is_block_device attribute

Which is useful for bmap-flasher, because it does not have find this out
itslelf.

Note, this is rather bad approach, and later I'll introduce a base class
for flashing anywhere and a child class for flashing to block devices.

Change-Id: I1959359f357a70fa45d09cbad7b16104023070cd
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapFlasher: check that the image file is a regular file
Artem Bityutskiy [Tue, 6 Nov 2012 12:47:31 +0000 (14:47 +0200)]
BmapFlasher: check that the image file is a regular file

Change-Id: Ic9ec219e212eed38c01c6d18dd38df934500674e
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapFlasher: do not postpone size initialization for uncompressed images
Artem Bityutskiy [Tue, 6 Nov 2012 12:39:11 +0000 (14:39 +0200)]
BmapFlasher: do not postpone size initialization for uncompressed images

When we are flashing images without bmap, we cannot initialize various
size-related attributes until we flash the image if the image is compressed.
However, we can do this for uncompressed images.

Change-Id: I8b8e604e68f680acbd059c7a44f92c654a9b4755
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapFlasher: separate sizes initialization to a function
Artem Bityutskiy [Tue, 6 Nov 2012 12:31:43 +0000 (14:31 +0200)]
BmapFlasher: separate sizes initialization to a function

We will need this function in the next patch, so this is just a preparation.

Change-Id: If2d8c1474dce3255f92da8ae7287c6f86d8bc204
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapFlasher: open the block device in write-only mode
Artem Bityutskiy [Tue, 6 Nov 2012 11:47:46 +0000 (13:47 +0200)]
BmapFlasher: open the block device in write-only mode

... we do not need the read access.

Change-Id: I3cabe1ec9a6966981678f4d460edf848f6b0cd2a
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmap-flasher: fix a typo in the warning message
Artem Bityutskiy [Tue, 6 Nov 2012 08:05:52 +0000 (10:05 +0200)]
bmap-flasher: fix a typo in the warning message

Change-Id: Ie62c1bf5b66f78848da280ee59f5b2f84e44a846
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmap-flasher: change order of arguments
Artem Bityutskiy [Fri, 2 Nov 2012 12:33:20 +0000 (14:33 +0200)]
bmap-flasher: change order of arguments

bmap-flasher <src> <dest> is more intuitive than bmap-flasher <dst> <src>.

Change-Id: Ida87d73e538b7ec9f9b715d3fecd22e5e725461b
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapHelpers: handle small sizes correctly
Artem Bityutskiy [Thu, 1 Nov 2012 14:25:11 +0000 (16:25 +0200)]
BmapHelpers: handle small sizes correctly

Make sure we provide sane human-readable size for small sizes like 1 byte or 10
bytes. With this change, for sizes less than 512 we'll print X bytes, while for
larger sized we'll print 0.YKiB.

Change-Id: I7a5a32ed3a9dc26fb754299c55d7dbffdf531a37
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmap-creator: print a warning if no holes found
Artem Bityutskiy [Thu, 1 Nov 2012 14:16:33 +0000 (16:16 +0200)]
bmap-creator: print a warning if no holes found

Probably this means that the image file was not handled correctly and holes
were expanded.

Change-Id: I602b52ee6471e0a15938e2100b29329a1b066b3f
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoflasher: rename 'total_size'
Artem Bityutskiy [Thu, 1 Nov 2012 14:05:51 +0000 (16:05 +0200)]
flasher: rename 'total_size'

There is inconsistenty between the flasher and creator - we use 'total_size' in
flasher to describe the image size, while we use 'image_size' in the creator
for the same. Let's use the same terminology everywhere, so kill 'total_size'
and use 'image_size' everywhere.

Change-Id: I6bb826a8cdf36b9c89aea97c54d9ff6cb2431f46
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoTeach Creator and Flasher modules to provide human sizes
Artem Bityutskiy [Thu, 1 Nov 2012 14:01:50 +0000 (16:01 +0200)]
Teach Creator and Flasher modules to provide human sizes

Which we can use in the comman-line tools, which is quite handy.

Change-Id: I904d5895d9422b3bc6a54fdbfbd4e51b06996f95
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCreator: implement FIEMAP support
Artem Bityutskiy [Thu, 1 Nov 2012 12:47:19 +0000 (14:47 +0200)]
BmapCreator: implement FIEMAP support

It does not require root, unlike FIBMAP.

Change-Id: I82010ca3e756a8ab895327d6e782981f5fc0b88d
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapCreator: synchronize the image file before generating bmap
Artem Bityutskiy [Thu, 1 Nov 2012 08:54:36 +0000 (10:54 +0200)]
BmapCreator: synchronize the image file before generating bmap

To make sure the block map is correct.

Change-Id: Ic486edf22b2d986117faf9f53997d78fc589b9fd
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agopackaging: make myself to be the maintainer
Artem Bityutskiy [Wed, 31 Oct 2012 09:43:04 +0000 (11:43 +0200)]
packaging: make myself to be the maintainer

I guess I am the package maintainer, not Ed, while I am happy to have
Ed as the maintainer of the packaging stuff :-). However, the contents
of the package is maintained by me.

Change-Id: I9e6bc1f50a271e5c8b3d3730b5f1effd84ad7289
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoAdd initial version of bmap-creator and BmapCreator
Artem Bityutskiy [Wed, 31 Oct 2012 15:50:53 +0000 (17:50 +0200)]
Add initial version of bmap-creator and BmapCreator

Change-Id: I3c27b8ba584b6ca4090bb9415a790c24e2b1c3cb
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoIntroduce BmapHelpers.py
Artem Bityutskiy [Thu, 1 Nov 2012 07:54:32 +0000 (09:54 +0200)]
Introduce BmapHelpers.py

This module will contain shared helper functions.

Change-Id: I7c0fe807f9587508bdfbacc22820edbcf970103d
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoRepackaged pythonic way
Ed Bartosh [Wed, 31 Oct 2012 14:19:50 +0000 (16:19 +0200)]
Repackaged pythonic way

As this package has been splitted to script and API it makes sense to
utilize proper Python packaging( so called Python Egg) using setuptools
functionality. This change does exactly that. All building and installation
is done using setup.py.

Debian and RPM packaging has been updated accordingly.

Artem: tweak package description and my e-mail address.

Change-Id: I46a6ad4e9c5b869190e4a001dc6fa274cae2ca7e
Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmap-flasher: clean-up help text
Artem Bityutskiy [Wed, 31 Oct 2012 13:45:01 +0000 (15:45 +0200)]
bmap-flasher: clean-up help text

argparse starts help text with a small letter and does not put the dot at the
end (see -h and --version). Do the same for all the other options for
consistency.

Change-Id: Id4e39481e27690e47662181f1901abb6aebcf4d3
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoKeep modules in bmaptools sub-directory
Artem Bityutskiy [Wed, 31 Oct 2012 13:29:11 +0000 (15:29 +0200)]
Keep modules in bmaptools sub-directory

Change-Id: I6b1b9dc5999aa20b4f02ed318556be6313c7df27
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmap-flasher: imrove docs some more and have less duplication
Artem Bityutskiy [Wed, 31 Oct 2012 13:13:39 +0000 (15:13 +0200)]
bmap-flasher: imrove docs some more and have less duplication

Add some more documentation and use own docstring for 'bmap-flasher -h',
instead of duplicating the text.

Change-Id: I3afc50d72b661b2200307c3b275fbb15940d6f69
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapFlasher: improve the documentation some more
Artem Bityutskiy [Wed, 31 Oct 2012 12:27:44 +0000 (14:27 +0200)]
BmapFlasher: improve the documentation some more

Change-Id: I442356bbe98cb8584eed0267fc228df430187b25
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapFlasher: provide a list of supported image formats
Artem Bityutskiy [Wed, 31 Oct 2012 12:09:08 +0000 (14:09 +0200)]
BmapFlasher: provide a list of supported image formats

Change-Id: I45b8014c14dfe863190ce2967c151b269d2c9af9
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapFlasher: move constant to the module level
Artem Bityutskiy [Wed, 31 Oct 2012 12:05:31 +0000 (14:05 +0200)]
BmapFlasher: move constant to the module level

The maximum supported bmap version is actually a module-level attribute, not a
class-level attribute - move it to the module level.

Change-Id: Ie2911478048da4e9ed4c2747e72f5222cd22071b
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmap-flasher: improve documentation a little bit
Artem Bityutskiy [Wed, 31 Oct 2012 12:01:03 +0000 (14:01 +0200)]
bmap-flasher: improve documentation a little bit

Change-Id: I28829fed8ec1a01cac38e58dd532b6b4bbd528e3
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agoBmapFlasher.py: remove undefined variable
Artem Bityutskiy [Wed, 31 Oct 2012 09:47:39 +0000 (11:47 +0200)]
BmapFlasher.py: remove undefined variable

Kill the left-over from old dayse when all the code was in 'bmap-flasher' and
we had 'args' variable.

Change-Id: Icc36deedd8e38b6488bcd35da78bab6ba7df1e9b
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmap-flasher: implement --version option
Artem Bityutskiy [Wed, 31 Oct 2012 08:58:17 +0000 (10:58 +0200)]
bmap-flasher: implement --version option

Change-Id: Iaea5577e387fb2a905231fef0dd5cd24c0a8e96c
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmap-flasher: print flashing speed
Artem Bityutskiy [Wed, 31 Oct 2012 08:08:17 +0000 (10:08 +0200)]
bmap-flasher: print flashing speed

Change-Id: I3c83f87deb458121590ebb8af2e06faceb7ea4c8
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmap-flasher: move API to a separate module
Artem Bityutskiy [Tue, 30 Oct 2012 12:00:32 +0000 (14:00 +0200)]
bmap-flasher: move API to a separate module

Change-Id: I8540547449818523cec6e49699852b5b30268834
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmap-flasher: use logger instead of plain print
Artem Bityutskiy [Tue, 30 Oct 2012 07:36:16 +0000 (09:36 +0200)]
bmap-flasher: use logger instead of plain print

And implement the --quiet option at the same time.

Also, kill the 'fatal()' helper.

Change-Id: Ia25f7162275854501aa7f7d2af8303e1121c20a6
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
11 years agobmap-flasher: add another TODO entry
Artem Bityutskiy [Tue, 30 Oct 2012 07:04:11 +0000 (09:04 +0200)]
bmap-flasher: add another TODO entry

Change-Id: Ia9eda13492ea89230b708b931f6a42dd2c2ada55
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>