Andes Workshop
http://forum.andestech.com/

cut binary files (split) use dd command
http://forum.andestech.com/viewtopic.php?f=23&t=812
Page 1 of 1

Author:  cindy [ Mon Mar 10, 2014 4:47 pm ]
Post subject:  cut binary files (split) use dd command

Use dd command to skip 0x20 bytes. (32 bytes)
In other word, we need to delete the first 32 bytes of a binary file.
Input file: demo-int-c-ext.bin
Outupt file: test.bin

In cygwin:
$ dd if=./demo-int-c-ext.bin of=./test.bin bs=1 skip=32
8004+0 records in
8004+0 records out
8004 bytes (8.0 kB) copied, 0.035 s, 229 kB/s

hylai@APC187 /cygdrive/d/Andestech/AndeSight201MCU/mcu_64/workspace/demo-int-
xt/Debug/output
$ ls -al
total 204
drwxrwxrwx+ 1 hylai mkpasswd 0 Mar 10 15:30 .
drwx------+ 1 hylai mkpasswd 4096 Mar 10 15:20 ..
-rwxrwxrwx 1 hylai mkpasswd 8036 Mar 10 15:20 demo-int-c-ext.bin
-rw-rw-rw- 1 hylai mkpasswd 116966 Mar 10 15:20 objdump.txt
-rw-rw-rw- 1 hylai mkpasswd 46241 Mar 10 15:20 readelf.txt
-rw-rw-rw- 1 hylai mkpasswd 19113 Mar 10 15:20 symbol.txt
-rw-r--r-- 1 hylai mkpasswd 8004 Mar 10 15:41 test.bin

Attachment:
cygwin.png
cygwin.png [ 55.82 KiB | Viewed 4227 times ]


Sample:
Attachment:
demo-int-c-ext.bin [7.85 KiB]
Downloaded 297 times

Attachment:
test.bin [7.82 KiB]
Downloaded 293 times


In AndeSight, add "dd if=./output/demo-int-c-ext.bin of=test.bin bs=1 skip=32" to post-build steps.


Attachment:
andesight1.png
andesight1.png [ 38.58 KiB | Viewed 4227 times ]


Attachment:
andesight2.png
andesight2.png [ 11.35 KiB | Viewed 4227 times ]

Author:  cindy [ Wed Mar 12, 2014 5:59 pm ]
Post subject:  Re: cut binary files (split) use dd command

If we would like to cut 2 KB file (but skip the first 32 bytes)
dd if=./demo-int-c-ext.bin of=./test.bin bs=1 skip=32 count=2048
It means cut 32~(32+2048) bytes, total 2048 bytes.

Attachment:
dd.png
dd.png [ 19.97 KiB | Viewed 4220 times ]


Reference: (Chinese page)
http://blog.csdn.net/do2jiang/article/details/5069536

Page 1 of 1 All times are UTC + 8 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/