1 From c87a500c45f36ad248b1298d63e590d1d7e74f12 Mon Sep 17 00:00:00 2001
2 From: Yangbo Lu <yangbo.lu@nxp.com>
3 Date: Tue, 3 Jul 2018 11:06:47 +0800
4 Subject: [PATCH] rcw: support byte swapping without tclsh tool
6 Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
9 byte_swap.py | 32 ++++++++++++++++++++++++++++++++
11 3 files changed, 33 insertions(+), 5 deletions(-)
12 create mode 100755 byte_swap.py
14 diff --git a/Makefile b/Makefile
15 index 9f0587e..393bb2c 100644
18 @@ -13,10 +13,6 @@ TCLSH := $(shell command -v tclsh 2> /dev/null)
19 VER = $(shell git describe --tags)
23 - $(error "tclsh is not available. please install it.")
26 @for board in $(BOARDS); do \
27 $(MAKE) -C $$board $@ DESTDIR=$(DESTDIR)/$$board; \
29 diff --git a/byte_swap.py b/byte_swap.py
31 index 0000000..386310e
35 +#!/usr/bin/env python
37 +Swap the 4/8 bytes endian except for PBI CRC
38 +2016-10-9: Initial version
41 + ./byte_swap.py <file_name> <byte>
46 + file_name = sys.argv[1]
47 + byte = int(sys.argv[2])
49 + print("Usage: ./byte_swap.py <file_name> <byte>")
50 + print("E.g.: ./byte_swap.py rcw_1600.bin 8\n")
53 +with open(file_name,'rb') as file:
57 +with open(file_name + '.swapped','wb') as file:
58 + for i in range(0, len(tmp) - 1, byte):
59 + if(tmp[i:i+4].encode('hex')) == "08610040":
60 + #print("PBI CRC command")
61 + file.write(tmp[i:i+8])
63 + file.write(tmp[i:i+byte][::-1])
66 +print("Swapped file: " + file_name + '.swapped')
67 diff --git a/qspi_swap.sh b/qspi_swap.sh
68 index 0b58e44..d23fd8b 100755
72 if [ "$board_name" = "$current_dir" ]; then
73 if [ -e $filename ]; then
74 swapped_file="$filename.swapped"
75 - tclsh ../tools/byte_swap.tcl $filename $swapped_file 8
76 + ../byte_swap.py $filename 8