| 1 | # mrc.bin |
| 2 | |
| 3 | All Haswell boards supported by coreboot currently require a proprietary |
| 4 | blob in order to initialise the DRAM and a few other components. The |
| 5 | blob, named `mrc.bin`, largely consists of Intel's memory reference code |
| 6 | (MRC), but it has been tailored specifically for ChromeOS. It is just |
| 7 | under 200 KiB in size. Another name for `mrc.bin` is the system agent |
| 8 | binary. |
| 9 | |
| 10 | Having a replacement for `mrc.bin` using native coreboot code is very |
| 11 | much desired, but it is not an easy task. |
| 12 | |
| 13 | ## Obtaining mrc.bin |
| 14 | |
| 15 | Unfortunately, it is not currently possible to distribute `mrc.bin` as |
| 16 | part of coreboot. Though, it can be obtained from a Haswell Chromebook |
| 17 | firmware image like so, starting in the root of the coreboot directory: |
| 18 | |
| 19 | ```bash |
| 20 | make -C util/cbfstool |
| 21 | cd util/chromeos |
| 22 | ./crosfirmware.sh peppy |
| 23 | ../cbfstool/cbfstool coreboot-*.bin extract -f mrc.bin -n mrc.bin -r RO_SECTION |
| 24 | ``` |
| 25 | |
| 26 | Now, place `mrc.bin` in the root of the coreboot directory. |
| 27 | Alternatively, place `mrc.bin` anywhere you want, and set `MRC_FILE` to |
| 28 | its location when building coreboot. |
| 29 | |
| 30 | ## SPD Addresses |
| 31 | |
| 32 | When porting a board from vendor firmware, the SPD addresses can be obtained |
| 33 | through `i2c-tools`, which can be found in many GNU/Linux distributions. A more |
| 34 | [detailed description](https://hannuhartikainen.fi/blog/hacking-ddr3-spd/) of |
| 35 | the procedure and beyond can be found in |
| 36 | [Hannu Hartikainen's blog](https://hannuhartikainen.fi). |
| 37 | |
| 38 | First load the kernel modules: |
| 39 | |
| 40 | ```bash |
| 41 | modprobe i2c-dev |
| 42 | modprobe eeprom |
| 43 | ``` |
| 44 | |
| 45 | Find the SMBus and the addresses of the DIMM's EEPROMs (example output): |
| 46 | ```bash |
| 47 | $ decode-dimms | grep Decoding |
| 48 | Decoding EEPROM: /sys/bus/i2c/drivers/eeprom/7-0050 |
| 49 | Decoding EEPROM: /sys/bus/i2c/drivers/eeprom/7-0052 |
| 50 | ``` |
| 51 | |
| 52 | Alternatively, look at the sys filesystem: |
| 53 | ```bash |
| 54 | $ ls -l /sys/bus/i2c/drivers/eeprom/ |
| 55 | total 0 |
| 56 | lrwxrwxrwx 1 root root 0 Apr 4 01:46 6-0050 -> ../../../../devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1/i2c-6/6-0050/ |
| 57 | lrwxrwxrwx 1 root root 0 Apr 4 01:46 7-0050 -> ../../../../devices/pci0000:00/0000:00:1f.3/i2c-7/7-0050/ |
| 58 | lrwxrwxrwx 1 root root 0 Apr 4 01:46 7-0052 -> ../../../../devices/pci0000:00/0000:00:1f.3/i2c-7/7-0052/ |
| 59 | --w------- 1 root root 4096 Apr 4 01:47 bind |
| 60 | lrwxrwxrwx 1 root root 0 Apr 4 01:47 module -> ../../../../module/eeprom/ |
| 61 | --w------- 1 root root 4096 Apr 4 01:46 uevent |
| 62 | --w------- 1 root root 4096 Apr 4 01:47 unbind |
| 63 | ``` |
| 64 | |
| 65 | The correct I2C bus is 7 in this case, and the EEPROMs are at `0x50` and `0x52`. |
| 66 | Note that the above values are actually hex values. |
| 67 | |
| 68 | You can check the correctness of the SMBus and the addresses of the EEPROMs via |
| 69 | `i2cdetect`: |
| 70 | |
| 71 | ```bash |
| 72 | $ i2cdetect -l |
| 73 | i2c-3 unknown i915 gmbus dpc N/A |
| 74 | i2c-1 unknown i915 gmbus vga N/A |
| 75 | i2c-6 unknown DPDDC-A N/A |
| 76 | i2c-4 unknown i915 gmbus dpb N/A |
| 77 | i2c-2 unknown i915 gmbus panel N/A |
| 78 | i2c-0 unknown i915 gmbus ssc N/A |
| 79 | i2c-7 unknown SMBus I801 adapter at f040 N/A |
| 80 | i2c-5 unknown i915 gmbus dpd N/A |
| 81 | ``` |
| 82 | |
| 83 | Probing the SMBus: |
| 84 | |
| 85 | ```bash |
| 86 | $ i2cdetect -r 7 |
| 87 | WARNING! This program can confuse your I2C bus, cause data loss and worse! |
| 88 | I will probe file /dev/i2c-7 using receive byte commands. |
| 89 | I will probe address range 0x03-0x77. |
| 90 | Continue? [Y/n] |
| 91 | 0 1 2 3 4 5 6 7 8 9 a b c d e f |
| 92 | 00: -- -- -- -- -- -- -- -- -- -- -- -- -- |
| 93 | 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- |
| 94 | 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- |
| 95 | 30: 30 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- |
| 96 | 40: -- -- -- -- 44 -- -- -- -- -- -- -- -- -- -- -- |
| 97 | 50: UU -- UU -- -- -- -- -- -- -- -- -- -- -- -- -- |
| 98 | 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- |
| 99 | 70: -- -- -- -- -- -- -- -- |
| 100 | ``` |
| 101 | |
| 102 | The SPD addresses need to be left-shifted by 1 for `mrc.bin`, i.e., multiplied |
| 103 | by 2. For example, if the addresses read through `i2c-tools` when booted from |
| 104 | vendor firmware are `0x50` and `0x52`, the correct values would be `0xa0` and |
| 105 | `0xa4`. This is because the I2C addresses are 7 bits long. |
| 106 | |
| 107 | ## ECC DRAM |
| 108 | |
| 109 | When `mrc.bin` has finished executing, ECC is active on the channels |
| 110 | populated with ECC DIMMs. However, `mrc.bin` was tailored specifically |
| 111 | for Haswell Chromebooks and Chomeboxes, none of which support ECC DRAM. |
| 112 | While ECC likely functions correctly, it is advised to further validate |
| 113 | the correct operation of ECC if data integrity is absolutely critical. |