Code Monkey home page Code Monkey logo

x210's Introduction

x210

Collection of patches and mods for the 51nb x210.

Table of Contents

Repo contents

  • blobs
  • coreboot_images - precompiled, flashable coreboot images containing the patched EC, CPU microcode updates, updated ME, battery capacity detection fixes and power management improvements
    • coreboot.rom Coreboot 4.13 w/Intel ME and libgfxinit
  • colour_profiles
    • X210-122.icm ICM colour profile for the 12.2" 1920x1200 screen.
    • LP130QP1_SPA1.icm ICM colour profile for the 13" 3000x2000 screen.
  • kernel_patches
    • x210-battery-fix.patch Detect correct battery capacity and discharge rate (only needed on stock BIOS)
    • r8169-enable-aspm.patch Enable L1 ASPM and substates on the realtek ethernet NIC. As of Linux 5.10 there seem to be no issues enabling ASPM for the chip contained in the x210. Alternatively the r8168 module from Realtek can be used. r8168 enables ASPM natively, however ASPM is often lost after resuming from sleep with this module.
    • hda_intel-enable-power-gating.patch /sys/kernel/debug/pmc_core/pch_ip_power_gating_status shows PCH IP: 9 - HDA-PGD0 State: Off with this patch. This is a precondition for s0ix (which does not work yet)
  • .config Coreboot .config file
  • bios-ec-mod.bin Full bios dump including the modified EC.
  • layout Layout file required to flash the EC portion of the BIOS contributed by Thinkpad forum user L29Ah https://forum.thinkpads.com/viewtopic.php?p=834229#p834229

How to patch the X210 BIOS

Option 1: use a patched embedded controller

You can replace the Embedded Controller with Vladislav's version:

flashrom -p internal -r x210-current-internal-flashrom.bin
dd if=x210-current-internal-flashrom.bin of=fw.bin bs=1024 count=2048
dd if=ec.bin of=fw.bin bs=1024 count=64 seek=2048
dd if=x210-current-internal-flashrom.bin of=fw.bin bs=1024 count=6080 seek=2112
flashrom -V -p internal -l layout -i ec -w fw.bin

Credit for this goes to Thinkpad forum user L29Ah https://forum.thinkpads.com/viewtopic.php?p=834033#p834033

Option 1a: cherry-pick EC patches

L29Ah built a handy tool to select which patches to apply to the EC: https://github.com/l29ah/x210-ec

Option 2: flash an already patched BIOS image

Alternatively you might want to flash the already patched bios:

flashrom -p internal -w bios-ec-mod.bin

Be advised that bios-ec-mod.bin contains my customizations and might not boot on a different machine. In particular, the SATA controller is disabled, only UEFI boot is enabled and the processor is undervolted by 100mV. You can modify these settings upon first boot from the BIOS setup panel. My configuration also enables several power saving features disabled by defatult.

Fix battery capacity detection

Once the BIOS is flashed, in order for a system running the stock UEFI bios to report the correct battery capacity and discharge rate, you'll need to patch the kernel with x210-battery-fix.patch. Most of the X210's EC is likely directly taken from the X201 EC, including the bugs. In particular, the Linux kernel sources hint at what has been causing the capacity detection issues:

On Lenovo Thinkpad models from 2010 and 2011, the power unit switches between mWh and mAh depending on whether the system is running on battery or not. When mAh is the unit, most reported values are incorrect and need to be adjusted by 10000/design_voltage. Verified on x201, t410, 410s, and x220. Pre-2010 and 2012 models appear to always report in mWh and are thus unaffected (tested with t42, t61, t500, x200, x300, and x230).

The only difference is that the power unit never changes on the X210, it's always mAh, and the values are always wrong. The patch fixes that by simply removing the checks on machine type and model and enabling the workaround on the X210

Coreboot

Matthew Garrett has been porting coreboot to the X210: https://forum.thinkpads.com/viewtopic.php?f=80&t=126731 As of 20 March 2020 the X210 is part of the official coreboot tree. Pre-compiled coreboot images for the x210 (3rd batch) are provided here.

Flash coreboot with the following command

flashrom -p internal -w coreboot.rom

