Packing lgapp partition

From Openlgtv
Jump to: navigation, search

LGAPP partition is CramFS Linear XIP (eXecuted In Place) image packed with modified LZO.


LZO algorythm modification made by LG quite simple. They extended magic from 1 byte with 0x00 and following 32 bits is size of uncompressed image. Thus making the famous 5 bytes differing from standard lzo.

Pathced by Arno1 lzo-2.03 lzopack example and it now decompress and recompress the "LG way": sources and binary

Sources from LG.

CramFS Linear XIP

Patched by jenya mkcramfs utility to make linear zip images: source, binary, original patch

Before make cramfs, XIP files in Linear XIP CramFS image should be marked with +t, to store it uncompressed and page-aligned.

More information on XIP can be found here:

Packing process

  1. LGAPP partition on Saturn6 platform should contain 2 files: RELEASE and RELEASE.sym. Put them in same dir.
  2. chmod +t RELEASE
  3. mkcramfs ./ lgapp.cramfs
  4. lzopack -9 lgapp.cramfs lgapp.cramfs.lzo

lgapp.cramfs.lzo - ready to flash lgapp partition image.

Image preparation

If you plan to flash partition using u-boot loadz command - no need to do this.

For Saturn 6 & 7 devices only there is a need to adjust the image size to be multiple of 4096 bytes before flashing it from command line. Therefore the image size must be increased accordingly by appending the appropriate number of bytes (0x00 or 0xFF).

It can be done using this command on your linux pc:

ibytes=`cat lgapp.cramfs.lzo | wc -c`; blockscount=`echo $ibytes/4096 | bc -l | cut -f1 -d. `;\
obytes=`echo \($blockscount+1\)*4096 | bc -l`; abytes=`echo $obytes-$ibytes | bc -l`;\
cp lgapp.cramfs.lzo lgapp.cramfs.lzo.flash; for i in `seq $abytes`; do printf "\xff" >> lgapp.cramfs.lzo.flash; done

lgapp.cramfs.lzo - input image file

lgapp.cramfs.lzo.flash - output file