1 From 61cf7655f6f165645d1659c7b256be4397d67572 Mon Sep 17 00:00:00 2001
2 From: Yutang Jiang <yutang.jiang@nxp.com>
3 Date: Tue, 15 Nov 2016 20:57:37 +0800
4 Subject: [PATCH 94/94] using perl script:byte_swap.pl to replace tcl
7 Signed-off-by: Yutang Jiang <yutang.jiang@nxp.com>
10 byte_swap.pl | 37 +++++++++++++++++++++++++++++++++++++
11 2 files changed, 38 insertions(+), 1 deletion(-)
12 create mode 100755 byte_swap.pl
14 diff --git a/Makefile b/Makefile
15 index b73375f..5293bc5 100644
18 @@ -836,7 +836,7 @@ dtbs dts/dt.dtb: checkdtc u-boot
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 + perl byte_swap.pl u-boot-dtb.bin u-boot-swap.bin 8
26 $(Q)$(MAKE) $(build)=arch/arm/imx-common $@
27 diff --git a/byte_swap.pl b/byte_swap.pl
29 index 0000000..1707139
35 +# Copyright (C) 2016 Jiang Yutang <jiangyutang1978@gmail.com>
37 +# This is free software, licensed under the GNU General Public License v2.
38 +# See /LICENSE for more information.
40 +open F_I, '<', $ARGV[0] or die "Error:$!\n";
41 +open F_O, '>', $ARGV[1] or die "Error:$!\n";
42 +$i_size = (stat $ARGV[0])[7];
46 +(@ary_i)=unpack("C$i_size", $str_i);
48 +if ( ($i_size % $ARGV[2]) != 0 )
50 + for ($i=0; $i<$ARGV[2] - ($i_size % $ARGV[2]); $i++)
52 + $ary_i[$i_size + $i]=0;
54 + $i_size=$i_size + ($ARGV[2] - ($i_size % $ARGV[2]));
57 +for ($i=0; $i<$i_size; $i += $ARGV[2])
59 + for ($j=0; $j<$ARGV[2]; $j++)
61 + $ary_o[$i+$j]=$ary_i[$i+$ARGV[2]-$j-1];
66 +print(F_O pack("C$i_size", @ary_o));