diff options
| author | Chunrong Guo <B40290@freescale.com> | 2015-02-04 15:18:11 +0800 |
|---|---|---|
| committer | Otavio Salvador <otavio@ossystems.com.br> | 2015-02-05 23:08:27 -0200 |
| commit | d00eecab000e179647d9503e0813139f0c97bf5f (patch) | |
| tree | 662069f4a61e1237f092096e490e4e352c380e53 | |
| parent | 95e2d5781b5ee196dfa546b0ff9fcd428eb4830a (diff) | |
| download | meta-freescale-d00eecab000e179647d9503e0813139f0c97bf5f.tar.gz | |
change-file-endianess: add recipe
provides the tcl script for endian swap
Signed-off-by: Chunrong Guo <B40290@freescale.com>
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
| -rw-r--r-- | meta-fsl-arm/recipes-bsp/change-file-endianess/change-file-endianess.bb | 23 | ||||
| -rwxr-xr-x | meta-fsl-arm/recipes-bsp/change-file-endianess/change-file-endianess/byte_swap.tcl | 29 |
2 files changed, 52 insertions, 0 deletions
diff --git a/meta-fsl-arm/recipes-bsp/change-file-endianess/change-file-endianess.bb b/meta-fsl-arm/recipes-bsp/change-file-endianess/change-file-endianess.bb new file mode 100644 index 000000000..2ad8c5882 --- /dev/null +++ b/meta-fsl-arm/recipes-bsp/change-file-endianess/change-file-endianess.bb | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | DESCRIPTION = "provides the tcl script for endian swap" | ||
| 2 | LICENSE = "MIT" | ||
| 3 | LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=4d92cd373abda3937c2bc47fbc49d690 \ | ||
| 4 | file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" | ||
| 5 | |||
| 6 | |||
| 7 | SRC_URI = "file://byte_swap.tcl" | ||
| 8 | |||
| 9 | RDEPENDS += "tcl-native" | ||
| 10 | |||
| 11 | inherit native | ||
| 12 | |||
| 13 | S = "${WORKDIR}" | ||
| 14 | |||
| 15 | do_configure[noexec] = "1" | ||
| 16 | do_compile[noexec] = "1" | ||
| 17 | |||
| 18 | do_install () { | ||
| 19 | install -d ${D}/${bindir} | ||
| 20 | install -m 755 ${WORKDIR}/byte_swap.tcl ${D}/${bindir} | ||
| 21 | } | ||
| 22 | |||
| 23 | BBCLASSEXTEND = "native nativesdk" | ||
diff --git a/meta-fsl-arm/recipes-bsp/change-file-endianess/change-file-endianess/byte_swap.tcl b/meta-fsl-arm/recipes-bsp/change-file-endianess/change-file-endianess/byte_swap.tcl new file mode 100755 index 000000000..aca956bdf --- /dev/null +++ b/meta-fsl-arm/recipes-bsp/change-file-endianess/change-file-endianess/byte_swap.tcl | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | puts $argv | ||
| 2 | set i_file [lindex $argv 0] | ||
| 3 | set o_file [lindex $argv 1] | ||
| 4 | set num_b [lindex $argv 2] | ||
| 5 | puts "" | ||
| 6 | |||
| 7 | set fileid_i [open $i_file "r"] | ||
| 8 | set fileid_o [open $o_file "w+"] | ||
| 9 | fconfigure $fileid_i -translation {binary binary} | ||
| 10 | fconfigure $fileid_o -translation {binary binary} | ||
| 11 | |||
| 12 | set old_bin [read $fileid_i] | ||
| 13 | set new_bin {} | ||
| 14 | for {set i 0} {$i<[string length $old_bin]} {incr i $num_b} { | ||
| 15 | for {set j $num_b} {$j>0} {incr j -1} { | ||
| 16 | append new_bin [string index $old_bin [expr $i+($j-1)]] | ||
| 17 | } | ||
| 18 | } | ||
| 19 | |||
| 20 | for {set i 0} {$i<[string length $old_bin]} {incr i $num_b} { | ||
| 21 | set binValue [string range $old_bin [expr $i+0] [expr $i+($num_b-1)]] | ||
| 22 | binary scan $binValue H[expr $num_b*2] hexValue | ||
| 23 | |||
| 24 | set binValue [string range $new_bin [expr $i+0] [expr $i+($num_b-1)]] | ||
| 25 | binary scan $binValue H[expr $num_b*2] hexValue | ||
| 26 | } | ||
| 27 | |||
| 28 | puts -nonewline $fileid_o $new_bin | ||
| 29 | close $fileid_o | ||
