71 lines
2 KiB
Diff
71 lines
2 KiB
Diff
|
From f13ff4fe020c9018eb5a472b7c8a69a54e45ce29 Mon Sep 17 00:00:00 2001
|
||
|
From: Yutang Jiang <yutang.jiang@nxp.com>
|
||
|
Date: Tue, 18 Oct 2016 22:37:17 +0800
|
||
|
Subject: [PATCH 93/93] add byte_swap.tcl script for uboot can run/save in
|
||
|
qspi flash
|
||
|
|
||
|
Signed-off-by: Yutang Jiang <yutang.jiang@nxp.com>
|
||
|
---
|
||
|
Makefile | 1 +
|
||
|
byte_swap.tcl | 36 ++++++++++++++++++++++++++++++++++++
|
||
|
2 files changed, 37 insertions(+)
|
||
|
create mode 100755 byte_swap.tcl
|
||
|
|
||
|
diff --git a/Makefile b/Makefile
|
||
|
index 1c2818c..b73375f 100644
|
||
|
--- a/Makefile
|
||
|
+++ b/Makefile
|
||
|
@@ -836,6 +836,7 @@ dtbs dts/dt.dtb: checkdtc u-boot
|
||
|
|
||
|
u-boot-dtb.bin: u-boot.bin dts/dt.dtb FORCE
|
||
|
$(call if_changed,cat)
|
||
|
+ tclsh byte_swap.tcl u-boot-dtb.bin u-boot-swap.bin 8
|
||
|
|
||
|
%.imx: %.bin
|
||
|
$(Q)$(MAKE) $(build)=arch/arm/imx-common $@
|
||
|
diff --git a/byte_swap.tcl b/byte_swap.tcl
|
||
|
new file mode 100755
|
||
|
index 0000000..a4e8008
|
||
|
--- /dev/null
|
||
|
+++ b/byte_swap.tcl
|
||
|
@@ -0,0 +1,36 @@
|
||
|
+puts $argv
|
||
|
+set i_file [lindex $argv 0]
|
||
|
+set o_file [lindex $argv 1]
|
||
|
+set num_b [lindex $argv 2]
|
||
|
+puts ""
|
||
|
+
|
||
|
+set fileid_i [open $i_file "r"]
|
||
|
+set fileid_o [open $o_file "w+"]
|
||
|
+fconfigure $fileid_i -translation {binary binary}
|
||
|
+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)]]
|
||
|
+ }
|
||
|
+}
|
||
|
+
|
||
|
+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
|
||
|
+}
|
||
|
+
|
||
|
+puts -nonewline $fileid_o $new_bin
|
||
|
+close $fileid_o
|
||
|
--
|
||
|
1.7.9.5
|
||
|
|