Table of Contents

TRX vs. TRX2 vs. BIN

Broadcom Firmware Format

The various headers

Some devices have firmware files with different file name endings. While the overall content of the files are identical, there are some slight differences at their beginnings:

TRX v1

  0                   1                   2                   3   
  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 
 +---------------------------------------------------------------+
 |                     magic number ('HDR0')                     |
 +---------------------------------------------------------------+
 |                  length (header size + data)                  |
 +---------------+---------------+-------------------------------+
 |                       32-bit CRC value                        |
 +---------------+---------------+-------------------------------+
 |           TRX flags           |          TRX version          |
 +-------------------------------+-------------------------------+
 |                      Partition offset[0]                      |
 +---------------------------------------------------------------+
 |                      Partition offset[1]                      |
 +---------------------------------------------------------------+
 |                      Partition offset[2]                      |
 +---------------------------------------------------------------+

TRX v2

  0                   1                   2                   3   
  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 
 +---------------------------------------------------------------+
 |                     magic number ('HDR0')                     |
 +---------------------------------------------------------------+
 |                  length (header size + data)                  |
 +---------------+---------------+-------------------------------+
 |                       32-bit CRC value                        |
 +---------------+---------------+-------------------------------+
 |           TRX flags           |          TRX version          |
 +-------------------------------+-------------------------------+
 |                      Partition offset[0]                      |
 +---------------------------------------------------------------+
 |                      Partition offset[1]                      |
 +---------------------------------------------------------------+
 |                      Partition offset[2]                      |
 +---------------------------------------------------------------+
 |                      Partition offset[3]                      |
 +---------------------------------------------------------------+

Source: openwrt/tools/firmware-utils/src/trx.c

BIN-Header

FIXME (which bin header?)

  0                   1                   2                   3   
  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 
 +---------------------------------------------------------------+
 |                            magic                              |
 +---------------------------------------------------------------+
 |                            res1                               |
 +---------------------------------------------------------------+
 |                fwdate                         |   fwvern...   |
 +---------------------------------------------------------------+
 |    ...fwvern                  |              ID...            |
 +---------------------------------------------------------------+
 |         ...ID                 |  hw_ver       |    s/n        |
 +---------------------------------------------------------------+
 |           flags               |           stable              |
 +---------------------------------------------------------------+
 |           try1                |           try2                |
 +---------------------------------------------------------------+
 |           try3                |           res3                |
 +---------------------------------------------------------------+
  0   1   2   3   4   5   6   7   8   9   a   b   c   d   e   f  
+---------------------------------------------------------------+
|    version    |          vendor_name...                       |
+---------------------------------------------------------------+
|                       ...vendor_name          | fw_version... |
+---------------------------------------------------------------+
|                       ...fw_version...                        |
+---------------------------------------------------------------+
|                       ...fw_version                           |
+---------------------------------------------------------------+
|     hw_id     |    hw_rev     |     unk1      |    md5sum1... |
+---------------------------------------------------------------+
|                         ...md5sum1            |     unk2      |
+---------------------------------------------------------------+
|                            md5sum2                            |
+---------------------------------------------------------------+
|     unk3      |   kernel_la   |   kernel_ep   |   fw_length   |
+---------------------------------------------------------------+
|  kernel_ofs   |   kernel_len  |   rootfs_ofs  |  rootfs_len   |
+---------------------------------------------------------------+
|   boot_ofs    |   boot_len    |ver_hi |ver_mid| ver_lo| pad...|
+---------------------------------------------------------------+
|                           ...pad...                           |
+---------------------------------------------------------------+

source: openwrt/tools/firmware-utils/src/mktplinkfw.c