Hi Mark,
On 10/07/2018 15:50, Jonas Mark (BT-FIR/ENG1) wrote:
> Hi Stefano,
>
> we are using swupdate in a product and are wondering if streaming the
> update to the target with zero copy would be possible with the
> following constraint:
>
> The update is downloaded to the target using a proprietary USB
> protocol. It is implemented using a userspace tool and GadgetFS. The
> tool will create a file containing the received firmware.
>
> What are the required preconditions for streaming a firmware image
> into swupdate?
>
> What we tried is to use a named pipe (mkfifo). The download tool would
> write into the pipe and swupdate should read from it. This does not
> work because extrace_sw_description() calls lseek()
This looks to me extra complicated. There is a simpler solutions that I
can propose.
.
>
> $ mkfifo /tmp/pipe.swu
> $ swupdate -e stable,second -i /tmp/pipe.swu -v
To make a general answer independently from your use case, this does
*not* work. The "-i" parameter implies to have a local file and SWUpdate
is informed that can use seek() on the file. This, of course, cannot work.
However, this case is foreseen using the API provided by SWUpdate and
the exported library (LGPL, you are allowed to link proprietary code).
There is in tools/client.c an example how to use.
Instead of writing into a pipe, you shoudl write into the pipe that
SWUpdate already makes available and using the function provided by the
library. The library has callbacks to push data, and you can fill in
when your data from the stream is available. Setup and free of internal
pipes are managed automatically by SWUpdate without user intervention.
>
> and in another shell
>
> $ cat /tmp/test.swu > /tmp/pipe.swu
>
> Then swupdate give the following errors.
>
> [ERROR] : SWUPDATE failed [0] ERROR core/cpio_utils.c : extract_sw_description : 541 : CPIO file corrupted : Illegal seek
No surprise: Illegal seek. This is expected.
>
> [ERROR] : SWUPDATE failed [0] ERROR parser/parser.c : parse_cfg : 702 : Missing version in configuration file
>
> [ERROR] : SWUPDATE failed [0] ERROR core/parser.c : parse : 196 : no parser available to parse sw-description!
>
> [ERROR] : SWUPDATE failed [0] ERROR core/swupdate.c : install_from_file : 307 : failed to parse sw-description!
>
The rest are consequences of the first error. You inform SWUpdate to use
a local file, but this is really a stream.
> The same swu file works just fine when opened as a file.
>
> $ swupdate -e stable,second -i /tmp/test.swu -v
It is enough to start :
swupdate -v -e stable,second
SWUpdate will start waiting for incoming requests.
>
> Does anybody have a proposal how to achieve a streaming update in the
> described setup?
Yes
>
> This is the sw-description we are using.
>
> software =
> {
> /* software version */
> version = "4.0.0";
>
> /* hardware revision, will be checked with /etc/hwrevision */
> hardware-compatibility: ["4.0"];
>
> /* because swupdate requires the user choose which image should be installed
> * into which location. Using software collection feature to achieve that the
> * the stand-by partition is already written.
> */
> stable = {
> first: {
> images: (
> {
> filename = "rootfs.ext4.gz";
> device = "/dev/mmcblk2p1";
> compressed = true;
if you are using a double-copy approach, you can safe add
"installed-directly" for zero copy, else the images are temporary stored
in your /tmp.
> sha256 = "@SHA256SUM@";
> }
> );
>
> bootenv: (
> {
> name = "boot_image";
> value = "image1";
> }
> );
> };
> second: {
> images: (
> {
> filename = "rootfs.ext4.gz";
> device = "/dev/mmcblk2p2";
> compressed = true;
> sha256 = "@SHA256SUM@";
> }
> );
>
> bootenv: (
> {
> name = "boot_image";
> value = "image2";
> }
> );
> };
> };
> }
>
Best regards,
Stefano
--
=====================================================================
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone:
+49-8142-66989-53 Fax:
+49-8142-66989-80 Email:
sba...@denx.de
=====================================================================