All of lore.kernel.org
 help / color / mirror / Atom feed
From: <b40290@freescale.com>
To: <meta-freescale@yoctoproject.org>
Subject: [meta-fsl-arm][PATCH 1/4] byte-swap: add recipe
Date: Tue, 3 Feb 2015 17:01:53 +0800	[thread overview]
Message-ID: <1422954116-26431-1-git-send-email-b40290@freescale.com> (raw)

From: Chunrong Guo <B40290@freescale.com>

  *provides the tcl script for endian swap

Signed-off-by: Chunrong Guo <B40290@freescale.com>
---
 recipes-bsp/byte-swap/byte-swap.bb            | 21 +++++++++++++++++++
 recipes-bsp/byte-swap/byte-swap/byte_swap.tcl | 29 +++++++++++++++++++++++++++
 2 files changed, 50 insertions(+)
 create mode 100644 recipes-bsp/byte-swap/byte-swap.bb
 create mode 100755 recipes-bsp/byte-swap/byte-swap/byte_swap.tcl

diff --git a/recipes-bsp/byte-swap/byte-swap.bb b/recipes-bsp/byte-swap/byte-swap.bb
new file mode 100644
index 0000000..9e7e868
--- /dev/null
+++ b/recipes-bsp/byte-swap/byte-swap.bb
@@ -0,0 +1,21 @@
+DESCRIPTION = "provides the tcl script for endian swap"
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=4d92cd373abda3937c2bc47fbc49d690 \
+                    file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
+
+
+SRC_URI = "file://byte_swap.tcl"
+
+RDEPENDS += "tcl-native"
+
+inherit native
+
+S = "${WORKDIR}"
+
+do_configure[noexec] = "1"
+do_compile[noexec] = "1"
+
+do_install () {
+    install -d ${D}/${bindir}
+    install -m 755 ${WORKDIR}/byte_swap.tcl ${D}/${bindir}
+}
diff --git a/recipes-bsp/byte-swap/byte-swap/byte_swap.tcl b/recipes-bsp/byte-swap/byte-swap/byte_swap.tcl
new file mode 100755
index 0000000..aca956b
--- /dev/null
+++ b/recipes-bsp/byte-swap/byte-swap/byte_swap.tcl
@@ -0,0 +1,29 @@
+puts $argv
+set i_file [lindex $argv 0]
+set o_file [lindex $argv 1]
+set num_b  [lindex $argv 2]
+puts ""
+
+set fileid_i [open $i_file "r"]
+set fileid_o [open $o_file "w+"]
+fconfigure $fileid_i -translation {binary binary}
+fconfigure $fileid_o -translation {binary binary}
+
+set old_bin [read $fileid_i]
+set new_bin {}
+for {set i 0} {$i<[string length $old_bin]} {incr i $num_b} {
+        for {set j $num_b} {$j>0} {incr j -1} {
+                append new_bin [string index $old_bin [expr $i+($j-1)]]
+        }
+}
+
+for {set i 0} {$i<[string length $old_bin]} {incr i $num_b} {
+        set binValue [string range $old_bin [expr $i+0] [expr $i+($num_b-1)]]
+        binary scan $binValue H[expr $num_b*2] hexValue
+        
+        set binValue [string range $new_bin [expr $i+0] [expr $i+($num_b-1)]]
+        binary scan $binValue H[expr $num_b*2] hexValue
+}
+
+puts -nonewline $fileid_o $new_bin
+close $fileid_o
-- 
1.9.2



             reply	other threads:[~2015-02-03  9:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-03  9:01 b40290 [this message]
2015-02-03  9:01 ` [meta-fsl-arm][PATCH 3/4] rcw: Added byte-swap as DEPENDS b40290
2015-02-03  9:01 ` [meta-fsl-arm][PATCH 2/4] u-boot-ls1: " b40290
2015-02-03  9:01 ` [meta-fsl-arm][PATCH 4/4] u-boot-ls1-tools-native: remove recipe b40290
2015-02-03 11:05 ` [meta-fsl-arm][PATCH 1/4] byte-swap: add recipe Otavio Salvador
2015-02-03 11:08   ` Otavio Salvador

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1422954116-26431-1-git-send-email-b40290@freescale.com \
    --to=b40290@freescale.com \
    --cc=meta-freescale@yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.