@@ -426,7 +426,7 @@ static int flash_detect(struct ddflash *ddf)
426426 }
427427 if (ddf -> sector_size ) {
428428 ddf -> buffer = malloc (ddf -> sector_size );
429- printf ("allocated buffer %08x@%08x\n" , ddf -> sector_size , (uint32_t ) ddf -> buffer );
429+ // printf("allocated buffer %08x@%08x\n", ddf->sector_size, (uint32_t) ddf->buffer);
430430 if (!ddf -> buffer )
431431 return -1 ;
432432 }
@@ -510,7 +510,12 @@ static int check_fw(struct ddflash *ddf, char *fn, uint32_t *fw_off)
510510 goto out ;
511511 }
512512 } else if (!strcasecmp (key , "Version" )) {
513- sscanf (val , "%x" , & version );
513+ if (strchr (val ,'.' )) {
514+ int major = 0 , minor = 0 ;
515+ sscanf (val ,"%d.%d" ,& major ,& minor );
516+ version = (major << 16 ) + minor ;
517+ } else
518+ sscanf (val , "%x" , & version );
514519 } else if (!strcasecmp (key , "Length" )) {
515520 sscanf (val , "%u" , & length );
516521 }
@@ -565,8 +570,13 @@ static int update_image(struct ddflash *ddf, char *fn,
565570 if (res < 0 )
566571 goto out ;
567572 res = flashwrite (ddf , fs , adr , len , fw_off );
568- if (res == 0 )
569- res = 1 ;
573+ if (res == 0 ) {
574+ res = flashcmp (ddf , fs , adr , len , fw_off );
575+ if (res == -2 ) {
576+ res = 1 ;
577+ }
578+ }
579+
570580out :
571581 close (fs );
572582 return res ;
@@ -607,18 +617,40 @@ static int update_flash(struct ddflash *ddf)
607617 if ((res = update_image (ddf , "/boot/fpga.img" , 0x10000 , 0xa0000 , 1 , 0 )) == 1 )
608618 stat |= 1 ;
609619 } else {
610- if ((res = update_image (ddf , "/config/fpga.img" , 0x10000 , 0xa0000 , 1 , 1 )) == 1 )
611- stat |= 1 ;
612- if (res == -1 )
613- if ((res = update_image (ddf , "/boot/fpga.img" , 0x10000 , 0xa0000 , 1 , 1 )) == 1 )
620+ if (ddf -> id .device == 0x0307 ) {
621+ if (res == -1 )
622+ if ((res = update_image (ddf , "/config/fpga_gtl.img" , 0x10000 , 0xa0000 , 1 , 1 )) == 1 )
623+ stat |= 1 ;
624+ if (res == -1 )
625+ if ((res = update_image (ddf , "/boot/fpga_gtl.img" , 0x10000 , 0xa0000 , 1 , 1 )) == 1 )
626+ stat |= 1 ;
627+ } else {
628+ if ((res = update_image (ddf , "/config/fpga.img" , 0x10000 , 0xa0000 , 1 , 1 )) == 1 )
614629 stat |= 1 ;
615- if (res == -1 )
616- if ((res = update_image (ddf , "/config/fpga_gtl.img" , 0x10000 , 0xa0000 , 1 , 1 )) == 1 )
630+ if (res == -1 )
631+ if ((res = update_image (ddf , "/boot/fpga.img" , 0x10000 , 0xa0000 , 1 , 1 )) == 1 )
632+ stat |= 1 ;
633+ }
634+ }
635+ #if 1
636+ if ( (stat & 1 ) && (ddf -> id .hw & 0xffffff ) <= 0x010001 ) {
637+ if (ddf -> id .device == 0x0307 ) {
638+ if ((res = update_image (ddf , "/config/fpga_gtl.img" , 0x160000 , 0x80000 , 1 , 0 )) == 1 )
617639 stat |= 1 ;
618- if (res == -1 )
619- if ((res = update_image (ddf , "/boot/fpga_gtl.img" , 0x10000 , 0xa0000 , 1 , 1 )) == 1 )
640+ if (res == -1 )
641+ if ((res = update_image (ddf , "/boot/fpga_gtl.img" , 0x160000 , 0x80000 , 1 , 0 )) == 1 )
642+ stat |= 1 ;
643+ } else {
644+ if ((res = update_image (ddf , "/config/fpga.img" , 0x160000 , 0x80000 , 1 , 0 )) == 1 )
620645 stat |= 1 ;
646+ if (res == -1 )
647+ if ((res = update_image (ddf , "/boot/fpga.img" , 0x160000 , 0x80000 , 1 , 0 )) == 1 )
648+ stat |= 1 ;
649+
650+ }
621651 }
652+ #endif
653+
622654 break ;
623655 case 0x320 :
624656 //fname="/boot/DVBNetV1A_DD01_0300.bit";
0 commit comments