0094-using-perl-script-byte_swap.pl-to-replace-tcl-script.patch 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. From 61cf7655f6f165645d1659c7b256be4397d67572 Mon Sep 17 00:00:00 2001
  2. From: Yutang Jiang <[email protected]>
  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. Signed-off-by: Yutang Jiang <[email protected]>
  7. ---
  8. Makefile | 2 +-
  9. byte_swap.pl | 37 +++++++++++++++++++++++++++++++++++++
  10. 2 files changed, 38 insertions(+), 1 deletion(-)
  11. create mode 100755 byte_swap.pl
  12. diff --git a/Makefile b/Makefile
  13. index b73375f..5293bc5 100644
  14. --- a/Makefile
  15. +++ b/Makefile
  16. @@ -836,7 +836,7 @@ dtbs dts/dt.dtb: checkdtc u-boot
  17. u-boot-dtb.bin: u-boot.bin dts/dt.dtb FORCE
  18. $(call if_changed,cat)
  19. - tclsh byte_swap.tcl u-boot-dtb.bin u-boot-swap.bin 8
  20. + perl byte_swap.pl u-boot-dtb.bin u-boot-swap.bin 8
  21. %.imx: %.bin
  22. $(Q)$(MAKE) $(build)=arch/arm/imx-common $@
  23. diff --git a/byte_swap.pl b/byte_swap.pl
  24. new file mode 100755
  25. index 0000000..1707139
  26. --- /dev/null
  27. +++ b/byte_swap.pl
  28. @@ -0,0 +1,37 @@
  29. +#!/usr/bin/perl
  30. +#
  31. +# Copyright (C) 2016 Jiang Yutang <[email protected]>
  32. +#
  33. +# This is free software, licensed under the GNU General Public License v2.
  34. +# See /LICENSE for more information.
  35. +#
  36. +open F_I, '<', $ARGV[0] or die "Error:$!\n";
  37. +open F_O, '>', $ARGV[1] or die "Error:$!\n";
  38. +$i_size = (stat $ARGV[0])[7];
  39. +
  40. +undef $/;
  41. +$str_i=<F_I>;
  42. +(@ary_i)=unpack("C$i_size", $str_i);
  43. +
  44. +if ( ($i_size % $ARGV[2]) != 0 )
  45. +{
  46. + for ($i=0; $i<$ARGV[2] - ($i_size % $ARGV[2]); $i++)
  47. + {
  48. + $ary_i[$i_size + $i]=0;
  49. + }
  50. + $i_size=$i_size + ($ARGV[2] - ($i_size % $ARGV[2]));
  51. +}
  52. +
  53. +for ($i=0; $i<$i_size; $i += $ARGV[2])
  54. +{
  55. + for ($j=0; $j<$ARGV[2]; $j++)
  56. + {
  57. + $ary_o[$i+$j]=$ary_i[$i+$ARGV[2]-$j-1];
  58. + }
  59. +}
  60. +
  61. +binmode F_O;
  62. +print(F_O pack("C$i_size", @ary_o));
  63. +
  64. +close F_I;
  65. +close F_O;
  66. --
  67. 1.7.9.5