Skip to content

Commit

Permalink
using python 3.4+; new packer script; multiple small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dipcore committed Jan 8, 2017
1 parent 26d30b6 commit 5e1388f
Show file tree
Hide file tree
Showing 8 changed files with 582 additions and 256 deletions.
4 changes: 0 additions & 4 deletions .gitignore

This file was deleted.

21 changes: 8 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# mstar-bin-tool

Command line tools for manipulating MStar bin firmware files.
Command line tools to pack/unpack MStar bin firmware

Currently available tools:
- **unpack.py** - unpack MStar bin firmware
- **pack-partition.py** - pack a single partition to MStar bin firmware
- **pack.py** - pack MStar bin firmware


## Unpack MStar bin firmware files
Expand All @@ -16,16 +16,11 @@ Usage: unpack.py <firmware> <output folder [default: ./unpacked/]>
```


## Pack a single partition and create MStar bin firmware
## Pack MStar bin firmware
```
Usage: pack-partition.py <firmware> <partition name> <image file> [<lzo> <chunk size KB,MB,GB>]
Example: pack-partition.py MstarUpdate.bin system unpacked/system.img lzo 150MB
<firmware> - Firmware file name to create. Ex. MstarUpdate.bin
<partition name> - Partition name. Important: The partition is not creating,
so make sure it already exists on your device. Check ./unpacked/~header_script
file for 'mmc create <partition name>' line.
<image file> - Image or bin file to pack.
<lzo> - Enable LZO packing. Non required param.
<chunk size KB,MB,GB> - Chunk size. Ex: 150MB.
Non required param, by default whole image file is used as a single chunk.
Usage: pack.py <config file>
Example: pack.py configs/letv-x355pro-full.ini
<config file> - Configuration file. The config file structure will be described later.
For now you can take a look at configs/letv-x355pro-full.ini
and use it as an example
```
208 changes: 208 additions & 0 deletions configs/letv-x355pro-full.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
#
# LeEco X3-55pro (Super3 x55 Pro) packer configuration file
# The TV is based on mst6a928 cpu
#

[Main]

# Output file name
FirmwareFileName=LetvUpgrade928.bin

# Folder which contains images to pack
ProjectFolder=./pack

# Use hex values in "mmc write.p" directive.
# Check your unpacked ~header_script file for the "mmc write.p" paramers.
# Set it to True, if the paramers have "0x" prefix.
# All newest Mstar firwares uses hex values
UseHexValues=false

# Firmware file name to use in "filepartload" directive.
# All newest Mstar firwares uses $(UpgradeImage) Otherwise it should be equal FirmwareFileName value.
SCRIPT_FIRMWARE_FILE_NAME=${FirmwareFileName}

# DRAM_BUF_ADDR value
DRAM_BUF_ADDR=20200000

# Magic footer value. It's reserved for future use, usually it's "12345678" string
MAGIC_FOOTER=12345678

# Header size is always 16KB
HEADER_SIZE=16KB

[HeaderScript]

# Custom header script directives at the beginning of the script
Prefix:
mmc slc 0 1
mmc rmgpt
factory_init factory 0x02000000

# Custom directives at the end of the script
Suffix:
cleanallenv
setenv filesize 6748c0
setenv LOAD_KERNEL mmc read.p 0x25000000 boot 0x01000000\; authenticateAN 0x25000000
setenv filesize 6748c0
setenv BOOT_KERNEL bootm 0x25000000
setenv recoverycmd mmc read.p 0x25000000 recovery 0x02000000\; authenticateAN 0x25000000\; bootm 0x25000000
setenv LOAD_NUTTX mmc read.p 0x5EC70000 tee 0x600000
setenv BOOT_NUTTX bootNuttx 0x1EC70000
setenv CMA_REG0 CMA0=mali0,miu=0,hid=16,sz=0x1F000000
setenv CMA_REG1 CMA1=mali1,miu=1,hid=17,sz=0x5400000
setenv CMA_REG2 CMA2=VDEC1,miu=1,hid=19,sz=0xCC00000,st=0x6C00000
setenv bootargs console=ttyS0,115200 androidboot.console=ttyS0 root=/dev/ram rw rootwait init=/init CORE_DUMP_PATH=/data/Logs/Log.0/core_dump.%%p.gz KDebug=1 delaylogo=True androidboot.selinux=permissive $(CMA_REG0) $(CMA_REG1) $(CMA_REG2) PM51_ADDR=0x20010000 PM51_LEN=0x10000 DRAM_LEN=0xC0000000 BOOTLOGO_IN_MBOOT ENV_VAR_OFFSET=0x0 ENV_VAR_SIZE=0x10000 ENV=EMMC SECURITY=ON
setenv bootlogo_gopidx 3
setenv bootlogo_buffer E_MMAP_ID_PHOTO_INTER
setenv str_crc 1
setenv db_table 0
setenv verify n
setenv bootcmd $(LOAD_KERNEL)\; $(LOAD_NUTTX)\; $(BOOT_NUTTX)\; $(BOOT_KERNEL)
setenv ForcePowerOn 1
setenv factory_poweron_mode secondary
setenv sync_mmap 1
setenv detect_mmap 1
saveenv
setenv LetvUpgrade_complete 1
setenv factory_mode 0
setenv ResetAfterUpgrade 1
setenv ForcePowerOn 1
setenv db_table 0
saveenv
printenv

# List of partitions to pack
# [partition_name] - Name of partition. Shold begin with "part/"
# create - flag to generate "mmc create" directive. It requires "size" parameter
# size - Required parameter, if create flag sets to True. Partition size to create [hex]
# erase - flag to generate "mmc erase.p" directive.
# imageFile - Path to image file to pack
# type - partition type:
# partitionImage - Plain partition image. It generates "filepartload" and "mmc write.p" directives
# secureInfo - signature file. Uses "store_secure_info" directive
# nuttxConfig - Nuttx config file. Uses "store_nuttx_config" directive
# lzo - pack partition/chunk to lzo. Uses "mmc unlzo" directive
# chunkSize - chunk size to split partition. A single chunk uses, if chunkSize is not set. Units: B, KB, MB, GB

[part/ipanic]
create=True
size=0x00200000

[part/misc]
create=True
size=0x00080000
erase=True

[part/reserved]
create=True
size=0x02000000

[part/recovery]
create=True
size=0x02000000
erase=True
imageFile=${Main:ProjectFolder}/recovery.img
type=partitionImage

[part/recoverySign]
imageFile=${Main:ProjectFolder}/recoverySign
type=secureInfo

[part/boot]
create=True
size=0x01000000
erase=True
imageFile=${Main:ProjectFolder}/boot.img
type=partitionImage

[part/bootSign]
imageFile=${Main:ProjectFolder}/bootSign
type=secureInfo

[part/tee]
create=True
size=0x01000000
erase=True
imageFile=${Main:ProjectFolder}/tee.img
type=partitionImage

[part/teeSign]
imageFile=${Main:ProjectFolder}/teeSign
type=secureInfo

[part/NuttxConfig]
imageFile=${Main:ProjectFolder}/NuttxConfig
type=nuttxConfig

[part/RTPM]
create=True
size=0x00040000
erase=True
imageFile=pack/RTPM.img
type=partitionImage

[part/system]
create=True
size=0x60000000
erase=True
imageFile=${Main:ProjectFolder}/system.img
type=partitionImage
lzo=True
chunkSize=150MB

[part/cache]
create=True
size=0x60000000
erase=True
imageFile=${Main:ProjectFolder}/cache.img
type=partitionImage
lzo=True

[part/tvservice]
create=True
size=0x09600000
erase=True
imageFile=${Main:ProjectFolder}/tvservice.img
type=partitionImage

[part/tvconfig]
create=True
size=0x06400000
erase=True
imageFile=${Main:ProjectFolder}/tvconfig.img
type=partitionImage

[part/tvdatabase]
create=True
size=0x02000000
erase=True
imageFile=${Main:ProjectFolder}/tvdatabase.img
type=partitionImage

[part/tvcustomer]
create=True
size=0x01000000
erase=True
imageFile=${Main:ProjectFolder}/tvcustomer.img
type=partitionImage

[part/userdata]
create=True
size=0x320D3F000 variable:0x1000000,0x64D93E000,0x2A9B3F000,0xD7C3F800
erase=True
imageFile=${Main:ProjectFolder}/userdata.img
type=partitionImage
lzo=True
chunkSize=150MB

[part/sboot]
imageFile=${Main:ProjectFolder}/sboot.img
type=sboot

[part/MBOOT]
imageFile=${Main:ProjectFolder}/MBOOT.img
type=partitionImage

[part/MPOOL]
erase=True

32 changes: 32 additions & 0 deletions configs/letv-x355pro-system.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#
# LeEco X3-55pro (Super3 x55 Pro)
# Config file to pack a single partition on firmware file (system.img)
# This will not create the partition, just erase and rewrite it
#

[Main]
FirmwareFileName=LetvUpgrade928.bin
ProjectFolder=./pack
UseHexValues=false

SCRIPT_FIRMWARE_FILE_NAME=${FirmwareFileName}
DRAM_BUF_ADDR=20200000
MAGIC_FOOTER=12345678
HEADER_SIZE=16KB

[HeaderScript]
Prefix:
dont_overwrite_init

Suffix:
setenv LetvUpgrade_complete 1
setenv ResetAfterUpgrade 1
setenv ForcePowerOn 0
saveenv

[part/system]
erase=True
imageFile=${Main:ProjectFolder}/system.img
type=partitionImage
lzo=True
chunkSize=150MB
Loading

0 comments on commit 5e1388f

Please sign in to comment.