diff options
author | Yuan Yao <yao.yuan@nxp.com> | 2016-07-16 00:28:34 +0800 |
---|---|---|
committer | Otavio Salvador <otavio@ossystems.com.br> | 2016-07-22 11:30:51 -0300 |
commit | 7d2c49acdf78a798c92b6d6fbe9cbf8ef324059c (patch) | |
tree | e2c549c2c91e9c1afdfb0734e94b83ef88728691 /recipes-bsp/change-file-endianess | |
parent | 92d730104790f7394bdaff8c60ee2b37a44f1200 (diff) | |
download | meta-freescale-7d2c49acdf78a798c92b6d6fbe9cbf8ef324059c.tar.gz |
change-file-endianess: keep 8 byte alignment
Signed-off-by: Yuan Yao <yao.yuan@nxp.com>
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
Diffstat (limited to 'recipes-bsp/change-file-endianess')
-rwxr-xr-x | recipes-bsp/change-file-endianess/change-file-endianess/byte_swap.tcl | 9 |
1 files changed, 8 insertions, 1 deletions
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} | |||
11 | 11 | ||
12 | set old_bin [read $fileid_i] | 12 | set old_bin [read $fileid_i] |
13 | set new_bin {} | 13 | set new_bin {} |
14 | set old_length [string length $old_bin] | ||
15 | set old_rem [expr $old_length % $num_b] | ||
16 | if {$old_rem != 0} { | ||
17 | for {set i 0} {$i< [expr $num_b - $old_rem]} {incr i 1} { | ||
18 | append old_bin y | ||
19 | } | ||
20 | } | ||
14 | for {set i 0} {$i<[string length $old_bin]} {incr i $num_b} { | 21 | for {set i 0} {$i<[string length $old_bin]} {incr i $num_b} { |
15 | for {set j $num_b} {$j>0} {incr j -1} { | 22 | for {set j $num_b} {$j>0} {incr j -1} { |
16 | append new_bin [string index $old_bin [expr $i+($j-1)]] | 23 | 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} { | |||
20 | for {set i 0} {$i<[string length $old_bin]} {incr i $num_b} { | 27 | for {set i 0} {$i<[string length $old_bin]} {incr i $num_b} { |
21 | set binValue [string range $old_bin [expr $i+0] [expr $i+($num_b-1)]] | 28 | set binValue [string range $old_bin [expr $i+0] [expr $i+($num_b-1)]] |
22 | binary scan $binValue H[expr $num_b*2] hexValue | 29 | binary scan $binValue H[expr $num_b*2] hexValue |
23 | 30 | ||
24 | set binValue [string range $new_bin [expr $i+0] [expr $i+($num_b-1)]] | 31 | set binValue [string range $new_bin [expr $i+0] [expr $i+($num_b-1)]] |
25 | binary scan $binValue H[expr $num_b*2] hexValue | 32 | binary scan $binValue H[expr $num_b*2] hexValue |
26 | } | 33 | } |