replacepart.pl
--------------

Task:
- list the parts of a firmware file
- add/remove/delete a part of the firmware file
- change the tag (firmware description) of the firmware file


Requirements:
- perl >= 5.6.1 under Linux/Unix environment


Notes:
- you always need as starting point a firmware file from peppercon
- this firmware file can contain firmware updates for the peppercon board,
  but it can be empty, too
- the firmware file consists of several parts, one part e.g. for each piece of
  hardware and a addional parts for special functions (as the PEM part)
- the delivered utility can do following:
  * add or replace a firmware part
  * delete a firmware part
  * change the tag of the firmware (user does see this during firmware update)
  * list the actual parts of a firmware file
- replacepart.pl changes the firmware file itself, so please be sure to have a copy!

Usage:

- get help
-----------------------
#./replacepart.pl

Usage:

  replacepart.pl [-d] [-a <part_file>] [-p <part_type>] [-s <part_subtype>]
                 [-t <tag>] [-v <version>] [-m <version>] [-M <version>]
                 <firmware_file>

    -d                - delete part
    -a <part_file>    - add or replace part with <part_file>
    -p <part_type>    - partition type to remove, add or replace
                        0 (flash)
                        4 (flashdisc directory)
    -s <part_subtype> - part subtype to remove, add or replace, depends on -p
                        (p=0)
                        (p=4)  1 (Root-FS), 0 (OEM directory)
    -t <tag>          - change firmware tag
    -v <version>      - change firmware version number without dots, eg 040100
    -m <version>      - change firmware minimum requested version
    -M <version>      - change firmware minimum downgrade version
    <firmware_file>   - the firmware file to change (must exist)
-------------------------


- display only the contents of a firmware file:
-------------------------
./replacepart.pl rc1kimfw-030401-948_peppercon.bin
ver:         030401
min_req_ver: 030201
build_nr:    948
tag:         Standard Edition
product:     rc1
  size:      182031
  type:      4 ( Flashdisk Directory )
  subtype:   0 ( OEM directory )
--------------------------
this firmware file consists only of one part:
the OEM directory with OEM specific data


- change tag (firmware description) from "Standard Edition" to "Test Release":
---------------------------
./replacepart.pl -t "Test Release" rc1kimfw-030401-948_peppercon.bin
[...]
Resulting firmware file:
ver:         030401
min_req_ver: 030201
build_nr:    948
tag:         Test Release
product:     rc1
  size:      182031
  type:      4 ( Flashdisk Directory )
  subtype:   0 ( OEM directory )
----------------------------


- add or replace an OEM part file
  (a firmware may contain only one OEM file)
---------------------------
./replacepart.pl -s 0 -p oem.tgz rc1kimfw-030401-948_peppercon.bin
[...]
will replace subtype 0 with file oem.tgz

Resulting firmware file:
ver:         030401
min_req_ver: 030201
build_nr:    948
tag:         Test Release
product:     rc1
  size:      182031
  type:      4 ( Flashdisk Directory )
  subtype:   0 ( OEM directory )
---------------------------

- delete the OEM part
---------------------------
./replacepart.pl -d -s 0 rc1kimfw-030401-948_peppercon.bin
[...]
will delete subtype : 0

Resulting firmware file:
ver:         030401
min_req_ver: 030201
build_nr:    948
tag:         Test Release
product:     rc1
---------------------------
The firmware file is now empty.
