Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| docs:techref:bootloader:cfe [2018/02/20 18:50] – ↷ Page moved from doc:techref:bootloader:cfe to docs:techref:bootloader:cfe bobafetthotmail | docs:techref:bootloader:cfe [2023/10/12 16:42] (current) – [Table] systemcrash | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== CFE ====== | ====== CFE ====== | ||
| - | * [[wp>Common Firmware Environment]] | + | {{page>meta:infobox:wip& |
| - | * [[http:// | + | |
| - | * [[http:// | + | |
| + | * [[wp> | ||
| + | * [[http:// | ||
| + | * Broadcom CFE sources for some test boards | ||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | * [[https:// | ||
| ===== Using the CFE ===== | ===== Using the CFE ===== | ||
| - | http:// | + | [[https:// |
| + | [[https:// | ||
| + | |||
| + | [[https:// | ||
| ===== bcm47xx CFE ===== | ===== bcm47xx CFE ===== | ||
| - | + | CFE on bcm47xx devices allows running/ | |
| - | CFE on bcm47xx devices allows running/ | + | |
| Below is the (hopefully) completed list of methods. The best idea is to find a one looking the best/ | Below is the (hopefully) completed list of methods. The best idea is to find a one looking the best/ | ||
| ==== Using auto-starting CFE TFTP server ==== | ==== Using auto-starting CFE TFTP server ==== | ||
| - | |||
| Some CFEs start TFTP server for few seconds right after hardware initialization. This is probably the only method of installing firmware with CFE that doesn' | Some CFEs start TFTP server for few seconds right after hardware initialization. This is probably the only method of installing firmware with CFE that doesn' | ||
| < | < | ||
| Line 25: | Line 32: | ||
| Unfortunately even if this method is available for you, it may not work. For example on Linksys E900 it fails after uploading firmware with the: | Unfortunately even if this method is available for you, it may not work. For example on Linksys E900 it fails after uploading firmware with the: | ||
| + | |||
| < | < | ||
| CMD: [boot -raw -z -addr=0x80001000 -max=0x1851e50 -fs=memory : | CMD: [boot -raw -z -addr=0x80001000 -max=0x1851e50 -fs=memory : | ||
| Line 32: | Line 40: | ||
| Please note that CFE may require a device specific firmware image (with a special header), otherwise (when using a generic .trx) it may fail with the: | Please note that CFE may require a device specific firmware image (with a special header), otherwise (when using a generic .trx) it may fail with the: | ||
| + | |||
| < | < | ||
| CMD: [flash -ctheader -mem -size=0x4c1000 0x807ae1b0 flash1.trx] | CMD: [flash -ctheader -mem -size=0x4c1000 0x807ae1b0 flash1.trx] | ||
| Line 39: | Line 48: | ||
| ==== Using CFE TFTP manually ==== | ==== Using CFE TFTP manually ==== | ||
| - | |||
| CFE almost always contains '' | CFE almost always contains '' | ||
| < | < | ||
| Line 55: | Line 63: | ||
| === TFTP client === | === TFTP client === | ||
| - | |||
| In this scenario we will tell CFE to connect to the remote TFTP server, download firmware and install it on the flash. This means that '' | In this scenario we will tell CFE to connect to the remote TFTP server, download firmware and install it on the flash. This means that '' | ||
| < | < | ||
| Line 65: | Line 72: | ||
| === TFTP server === | === TFTP server === | ||
| - | |||
| It's also possible to make '' | It's also possible to make '' | ||
| < | < | ||
| Line 74: | Line 80: | ||
| ==== Using upgrade command ==== | ==== Using upgrade command ==== | ||
| - | |||
| Some manufacturers provide an '' | Some manufacturers provide an '' | ||
| * Setting parameters automatically | * Setting parameters automatically | ||
| Line 80: | Line 85: | ||
| The most common (and probably safe) usage is to call it with '' | The most common (and probably safe) usage is to call it with '' | ||
| + | |||
| < | < | ||
| CFE> upgrade code.bin | CFE> upgrade code.bin | ||
| Line 88: | Line 94: | ||
| Another possible parameters: | Another possible parameters: | ||
| + | |||
| < | < | ||
| boot.bin Usually works the same way as code.bin | boot.bin Usually works the same way as code.bin | ||
| Line 95: | Line 102: | ||
| ==== Using web (http) server ==== | ==== Using web (http) server ==== | ||
| - | |||
| Unfortunately only few manufacturers decide to enable it, but it's probably the most user friendly way of installing firmware. | Unfortunately only few manufacturers decide to enable it, but it's probably the most user friendly way of installing firmware. | ||
| {{: | {{: | ||
| - | |||
| ==== Changing CFE defaults ==== | ==== Changing CFE defaults ==== | ||
| - | + | Every bcm47xx CFE has a small NVRAM backup that is used to restore the main NVRAM when it gets deleted or corrupted. If you want to modify that backup NVRAM, see [[docs: | |
| - | Every bcm47xx CFE has a small NVRAM backup that is used to restore the main NVRAM when it gets deleted or corrupted. If you want to modify that backup NVRAM, see [[doc: | + | |
| - | + | ||
| ===== bcm63xx CFE ===== | ===== bcm63xx CFE ===== | ||
| - | bcm63xx CFE is totally different | + | bcm63xx CFE is totally different |
| - | To access CFE you need to attach a [[doc: | + | To access CFE you need to attach a [[docs: |
| This is a typical output when starting up the CFE and entering the CLI: | This is a typical output when starting up the CFE and entering the CLI: | ||
| - | | '' | + | < |
| CFE version 1.0.37-104.4 for BCM96368 (32bit, | CFE version 1.0.37-104.4 for BCM96368 (32bit, | ||
| Build Date: Mon Feb 21 17:59:46 CST 2011 (finerain@moonlight) | Build Date: Mon Feb 21 17:59:46 CST 2011 (finerain@moonlight) | ||
| Line 144: | Line 146: | ||
| Auto run second count down: 1 | Auto run second count down: 1 | ||
| CFE> | CFE> | ||
| - | CFE>'' | + | CFE> |
| + | </ | ||
| ==== Using CFE web (http) server ==== | ==== Using CFE web (http) server ==== | ||
| - | |||
| It's probably the most user friendly way of installing firmware. But sometimes some manufacturers decide to disable it (very uncommon). | It's probably the most user friendly way of installing firmware. But sometimes some manufacturers decide to disable it (very uncommon). | ||
| Line 159: | Line 161: | ||
| - Wait some seconds | - Wait some seconds | ||
| - <color green> | - <color green> | ||
| - | - Browse to http:// | + | - Browse to '' |
| - Send the new firmware and wait some minutes until the firmware upgrade finish. | - Send the new firmware and wait some minutes until the firmware upgrade finish. | ||
| **Note**: The RESET button doesn' | **Note**: The RESET button doesn' | ||
| - | * Attach a [[doc: | + | * Attach a [[docs: |
| * Shortcircuit TX and RX serial pins some seconds when powering on the router to simulate keyboard buttons pressing; this is ugly but it should work. | * Shortcircuit TX and RX serial pins some seconds when powering on the router to simulate keyboard buttons pressing; this is ugly but it should work. | ||
| * Delete existing firmware, if the current firmware allows to delete partitions. | * Delete existing firmware, if the current firmware allows to delete partitions. | ||
| * Or upgrade the router with a new fake firmware (filled with zeroes). This will force CFE to stop for requesting a new firmware. | * Or upgrade the router with a new fake firmware (filled with zeroes). This will force CFE to stop for requesting a new firmware. | ||
| * Download tftp by http:// | * Download tftp by http:// | ||
| + | |||
| + | ==== CFE Secure Boot ==== | ||
| + | In modern SoC releases, Broadcom is integrating a [[[wp> | ||
| + | |||
| + | The following information is deduced from the sources available and therefore must be taken with caution. | ||
| + | |||
| + | Up to date, there are three generations of Secure Boot that embraces the following models: | ||
| + | * GEN1: 63268 | ||
| + | * GEN2: 63138, 63148, 63381, 6838 and 6848 | ||
| + | * GEN3: 63158, 4908, 6858, 6856, 6846, 6878, 63178 and 47622 | ||
| + | |||
| + | === Mechanism === | ||
| + | - The SoC has as factory settings, most probably in the OTP fuses, the private key unique per each model and also 2 keys AES CBC (ek & iv). This is the Root of Trust which is known by OEM. | ||
| + | - During boot, the //PBL// (Primary Boot Loader coded in the SoC) will search for storage peripherals e.g. NAND or NOR SPI. If found then loads a small portion from start of storage into memory. Exact amount may depend on model and storage but most typically 64kb. In the sources this chunk is called CFEROM. | ||
| + | - Once loaded the CFEROM, the PBL will analyse the structure, which is a compound of different chunks: valid header, magic numbers, signed credentials, | ||
| + | - Typically, CFEROM will start PLL's and full memory span. Most probably doesn' | ||
| + | - CFERAM binary is encoded in JFFS2 filesystem. It must meet a certain structure as CFEROM. The compiled code is usually LZMA compressed and AES CBC encrypted, rendering the resulting binary absolutely meaningless. | ||
| + | |||
| + | === Secure modes === | ||
| + | Several modes can be chosen inside the CFEROM, putting appropiate headers: | ||
| + | * UNSECURE. The chain of trust is consciously dropped. The compiled code will be executed as trusted. **This is potentially very interesting in order to develop other bootloaders like U-Boot** | ||
| + | * SECURE. This sets the kind of encryption and keys used, which in turn can be: | ||
| + | * GEN2 = MFG | ||
| + | * GEN3 = MFG or FLD | ||
| + | |||
| + | === CFEROM structure === | ||
| + | The actual implementation differs depending on the generation and the storage media, but roughly this guidelines are true: | ||
| + | |||
| + | == GEN1 == | ||
| + | WIP | ||
| + | |||
| + | == GEN2 == | ||
| + | ^ Offset | ||
| + | | 0x0 | 0x14 | Unauth header | | | | | ||
| + | | 0x0 | 0x4 | ::: | Magic number 1 | 0x0001B669 | In decimal = 112233 | ||
| + | | 0x4 | 0x4 | ::: | Magic number 2 | 0x0006CC7E | In decimal = 445566 | ||
| + | | 0x8 | 0x4 | ::: | Version | ||
| + | | 0x0c | 0x4 | ::: | SBI_length | ||
| + | | 0x10 | 0x4 | ::: | JAM CRC32 | variable | ||
| + | | 0x14 | variable | SBI | | | | | ||
| + | | 0x14 | 0x2 | ::: | type | 0x00 | This seems a legacy field | | ||
| + | | 0x16 | 0x2 | ::: | ver | 0x00 | This seems a legacy field | | ||
| + | | 0x18 | 0x2 | ::: | len | 0x00 | This seems a legacy field | | ||
| + | | 0x1a | 0x2 | ::: | config | ||
| + | | 0x1c | 0x180 | ::: | mfg.oem.bin | ||
| + | | 0x19c | 0x100 | ::: | mfg.oem.sig | ||
| + | | 0x29c | 0x180 | ::: | op.cot.bin | ||
| + | | 0x41c | 0x100 | ::: | op.cot.sig | ||
| + | | 0x51c | variable | ::: | cferom.bin | ||
| + | | SBI_length-0x104 | 0x100 | ::: | SHA256 sig | variable | ||
| + | | SBI_length-0x4 | ||
| + | |||
| + | From the sources, we can reverse the structure of mfg.oem.bin: | ||
| + | ^ Offset | ||
| + | | 0x0 | 0x148 | mfg.oem.bin | | | | | ||
| + | | 0x0 | 0x6 | ::: | Signature header | 0x000000010242 | This seems like a magic word | | ||
| + | | 0x6 | 0x2 | ::: | Mid | 0x1234 | ||
| + | | 0x8 | 0x100 | ::: | KrsaMfgPub.bin | ||
| + | | 0x108 | 0x20 | ::: | mfg.ek.enc | ||
| + | | 0x128 | 0x20 | ::: | mfg.iv.enc | ||
| + | |||
| + | |||
| + | == GEN3 == | ||
| + | WIP | ||
| + | |||
| + | \\ | ||
| + | === In the search of the RoT password === | ||
| + | If the PBL password was known, **we could develop any bootloader** with or without the CoT characteristic. It is most likely that this will never be exposed being Broadcom so obscure with their products. | ||
| + | |||
| + | However, we must remain attentive to the GPL bundles that pop up from time to time. | ||
| + | |||
| + | More precisely, in the following repo [[https:// | ||
| + | |||
| + | Basically the [[https:// | ||
| + | < | ||
| + | The file Krot-mfg-encrypted.pem is aes-128-cbc encrypted with the same pass-phrase that encrypts the files bcm63xx_encr*.c located in the cfe/ | ||
| + | </ | ||
| + | |||
| + | This means: | ||
| + | * The PBL MFG password is encrypted in the file Krot-mfg-encrypted.pem | ||
| + | * The password must be declared in the files bcm63xx_encr*.c, | ||
| + | * Analysing the script [[https:// | ||
| + | |||
| + | Therefore **we must focus on finding " | ||
| + | |||
| + | \\ | ||
| + | === Sources === | ||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | |||
| ==== Using CFE TFTP client ==== | ==== Using CFE TFTP client ==== | ||
| If you want to install a firmware using TFTP, follow these steps (as an alternative to the above install process). | If you want to install a firmware using TFTP, follow these steps (as an alternative to the above install process). | ||
| - | * Connect a [[doc: | + | * Connect a [[docs: |
| * Start a TFTP server in your PC. Copy the // | * Start a TFTP server in your PC. Copy the // | ||
| * Set the IP at your pc to 192.168.1.35 (or any compatible), | * Set the IP at your pc to 192.168.1.35 (or any compatible), | ||
| Line 192: | Line 285: | ||
| ==== CFE HEADER ==== | ==== CFE HEADER ==== | ||
| At the begining of CFE, outside the NVRAM area there exist three interesting parameters: | At the begining of CFE, outside the NVRAM area there exist three interesting parameters: | ||
| - | ^ Offsets ^ parameter ^ possible values | + | ^ Offsets |
| - | | 0x010-0x013 | **BpGetSdramSize** | 8MB 1 CHIP\\ 16MB 1 CHIP\\ 32MB 1 CHIP\\ 64MB 2 CHIP\\ 32MB 2 CHIP\\ 16MB 2 CHIP\\ 64MB 1 CHIP | **0**\\ **1**\\ **2**\\ **3**\\ **4**\\ **5**\\ **6** | 4 bytes\\ (unsigned long) | | + | | 0x010-0x013 |
| - | | 0x014-0x017 | **BpGetCMTThread**\\ (Main Thread) | core0\\ core1 | **0**\\ **1** | 4 bytes\\ (unsigned long) | | + | | 0x014-0x017 |
| - | | 0x570 | **CFE Version** | any | | | + | | 0x570 | **CFE Version** |
| + | | 0x575 | **CFE Version Number** | ||
| + | | 0x57A | **unused** | ||
| === NVRAM === | === NVRAM === | ||
| Line 217: | Line 311: | ||
| | {{: | | {{: | ||
| - | ^ NVRAM version> | + | ^ NVRAM version> |
| - | ^ Offsets ^ parameter | + | ^ Offsets |
| - | | 0x580 | **NVRAM Version** || 4 | | + | | 0x580 |
| - | | 0x584 | **BOOT LINE** | e=192.168.1.1 (Board IP)\\ h=192.168.1.100 (Host IP)\\ g= (Gateway IP)\\ r=f/h (run from flash/ | + | | 0x584 |
| - | | 0x684 | **Board ID** || 16 | | + | | 0x684 |
| - | | 0x694 | **Main Thread** || 4 | | + | | 0x694 |
| - | | 0x698 | **Psi size** || 4 | | + | | 0x698 |
| - | | 0x69C | **Number MAC Addresses** || 4 | | + | | 0x69C |
| - | | 0x6A0 | **Base MAC Address** || 6 | | + | | 0x6A0 |
| - | | 0x6A6 | **reserved** || 2 | | + | | 0x6A6 |
| - | | 0x6A8 | **old CheckSum** || 4 | | + | | 0x6A7 | **allocate space for backup PSI flag** |
| - | | 0x6AC | **gpon Serial Number** || 13 | | + | | 0x6A8 |
| - | | 0x6B9 | **gpon Password** || 11 | | + | | 0x6AC |
| - | | 0x6C4 | **wps Device Pin** || 8 | | + | | 0x6B9 |
| - | | 0x6CC | **wlan Params** || 256 | | + | | 0x6C4 |
| - | | 0x7CC | **Syslog Size** || 4 | | + | | 0x6CC |
| - | | 0x7D0 | **Nand Part Ofs Kb** || 20 | | + | | 0x7CC |
| - | | 0x7E4 | **Nand Part Size Kb** || 20 | | + | | 0x7D0 |
| - | | 0x7F8 | **Voice Board Id** || 16 | | + | | 0x7E4 |
| - | | 0x808 | **afe Id** || 8 | | + | | 0x7F8 |
| - | | 0x810 | **Unused** || 364 | | + | | 0x808 |
| - | | 0x97C | **CheckSum** || 4 | | + | | 0x810 |
| + | | 0x812 | **OptoRxPower Offset** | ||
| + | | 0x814 | **OptoTxPower Reading** | ||
| + | | 0x816 | **unused** | ||
| + | | 0x850 | **Flash Block Size** | ||
| + | | 0x851 | **AuxFS Size Percentage** | ||
| + | | 0x852 | **unused** | ||
| + | | 0x8FB | **Reset to Default CFG Flag** | ||
| + | | 0x8FC | **Model Name** | ||
| + | | 0x91C | **DES Key** || 32 | | ||
| + | | 0x93C | **WEP Key** || 32 | | ||
| + | | 0x95C | **Serial Number** | ||
| + | | 0x97C | ||
| + | | 0x980 | --end-- | ||
| NVRAM versions >=5 always have the checksum placed at the end of the NVRAM. | NVRAM versions >=5 always have the checksum placed at the end of the NVRAM. | ||
| - | |||
| - | |||
| ==== PSI ==== | ==== PSI ==== | ||
| - | |||
| At the end of the flash outside the CFE, there exists a PSI partition (Profile Storage Information), | At the end of the flash outside the CFE, there exists a PSI partition (Profile Storage Information), | ||
| There isn't any interaction between CFE and PSI except for restoring it to defaults or erasing this area. The settings present in this area are only used by the OEM firmware. | There isn't any interaction between CFE and PSI except for restoring it to defaults or erasing this area. The settings present in this area are only used by the OEM firmware. | ||
| - | |||
| - | |||
| - | ---- | ||
| - | |||
| - | {{tag> | ||