5/13/2012

eMMC Partition tools usage for msm7x30/msm8x60

In the emmc boot, There are some changes in emmc partition
     partition.xml � Everything begins with this file, which describes the number of partitions desired, and how many 
                              sectors  each one should be.
    PartitioningTool.py � translates partition.xml into binary partitions
    msp.exe � writes binary partitions to SD/eMMC cards using card reader
    mjsdload.cmm � writes binary partitions to SD/eMMC cards using Trace32
    msp.py � writes binary partitions to a single image file
    QPST � writes binary partitions to SD/eMMC cards on Target

Helper /Debug Tools
    parseBinaryPartitionFile.pl � decodes MBR partition tables . Run "Perl parseBinaryPartitionFile.pl partition.bin" 
                                                 can generate the partition information
    parseGPT.pl � decodes GPT partition tables
    
Partition.xml

  There add some property entry can be added in new partiton.xml  to specified the configuration.
  <parser_instructions>
          WRITE_PROTECT_BOUNDARY_IN_KB                = 0
          GROW_LAST_PARTITION_TO_FILL_DISK            = false
          ALIGN_ALL_LOGICAL_PARTITIONS_TO_WP_BOUNDARY = false
  </parser_instructions>

    WRITE_PROTECT_BOUNDARY_IN_KB: Typical boundaries are 64MB, i.e. 65536 KB. This means that a 256MB eMMC
     card has 4 write protect boundaries. Any or all of them can be marked as read-only. Different vendors allow 
    for different sized boundaries.
    
    GROW_LAST_PARTITION_TO_FILL_DISK: In partition.xml the size of each partition is specified. If this field 
    is TRUE, then the last partition size is ignored and set to 0. Then during patching this size is updated 
    such that the last partition extends to use all remaining space. 
    
    ALIGN_ALL_LOGICAL_PARTITIONS_TO_WP_BOUNDARY: To allow total flexibility, it could be that a partition that
    is currently writeable might need to be marked as read-only. This can only happen *if* that partition begins
    on a write protect boundary (i.e. 64MB). Thus if this field is TRUE, then all logical partitions are 
    positioned such that they begin on a write protect boundary.
  
   More detail, please refer 80-N4584-1 eMMC_Partition_Tables_Raw_Program for the detail.


PartitioningTool.py , new tools used to generate the the partition.xml
    When run the PartitioningTool.py, it will output following files 
 
     1. emmc_lock_regions.xml � holds the sector ranges that need to be marked as read-only by the operating system (this is
          from readonly="true" in partition.xml)
      i.e. modem code and boot images are typically on read-only partitions
      Typical Write-Protect boundary is 64MB = 131072 sectors = 0x20000 sectors This file below is protecting the very first
     64MB region of the card, Boundary #0 
        Starting at sector 0
        Ending at sector 131071 (for a total of 131072 sectors)

        <?xml version="1.0" ?>
        <protect>
          <!-- NOTE: This is an ** Autogenerated file ** -->
          <!-- NOTE: Sector size is 512bytes, WRITE_PROTECT_BOUNDARY_IN_KB=0,   WRITE_PROTECT_BOUNDARY_IN_SECTORS=0 -->
          <!-- NOTE: "num_sectors" in HEX "start_sector" in HEX, i.e. 10 really equals 16 !! -->
          <program boundary_num="0" num_boundaries_covered="1" 
               num_sectors="20000" num_sectors_dec="131072" physical_partition_number="0"  
               start_sector="0"    start_sector_dec="0"/>
          <information WRITE_PROTECT_BOUNDARY_IN_KB="0"/>
        </protect>

    2.partition0.bin � holds the partition tables, i.e. MBR followed by all EBRs
    This is the partition table in binary format. It is copied over to the storage device in a 1 to 1 manner.
    i.e. how it looks in partition0.bin is exactly how the partition table will look on the storage device.
    partition0.bin  s a "generic" file meant to fit on *any* size SD/eMMC  card, as a result, there are 0's that need to be 
    patched,such as EXT partition and last partition size.
    
    3. patch0.xml � patching instructions to tailor each partition table "partition0.bin" to a specific SD/eMMC card
    i.e. the partition0.bin partition tables can be applied to any size storage device
    As a result, there are empty values (zeros) in the partition tables that must be filled in with a specific cards sector size
    There are two ways to apply this patch
        
        (patch before) When you patch the "zeros" in the partition tables held in the file partition0.bin, and then write it to the card 
        (patch after) When you write partition0.bin to the card (which still has "zeros" in it),  and then patch the cards partition 
                             tables directly
    
    4.rawprogram0.xml � precise sector details of all partitions and what files (if any) need to be placed there,In addition to 
       writing partition tables onto a device, often times it is desired to write one or more files into the partition area as well,
      The File has partition name (i.e. label), where it begins (start_sector) and how big it is   (num_partition_sectors) It also 
      describes what file(s) to write to this partition, as well  as any offsets.
   
    example
     <program file_sector_offset="0" filename="partition0.bin" label="MBR" 
               num_partition_sectors="1" physical_partition_number="0" 
               size_in_KB="0.5" start_sector="0"/>

    <program file_sector_offset="1" filename="partition0.bin " label="EXT" 
               num_partition_sectors="2"  physical_partition_number="0" 
               size_in_KB="1.0" start_sector="779"/>
               
    The 1st line describes taking the 1st sector from partition0.bin, and writing it to
     sector 0 of the card

     The 2nd line describes taking the 2nd and 3rd sector from partition0.bin and writing it to sector 
     779 of the card
     i.e. file_sector_offset = 2 and num_partition_sectors=2
     
   5.loadpt.cmm: used by the mjsdload.cmm to flash the image.


