Hello,
If I understand the problem correctly, it is all about slow USB
transfer speed. We have two possible ways to deal with it:
1. Improve the performance to finish the job faster
2. Entertain the user while the transfer is in progress
Improving the performance of transferring huge initramfs images
to the device can be done by using some other USB protocol in
U-Boot (fastboot or DFU) instead of the inherently less than
perfect FEL implementation in the BROM. Out of these two, DFU
is reasonably simple and easy to use:
http://lists.denx.de/pipermail/u-boot/2015-October/231589.html
Please note that U-Boot is not quite ready yet and needs some
work because not all of the sunxi devices have USB OTG enabled
in defconfigs and U-Boot still can't select the host/device
role based on the state of the ID pin. For smooth integration
and ease of use, the sunxi-fel tool would probably have to
cannibalize the dfu-util code (which is rather small and has a
compatible license) and automatically handle the transition
from the FEL protocol to DFU. The U-Boot SPL header would also
need to have some flag, which indicates that it supports DFU.
Some tuning is possible for the FEL transfers too. This had
been taken care of by the older "fel: Faster USB transfers via
'fel write' to DRAM" commit:
https://github.com/linux-sunxi/sunxi-tools/commit/e4b3da2b17ee9d7c
Not all of the SoC variants can benefit from it yet, but this
can be fixed.
The transfer speed using different methods is listed in the
SoC support status table in the linux-sunxi wiki:
https://linux-sunxi.org/FEL/USBBoot#SoC_support_status
Now regarding the "entertainment" part. Adding a progress bar is
reasonably simple. The most challenging aspect is the 'sunxi-fel'
command line interface evolution, so that it remains easy and
intuitive to use and also does not break compatibility with older
'sunxi-fel' versions unnecessarily in the future. Let's consider
the following current command line usage example:
sunxi-fel uboot u-boot-sunxi-with-spl.bin \
write 0x42000000 uImage \
write 0x43000000 sun7i-a20-cubietruck.dtb \
write 0x43100000 boot.scr \
write 0x43300000 rootfs.cpio.lzma.uboot
This boots the whole system with a single 'sunxi-fel' tool invocation.
How many progress bars do we want to see in this case? Do we want
to have a progress bar for each of the files? Do we want a common
progress bar for all of them? Do we want to selectively enable
progress bars only for some of the files (for example, the initramfs
image 'rootfs.cpio.lzma.uboot' can be huge, but 'boot.scr' and the
dtb files are usually tiny).
I see that you seem to be proposing a solution, which allows placing
the '-p' option at any part of the command line. So that for having
the progress bar only for the initramfs file, we can use it as:
sunxi-fel uboot u-boot-sunxi-with-spl.bin \
write 0x42000000 uImage \
write 0x43000000 sun7i-a20-cubietruck.dtb \
write 0x43100000 boot.scr \
-p write 0x43300000 rootfs.cpio.lzma.uboot
This looks rather clever/smartass. The down side is that it looks a
little bit unorthodox. The command line tools usually have the options
prefixed by '-' only in the beginning of the command line. Additionally,
we might want to have another option to toggle the progress bar off in
the middle of the command line too.
But maybe as an alternative, we could just substitute "-p write" with
a new command "writep"? The exact name is yet to be decided, it could
be either short or a rather verbose. Which would do the write with
the progress bar enabled for this particular transfer. We can even
introduce another command to transfer multiple files with a common
progress bar. For example, something like this:
sunxi-fel uboot u-boot-sunxi-with-spl.bin \
write-many-with-progress 4 \
0x42000000 uImage \
0x43000000 sun7i-a20-cubietruck.dtb \
0x43100000 boot.scr \
0x43300000 rootfs.cpio.lzma.uboot
This would transfer 4 files with a common shared progress bar. Now
regarding the progress bar itself. It would be also very nice to
see the current transfer speed and remaining time. The progress bar
of 'wget' or similar tools could be used as an inspiration.
Alternatively, it may be a good idea to support integration with
tools like 'dialog' for implementing nice loking console user
interfaces:
http://swoolley.org/man.cgi/dialog
An example of implementing progress bar with 'dialog':
for i in $(seq 0 10 100) ; do sleep 1; echo $i | dialog --gauge \
"Please wait" 10 70 0; done
If we want to support 'dialog', then we might introduce one more
command "write-many-with-dialog-progress", which would just print
the current percent of transferred data to stdout for piping
into 'dialog'.
The syntax of "write-many-with-progress" might look a bit cumbersome
when typing short commands in the command line. So we might want to
introduce a syntax sugar :-) The '-p' option in the beginning
of the command line might be handy. It could be interpreted as a
global option, which would join back-to-back "write" commands and
display a common progress bar for all of them.
Regarding the implementation details. IMHO the right place to integrate
all of this would be in the part of code, which currently benchmarks
the transfer speed:
https://github.com/linux-sunxi/sunxi-tools/blob/9bf1de0ad822/fel.c#L1144
In order to get progress updates, we would need to use something like
a new "aw_fel_write_with_progress_callback()" function instead of
"aw_fel_write()". The progress callback would get an opaque pointer
parameter (a pointer to a struct with all the progress bar state data)
and the size of the just transferred data chunk.
It had been already discussed before that the "aw_fel_write()" is a
kind of privileged operation, which is heavily used as a part of
implementing more complex commands (such as "spl"). We don't want
to hook up tons of ballast there, even the following check should
be better done outside of "aw_fel_write()" and also handle the
"fill" and "clear" commands too:
https://github.com/linux-sunxi/sunxi-tools/blob/9bf1de0ad822/fel.c#L258
We can introduce a separate non-privileged write operation for
serving commands from the command line, with an optional
progress callback argument. The callback functions could have
different implementations for the regular progress bar and
dialog-compatible progress bar.
Please let me know what you think about this. The point is that
the main concern is about *what* we want to implement, and much
less about *how* we do it. If we add some weird command line options
now, they can become a liability in the future and become a source
of confusion for the users.
> Let me know if you'd prefer a set of patches sent to the mailing list
> (@Siarhei?).
The mailing list is currently used because it allows the patches to
be noticed and reviewed by a large crowd of mailing list subscribers.
Yes, it is possible to stop spamming the mailing list and move entirely
to github with the pull requests based workflow. How many people would
be willing to subscribe to github notifications for the sunxi-tools
project on github? Also such workflow works best when having a real
maintainer, who is responsible for reviewing such pull requests in
a timely manner. Instead of random people who may or may not be in
the mood to do it :-)
Bernhard, would you perhaps want to become the maintainer of
sunxi-tools?
--
Best regards,
Siarhei Siamashka