Skip to contentSkip to conversation

Add support for LZMA uncompression algorithm.

PATCH New Luigi 'Comio' Mantellini 2 participants 4 messages Apr 1, 2008 – Apr 18, 2008 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add support for LZMA uncompression algorithm.

---
 Makefile                   |    1 +
 README                     |   23 ++
 common/cmd_bootm.c         |   23 ++
 common/image.c             |    7 +-
 include/image.h            |    1 +
 include/lzma/LzmaDecode.h  |   31 ++
 include/lzma/LzmaTools.h   |   31 ++
 include/lzma/LzmaTypes.h   |   31 ++
 lib_lzma/LGPL.txt          |  504 +++++++++++++++++++++++++++++++++
 lib_lzma/LzmaDecode.c      |  584 ++++++++++++++++++++++++++++++++++++++
 lib_lzma/LzmaDecode.h      |  113 ++++++++
 lib_lzma/LzmaTools.c       |  143 ++++++++++
 lib_lzma/LzmaTools.h       |   35 +++
 lib_lzma/LzmaTypes.h       |   45 +++
 lib_lzma/Makefile          |   51 ++++
 lib_lzma/README.txt        |   28 ++
 lib_lzma/history.txt       |  198 +++++++++++++
 lib_lzma/import_lzmasdk.sh |   38 +++
 lib_lzma/lzma.txt          |  663 ++++++++++++++++++++++++++++++++++++++++++++
 19 files changed, 2548 insertions(+), 2 deletions(-)
 create mode 100644 include/lzma/LzmaDecode.h
 create mode 100644 include/lzma/LzmaTools.h
 create mode 100644 include/lzma/LzmaTypes.h
 create mode 100644 lib_lzma/LGPL.txt
 create mode 100644 lib_lzma/LzmaDecode.c
 create mode 100644 lib_lzma/LzmaDecode.h
 create mode 100644 lib_lzma/LzmaTools.c
 create mode 100644 lib_lzma/LzmaTools.h
 create mode 100644 lib_lzma/LzmaTypes.h
 create mode 100644 lib_lzma/Makefile
 create mode 100644 lib_lzma/README.txt
 create mode 100644 lib_lzma/history.txt
 create mode 100644 lib_lzma/import_lzmasdk.sh
 create mode 100644 lib_lzma/lzma.txt
Makefile +1 -0
index 4255cf5..03b16e2 100644
@@ -192,6 +192,7 @@ endif
 OBJS := $(addprefix $(obj),$(OBJS))
 
 LIBS  = lib_generic/libgeneric.a
+LIBS += lib_lzma/lib_lzma.a
 LIBS += $(shell if [ -f board/$(VENDOR)/common/Makefile ]; then echo \
 	"board/$(VENDOR)/common/lib$(VENDOR).a"; fi)
 LIBS += board/$(BOARDDIR)/lib$(BOARD).a
README +23 -0
index 5cbe7c1..d568e8a 100644
@@ -1038,6 +1038,29 @@ The following options need to be configured:
 		the malloc area (as defined by CFG_MALLOC_LEN) should
 		be at least 4MB.
 
+		CONFIG_LZMA
+
+		If this option is set, support for lzma compressed
+		images is included.
+
+		Note: The LZMA algorithm adds about 2KB of code and it
+		requires an amount of dynamic memory that is given by the
+		formula:
+
+		         (1846 + 768 << (lc + lp)) * sizeof(uint16)
+
+		Where lc and lp stand for, respectively, Literal context bits
+		and Literal pos bits.
+
+		This value is upper-bounded by 14MB in the worst case. Anyway,
+		for a ~4MB large kernel image, we have lc=3 and lp=0 for a
+		total amount of (1846 + 768 << (3 + 0)) * 2 = ~41KB... that is
+		a very small buffer.
+                
+		Use the lzmainfo tool to determinate the lc and lp values and
+		then calculate the  amount of needed dynamic memory (ensuring
+		the appropriate CFG_MALLOC_LEN value).
+
 - MII/PHY support:
 		CONFIG_PHY_ADDR
 
