From: Yuan Yao Date: Fri, 15 Jul 2016 16:28:34 +0000 (+0800) Subject: change-file-endianess: keep 8 byte alignment X-Git-Tag: 2.2~391 X-Git-Url: https://code.ossystems.io/gitweb?a=commitdiff_plain;h=7d2c49acdf78a798c92b6d6fbe9cbf8ef324059c;p=meta-freescale.git change-file-endianess: keep 8 byte alignment Signed-off-by: Yuan Yao Signed-off-by: Otavio Salvador --- diff --git a/recipes-bsp/change-file-endianess/change-file-endianess/byte_swap.tcl b/recipes-bsp/change-file-endianess/change-file-endianess/byte_swap.tcl index aca956bd..a4e8008f 100755 --- a/recipes-bsp/change-file-endianess/change-file-endianess/byte_swap.tcl +++ b/recipes-bsp/change-file-endianess/change-file-endianess/byte_swap.tcl @@ -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 }