5050#include "qdl.h"
5151#include "ufs.h"
5252#include "oscompat.h"
53+ #include "vip.h"
5354
5455enum {
5556 FIREHOSE_ACK = 0 ,
@@ -183,9 +184,11 @@ static int firehose_write(struct qdl_device *qdl, xmlDoc *doc)
183184
184185 xmlDocDumpMemory (doc , & s , & len );
185186
187+ vip_gen_chunk_init (qdl );
188+
186189 for (;;) {
187190 ux_debug ("FIREHOSE WRITE: %s\n" , s );
188-
191+ vip_gen_chunk_update ( qdl , s , len );
189192 ret = qdl_write (qdl , s , len );
190193 saved_errno = errno ;
191194
@@ -202,6 +205,7 @@ static int firehose_write(struct qdl_device *qdl, xmlDoc *doc)
202205 }
203206 }
204207 xmlFree (s );
208+ vip_gen_chunk_store (qdl );
205209 return ret < 0 ? - saved_errno : 0 ;
206210}
207211
@@ -423,7 +427,16 @@ static int firehose_program(struct qdl_device *qdl, struct program *program, int
423427
424428 lseek (fd , (off_t ) program -> file_offset * program -> sector_size , SEEK_SET );
425429 left = num_sectors ;
430+
431+ ux_debug ("FIREHOSE RAW BINARY WRITE: %s, %d bytes\n" ,
432+ program -> filename , program -> sector_size * num_sectors );
433+
426434 while (left > 0 ) {
435+ /*
436+ * We should calculate hash for every raw packet sent,
437+ * not for the whole binary.
438+ */
439+ vip_gen_chunk_init (qdl );
427440 chunk_size = MIN (max_payload_size / program -> sector_size , left );
428441
429442 n = read (fd , buf , chunk_size * program -> sector_size );
@@ -435,6 +448,7 @@ static int firehose_program(struct qdl_device *qdl, struct program *program, int
435448 if (n < max_payload_size )
436449 memset (buf + n , 0 , max_payload_size - n );
437450
451+ vip_gen_chunk_update (qdl , buf , chunk_size * program -> sector_size );
438452 n = qdl_write (qdl , buf , chunk_size * program -> sector_size );
439453 if (n < 0 ) {
440454 ux_err ("USB write failed for data chunk\n" );
@@ -448,6 +462,7 @@ static int firehose_program(struct qdl_device *qdl, struct program *program, int
448462 }
449463
450464 left -= chunk_size ;
465+ vip_gen_chunk_store (qdl );
451466
452467 ux_progress ("%s" , num_sectors - left , num_sectors , program -> label );
453468 }
0 commit comments