msp.exe .used to apply the patches

  This program will program a memory card (SD/eMMC) attached to the PC as USB mass storage device
  Use -d to detect the path of the memory card if you are unsure what to do first
  
  Commands list:
  
    -h    (Print this help message)                    Ex. msp -h
    -d    (Detect which storage device ID is active)            Ex. msp -d
    -p    (Print partition information)                    Ex. msp -p /dev/sdb
    -pp    (Print partition information - DETAILED)            Ex. msp -pp /dev/sdb
    -x    (Write files as outlined in rawprogram.xml)            Ex. msp -x rawprogram.xml /dev/sdb
    -xx    (Write files as outlined in rawprogram.xml - DETAILED)        Ex. msp -xx rawprogram.xml /dev/sdb
    -s    (Write SINGLE IMAGE "singleimage.bin" as outlined in rawprogram.xml)            Ex. msp -s rawprogram.xml 8192
    -v    (Verify file written correctly as outlined in rawprogram.xml)    Ex. msp -v rawprogram.xml boot.img /dev/sdb
    -f    (Program single file as outlined in rawprogram.xml)        Ex. msp -f rawprogram.xml boot.img /dev/sdb

Program the SD/eMMC with msp.exe in mass storage mode

  STEPS                        Complete example (patchafter)
  parse partition.xml      python PartitioningTool.py partition.xml 
  Detect your device      msp -d
  Program your device   msp �x rawprogram0.xml /dev/sdb
  Patch your device        msp �xx patch0.xml /dev/sdb


  STEPS                         Complete example (patchbefore)
  parse partition.xml        python PartitioningTool.py partition.xml 
  Detect your device       msp -d
  Patch your files             msp �xx patch0.xml 15758336 (patch the 8GB card offline,this will change the partition0.bin)
  Program your device     msp �x rawprogram0.xml /dev/sdb
  
the msp.py can also used to patch the files , such as 
   python msp.py patch0.xml 15758336 ( (patch the 8GB card offline,this will change the partition0.bin)
  
  

3 comments:

  1. any chance of help here
    because i really need help to make the
    partition_boot.xml for HTC EVO 3D
    and i will be able to use a working phone
    but i need help in this

    ReplyDelete
  2. How to make partition_boot.xml is described here:
    http://www.anyclub.org/2012/05/how-to-generate-8660msimagembn.html

    ReplyDelete
  3. how I can get a files specifed in this threat ?

    ReplyDelete