8040ad2497a526db56a52381c6880474aa5a529d
[openwrt/staging/noltari.git] /
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
5 script:byte_swap.tcl
6
7 Signed-off-by: Yutang Jiang <yutang.jiang@nxp.com>
8 ---
9 Makefile | 2 +-
10 byte_swap.pl | 37 +++++++++++++++++++++++++++++++++++++
11 2 files changed, 38 insertions(+), 1 deletion(-)
12 create mode 100755 byte_swap.pl
13
14 diff --git a/Makefile b/Makefile
15 index b73375f..5293bc5 100644
16 --- a/Makefile
17 +++ b/Makefile
18 @@ -836,7 +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 + perl byte_swap.pl u-boot-dtb.bin u-boot-swap.bin 8
24
25 %.imx: %.bin
26 $(Q)$(MAKE) $(build)=arch/arm/imx-common $@
27 diff --git a/byte_swap.pl b/byte_swap.pl
28 new file mode 100755
29 index 0000000..1707139
30 --- /dev/null
31 +++ b/byte_swap.pl
32 @@ -0,0 +1,37 @@
33 +#!/usr/bin/perl
34 +#
35 +# Copyright (C) 2016 Jiang Yutang <jiangyutang1978@gmail.com>
36 +#
37 +# This is free software, licensed under the GNU General Public License v2.
38 +# See /LICENSE for more information.
39 +#
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];
43 +
44 +undef $/;
45 +$str_i=<F_I>;
46 +(@ary_i)=unpack("C$i_size", $str_i);
47 +
48 +if ( ($i_size % $ARGV[2]) != 0 )
49 +{
50 + for ($i=0; $i<$ARGV[2] - ($i_size % $ARGV[2]); $i++)
51 + {
52 + $ary_i[$i_size + $i]=0;
53 + }
54 + $i_size=$i_size + ($ARGV[2] - ($i_size % $ARGV[2]));
55 +}
56 +
57 +for ($i=0; $i<$i_size; $i += $ARGV[2])
58 +{
59 + for ($j=0; $j<$ARGV[2]; $j++)
60 + {
61 + $ary_o[$i+$j]=$ary_i[$i+$ARGV[2]-$j-1];
62 + }
63 +}
64 +
65 +binmode F_O;
66 +print(F_O pack("C$i_size", @ary_o));
67 +
68 +close F_I;
69 +close F_O;
70 --
71 1.7.9.5
72