common/cmd_bootm.c +23 -0
index 9e5ce4b..ba6de50 100644
@@ -40,6 +40,13 @@
 #include <hush.h>
 #endif
 
+#ifdef CONFIG_LZMA
+#define _7ZIP_BYTE_DEFINED /* Byte already defined by zlib */
+#include <lzma/LzmaTypes.h>
+#include <lzma/LzmaDecode.h>
+#include <lzma/LzmaTools.h>
+#endif /* CONFIG_LZMA */
+
 DECLARE_GLOBAL_DATA_PTR;
 
 extern int gunzip (void *dst, int dstlen, unsigned char *src, unsigned long *lenp);
@@ -271,6 +278,22 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 		load_end = load_start + unc_len;
 		break;
 #endif /* CONFIG_BZIP2 */
+#ifdef CONFIG_LZMA
+	case IH_COMP_LZMA:
+		printf ("   Uncompressing %s ... ", type_name);
+
+		int ret = lzmaBuffToBuffDecompress(
+			(unsigned char *)load_start, &unc_len,
+			(unsigned char *)os_data, os_len);
+		if (ret != LZMA_RESULT_OK) {
+			printf ("LZMA: uncompress or overwrite error %d "
+				"- must RESET board to recover\n", ret);
+			show_boot_progress (-6);
+			do_reset (cmdtp, flag, argc, argv);
+		}
+		load_end = load_start + unc_len;
+		break;
+#endif /* CONFIG_LZMA */
 	default:
 		if (iflag)
 			enable_interrupts();
common/image.c +5 -2
index f04826a..d358095 100644
@@ -152,6 +152,9 @@ static table_entry_t uimage_comp[] = {
 	{	IH_COMP_NONE,	"none",		"uncompressed",		},
 	{	IH_COMP_BZIP2,	"bzip2",	"bzip2 compressed",	},
 	{	IH_COMP_GZIP,	"gzip",		"gzip compressed",	},
+#if defined(CONFIG_LZMA) || defined(USE_HOSTCC)
+	{	IH_COMP_LZMA,	"lzma",		"lzma compressed",	},
+#endif
 	{	-1,		"",		"",			},
 };
 
@@ -1950,7 +1953,7 @@ static int calculate_hash (const void *data, int data_len, const char *algo,
 	return 0;
 }
 
-#ifdef USE_HOSTCC
+// #ifdef USE_HOSTCC
 /**
  * fit_set_hashes - process FIT component image nodes and calculate hashes
  * @fit: pointer to the FIT format image header
@@ -2119,7 +2122,7 @@ int fit_image_hash_set_value (void *fit, int noffset, uint8_t *value,
 
 	return 0;
 }
-#endif /* USE_HOSTCC */
+// #endif /* USE_HOSTCC */
 
 /**
  * fit_image_check_hashes - verify data intergity
include/image.h +1 -0
index 36143e2..0126284 100644
@@ -164,6 +164,7 @@
 #define IH_COMP_NONE		0	/*  No	 Compression Used	*/
 #define IH_COMP_GZIP		1	/* gzip	 Compression Used	*/
 #define IH_COMP_BZIP2		2	/* bzip2 Compression Used	*/
+#define IH_COMP_LZMA		3	/* lzma  Compression Used	*/
 
 #define IH_MAGIC	0x27051956	/* Image Magic Number		*/
 #define IH_NMLEN		32	/* Image Name Length		*/
