Bug 7544

Summary: flashcp -v progress does not reach 100% reliably
Product: Busybox Reporter: Ralph Siemsen <ralphs>
Component: OtherAssignee: unassigned
Status: NEW ---    
Severity: trivial CC: busybox-cvs
Priority: P5    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Host: Target:
Build:
Attachments: One possible fix. Has been tested using MTD_DEBUG.

Description Ralph Siemsen 2014-10-17 13:07:29 UTC
Created attachment 5732 [details]
One possible fix. Has been tested using MTD_DEBUG.

This is very minor issue, but can cause confusion for end-users. Recent example:
http://forums.xilinx.com/t5/Embedded-Linux/flashcp-command-finish-99-when-Writing/td-p/533137

On certain sized files (for example, 3051kB), the output from verbose mode ("flashcp -v") is a bit misleading:

Erasing block: 48/48 (100%) 
Writing kb: 3048/3051 (99%) 
Verifying kb: 3048/3051 (99%)

In fact, all 3051kB were correctly written, even though it only shows 99% complete. This is because progress() reporting occurs before writing data, and no report occurs after the final (often partial) block is written.

This can easily be fixed by either:
- moving the existing progress() function call towards the end of the loop, or
- adding another call to progress() at the end of the loop to print 100%.

A trivial patch is attached. This produces the expected output:

Erasing block: 48/48 (100%) 
Writing kb: 3051/3051 (100%) 
Verifying kb: 3051/3051 (100%)