]> code.ossystems Code Review - meta-freescale.git/commitdiff
change-file-endianess: keep 8 byte alignment
authorYuan Yao <yao.yuan@nxp.com>
Fri, 15 Jul 2016 16:28:34 +0000 (00:28 +0800)
committerOtavio Salvador <otavio@ossystems.com.br>
Fri, 22 Jul 2016 14:30:51 +0000 (11:30 -0300)
Signed-off-by: Yuan Yao <yao.yuan@nxp.com>
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
recipes-bsp/change-file-endianess/change-file-endianess/byte_swap.tcl

index aca956bdfb6ad41f9b8695a2e76d40beb4ad53dc..a4e8008f13e5c5cc9fb303ccf0be1d75eedcd9ed 100755 (executable)
@@ -11,6 +11,13 @@ fconfigure $fileid_o -translation {binary binary}
 
 set old_bin [read $fileid_i]
 set new_bin {}
+set old_length [string length $old_bin]
+set old_rem [expr $old_length % $num_b]
+if {$old_rem != 0} {
+       for {set i 0} {$i< [expr $num_b - $old_rem]} {incr i 1} {
+               append old_bin y
+       }
+}
 for {set i 0} {$i<[string length $old_bin]} {incr i $num_b} {
         for {set j $num_b} {$j>0} {incr j -1} {
                 append new_bin [string index $old_bin [expr $i+($j-1)]]
@@ -20,7 +27,7 @@ for {set i 0} {$i<[string length $old_bin]} {incr i $num_b} {
 for {set i 0} {$i<[string length $old_bin]} {incr i $num_b} {
         set binValue [string range $old_bin [expr $i+0] [expr $i+($num_b-1)]]
         binary scan $binValue H[expr $num_b*2] hexValue
-        
+
         set binValue [string range $new_bin [expr $i+0] [expr $i+($num_b-1)]]
         binary scan $binValue H[expr $num_b*2] hexValue
 }