include/lzma/LzmaDecode.h new file +31 -0
new file mode 100644
index 0000000..5e96fbf
@@ -0,0 +1,31 @@
+/*
+ * Fake include for LzmaDecode.h
+ *
+ * Copyright (C) 2007-2008 Industrie Dial Face S.p.A.
+ * Luigi 'Comio' Mantellini (luigi.mantellini at idf-hit.com)
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+ 
+#ifndef __LZMADECODE_H__FAKE__
+#define __LZMADECODE_H__FAKE__
+
+#include "../../lib_lzma/LzmaDecode.h"
+
+#endif
include/lzma/LzmaTools.h new file +31 -0
new file mode 100644
index 0000000..bf6df55
@@ -0,0 +1,31 @@
+/*
+ * Fake include for LzmaTools.h
+ *
+ * Copyright (C) 2007-2008 Industrie Dial Face S.p.A.
+ * Luigi 'Comio' Mantellini (luigi.mantellini at idf-hit.com)
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+ 
+#ifndef __LZMATOOLS_H__FAKE__
+#define __LZMATOOLS_H__FAKE__
+ 
+#include "../../lib_lzma/LzmaTools.h"
+ 
+#endif
include/lzma/LzmaTypes.h new file +31 -0
new file mode 100644
index 0000000..073d16e
@@ -0,0 +1,31 @@
+/*
+ * Fake include for LzmaTypes.h
+ *
+ * Copyright (C) 2007-2008 Industrie Dial Face S.p.A.
+ * Luigi 'Comio' Mantellini (luigi.mantellini at idf-hit.com)
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+ 
+#ifndef __LZMATYPES_H__FAKE__
+#define __LZMATYPES_H__FAKE__
+ 
+#include "../../lib_lzma/LzmaTypes.h"
+ 
+#endif
lib_lzma/LGPL.txt new file +504 -0

504 lines not on this page · raw message

lib_lzma/LzmaDecode.c new file +584 -0

584 lines not on this page · raw message

lib_lzma/LzmaDecode.h new file +113 -0

113 lines not on this page · raw message

lib_lzma/LzmaTools.c new file +143 -0

143 lines not on this page · raw message

lib_lzma/LzmaTools.h new file +35 -0
new file mode 100644
index 0000000..ea51eef
@@ -0,0 +1,35 @@
+/*
+ * Usefuls routines based on the LzmaTest.c file from LZMA SDK 4.57
+ *
+ * Copyright (C) 2007-2008 Industrie Dial Face S.p.A.
+ * Luigi 'Comio' Mantellini (luigi.mantellini at idf-hit.com)
+ *
+ * Copyright (C) 1999-2005 Igor Pavlov
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+ 
+#ifndef __LZMA_TOOL_H__
+#define __LZMA_TOOL_H__
+
+#include "LzmaTypes.h"
+
+extern int lzmaBuffToBuffDecompress (unsigned char *outStream, SizeT *uncompressedSize,
+			      unsigned char *inStream,  SizeT  length);
+#endif
lib_lzma/LzmaTypes.h new file +45 -0

45 lines not on this page · raw message

lib_lzma/Makefile new file +51 -0

51 lines not on this page · raw message

lib_lzma/README.txt new file +28 -0
new file mode 100644
index 0000000..8af698d
@@ -0,0 +1,28 @@
+The lib_lzma functionality was written by Igor Pavlov. 
+The original source cames from the LZMA SDK web page:
+
+URL: 		http://www.7-zip.org/sdk.html
+Author:         Igor Pavlov
+
+The import is made using the import_lzmasdk.sh script that:
+
+* untars the lzmaXYY.tar.bz2 file (from the download web page)
+* copies the files LzmaDecode.h, LzmaTypes.h, LzmaDecode.c, history.txt,
+  LGPL.txt, and lzma.txt from source archive into the lib_lzma directory (pwd).
+
+Example:
+
+ ./import_lzmasdk.sh ~/lzma457.tar.bz2
+
+Notice: The files from lzma sdk are not _modified_ by this script!
+
+The files LzmaTools.{c,h} are provided to export the lzmaBuffToBuffDecompress()
+function that wraps the complex LzmaDecode() function from the LZMA SDK. The
+do_bootm() function uses the lzmaBuffToBuffDecopress() function to expand the
+compressed image.
+
+The directory U-BOOT/include/lzma contains stubs files that permit to use the
+library directly from U-BOOT code without touching the original LZMA SDK's
+files.
+
+Luigi 'Comio' Mantellini <[email protected]>
lib_lzma/history.txt new file +198 -0

198 lines not on this page · raw message

lib_lzma/import_lzmasdk.sh new file +38 -0
new file mode 100644
index 0000000..3b4e232
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+usage() {
+	echo "Usage: $0 lzmaVERSION.tar.bz2" >&2
+	echo >&2
+	exit 1
+}
+
+if [ "$1" = "" ] ; then
+ 	 usage
+fi
+
+if [ ! -f $1 ] ; then
+	echo "$1 doesn't exist!" >&2
+	exit 1
+fi
+
+BASENAME=`basename $1 .tar.bz2`
+TMPDIR=/tmp/tmp_lib_$BASENAME
+FILES="C/Compress/Lzma/LzmaDecode.h
+      C/Compress/Lzma/LzmaTypes.h  
+      C/Compress/Lzma/LzmaDecode.c 
+      history.txt                  
+      LGPL.txt                     
+      lzma.txt"
+
+
+mkdir -p $TMPDIR
+echo "Untar $1 -> $TMPDIR"
+tar -jxf $1 -C $TMPDIR
+
+for i in $FILES; do
+	echo Copying  $TMPDIR/$i \-\> `basename $i`
+	cp $TMPDIR/$i .
+	chmod -x `basename $i`
+done
+
+echo "done!"
lib_lzma/lzma.txt new file +663 -0

663 lines not on this page · raw message

Signature · 1 line
1.5.4.3
#1 lore raw

PATCH 1/1 Add support for LZMA uncompression algorithm.

Hi u-boot users,

Has anyone tried the lzma patch? On my system works fine but I would like to have a feedback from you :)

IS there the possibility to see this patch integrated into the official u-boot tree?

Thanks a lot,

luigi

Quoted 37 lines · Luigi 'Comio' Mantellini
---
 Makefile                   |    1 +
 README                     |   23 ++
 common/cmd_bootm.c         |   23 ++
 common/image.c             |    7 +-
 include/image.h            |    1 +
 include/lzma/LzmaDecode.h  |   31 ++
 include/lzma/LzmaTools.h   |   31 ++
 include/lzma/LzmaTypes.h   |   31 ++
 lib_lzma/LGPL.txt          |  504 +++++++++++++++++++++++++++++++++
 lib_lzma/LzmaDecode.c      |  584 ++++++++++++++++++++++++++++++++++++++
 lib_lzma/LzmaDecode.h      |  113 ++++++++
 lib_lzma/LzmaTools.c       |  143 ++++++++++
 lib_lzma/LzmaTools.h       |   35 +++
 lib_lzma/LzmaTypes.h       |   45 +++
 lib_lzma/Makefile          |   51 ++++
 lib_lzma/README.txt        |   28 ++
 lib_lzma/history.txt       |  198 +++++++++++++
 lib_lzma/import_lzmasdk.sh |   38 +++
 lib_lzma/lzma.txt          |  663 ++++++++++++++++++++++++++++++++++++++++++++
 19 files changed, 2548 insertions(+), 2 deletions(-)
 create mode 100644 include/lzma/LzmaDecode.h
 create mode 100644 include/lzma/LzmaTools.h
 create mode 100644 include/lzma/LzmaTypes.h
 create mode 100644 lib_lzma/LGPL.txt
 create mode 100644 lib_lzma/LzmaDecode.c
 create mode 100644 lib_lzma/LzmaDecode.h
 create mode 100644 lib_lzma/LzmaTools.c
 create mode 100644 lib_lzma/LzmaTools.h
 create mode 100644 lib_lzma/LzmaTypes.h
 create mode 100644 lib_lzma/Makefile
 create mode 100644 lib_lzma/README.txt
 create mode 100644 lib_lzma/history.txt
 create mode 100644 lib_lzma/import_lzmasdk.sh
 create mode 100644 lib_lzma/lzma.txt

diff

Signature · 20 lines
     ______       Luigi Mantellini
   .'______'.     R&D - Software
  (.'      '.)    Industrie Dial Face S.p.A.
  ( :=----=: )    Via Canzo, 4
  ('.______.')    20068 Peschiera Borromeo (MI), Italy
   '.______.'     Tel.: +39 02 5167 2813
                  Fax:  +39 02 5167 2459
Ind.  Dial Face   Email: luigi.mantellini at idf-hit.com
www.idf-hit.com   GPG fingerprint: 3DD1 7B71 FBDF 6376 1B4A
                                   B003 175F E979 907E 1650



-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.denx.de/pipermail/u-boot/attachments/20080405/3ca73393/attachment.pgp 
#2 lore raw

PATCH 1/1 Add support for LZMA uncompression algorithm.

In reply to Luigi 'Comio' Mantellini
Quoted 27 lines · In message <1207041489.12115.2.camel@localhost> you wrote:
---
 Makefile                   |    1 +
 README                     |   23 ++
 common/cmd_bootm.c         |   23 ++
 common/image.c             |    7 +-
 include/image.h            |    1 +
 include/lzma/LzmaDecode.h  |   31 ++
 include/lzma/LzmaTools.h   |   31 ++
 include/lzma/LzmaTypes.h   |   31 ++
 lib_lzma/LGPL.txt          |  504 +++++++++++++++++++++++++++++++++
 lib_lzma/LzmaDecode.c      |  584 ++++++++++++++++++++++++++++++++++++++
 lib_lzma/LzmaDecode.h      |  113 ++++++++
 lib_lzma/LzmaTools.c       |  143 ++++++++++
 lib_lzma/LzmaTools.h       |   35 +++
 lib_lzma/LzmaTypes.h       |   45 +++
 lib_lzma/Makefile          |   51 ++++
 lib_lzma/README.txt        |   28 ++
 lib_lzma/history.txt       |  198 +++++++++++++
 lib_lzma/import_lzmasdk.sh |   38 +++
 lib_lzma/lzma.txt          |  663 ++++++++++++++++++++++++++++++++++++++++++++
 19 files changed, 2548 insertions(+), 2 deletions(-)
 create mode 100644 include/lzma/LzmaDecode.h
 create mode 100644 include/lzma/LzmaTools.h
 create mode 100644 include/lzma/LzmaTypes.h
 create mode 100644 lib_lzma/LGPL.txt
 create mode 100644 lib_lzma/LzmaDecode.c
 create mode 100644 lib_lzma/LzmaDecode.h
Quoted 8 lines
 create mode 100644 lib_lzma/LzmaTools.c
 create mode 100644 lib_lzma/LzmaTools.h
 create mode 100644 lib_lzma/LzmaTypes.h
 create mode 100644 lib_lzma/Makefile
 create mode 100644 lib_lzma/README.txt
 create mode 100644 lib_lzma/history.txt
 create mode 100644 lib_lzma/import_lzmasdk.sh
 create mode 100644 lib_lzma/lzma.txt

Signed-off-by line is missing. Please add and resubmit.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
History tends to exaggerate.
	-- Col. Green, "The Savage Curtain", stardate 5906.4
#3 lore raw

PATCH 1/1 Add support for LZMA uncompression algorithm.

---
 Makefile                   |    1 +
 README                     |   23 ++
 common/cmd_bootm.c         |   23 ++
 common/image.c             |    7 +-
 include/image.h            |    1 +
 include/lzma/LzmaDecode.h  |   31 ++
 include/lzma/LzmaTools.h   |   31 ++
 include/lzma/LzmaTypes.h   |   31 ++
 lib_lzma/LGPL.txt          |  504 +++++++++++++++++++++++++++++++++
 lib_lzma/LzmaDecode.c      |  584 ++++++++++++++++++++++++++++++++++++++
 lib_lzma/LzmaDecode.h      |  113 ++++++++
 lib_lzma/LzmaTools.c       |  142 ++++++++++
 lib_lzma/LzmaTools.h       |   35 +++
 lib_lzma/LzmaTypes.h       |   45 +++
 lib_lzma/Makefile          |   51 ++++
 lib_lzma/README.txt        |   28 ++
 lib_lzma/history.txt       |  198 +++++++++++++
 lib_lzma/import_lzmasdk.sh |   38 +++
 lib_lzma/lzma.txt          |  663 ++++++++++++++++++++++++++++++++++++++++++++
 19 files changed, 2547 insertions(+), 2 deletions(-)
 create mode 100644 include/lzma/LzmaDecode.h
 create mode 100644 include/lzma/LzmaTools.h
 create mode 100644 include/lzma/LzmaTypes.h
 create mode 100644 lib_lzma/LGPL.txt
 create mode 100644 lib_lzma/LzmaDecode.c
 create mode 100644 lib_lzma/LzmaDecode.h
 create mode 100644 lib_lzma/LzmaTools.c
 create mode 100644 lib_lzma/LzmaTools.h
 create mode 100644 lib_lzma/LzmaTypes.h
 create mode 100644 lib_lzma/Makefile
 create mode 100644 lib_lzma/README.txt
 create mode 100644 lib_lzma/history.txt
 create mode 100644 lib_lzma/import_lzmasdk.sh
 create mode 100644 lib_lzma/lzma.txt
Makefile +1 -0
index e56889e..253fa9f 100644
@@ -199,6 +199,7 @@ endif
 OBJS := $(addprefix $(obj),$(OBJS))
 
 LIBS  = lib_generic/libgeneric.a
+LIBS += lib_lzma/lib_lzma.a
 LIBS += $(shell if [ -f board/$(VENDOR)/common/Makefile ]; then echo \
 	"board/$(VENDOR)/common/lib$(VENDOR).a"; fi)
 LIBS += board/$(BOARDDIR)/lib$(BOARD).a
README +23 -0
index 7c16345..3f10f9c 100644
@@ -1031,6 +1031,29 @@ The following options need to be configured:
 		the malloc area (as defined by CFG_MALLOC_LEN) should
 		be at least 4MB.
 
+		CONFIG_LZMA
+
+		If this option is set, support for lzma compressed
+		images is included.
+
+		Note: The LZMA algorithm adds about 2KB of code and it
+		requires an amount of dynamic memory that is given by the
+		formula:
+
+		         (1846 + 768 << (lc + lp)) * sizeof(uint16)
+
+		Where lc and lp stand for, respectively, Literal context bits
+		and Literal pos bits.
+
+		This value is upper-bounded by 14MB in the worst case. Anyway,
+		for a ~4MB large kernel image, we have lc=3 and lp=0 for a
+		total amount of (1846 + 768 << (3 + 0)) * 2 = ~41KB... that is
+		a very small buffer.
+                
+		Use the lzmainfo tool to determinate the lc and lp values and
+		then calculate the  amount of needed dynamic memory (ensuring
+		the appropriate CFG_MALLOC_LEN value).
+
 - MII/PHY support:
 		CONFIG_PHY_ADDR
 
common/cmd_bootm.c +23 -0
index 9e5ce4b..ba6de50 100644
@@ -40,6 +40,13 @@
 #include <hush.h>
 #endif
 
+#ifdef CONFIG_LZMA
+#define _7ZIP_BYTE_DEFINED /* Byte already defined by zlib */
+#include <lzma/LzmaTypes.h>
+#include <lzma/LzmaDecode.h>
+#include <lzma/LzmaTools.h>
+#endif /* CONFIG_LZMA */
+
 DECLARE_GLOBAL_DATA_PTR;
 
 extern int gunzip (void *dst, int dstlen, unsigned char *src, unsigned long *lenp);
