5bcdd81b0c203f06ae1efd0278b21b80060b4fcb
[openwrt/staging/thess.git] /
1 From f13ff4fe020c9018eb5a472b7c8a69a54e45ce29 Mon Sep 17 00:00:00 2001
2 From: Yutang Jiang <yutang.jiang@nxp.com>
3 Date: Tue, 18 Oct 2016 22:37:17 +0800
4 Subject: [PATCH 93/93] add byte_swap.tcl script for uboot can run/save in
5 qspi flash
6
7 Signed-off-by: Yutang Jiang <yutang.jiang@nxp.com>
8 ---
9 Makefile | 1 +
10 byte_swap.tcl | 36 ++++++++++++++++++++++++++++++++++++
11 2 files changed, 37 insertions(+)
12 create mode 100755 byte_swap.tcl
13
14 diff --git a/Makefile b/Makefile
15 index 1c2818c..b73375f 100644
16 --- a/Makefile
17 +++ b/Makefile
18 @@ -836,6 +836,7 @@ dtbs dts/dt.dtb: checkdtc u-boot
19
20 u-boot-dtb.bin: u-boot.bin dts/dt.dtb FORCE
21 $(call if_changed,cat)
22 + tclsh byte_swap.tcl u-boot-dtb.bin u-boot-swap.bin 8
23
24 %.imx: %.bin
25 $(Q)$(MAKE) $(build)=arch/arm/imx-common $@
26 diff --git a/byte_swap.tcl b/byte_swap.tcl
27 new file mode 100755
28 index 0000000..a4e8008
29 --- /dev/null
30 +++ b/byte_swap.tcl
31 @@ -0,0 +1,36 @@
32 +puts $argv
33 +set i_file [lindex $argv 0]
34 +set o_file [lindex $argv 1]
35 +set num_b [lindex $argv 2]
36 +puts ""
37 +
38 +set fileid_i [open $i_file "r"]
39 +set fileid_o [open $o_file "w+"]
40 +fconfigure $fileid_i -translation {binary binary}
41 +fconfigure $fileid_o -translation {binary binary}
42 +
43 +set old_bin [read $fileid_i]
44 +set new_bin {}
45 +set old_length [string length $old_bin]
46 +set old_rem [expr $old_length % $num_b]
47 +if {$old_rem != 0} {
48 + for {set i 0} {$i< [expr $num_b - $old_rem]} {incr i 1} {
49 + append old_bin y
50 + }
51 +}
52 +for {set i 0} {$i<[string length $old_bin]} {incr i $num_b} {
53 + for {set j $num_b} {$j>0} {incr j -1} {
54 + append new_bin [string index $old_bin [expr $i+($j-1)]]
55 + }
56 +}
57 +
58 +for {set i 0} {$i<[string length $old_bin]} {incr i $num_b} {
59 + set binValue [string range $old_bin [expr $i+0] [expr $i+($num_b-1)]]
60 + binary scan $binValue H[expr $num_b*2] hexValue
61 +
62 + set binValue [string range $new_bin [expr $i+0] [expr $i+($num_b-1)]]
63 + binary scan $binValue H[expr $num_b*2] hexValue
64 +}
65 +
66 +puts -nonewline $fileid_o $new_bin
67 +close $fileid_o
68 --
69 1.7.9.5
70