summaryrefslogtreecommitdiff
authorFrank Chen <frank.chen@amlogic.com>2014-11-21 12:33:49 (GMT)
committer Frank Chen <frank.chen@amlogic.com>2014-11-21 12:33:57 (GMT)
commite94b7ad695cde004329a257af2b3f39bf0e2a22d (patch)
tree9156645d82b0a2ba98d7057d6011c286cd620b01
parent5663b9d336196ceb347a55c8dd37868c71ecaa4c (diff)
downloadtools-e94b7ad695cde004329a257af2b3f39bf0e2a22d.zip
tools-e94b7ad695cde004329a257af2b3f39bf0e2a22d.tar.gz
tools-e94b7ad695cde004329a257af2b3f39bf0e2a22d.tar.bz2
add aml_upgrade & logo_img_packer
move from kk Change-Id: I5ad04e307e2cdedf002895219d4a86b4d2d0f255
Diffstat
-rwxr-xr-xaml_upgrade/aml_image_v2_packer2467
-rwxr-xr-xlogo_img_packer/Android.mk38
-rw-r--r--logo_img_packer/README2
-rwxr-xr-xlogo_img_packer/crc32.cpp104
-rwxr-xr-xlogo_img_packer/crc32.h17
-rwxr-xr-xlogo_img_packer/res_dll_if.h30
-rwxr-xr-xlogo_img_packer/res_pack.cpp615
-rwxr-xr-xlogo_img_packer/res_pack.h73
-rwxr-xr-xlogo_img_packer/res_pack_i.h50
9 files changed, 3396 insertions, 0 deletions
diff --git a/aml_upgrade/aml_image_v2_packer b/aml_upgrade/aml_image_v2_packer
new file mode 100755
index 0000000..1129831
--- a/dev/null
+++ b/aml_upgrade/aml_image_v2_packer
@@ -0,0 +1,2467 @@
+ELF
+
+@< HuDMt
+,t .tSH-.LLIEHHHH) H@<
+@< HuHL9eEuL
+@< HuDMt
+,t .tSH-.LLIEHHHH) H@<
+@< HuHL9eEuL1
+Mt,t.u
+.MEM
+HHLbH9sEuH
+
+/
+~C1A
+8L
+
+HEH@ HHEHP HEH@ HEHP HEH@(HHEHP HEH@(HHEHPHEH@(HHEHPHEH@(HEHPHEH@0HHEHPHEH@0HHEHPHEH@0HHEHPHEH@0HEdH3%(
+L HHHH0H8
+
+
+f t[HE@
+HE@HE@Hj_-
+
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+
+
+@m
+@m
+@m
+@m
+A@
+fDofDofDofDofDdfDdfDdfDdfEfEfDfDfAfAftffDAD)
+ffDofDofDofDofDdfDdfDdfDdfEfEfDfDfAfAftftffс
+ffDofDofDofDofDdfDdfDdfDdfEfEfDfDfAfAftftffс
+vfI
+
+I
+fsffDofDofDofDofDdfDdfDdfDdfEfEfDfDfAfAftftffс
+fsffDofDofDofDofDdfDdfDdfDdfEfEfDfDfAfAftftffс
+fs
+
+
+
+
+A@
+H 7
+
+fofDofDofDofdfDdfDdfDdfAfEffDffAftffDAD)
+
+I
+fo fofDofDofDofdfDdfDdfDdfAfEffDffAf:cv
+
+
+fo fofDofDofDofdfDdfDdfDdfAfEffDffAf:c
+
+f:c:L9e
+A@
+H 
+ 
+dqdidid9A)9)ŹũtyAD)
+
+
+
+
+
+
+
+
+I
+o dydqdqd9A)9)ŹũycO
+o dydqdqd9A)9)Źũyc
+yc:L9
+%
+A@
+fDofDofDofDofDdfDdfDdfDdfEfEfDfDfAfAftffDAD)_
+vfI
+
+I
+fDofDofDofDofDdfDdfDdfDdfEfEfDfDfAfAftftffс
+fDofDofDofDofDdfDdfDdfDdfEfEfDfDfAfAftftffс
+fs
+<
+
+
+
+H5#
+H4#
+H0#
+H'/#
+@m
+
+@m
+Hy(#
+
+H%#
+H$#
+H="#
+f.
+H IH ȉq rDILH1wLHqJ uW tHHX
+H #
+
+O
+HL$ 
+
+
+
+D
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+main_type:[%s] sub_type:[%s] is reduplicate
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ # pack files in directory to the archive
+ %s -r <config file> <src dir> <target file>
+ # unpack files in directory to the archive
+ %s -d <archive> [out dir]
+ # check the image
+ %s -c <archive>
+
+
+
+
+
+
+
+
+
+
+
+<sizes>
+
+
+
+
+
+
+
+
+
+
+
+
+<total type="fast" count="%zu" size="%zu"/>
+<total type="rest" count="%zu" size="%zu"/>
+<system type="current" size="%zu"/>
+<system type="max" size="%zu"/>
+
+<aspace type="mprotect" size="%zu"/>
+
+
+<total type="rest" count="%zu" size="%zu"/>
+<system type="current" size="%zu"/>
+<system type="max" size="%zu"/>
+<aspace type="total" size="%zu"/>
+<aspace type="mprotect" size="%zu"/>
+</malloc>
+
+B
+B
+B
+B
+*Jj0Pp
+"C
+!C
+#C
+ 
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+!
+$
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
+
+%n
+
+  
+  
+      
+ 
+ 
+   
+
+p=
+ףp=
+؉؉ %^B{ $I$I$ =B!B|PuPuPqq
+
+
+
+ wcrtomb.c
+
+ entry: 0x%0*lx phdr: 0x%0*lx phnum: %*u
+
+
+file=%s [%lu]; needed by %s [%lu]
+
+file=%s [%lu]; dynamically loaded by %s [%lu]
+
+
+
+
+
+
+
+
+
+file=%s [%lu]; needed by %s [%lu] (relocation dependency)
+
+
+
+
+
+
+
+relocation processing: %s%s
+
+
+
+
+ 
+  +
+
+
+
+}L,D4fl}C}Ο+#U>#`e!Q4\Ycɟ+1*ZibBtz["؊4س?ŏmk1Ke6ukG܉ـ( f13j~{j6h߸<bBQuɶluYD?e1Væ5RğIJ@A[
+"Ωo$po?b(UxI>Nkw};u
+
+#6'0q'"(\<a+H+Tq40{&)tJSܵ
+z!pt0tvlw뛡c5ތ7d@ч;Bb&.^ Y]=u8Q)+
+9/%->؄t.z-TMеub
+<4 9Ԣ7.~2!'{n $-PԓX+1"#+%? D~br*~xxކzos{'~j=jr1|òAv09&Ѷ~j2=_+0cm-X%<|b
+7w
+ʐ,5P6xPnx [4? E,W8 9qIHۚ풴lMP#*wg:8-ñj@?F[$GtJL0s-o|;#o`Is{Kҵ65m1 k?f%(炸r;v=4tP
+IA?7߻D!W
+dKE)0b
+
+
+
+
+
+
+
+
+
+add %s [%lu] to global scope
+
+
+
+calling fini: %s [%lu]
+
+
+closing file=%s; direct_opencount=%u
+
+file=%s [%lu]; destroying link map
+
+
+
+
+
+
+calling init: %s
+
+
+calling preinit: %s
+
+
+
+
+A i
+O
+8A0A(B BBBG
+8A0A(B BBBG
+ABA
+ AABD
+DAJ
+A
+CBE
+A
+A
+D
+E L
+H L
+CBI
+A
+
+
+A
+A
+"H 
+F y
+G
+ A
+G
+
+8A0A(B BBBH ~
+8A0A(B BBBH 
+8A0A(B BBGG Q
+8A0A(B BBBE
+A K
+AFE F
+AAH
+8A0A(B BBBD
+E $
+H
+CAG 
+ACF |
+AAR d
+DAO L
+B H
+A Y
+F 
+AAG
+H
+(A HBBF ~
+(A HBBE
+J
+(A ABBK
+F
+B
+DAF c
+ADH
+F ]
+A K
+G
+E G
+E `,
+AAH
+AED
+F V
+J
+A
+ D P
+ H  
+ E 
+ G
+J
+D R
+AAJ G
+AAG M
+FAD ,
+ABH
+8A0A(B BBBD
+AAF
+AAH
+E
+F
+G K
+E q
+G D
+D R
+F
+G K
+E y
+G R
+F
+H
+A
+(A BBBA
+(G BBBG
+E
+K
+F
+C
+B U
+8D0A(B BBBJ
+8D0A(B BBBH
+
+(A ABBE
+AF
+F 
+F $
+J $
+D
+E
+A
+A
+D d"H 
+@
+=
+H
+8F0A(B BBBE
+B
+F
+E
+K
+8A0A(B BBBA
+H
+CAD
+(A ABBJ
+ AABA
+8A0A(B BBBF |
+8A0A(B BBBB x
+8A0A(B BBBN 
+8E0A(B BBBH f
+8D0A(B BBBE
+G c
+M s
+E Z
+8D0A(B BBBD
+F
+K U
+K 4
+DAA D
+FAE
+K
+C
+A 
+A F
+A
+G u
+B
+I N
+R 
+J U
+K H
+B 
+J [
+E D
+(D ABBD (D AEB
+(A BBEC (A BBB
+
+C "
+E
+8A0A(B BBBG
+8A0A(B BBBH
+H
+J V
+J i
+A ,
+AH 
+CH
+A @
+E t
+A 
+(D ABBG 
+(D ABBB
+K
+
+AB
+ABF
+8A0A(B BBBA
+8D0A(B BBBF
+I
+E S
+E d
+L k
+E L
+D O
+A W
+F F
+A F
+A F
+A F
+A F
+A F
+A F
+A D
+A Q
+C U
+0A(A BBBB
+B \
+L J
+ABA :
+NIA
+I A
+DAD LAD
+ H
+AAA
+AAA |
+AAB c
+FAF
+AAF
+F
+A
+ABG 
+ABS
+B
+E
+J
+A ,
+ H
+ CABA
+
+
+AA
+ AAEE
+A
+CAA
+ J
+ A L 
+8A0A(B BBBG
+0A(B BBBG
+ AABG ]
+ AABG
+8D0A(B BBBH
+D \
+D
+ CABA Q
+ JABE
+N
+B
+(D ABBE
+G N
+8A0A(B BBBA
+FAL DAA
+J ,
+
+ A
+G
+B 4
+(A BBBB H
+(A BEBE i(A BBB
+ F
+ F
+ A [
+ A
+A
+8A0A(B BBBA
+8A0A(B BBBA
+8A0A(B BBBA
+8A0A(B BBBJ
+8A0A(B BBBA
+8A0A(B BBBA
+8A0A(B BBBA
+8A0A(B BBBA
+8A0A(B BBBA
+8A0A(B BBBA
+8A0A(B BBBA
+8A0A(B BBBA
+8F0A(B BBBG K8C0A(B BBB,
+ CABA
+J
+E
+A E
+K K
+A D
+ DABH ^
+ AABF
+8D0A(B BBBJ 8G0A(B BBB
+ E
+ D
+8A0A(B BBBA
+ A
+M
+ J 
+ A
+AAA
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
+
+
+
+
+
+J
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+L
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+A
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+(
+
+
+
+
+
+
+
+
+
+
+
+o
+o
+o
+o
+o
+o
+o
+o
+o
+o
+
+
+
+
+
+
+
+
+
+
+
++
+o
+o
+o
+
+,
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+0
+
+
+G
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+@
+
+
+F
+
+
+
+
+
+
+
+
+
+
+
+G
+
+
+
+
+
+G
+T
+
+
+
+
+
+
+
+
+
+
+
+_
+
+
+
+
+d
+
+
+
+
+
+
+
+
+
+F
+
+
+
+
+
+
+F
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+F
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/logo_img_packer/Android.mk b/logo_img_packer/Android.mk
new file mode 100755
index 0000000..5577873
--- a/dev/null
+++ b/logo_img_packer/Android.mk
@@ -0,0 +1,38 @@
+# Copyright 2005 The Android Open Source Project
+#
+#
+
+LOCAL_PATH:= $(call my-dir)
+
+# target tool
+# =========================================================
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := res_pack.cpp crc32.cpp
+LOCAL_MODULE := logo_img_packer
+
+ifeq ($(HOST_OS),cygwin)
+LOCAL_CFLAGS += -DWIN32_EXE
+endif
+ifeq ($(HOST_OS),darwin)
+LOCAL_CFLAGS += -DMACOSX_RSRC
+endif
+ifeq ($(HOST_OS),linux)
+endif
+
+LOCAL_STATIC_LIBRARIES := libhost
+LOCAL_C_INCLUDES := build/libs/host/include
+#LOCAL_ACP_UNAVAILABLE := true
+
+include $(BUILD_HOST_EXECUTABLE)
+
+# host tool
+# =========================================================
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := res_pack.cpp crc32.cpp
+LOCAL_MODULE := logo_img_packer
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_EXECUTABLE)
+
diff --git a/logo_img_packer/README b/logo_img_packer/README
new file mode 100644
index 0000000..ca1a83e
--- a/dev/null
+++ b/logo_img_packer/README
@@ -0,0 +1,2 @@
+Amlogic image array pack tool v2
+
diff --git a/logo_img_packer/crc32.cpp b/logo_img_packer/crc32.cpp
new file mode 100755
index 0000000..8f02e80
--- a/dev/null
+++ b/logo_img_packer/crc32.cpp
@@ -0,0 +1,104 @@
+/*
+ * crc32.c
+ *
+ * Created on: 2013-5-31
+ * Author: binsheng.xu@amlogic.com
+ */
+#include "res_pack_i.h"
+
+#define BUFSIZE 1024*16
+
+static unsigned int crc_table[256];
+
+
+static void init_crc_table(void)
+{
+ unsigned int c;
+ unsigned int i, j;
+
+ for (i = 0; i < 256; i++) {
+ c = (unsigned int)i;
+ for (j = 0; j < 8; j++) {
+ if (c & 1)
+ c = 0xedb88320L ^ (c >> 1);
+ else
+ c = c >> 1;
+ }
+ crc_table[i] = c;
+ }
+}
+
+//generate crc32 with buffer data
+unsigned int crc32(unsigned int crc,unsigned char *buffer, unsigned int size)
+{
+ unsigned int i;
+ for (i = 0; i < size; i++) {
+ crc = crc_table[(crc ^ buffer[i]) & 0xff] ^ (crc >> 8);
+ }
+ return crc ;
+}
+
+//Generate crc32 value with file steam, which from 'offset' to end if checkSz==0
+unsigned calc_img_crc(FILE* fp, off_t offset, unsigned checkSz)
+{
+
+ unsigned char buf[BUFSIZE];
+ /*һδֵҪ̶,ͶʹøֵcrcУ,
+ **ôնҲͬҪʹøֵм*/
+ unsigned int crc = 0xffffffff;
+ unsigned MaxCheckLen = 0;
+ unsigned totalLenToCheck = 0;
+
+ if (fp == NULL) {
+ fprintf(stderr,"bad param!!\n");
+ return 0;
+ }
+
+ fseeko(fp, 0, SEEK_END);
+ MaxCheckLen = ftell(fp);
+ MaxCheckLen -= offset;
+ if(!checkSz){
+ checkSz = MaxCheckLen;
+ }
+ else if(checkSz > MaxCheckLen){
+ fprintf(stderr, "checkSz %u > max %u\n", checkSz, MaxCheckLen);
+ return 0;
+ }
+ //fprintf(stderr,"L%d, checkSz=%u\n", __LINE__, checkSz);
+
+ init_crc_table();
+ fseeko(fp,offset,SEEK_SET);
+
+ while(totalLenToCheck < checkSz)
+ {
+ int nread;
+ unsigned leftLen = checkSz - totalLenToCheck;
+ int thisReadSz = leftLen > BUFSIZE ? BUFSIZE : leftLen;
+
+ nread = fread(buf,1, thisReadSz, fp);
+ if (nread < 0) {
+ fprintf(stderr,"%d:read %s.\n", __LINE__, strerror(errno));
+ return 0;
+ }
+ crc = crc32(crc, buf, thisReadSz);
+
+ totalLenToCheck += thisReadSz;
+ }
+
+ return crc;
+}
+
+int check_img_crc(FILE* fp, off_t offset, const unsigned orgCrc, unsigned checkSz/* checkSz from offset */)
+{
+ const unsigned genCrc = calc_img_crc(fp, offset, checkSz);
+
+ if(genCrc != orgCrc)
+ {
+ fprintf(stderr,"%d:genCrc 0x%x != orgCrc 0x%x, error(%s).\n", __LINE__, genCrc, orgCrc, strerror(errno));
+ return -1;
+ }
+
+ return 0;
+}
+
+
diff --git a/logo_img_packer/crc32.h b/logo_img_packer/crc32.h
new file mode 100755
index 0000000..8594753
--- a/dev/null
+++ b/logo_img_packer/crc32.h
@@ -0,0 +1,17 @@
+/*
+ * crc32.h
+ *
+ * Created on: 2013-5-31
+ * Author: binsheng.xu@amlogic.com
+ */
+
+#ifndef CRC32_H_
+#define CRC32_H_
+
+unsigned int crc32(unsigned int crc,unsigned char *buffer, unsigned int size);
+
+unsigned calc_img_crc(FILE* fd, off_t offset, unsigned checkSz);
+
+int check_img_crc(FILE* fp, off_t offset, const unsigned orgCrc, unsigned checkSz);
+
+#endif /* CRC32_H_ */
diff --git a/logo_img_packer/res_dll_if.h b/logo_img_packer/res_dll_if.h
new file mode 100755
index 0000000..17b052a
--- a/dev/null
+++ b/logo_img_packer/res_dll_if.h
@@ -0,0 +1,30 @@
+/*
+ * \file res_dll_if.h
+ * \brief This interfaces is included by user who use this dll
+ *
+ * \version 1.0.0
+ * \date 29/10/2013 14:19
+ * \author Sam.Wu <yihui.wu@amlgic.com>
+ *
+ * Copyright (c) 2013 Amlogic Inc.. All Rights Reserved.
+ *
+ */
+#ifndef __RES_DLL_IF_H__
+#define __RES_DLL_IF_H__
+
+
+#ifdef BUILD_DLL
+
+/* DLL export */
+#define DLL_API __declspec(dllexport)
+#else
+
+/* DLL import */
+#define DLL_API __declspec(dllimport)
+#endif
+
+DLL_API int res_img_pack(const char* const szDir, const char* const outResImg);
+
+DLL_API int res_img_unpack(const char* const path_src, const char* const unPackDirPath, int needCheckCrc);
+
+#endif // __RES_DLL_IF$_H__
diff --git a/logo_img_packer/res_pack.cpp b/logo_img_packer/res_pack.cpp
new file mode 100755
index 0000000..953e3ff
--- a/dev/null
+++ b/logo_img_packer/res_pack.cpp
@@ -0,0 +1,615 @@
+/*
+ * Command for pack imgs.
+ *
+ * Copyright (C) 2012 Amlogic.
+ * Elvis Yu <elvis.yu@amlogic.com>
+ */
+#include "res_pack_i.h"
+
+#define COMPILE_TYPE_CHK(expr, t) typedef char t[(expr) ? 1 : -1]
+
+COMPILE_TYPE_CHK(AML_RES_IMG_HEAD_SZ == sizeof(AmlResImgHead_t), a);//assert the image header size 64
+COMPILE_TYPE_CHK(AML_RES_ITEM_HEAD_SZ == sizeof(AmlResItemHead_t), b);//assert the item head size 64
+
+#define IMG_HEAD_SZ sizeof(AmlResImgHead_t)
+#define ITEM_HEAD_SZ sizeof(AmlResItemHead_t)
+//#define ITEM_READ_BUF_SZ (1U<<20)//1M
+#define ITEM_READ_BUF_SZ (64U<<10)//64K to test
+
+
+typedef int (*pFunc_getFile)(const char** const , __hdle *, char* );
+
+static size_t get_filesize(const char *fpath)
+{
+ struct stat buf;
+ if(stat(fpath, &buf) < 0)
+ {
+ fprintf (stderr, "Can't stat %s : %s\n", fpath, strerror(errno));
+ exit (EXIT_FAILURE);
+ }
+ return buf.st_size;
+}
+
+
+static const char* get_filename(const char *fpath)
+{
+#if 1
+ int i;
+ const char *filename = fpath;
+ for(i=strlen(fpath)-1; i>=0; i--)
+ {
+ if('/' == fpath[i] || '\\' == fpath[i])
+ {
+ i++;
+ filename = fpath + i;
+ break;
+ }
+ }
+
+ return filename;
+#else
+ return (strrchr(fpath, '/')+1);
+#endif
+}
+
+
+int get_file_path_from_argv(const char** const argv, __hdle *hDir, char* fileName)
+{
+ long index = (long)hDir;
+ const char* fileSrc = argv[index];
+
+ strcpy(fileName, fileSrc);
+ return 0;
+}
+
+#if defined(WIN32)
+static __hdle _find_first_file(const char* const dirPath, WIN32_FIND_DATA& findFileData)
+{
+ HANDLE hdle = INVALID_HANDLE_VALUE;
+ TCHAR szDir[MAX_PATH];
+ size_t length_of_arg;
+ // Check that the input path plus 3 is not longer than MAX_PATH.
+ // Three characters are for the "\*" plus NULL appended below.
+ StringCchLength(dirPath, MAX_PATH, &length_of_arg);
+
+ if (length_of_arg > (MAX_PATH - 3))
+ {
+ _tprintf(TEXT("\nDirectory path is too long.\n"));
+ return NULL;
+ }
+
+ _tprintf(TEXT("\nTarget directory is %s\n\n"), dirPath);
+
+ // Prepare string for use with FindFile functions. First, copy the
+ // string to a buffer, then append '\*' to the directory name.
+
+ StringCchCopy(szDir, MAX_PATH, dirPath);
+ StringCchCat(szDir, MAX_PATH, TEXT("\\*"));
+
+ hdle = FindFirstFile(szDir, &findFileData);
+ if(INVALID_HANDLE_VALUE == hdle){
+ errorP("Fail to open dir\n");
+ return NULL;
+ }
+
+ return hdle;
+}
+
+int traverse_dir(const char** const dirPath, __hdle *hDir, char* filePath)
+{
+ WIN32_FIND_DATA findFileData;
+ HANDLE hdle = INVALID_HANDLE_VALUE;
+ int ret = 0;
+
+ if (!*hDir)//not open yet!
+ {
+ hdle = _find_first_file(*dirPath, findFileData);
+ if(INVALID_HANDLE_VALUE == hdle){
+ errorP("Fail to find first file in dir(%s)\n", *dirPath);
+ return __LINE__;
+ }
+ *hDir = hdle;
+ if(strcmp(".", findFileData.cFileName) && strcmp("..", findFileData.cFileName))goto _ok;
+ }
+
+ hdle = *hDir;
+ do
+ {
+ ret = !FindNextFile(hdle, &findFileData);
+ if(ret){
+ debugP("Find end.\n");
+ FindClose(hdle);
+ return __LINE__;
+ }
+ } while(!strcmp(".", findFileData.cFileName) || !strcmp("..", findFileData.cFileName) );
+
+_ok:
+ //debugP("file %s\n", findFileData.cFileName);
+ if(MAX_PATH < strlen(findFileData.cFileName)){
+ errorP("Buffer samll\n");
+ FindClose(hdle);
+ return __LINE__;
+ }
+ sprintf(filePath, "%s\\%s", *dirPath, findFileData.cFileName);
+ return ret;
+}
+
+int get_dir_filenums(const char * const dirPath)
+{
+ WIN32_FIND_DATA findFileData;
+ HANDLE hdle = INVALID_HANDLE_VALUE;
+ int fileNum = 0;
+ int ret = 0;
+ TCHAR szDir[MAX_PATH];
+ size_t length_of_arg;
+
+ hdle = _find_first_file(dirPath, findFileData);
+ if(INVALID_HANDLE_VALUE == hdle){
+ errorP("Fail to open dir %s\n", szDir);
+ return __LINE__;
+ }
+
+ do {
+ if(strcmp(findFileData.cFileName, ".") && strcmp(findFileData.cFileName, ".."))
+ {
+ ++fileNum;
+ }
+ } while (FindNextFile(hdle, &findFileData));
+
+_ok:
+ if(INVALID_HANDLE_VALUE != hdle)FindClose(hdle);
+ return fileNum;
+}
+
+#else//Follwing is for Linux platform
+int get_dir_filenums(const char *dir_path)
+{
+ int count = 0;
+ DIR *d;
+ struct dirent *de;
+ d = opendir(dir_path);
+ if(d == 0) {
+ fprintf(stderr, "opendir failed, %s\n", strerror(errno));
+ return -1;
+ }
+ while((de = readdir(d)) != 0){
+ if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, "..")) continue;
+ if(de->d_name[0] == '.') continue;
+ count++;
+ }
+ closedir(d);
+ return count;
+}
+
+int traverse_dir(const char** const dirPath, __hdle *hdle, char* filePath)
+{
+ DIR* hDir = (DIR*)*hdle;
+ const char* fileName = NULL;
+
+ if(!hDir)
+ {
+ hDir = opendir(*dirPath);
+ if(!hDir){
+ errorP("Fail to open dir(%s), strerror(%s)\n", *dirPath, strerror(errno));
+ return __LINE__;
+ }
+ *hdle = hDir;
+ }
+
+ do{
+ struct dirent* dirEntry = NULL;
+
+ dirEntry = readdir(hDir);
+ if(!dirEntry){
+ debugP("travese end.\n");
+ closedir(hDir);
+ return __LINE__;
+ }
+ fileName = dirEntry->d_name;
+ }while(!strcmp(".", fileName) || !strcmp("..", fileName));
+
+ sprintf(filePath, "%s/%s", *dirPath, fileName);
+ return 0;
+}
+#endif//#if defined(WIN32)
+
+//@imgVersion: if success, then 0--> oldest version; 1-->img header + n * (item header + item body); 2 --> img header + n * item header + n * item body
+static int _img_unpack_check_img_header(FILE* fdResImg, const char* const path_src,
+ int needCheckCrc, AmlResImgHead_t* pImgHead, int* imgVersion)
+{
+ int ret = 0;
+ const unsigned ImgFileSz = get_filesize(path_src);
+
+ if(ImgFileSz <= IMG_HEAD_SZ){
+ errorP("file size 0x%x too small\n", ImgFileSz);
+ return __LINE__;
+ }
+
+ unsigned thisReadSz = ITEM_READ_BUF_SZ > ImgFileSz ? ImgFileSz : ITEM_READ_BUF_SZ;
+ unsigned actualReadSz = 0;
+
+ actualReadSz = fread(pImgHead, 1, thisReadSz, fdResImg);
+ if(actualReadSz != thisReadSz){
+ errorP("Want to read 0x%x, but only read 0x%x\n", thisReadSz, actualReadSz);
+ return __LINE__;
+ }
+
+ if(!strncmp(AML_RES_IMG_V1_MAGIC, (char*)pImgHead->magic, AML_RES_IMG_V1_MAGIC_LEN))
+ {//new version magic matched
+ if(ImgFileSz < pImgHead->imgSz){
+ errorP("error, image size in head 0x%x != fileSz 0x%x\n", pImgHead->imgSz, ImgFileSz);
+ return __LINE__;
+ }
+ if(AML_RES_IMG_VERSION_V2 < pImgHead->version){
+ errorP("Error, version 0x%x not supported\n", pImgHead->version);
+ return __LINE__;
+ }
+ *imgVersion = pImgHead->version;
+
+ if(needCheckCrc)
+ {
+ ret = check_img_crc(fdResImg, 4, pImgHead->crc, pImgHead->imgSz - 4);
+ if(ret){
+ errorP("Error when check crc\n");
+ return __LINE__;
+ }
+ }
+ unsigned ImgHeadSz = IMG_HEAD_SZ;
+ if(AML_RES_IMG_VERSION_V2 == pImgHead->version) ImgHeadSz += pImgHead->imgItemNum * ITEM_HEAD_SZ;
+ fseek(fdResImg, ImgHeadSz, SEEK_SET);//seek escape the image header to prepare for reading item header
+ }
+ else
+ {
+ AmlResItemHead_t* pItemHeadInfo = (AmlResItemHead_t*)pImgHead;
+ debugP("magic error, try old version image.\n");
+ if(IH_MAGIC != pItemHeadInfo->magic){
+ errorP("magic err, old version image header not item header!\n");
+ return __LINE__;
+ }
+ *imgVersion = 0;
+ fseek(fdResImg, 0, SEEK_SET);//seek escape the image header to prepare for reading item header
+ }
+
+ debugP("res-img ver is 0x%x\n", *imgVersion);
+ return 0;
+}
+
+//Get the item header info
+//If the @imgVersion is V2, the item header already stored in @pImgHead, if @imgVersion is V2 or old, also read it into 64K size pImgHead
+static const AmlResItemHead_t* _img_unpack_get_item_header(const int imgVersion, const AmlResImgHead_t* pImgHead, int itemIndex, FILE* fdResImg)
+{
+ const AmlResItemHead_t* pItemNext = NULL;
+ AmlResItemHead_t* tmpItem = NULL;
+
+ tmpItem = (AmlResItemHead_t*)(pImgHead + 1);
+ tmpItem += itemIndex;
+
+ switch(imgVersion) {
+ case AML_RES_IMG_VERSION_V2:
+ pItemNext = tmpItem;
+ break;
+
+ case AML_RES_IMG_VERSION_V1:
+ case 0:
+ {
+ const unsigned readSz = fread(tmpItem, 1, ITEM_HEAD_SZ, fdResImg);
+ if(ITEM_HEAD_SZ != readSz){
+ errorP("Fail to read item head\n");
+ return NULL;
+ }
+ pItemNext = tmpItem;
+ }
+ break;
+ default:
+ break;
+ }
+
+ if(IH_MAGIC != pItemNext->magic){
+ errorP("Item magic error.\n");
+ return NULL;
+ }
+
+ return pItemNext;
+}
+
+#ifdef BUILD_DLL
+DLL_API
+#endif// #ifdef BUILD_DLL
+int res_img_unpack(const char* const path_src, const char* const unPackDirPath, int needCheckCrc)
+{
+ char* itemReadBuf = NULL;
+ FILE* fdResImg = NULL;
+ int ret = 0;
+ AmlResImgHead_t* pImgHead = NULL;
+ int imgVersion = -1;
+
+ fdResImg = fopen(path_src, "rb");
+ if(!fdResImg){
+ errorP("Fail to open res image at path %s\n", path_src);
+ return __LINE__;
+ }
+
+ itemReadBuf = new char[ITEM_READ_BUF_SZ * 2];
+ if(!itemReadBuf){
+ errorP("Fail to new buffer at size 0x%x\n", ITEM_READ_BUF_SZ*2);
+ fclose(fdResImg), fdResImg = NULL; return __LINE__;
+ }
+ pImgHead = (AmlResImgHead_t*)(itemReadBuf + ITEM_READ_BUF_SZ);
+
+ ret = _img_unpack_check_img_header(fdResImg, path_src, needCheckCrc, pImgHead, &imgVersion);
+ if(ret){
+ errorP("Fail at check image header\n");
+ delete[] itemReadBuf, itemReadBuf = NULL;
+ fclose(fdResImg), fdResImg = NULL;
+ return __LINE__;
+ }
+
+ //for each loop:
+ // 1, read item body and save as file;
+ // 2, get next item head
+ const unsigned itemAlignSz = AML_RES_IMG_ITEM_ALIGN_SZ;
+ const unsigned itemAlignMod = itemAlignSz - 1;
+ const unsigned itemSzAlignMask = ~itemAlignMod;
+ unsigned totalReadItemNum = 0;
+ const AmlResItemHead_t* pItemHead = NULL;
+
+ do{
+ char itemFullPath[MAX_PATH*2];//TODO:512 is enough ??
+ FILE* fp_item = NULL;
+
+ pItemHead = _img_unpack_get_item_header(imgVersion, pImgHead, totalReadItemNum++, fdResImg);
+ if(!pItemHead){
+ errorP("Fail to get item header at index %d\n", totalReadItemNum - 1);
+ goto _exit;
+ }
+
+ sprintf(itemFullPath, "%s/%s", unPackDirPath, pItemHead->name);
+ debugP("item %s\n", itemFullPath);
+
+ fp_item = fopen(itemFullPath, "wb");
+ if(!fp_item){
+ errorP("Fail to create file %s, strerror(%s)\n", itemFullPath, strerror(errno));
+ ret = __LINE__; goto _exit;
+ }
+
+ const unsigned thisItemBodySz = pItemHead->size;
+ const unsigned thisItemBodyOccupySz = (thisItemBodySz & itemSzAlignMask) + itemAlignSz;
+ const unsigned stuffLen = thisItemBodyOccupySz - thisItemBodySz;
+
+ for(unsigned itemTotalReadLen = 0; itemTotalReadLen < thisItemBodyOccupySz; )
+ {
+ const unsigned leftLen = thisItemBodyOccupySz - itemTotalReadLen;
+ const unsigned thisReadSz = min(leftLen, ITEM_READ_BUF_SZ);
+
+ unsigned actualReadSz = fread(itemReadBuf, 1, thisReadSz, fdResImg);
+ if(thisReadSz != actualReadSz){
+ errorP("thisReadSz 0x%x != actualReadSz 0x%x\n", thisReadSz, actualReadSz);
+ ret = __LINE__;goto _exit;
+ }
+ itemTotalReadLen += thisReadSz;
+
+ const unsigned thisWriteSz = itemTotalReadLen < thisItemBodySz ? thisReadSz : (thisReadSz - stuffLen);
+ actualReadSz = fwrite(itemReadBuf, 1, thisWriteSz, fp_item);
+ if(thisWriteSz != actualReadSz){
+ errorP("want write 0x%x, but 0x%x\n", thisWriteSz, actualReadSz);
+ ret = __LINE__;goto _exit;
+ }
+
+ }
+ fclose(fp_item), fp_item = NULL;
+
+ }while(pItemHead->next);
+
+
+_exit:
+ if(itemReadBuf)delete[] itemReadBuf, itemReadBuf = NULL;
+ if(fdResImg)fclose(fdResImg), fdResImg = NULL;
+ return ret;
+}
+
+/*
+ * 1,
+ */
+static int _img_pack(const char** const path_src, const char* const packedImg,
+ pFunc_getFile getFile, const int totalFileNum)
+{
+ FILE *fd_src = NULL;
+ FILE *fd_dest = NULL;
+ unsigned int pos = 0;
+ char file_path[MAX_PATH];
+ const char *filename = NULL;
+ unsigned imageSz = 0;
+ const unsigned BufSz = ITEM_READ_BUF_SZ;
+ char* itemBuf = NULL;
+ unsigned thisWriteLen = 0;
+ unsigned actualWriteLen = 0;
+ int ret = 0;
+ __hdle hDir = NULL;
+ const unsigned itemAlignSz = AML_RES_IMG_ITEM_ALIGN_SZ;
+ const unsigned itemAlignMod = itemAlignSz - 1;
+ const unsigned itemSzAlignMask = ~itemAlignMod;
+ const unsigned totalItemNum = totalFileNum ? totalFileNum : get_dir_filenums(*path_src);
+ const unsigned HeadLen = IMG_HEAD_SZ + ITEM_HEAD_SZ * totalItemNum;
+
+ if(HeadLen > BufSz){
+ errorP("head size 0x%x > max(0x%x)\n", HeadLen, BufSz); return __LINE__;
+ }
+ fd_dest = fopen(packedImg, "wb+");
+ if(NULL == fd_dest) {
+ fprintf(stderr,"open %s failed: %s\n", packedImg, strerror(errno));
+ return __LINE__;
+ }
+
+ itemBuf = new char[BufSz * 2];
+ if(!itemBuf){
+ errorP("Exception: fail to alloc buuffer\n");
+ fclose(fd_dest); return __LINE__;
+ }
+ memset(itemBuf, 0, BufSz*2);
+ AmlResImgHead_t* const aAmlResImgHead = (AmlResImgHead_t*)(itemBuf + BufSz);
+
+ actualWriteLen = fwrite(aAmlResImgHead, 1, HeadLen, fd_dest);
+ if(actualWriteLen != HeadLen){
+ errorP("fail to write head, want 0x%x, but 0x%x\n", HeadLen, actualWriteLen);
+ fclose(fd_dest); delete[] itemBuf;
+ return __LINE__;
+ }
+ imageSz += HeadLen; //Increase imageSz after pack each item
+ AmlResItemHead_t* pItemHeadInfo = (AmlResItemHead_t*)(aAmlResImgHead + 1);
+ AmlResItemHead_t* const pFirstItemHeadInfo = pItemHeadInfo;
+
+ debugP("item num %d\n", totalItemNum);
+ //for each loop: first create item header and pack it, second pack the item data
+ //Fill the item head, 1) magic, 2)data offset, 3)next head start offset
+ for(unsigned itemIndex = 0; itemIndex < totalItemNum; ++itemIndex)
+ {
+ char filePath[MAX_PATH*2];
+
+ if(totalFileNum)//File list mode
+ {
+ if((*getFile)(path_src, (__hdle*)itemIndex, filePath)) {
+ break;
+ }
+ }
+ else
+ {//file directory mode
+ if((*getFile)(path_src, &hDir, filePath)) {
+ break;
+ }
+ }
+ const size_t itemSz = get_filesize(filePath);
+ const char* itemName = get_filename(filePath);
+ const unsigned itemBodyOccupySz = (itemSz & itemSzAlignMask) + itemAlignSz;
+ const unsigned itemStuffSz = itemBodyOccupySz - itemSz;
+
+ if(IH_NMLEN - 1 < strlen(itemName)){
+ errorP("Item name %s len %d > max(%d)\n", itemName, (int)strlen(itemName), IH_NMLEN - 1);
+ ret = __LINE__; goto _exit;
+ }
+ pItemHeadInfo->magic = IH_MAGIC;
+ pItemHeadInfo->size = itemSz;
+ //imageSz += ITEM_HEAD_SZ;//not needed yet as all item_head moves to image header
+ pItemHeadInfo->start = imageSz;
+ pItemHeadInfo->next = (char*)(pItemHeadInfo + 1) - (char*)aAmlResImgHead;
+ pItemHeadInfo->index = itemIndex;
+ imageSz += itemBodyOccupySz;
+ pItemHeadInfo->nums = totalItemNum;
+ memcpy(pItemHeadInfo->name, itemName, strlen(itemName));
+ debugP("pack item [%s]\n", itemName);
+ ++pItemHeadInfo;//prepare for next item
+
+ fd_src = fopen(filePath, "rb");
+ if(!fd_src){
+ errorP("Fail to open file [%s], strerror[%s]\n", filePath, strerror(errno));
+ ret = __LINE__; goto _exit;
+ }
+ for(size_t itemWriteLen = 0; itemWriteLen < itemSz; itemWriteLen += thisWriteLen)
+ {
+ size_t leftLen = itemSz - itemWriteLen;
+
+ thisWriteLen = leftLen > BufSz ? BufSz : leftLen;
+ actualWriteLen = fread(itemBuf, 1, thisWriteLen, fd_src);
+ if(actualWriteLen != thisWriteLen){
+ errorP("Want to read 0x%x but actual 0x%x, at itemWriteLen 0x%x, leftLen 0x%x\n",
+ thisWriteLen, actualWriteLen, (unsigned)itemWriteLen, (unsigned)leftLen);
+ ret = __LINE__; goto _exit;
+ }
+ actualWriteLen = fwrite(itemBuf, 1, thisWriteLen, fd_dest);
+ if(actualWriteLen != thisWriteLen){
+ errorP("Want to write 0x%x but actual 0x%x\n", thisWriteLen, actualWriteLen);
+ ret = __LINE__; goto _exit;
+ }
+ }
+ fclose(fd_src), fd_src = NULL;
+ memset(itemBuf, 0, itemStuffSz);
+ thisWriteLen = itemStuffSz;
+ actualWriteLen = fwrite(itemBuf, 1, thisWriteLen, fd_dest);
+ if(actualWriteLen != thisWriteLen){
+ errorP("Want to write 0x%x, but 0x%x\n", thisWriteLen, actualWriteLen);
+ ret = __LINE__; goto _exit;
+ }
+ }
+ (--pItemHeadInfo)->next = 0;
+
+ //Create the header
+ aAmlResImgHead->version = AML_RES_IMG_VERSION_V2;
+ memcpy(&aAmlResImgHead->magic[0], AML_RES_IMG_V1_MAGIC, AML_RES_IMG_V1_MAGIC_LEN);
+ aAmlResImgHead->imgSz = imageSz;
+ aAmlResImgHead->imgItemNum = totalItemNum;
+ aAmlResImgHead->alignSz = itemAlignSz;
+ aAmlResImgHead->crc = 0;
+ //
+ //Seek to file header to correct the header
+ fseek(fd_dest, 0, SEEK_SET);
+ actualWriteLen = fwrite(aAmlResImgHead, 1, HeadLen, fd_dest);
+ if(actualWriteLen != HeadLen){
+ errorP("Want to write 0x%x, but 0x%x\n", HeadLen, actualWriteLen);
+ ret = __LINE__; goto _exit;
+ }
+
+ aAmlResImgHead->crc = calc_img_crc(fd_dest, 4, 0);//Gen crc32
+ fseek(fd_dest, 0, SEEK_SET);
+ actualWriteLen = fwrite(&aAmlResImgHead->crc, 1, 4, fd_dest);
+ if(4 != actualWriteLen){
+ errorP("Want to write 4, but %d\n", actualWriteLen);
+ ret = __LINE__; goto _exit;
+ }
+
+_exit:
+ if(itemBuf) delete[] itemBuf, itemBuf = NULL;
+ if(fd_src) fclose(fd_src), fd_src = NULL;
+ if(fd_dest) fclose(fd_dest), fd_dest = NULL;
+ return ret;
+}
+
+#ifdef BUILD_DLL
+DLL_API
+#endif// #ifdef BUILD_DLL
+int res_img_pack(const char* szDir, const char* const outResImg)
+{
+ return _img_pack(&szDir, outResImg, traverse_dir, 0);
+}
+
+#ifndef BUILD_DLL
+static const char * const doc = "Amlogic `imgpack v3' usage:\n\
+\n\
+ # unpack files to the archive\n\
+ imgpack -d [archive] [destination-directory]\n\
+ # pack files in directory to the archive\n\
+ imgpack -r [source-directory] [archive]\n\
+ # pack files to the archive\n\
+ imgpack [file1].. [fileN] [archive]\n";
+
+int main(int argc, const char ** const argv)
+{
+ int ret = 0;
+ int c = 0;
+ const char* opt = argv[1];
+
+ if(argc < 3) {
+ printf("invalid arguments\n");
+ printf("%s",doc);
+ exit(-1);
+ }
+
+ if(!strcmp("?", opt))
+ {
+ printf("%s",doc);
+ exit(-1);
+ }
+ if(!strcmp("-d", opt))//Unpack imgPath, dest-dir
+ {
+ ret = res_img_unpack(argv[2], argv[3], 1);
+ exit(ret);
+ }
+
+ if(!strcmp("-r", opt))//pack: fileSrc, destImg,
+ {
+ ret = res_img_pack(argv[2], argv[3]);
+ exit(ret);
+ }
+
+ ret = _img_pack(&argv[1], argv[argc -1], get_file_path_from_argv, argc - 2);
+ exit(ret);
+}
+#endif// #ifndef BUILD_DLL
diff --git a/logo_img_packer/res_pack.h b/logo_img_packer/res_pack.h
new file mode 100755
index 0000000..ea44caa
--- a/dev/null
+++ b/logo_img_packer/res_pack.h
@@ -0,0 +1,73 @@
+/*
+ * \file imgpack.h
+ * \brief Amlogic resource image header define
+ *
+ * \version 1.0.0
+ * \date 2013/10/24
+ * \author Sam.Wu <yihui.wu@amlgic.com>
+ *
+ * Copyright (c) 2013 Amlogic Inc.. All Rights Reserved.
+ *
+ */
+#ifndef __IMGPACK_H__
+#define __IMGPACK_H__
+
+typedef unsigned int __u32;
+typedef signed int __s32;
+typedef unsigned char __u8;
+typedef signed char __s8;
+
+#define IH_MAGIC 0x27051956 /* Image Magic Number */
+#define IH_NMLEN 32 /* Image Name Length */
+
+#define AML_RES_IMG_ITEM_ALIGN_SZ 16
+#define AML_RES_IMG_V1_MAGIC_LEN 8
+#define AML_RES_IMG_V1_MAGIC "AML_RES!"//8 chars
+#define AML_RES_IMG_HEAD_SZ (AML_RES_IMG_ITEM_ALIGN_SZ * 4)//64
+#define AML_RES_ITEM_HEAD_SZ (AML_RES_IMG_ITEM_ALIGN_SZ * 4)//64
+
+#define AML_RES_IMG_VERSION_V1 (0x01)
+#define AML_RES_IMG_VERSION_V2 (0x02)
+
+#pragma pack(push, 1)
+typedef struct pack_header{
+ unsigned int magic; /* Image Header Magic Number */
+ unsigned int hcrc; /* Image Header CRC Checksum */
+ unsigned int size; /* Image Data Size */
+ unsigned int start; /* item data offset in the image*/
+ unsigned int end; /* Entry Point Address */
+ unsigned int next; /* Next item head offset in the image*/
+ unsigned int dcrc; /* Image Data CRC Checksum */
+ unsigned char index; /* Operating System */
+ unsigned char nums; /* CPU architecture */
+ unsigned char type; /* Image Type */
+ unsigned char comp; /* Compression Type */
+ char name[IH_NMLEN]; /* Image Name */
+}AmlResItemHead_t;
+#pragma pack(pop)
+
+//typedef for amlogic resource image
+#pragma pack(push, 4)
+typedef struct {
+ __u32 crc; //crc32 value for the resouces image
+ __s32 version;//0x01 means 'AmlResItemHead_t' attach to each item , 0x02 means all 'AmlResItemHead_t' at the head
+
+ __u8 magic[AML_RES_IMG_V1_MAGIC_LEN]; //resources images magic
+
+ __u32 imgSz; //total image size in byte
+ __u32 imgItemNum;//total item packed in the image
+
+ __u32 alignSz;//AML_RES_IMG_ITEM_ALIGN_SZ
+ __u8 reserv[AML_RES_IMG_HEAD_SZ - 8 * 3 - 4];
+
+}AmlResImgHead_t;
+#pragma pack(pop)
+
+/*The Amlogic resouce image is consisted of a AmlResImgHead_t and many
+ *
+ * |<---AmlResImgHead_t-->|<--AmlResItemHead_t-->---...--|<--AmlResItemHead_t-->---...--|....
+ *
+ */
+
+#endif//ifndef __IMGPACK_H__
+
diff --git a/logo_img_packer/res_pack_i.h b/logo_img_packer/res_pack_i.h
new file mode 100755
index 0000000..5ef2e87
--- a/dev/null
+++ b/logo_img_packer/res_pack_i.h
@@ -0,0 +1,50 @@
+/*
+ * \file res_pack_i.h
+ * \brief include file for res_pack
+ *
+ * \version 1.0.0
+ * \date 25/10/2013 11:33
+ * \author Sam.Wu <yihui.wu@amlgic.com>
+ *
+ * Copyright (c) 2013 Amlogic Inc.. All Rights Reserved.
+ *
+ */
+#ifndef __RES_PACK_I_H__
+#define __RES_PACK_I_H__
+
+#ifndef WIN32
+#include <unistd.h>
+#include <dirent.h>
+
+#define MAX_PATH 512
+#define min(a, b) ((a) > (b) ? (b) : (a))
+#else
+//For windows platform
+#include <windows.h>
+#include <tchar.h>
+#include <strsafe.h>
+
+#define fseeko _fseeki64
+#endif// #ifndef WIN32
+
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <stdlib.h>
+
+#include "res_pack.h"
+#include "crc32.h"
+
+#ifdef BUILD_DLL
+#include "res_dll_if.h"
+#endif// #ifdef BUILD_DLL
+
+typedef void* __hdle;
+
+#define debugP(...) printf("dbg:"),printf(__VA_ARGS__)
+#define errorP(...) printf("ERR(L%d):", __LINE__),printf(__VA_ARGS__)
+
+#endif // __RES_PACK_I$_H__