The build provided includes the patched EC, fixes battery capacity detection problems so that no kernel patching is required, and enables several power saving features such as SATA Aggressive PM, Devslp, ASPM L1 substates for all PCIe devices including NVMe. It also includes CPU microcode updates from Intel.

The payload is tianocore, therefore it will boot a UEFI operating system, not a BIOS one. It'll also boot the installer or an existing installation of Windows 10.

This build includes the full 3rd gen Management Engine. It may or may not work on other generations of the X210. Coreboot gives the ability to strip down the ME at build time using me_cleaner. If you want to neuter the ME completely you should build your own image following the steps below.

Coreboot build HOWTO

If you want a bleeding edge coreboot for your X210 do the following.

Download the latest coreboot tree:

git clone https://review.coreboot.org/coreboot
cd coreboot
git submodule update --init --checkout

Copy the .config file from the repo into the coreboot dir.

Extract the the stock bios: flashrom -p internal -r x210-stock-bios.rom

Open the stock bios in UEFITool https://github.com/LongSoft/UEFITool and extract Descriptor region and ME Region to descriptor.bin and me.bin ("Extract as is"). Then search for VGA Compatible BIOS (unselect UNICODE), double click on the string in "Messages" which will take you to the relevant section, then Action -> Section -> Extract Body. Save it as vgabios.bin

Copy the VBT: cp /sys/kernel/debug/dri/0/i915_vbt vbt.bin

Put all the .bin files (including ec.bin from the repo) in coreboot/3rdparty/blobs/mainboard/51nb/x210. If you plan to use libgfxinit you can safely omit vgabios.bin and vbt.bin (although linux will complain about not finding the VBT). Then build the crosstools. make crosstools-i386 CPUS=8

Run make menuconfig in the main coreboot directory. The .config provided here should work well for all users. You have the option of neutering the ME in the "Chipset" menu. In System tables you can add the serial number of your machine to the SMBIOS tables. The SN is usually found on a handwritten sticker attached to one of the RAM slots.

Compile coreboot: make -j8

Pay attention to any error/issue that might arise. If all goes well the image will be generated under build/ and it won't brick your machine. flashrom -p internal -w coreboot.rom

You can keep your coreboot tree up to date by issuing git pull in the root directory, if you want to recompile later.

x210's People

Contributors

harrykipper avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

x210's Issues

guide is misleading

(this is NOT recommeded at the moment if you have a NVMe drive. NVMe L1 substates might depend from the ME being operational. If that doesn't work your drive might end up undetected).

This seems to be purely wrong.

OpenBSD/Audio

Hi,
I'm using your provided coreboot.rom on my x210 with the i7-8550U CPU and the 2880x1920 screen (it got shipped before batch 4 was announced, so I think it's still batch 3).

I experience some issues regarding the audio device. Sometimes the audio device is present in the OS, sometimes not. And sometimes the boot falls into the kernel debugger with a page_fault. Neither did happen with the stock BIOS from 51nb.

If you can't help (or don't want to) this is fine. I'm just dropping the issue here, maybe others experience the same and we can fix it together.

Dmesg reports the audio device as:

azalia0: codecs: Conexant/0x5069, Intel/0x280b, using Conexant/0x5069

This is the page fault:
Page Fault

Backtrace:
Backtrace

Full dmesg:
https://codevoid.de/0/p/x210_dmesg.txt

Pcidump:
https://codevoid.de/0/p/x210_pcidump.txt

If you're interested, this is the stock rom from 51nb on my board:
https://codevoid.de/9/p/x210_stock.rom
(sha1: df8ad4124c5a5a550c2f9f209eb72cc560f91c9c)

Thanks to you and mjg59 for all the work so far!

Best Regards,

fn+ctrl swap

Hello,
Is it possible to add coreboot image with this option?
It would be great if there was a bios with this option too.

Small issue with the BIOS generation

Just wanna let you know the commands for generating the new BIOS has a slight mistake in the readme.

dd if=x210-current-internal-flashrom.bin of=fw.bin bs=1024 count=2048
dd if=ec.bin of=fw.bin bs=1024 count=64 seek=2048
dd if=x210-current-internal-flashrom.bin of=fw.bin bs=1024 count=6080 skip=2112 seek=2112

The skip=2112 was missing and if the commands are copy pasted, it'll result in a faulty firmware.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.