@@ -271,6 +278,22 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 		load_end = load_start + unc_len;
 		break;
 #endif /* CONFIG_BZIP2 */
+#ifdef CONFIG_LZMA
+	case IH_COMP_LZMA:
+		printf ("   Uncompressing %s ... ", type_name);
+
+		int ret = lzmaBuffToBuffDecompress(
+			(unsigned char *)load_start, &unc_len,
+			(unsigned char *)os_data, os_len);
+		if (ret != LZMA_RESULT_OK) {
+			printf ("LZMA: uncompress or overwrite error %d "
+				"- must RESET board to recover\n", ret);
+			show_boot_progress (-6);
+			do_reset (cmdtp, flag, argc, argv);
+		}
+		load_end = load_start + unc_len;
+		break;
+#endif /* CONFIG_LZMA */
 	default:
 		if (iflag)
 			enable_interrupts();
common/image.c +5 -2
index 9e63432..01cea4e 100644
@@ -152,6 +152,9 @@ static table_entry_t uimage_comp[] = {
 	{	IH_COMP_NONE,	"none",		"uncompressed",		},
 	{	IH_COMP_BZIP2,	"bzip2",	"bzip2 compressed",	},
 	{	IH_COMP_GZIP,	"gzip",		"gzip compressed",	},
+#if defined(CONFIG_LZMA) || defined(USE_HOSTCC)
+	{	IH_COMP_LZMA,	"lzma",		"lzma compressed",	},
+#endif
 	{	-1,		"",		"",			},
 };
 
