Comment 500 for bug 1734147

Revision history for this message
Mika Westerberg (mika-westerberg) wrote :

This is what I typically do when I compile a custom kernel on a new
machine. You need development tools like git, gcc, gmake etc. but I
guess many distros have most of that stuff already installed. I did not
try these so there might be typos and something could be missing.

These steps should help to recover a system where there is some Linux
distro (not necessarily Ubuntu).

  1. Get the latest kernel tree

    $ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
    $ cd linux

  2. Checkout the v4.15-rc7 branch

    $ git checkout -b spi-nor-recover v4.15-rc7

  3. Save and apply the patch from https://goo.gl/xUKJFR (this is the
     same patch that is linked in the bug description)

    $ git am 0001-Clear-both-SR-and-CR-explicitly-and-also-add-debug-m.patch

  4. Configure the kernel so that it takes only those modules that you
     have currently loaded

    $ make localmodconfig

  5. You may need to enable MTD subsystem, SPI-NOR and the intel-spi
     driver so run

    $ make nconfig

     Then select following from the config

       Device Drivers --->
         <*> Memory Technology Device (MTD) support --->
           <M> SPI-NOR device support --->
             <M> Intel PCH/PCU SPI flash platform driver

     Then press F9 and to save .config and exit nconfig.

  6. Build the kernel image and modules

    $ make -j8

  7. Once it is properly built without any errors you can install it
     along with the modules

    $ sudo make modules_install
    $ sudo make install

Once the custom kernel is installed, you can reboot to this new kernel
and it should clear the CMP bit from the serial flash status register.
It logs something like below to your dmesg:

[ 19.724288] intel-spi intel-spi: wrote SSFSTS_CTL=0x0045020c
[ 19.724301] intel-spi intel-spi: wrote FDATA(0)=00 00
[ 19.724304] intel-spi intel-spi: wrote SSFSTS_CTL=0x0041360c
[ 19.736538] intel-spi intel-spi: wrote SSFSTS_CTL=0x0040520c
[ 19.736542] intel-spi intel-spi: Both SR/CR cleared

Then when you reboot, the BIOS should be able to save settings again and
you can boot back to your distro kernel.

After this you can remove the custom kernel from /boot and modules from
/lib/modules.