| 1 | # Sandy Bridge Raminit |
| 2 | |
| 3 | ## Introduction |
| 4 | |
| 5 | This documentation is intended to document the closed source memory controller |
| 6 | hardware for Intel 2nd Gen (Sandy Bridge) and 3rd Gen (Ivy Bridge) core-i CPUs. |
| 7 | |
| 8 | The memory initialization code has to take care of lots of duties: |
| 9 | 1. Selection of operating frequency |
| 10 | * Selection of common timings |
| 11 | * Applying frequency specific compensation values |
| 12 | * Read training of all populated channels |
| 13 | * Write training of all populated channels |
| 14 | * Adjusting delay networks of address and command signals |
| 15 | * DQS training of all populated channels |
| 16 | * Programming memory map |
| 17 | * Report DRAM configuration |
| 18 | * Error handling |
| 19 | |
| 20 | ## Definitions |
| 21 | ```{eval-rst} |
| 22 | +---------+-------------------------------------------------------------------+------------+--------------+ |
| 23 | | Symbol | Description | Units | Valid region | |
| 24 | +=========+===================================================================+============+==============+ |
| 25 | | SCK | DRAM system clock cycle time | s | | |
| 26 | +---------+-------------------------------------------------------------------+------------+--------------+ |
| 27 | | tCK | DRAM system clock cycle time | 1/256th ns | | |
| 28 | +---------+-------------------------------------------------------------------+------------+--------------+ |
| 29 | | DCK | Data clock cycle time: The time between two SCK clock edges | s | | |
| 30 | +---------+-------------------------------------------------------------------+------------+--------------+ |
| 31 | | timA | IO phase: The phase delay of the IO signals | 1/64th DCK | [0-512) | |
| 32 | +---------+-------------------------------------------------------------------+------------+--------------+ |
| 33 | | SPD | Manufacturer set memory timings located on an EEPROM on every DIMM| bytes | | |
| 34 | +---------+-------------------------------------------------------------------+------------+--------------+ |
| 35 | | REFCK | Reference clock, either 100 or 133 | Mhz | 100, 133 | |
| 36 | +---------+-------------------------------------------------------------------+------------+--------------+ |
| 37 | | MULT | DRAM PLL multiplier | | [3-12] | |
| 38 | +---------+-------------------------------------------------------------------+------------+--------------+ |
| 39 | | XMP | Extreme Memory Profiles | | | |
| 40 | +---------+-------------------------------------------------------------------+------------+--------------+ |
| 41 | ``` |
| 42 | |
| 43 | ## (Unofficial) register documentation |
| 44 | ```{toctree} |
| 45 | :maxdepth: 1 |
| 46 | |
| 47 | Sandy Bridge - Register documentation <nri_registers.md> |
| 48 | ``` |
| 49 | |
| 50 | ## Frequency selection |
| 51 | ```{toctree} |
| 52 | :maxdepth: 1 |
| 53 | |
| 54 | Sandy Bridge - Frequency selection <nri_freq.md> |
| 55 | ``` |
| 56 | |
| 57 | ## Read training |
| 58 | ```{toctree} |
| 59 | :maxdepth: 1 |
| 60 | |
| 61 | Sandy Bridge - Read training <nri_read.md> |
| 62 | ``` |
| 63 | |
| 64 | ### SMBIOS type 17 |
| 65 | The SMBIOS specification allows to report the memory configuration in use. |
| 66 | On GNU/Linux you can run `# dmidecode -t 17` to view it. |
| 67 | Example output of dmidecode: |
| 68 | |
| 69 | ``` |
| 70 | Handle 0x0045, DMI type 17, 34 bytes |
| 71 | Memory Device |
| 72 | Array Handle: 0x0042 |
| 73 | Error Information Handle: Not Provided |
| 74 | Total Width: 64 bits |
| 75 | Data Width: 64 bits |
| 76 | Size: 8192 MB |
| 77 | Form Factor: DIMM |
| 78 | Set: None |
| 79 | Locator: ChannelB-DIMM0 |
| 80 | Bank Locator: BANK 2 |
| 81 | Type: DDR3 |
| 82 | Type Detail: Synchronous |
| 83 | Speed: 933 MHz |
| 84 | Manufacturer: 0420 |
| 85 | Serial Number: 00000000 |
| 86 | Asset Tag: 9876543210 |
| 87 | Part Number: F3-1866C9-8GSR |
| 88 | Rank: 2 |
| 89 | Configured Clock Speed: 933 MHz |
| 90 | ``` |
| 91 | The memory frequency printed by dmidecode is the active memory frequency. It's |
| 92 | **not** the double datarate and it's **not** the one encoded maximum frequency |
| 93 | in each DIMM's SPD. |
| 94 | |
| 95 | > **Note:** This feature is available since coreboot 4.4 |
| 96 | |
| 97 | ### MRC cache |
| 98 | The name *MRC cache* might be misleading as in case of *Native RAM init* |
| 99 | there's no MRC, but for historical reasons it's still named *MRC cache*. |
| 100 | The MRC cache is part of flash memory that is writeable by coreboot. |
| 101 | At the end of the boot process coreboot will write the RAM training results to |
| 102 | flash for future use, as RAM training is time intensive. Storing the results |
| 103 | allows to boot faster on normal boot and allows to support S3 resume, |
| 104 | as the RAM training results can't be stored in RAM (you need to configure |
| 105 | the memory controller first to access RAM). |
| 106 | |
| 107 | The MRC cache needs to be invalidated in case the memory configuration has |
| 108 | been changed. To detect a changed memory configuration the CRC16 of each DIMM |
| 109 | is stored to MRC cache. |
| 110 | > **Note:** This feature is available since coreboot 4.4 |
| 111 | |
| 112 | ### Error handling |
| 113 | As of writing the only supported error handling is to disable the failing |
| 114 | channel and restart the memory training sequence. It's very likely to succeed, |
| 115 | as memory channels operate independent of each other. |
| 116 | In case no DIMM could be initialized coreboot will halt. The screen will stay |
| 117 | black until you power of your device. On some platforms there's additional |
| 118 | feedback to indicate such an event. |
| 119 | |
| 120 | If you find `dmidecode -t 17` to report only half of the memory installed, |
| 121 | it's likely that a fatal memory init failure had happened. |
| 122 | It is assumed, that a working board with less physical memory, is much better, |
| 123 | than a board that doesn't boot at all. |
| 124 | |
| 125 | > **Note:** This feature is available since coreboot 4.5 |
| 126 | |
| 127 | Try to swap memory modules and or try to use a different vendor. If nothing |
| 128 | helps you could have a look at chapter [Debugging] or report a ticket |
| 129 | at [ticket.coreboot.org]. Please provide a full RAM init log, |
| 130 | that has been captured using EHCI debug. |
| 131 | |
| 132 | To enable extensive RAM training logging enable the Kconfig option |
| 133 | `DEBUG_RAM_SETUP` |
| 134 | #### Lenovo Thinkpads |
| 135 | Lenovo Thinkpads do have an additional feature to indicate that RAM init has |
| 136 | failed and coreboot has died (it calls die() on fatal error, thus the name). |
| 137 | The Kconfig options |
| 138 | `H8_BEEP_ON_DEATH` |
| 139 | `H8_FLASH_LEDS_ON_DEATH` |
| 140 | enable blinking LEDs and enable a beep to indicate death. |
| 141 | |
| 142 | > **Note:** This feature is available since coreboot 4.7 |
| 143 | |
| 144 | ## Debugging |
| 145 | It's recommended to use an external debugger, such as serial or EHCI debug |
| 146 | dongle. In case of failing memory init the board might not boot at all, |
| 147 | preventing you from using CBMEM. |