@@ -1950,7 +1953,7 @@ static int calculate_hash (const void *data, int data_len, const char *algo,
 	return 0;
 }
 
-#ifdef USE_HOSTCC
+// #ifdef USE_HOSTCC
 /**
  * fit_set_hashes - process FIT component image nodes and calculate hashes
  * @fit: pointer to the FIT format image header
@@ -2119,7 +2122,7 @@ int fit_image_hash_set_value (void *fit, int noffset, uint8_t *value,
 
 	return 0;
 }
-#endif /* USE_HOSTCC */
+// #endif /* USE_HOSTCC */
 
 /**
  * fit_image_check_hashes - verify data intergity
include/image.h +1 -0
index c1a6cbb..ef38edc 100644
@@ -164,6 +164,7 @@
 #define IH_COMP_NONE		0	/*  No	 Compression Used	*/
 #define IH_COMP_GZIP		1	/* gzip	 Compression Used	*/
 #define IH_COMP_BZIP2		2	/* bzip2 Compression Used	*/
+#define IH_COMP_LZMA		3	/* lzma  Compression Used	*/
 
 #define IH_MAGIC	0x27051956	/* Image Magic Number		*/
 #define IH_NMLEN		32	/* Image Name Length		*/
include/lzma/LzmaDecode.h new file +31 -0
new file mode 100644
index 0000000..618c005
@@ -0,0 +1,31 @@
+/*
+ * Fake include for LzmaDecode.h
+ *
+ * Copyright (C) 2007-2008 Industrie Dial Face S.p.A.
+ * Luigi 'Comio' Mantellini (luigi.mantellini at idf-hit.com)
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __LZMADECODE_H__FAKE__
+#define __LZMADECODE_H__FAKE__
+
+#include "../../lib_lzma/LzmaDecode.h"
+
+#endif
include/lzma/LzmaTools.h new file +31 -0
new file mode 100644
index 0000000..ac96800
@@ -0,0 +1,31 @@
+/*
+ * Fake include for LzmaTools.h
+ *
+ * Copyright (C) 2007-2008 Industrie Dial Face S.p.A.
+ * Luigi 'Comio' Mantellini (luigi.mantellini at idf-hit.com)
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __LZMATOOLS_H__FAKE__
+#define __LZMATOOLS_H__FAKE__
+
+#include "../../lib_lzma/LzmaTools.h"
+
+#endif
include/lzma/LzmaTypes.h new file +31 -0
new file mode 100644
index 0000000..f26c1a8
@@ -0,0 +1,31 @@
+/*
+ * Fake include for LzmaTypes.h
+ *
+ * Copyright (C) 2007-2008 Industrie Dial Face S.p.A.
+ * Luigi 'Comio' Mantellini (luigi.mantellini at idf-hit.com)
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __LZMATYPES_H__FAKE__
+#define __LZMATYPES_H__FAKE__
+
+#include "../../lib_lzma/LzmaTypes.h"
+
+#endif
lib_lzma/LGPL.txt new file +504 -0

504 lines not on this page · raw message

lib_lzma/LzmaDecode.c new file +584 -0

584 lines not on this page · raw message

lib_lzma/LzmaDecode.h new file +113 -0

113 lines not on this page · raw message

lib_lzma/LzmaTools.c new file +142 -0

142 lines not on this page · raw message

lib_lzma/LzmaTools.h new file +35 -0
new file mode 100644
index 0000000..ea51eef
@@ -0,0 +1,35 @@
+/*
+ * Usefuls routines based on the LzmaTest.c file from LZMA SDK 4.57
+ *
+ * Copyright (C) 2007-2008 Industrie Dial Face S.p.A.
+ * Luigi 'Comio' Mantellini (luigi.mantellini at idf-hit.com)
+ *
+ * Copyright (C) 1999-2005 Igor Pavlov
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+ 
+#ifndef __LZMA_TOOL_H__
+#define __LZMA_TOOL_H__
+
+#include "LzmaTypes.h"
+
+extern int lzmaBuffToBuffDecompress (unsigned char *outStream, SizeT *uncompressedSize,
+			      unsigned char *inStream,  SizeT  length);
+#endif
lib_lzma/LzmaTypes.h new file +45 -0

45 lines not on this page · raw message

lib_lzma/Makefile new file +51 -0

51 lines not on this page · raw message

lib_lzma/README.txt new file +28 -0
new file mode 100644
index 0000000..8af698d
@@ -0,0 +1,28 @@
+The lib_lzma functionality was written by Igor Pavlov. 
+The original source cames from the LZMA SDK web page:
+
+URL: 		http://www.7-zip.org/sdk.html
+Author:         Igor Pavlov
+
+The import is made using the import_lzmasdk.sh script that:
+
+* untars the lzmaXYY.tar.bz2 file (from the download web page)
+* copies the files LzmaDecode.h, LzmaTypes.h, LzmaDecode.c, history.txt,
+  LGPL.txt, and lzma.txt from source archive into the lib_lzma directory (pwd).
+
+Example:
+
+ ./import_lzmasdk.sh ~/lzma457.tar.bz2
+
+Notice: The files from lzma sdk are not _modified_ by this script!
+
+The files LzmaTools.{c,h} are provided to export the lzmaBuffToBuffDecompress()
+function that wraps the complex LzmaDecode() function from the LZMA SDK. The
+do_bootm() function uses the lzmaBuffToBuffDecopress() function to expand the
+compressed image.
+
+The directory U-BOOT/include/lzma contains stubs files that permit to use the
+library directly from U-BOOT code without touching the original LZMA SDK's
+files.
+
+Luigi 'Comio' Mantellini <[email protected]>
lib_lzma/history.txt new file +198 -0

198 lines not on this page · raw message

lib_lzma/import_lzmasdk.sh new file +38 -0
new file mode 100644
index 0000000..3b4e232
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+usage() {
+	echo "Usage: $0 lzmaVERSION.tar.bz2" >&2
+	echo >&2
+	exit 1
+}
+
+if [ "$1" = "" ] ; then
+ 	 usage
+fi
+
+if [ ! -f $1 ] ; then
+	echo "$1 doesn't exist!" >&2
+	exit 1
+fi
+
+BASENAME=`basename $1 .tar.bz2`
+TMPDIR=/tmp/tmp_lib_$BASENAME
+FILES="C/Compress/Lzma/LzmaDecode.h
+      C/Compress/Lzma/LzmaTypes.h  
+      C/Compress/Lzma/LzmaDecode.c 
+      history.txt                  
+      LGPL.txt                     
+      lzma.txt"
+
+
+mkdir -p $TMPDIR
+echo "Untar $1 -> $TMPDIR"
+tar -jxf $1 -C $TMPDIR
+
+for i in $FILES; do
+	echo Copying  $TMPDIR/$i \-\> `basename $i`
+	cp $TMPDIR/$i .
+	chmod -x `basename $i`
+done
+
+echo "done!"
lib_lzma/lzma.txt new file +663 -0

663 lines not on this page · raw message

Signature · 1 line
1.5.4.3