Rewrote the T480 thunderbolt flashing instructions

Signed-off-by: Leah Rowe <info@minifree.org>
master
Leah Rowe 2024-12-29 18:04:10 +00:00
parent 19fab47201
commit bf443e2e4d
1 changed files with 153 additions and 37 deletions

View File

@ -177,57 +177,173 @@ Thunderbolt issue (READ THIS BEFORE FLASHING)
The thunderbolt firmware on launch units had a bug where certain debug
info is written on certain events, such as plugging in a charger to the USB-C
connector. This logging is stored in the Thunderbolt firmware's own SPI flash,
connector. Log data is stored in the Thunderbolt firmware's own SPI flash,
which is separate from the main SPI flash containing the system firmware
e.g. coreboot.
If that flash gets full, thunderbolt (on factory firmware) stops working and
fast charging stops working. It can be prevented by updating the Thunderbolt
firmware. You can do this from Lenovo's firmware, using these instructions:
This photo shows that flash chip on a ThinkPad T480:
<img tabindex=1 alt="ThinkPad T480 NOR flash (thunderbolt firmware)" class="p" src="https://av.libreboot.org/t480/t480tbspi.jpg" /><span class="f"><img src="https://av.libreboot.org/t480/t480tbspi.jpg" /></span>
It's also present on the T480S (S model), but in a different location; on
the S model, the main system flash is still located somewhere near the
centre of the board, and the ThunderBolt flash near the edge of the board, as
it is on the T480, but the T480/T480s use slightly different wiring and they
have a slightly different board layout.
If that flash gets full, thunderbolt PCI-E stops working and fast charging
stops working, but slow charging still works. The issue can be prevented by
updating the firmware. See:
<https://pcsupport.lenovo.com/gb/en/products/laptops-and-netbooks/thinkpad-t-series-laptops/thinkpad-t480s-type-20l7-20l8/solutions/ht508988-critical-intel-thunderbolt-software-and-firmware-updates-thinkpad>
If you're already affected by the bug, you can restore it to a working state
by flashing the Thunderbolt firmware externally. For example this is where its
NOR flash is on a T480:
by flashing the Thunderbolt firmware externally. You *cannot* fix the issue
with Lenovo's software-based flasher, if the issue is already present, so
you *must* flash externally in that case; you can also flash externally, even
if the issue is not yet present.
<img tabindex=1 alt="ThinkPad T480 NOR flash (thunderbolt firmware)" class="p" src="https://av.libreboot.org/t480/t480tbspi.jpg" /><span class="f"><img src="https://av.libreboot.org/t480/t480tbspi.jpg" /></span>
This page shows how to do that:
<https://gitlab.com/MobileAZN/lenovo-t480-thunderbolt-firmware-fixes>\
**WARNING! Please follow the guide PRECISELY, if you follow it, but please
only follow it if your ThunderBolt is already broken. If it isn't, use
Lenovo's software-based updater. If you do the external method, you MUST be
very careful; the guide there for example says to disable ThunderBolt assist.
It also says to erase first, then flash the `null.bin` (file with zeroes in
it), then BOOT, and when it boots, power off and re-connect clip again and
then flash the padded TBT.bin - whereas, for example, if you simply flashed
a padded TBT.bin and nothing else first, and boot, it will be perma-bricked,
in that the CPU won't come out of reset (it'll bootloop). We don't yet know
how to recover from this brick scenario. So all of this is to say: flashing
the ThunderBolt externally is EXTREMELY HAZARDOUS, and should be done with
the UTMOST CARE, ideally NOT AT ALL. -- ALSO: the guide only covers T480,
but should be similar on T480s and other ThinkPad models.**
You unbrick the Thunderbolt controller by pulling the firmware from Lenovo's
update, from Lenovo's update utility. Once extracted, you then pad it properly
so that it can be flashed manually, using a normal SPI flasher (the same one
that you would use to flash Libreboot).
The benefit of flashing it *externally* is that you would then no longer need
to boot Windows, because there is currently no way of doing it from Linux, and
Lenovo does not provide a *boot image* like they do for UEFI updates. So, to
use Lenovo's software-based flasher, you must install and boot Windows. We
always recommend using Free Software whenever possible, *so we always recommend
flashing the new firmware externally, as a matter of course.*
Use the [25XX NOR flashing guide](spi.md) if you need to flash this chip. It's
the same guide that you will use for the main system flash, which is a separate
flash IC.
AGAIN: This is not the Libreboot flash IC. This is separate to the system flash.
Read on to know how to reprogram the main system flash!
The firmware can be extracted from Lenovo's updater, specifically the `.exe`
file. For your convenience, lbmk (Libreboot's build system) can download this
for you. Run the following commands in lbmk:
**AGAIN: It is extremely easy to permanently brick the ThunderBolt controller,
rendering your system completely unbootable, if you use the external recovery
method. If you're still able to fix it with a software-based flasher like the
one Lenovo provides, please use that at all - or simply don't fix it at all,
because the machine will at least still charge while it has the ThunderBolt
issue, where older firmware is used.**
(please install [build dependencies](../build/) first)
Commands:
./mk -d coreboot t480s_vfsp_16mb
./mk -d coreboot t480_vfsp_16mb
You will find the files at these locations in lbmk:
* `vendorfiles/t480/tb.bin`
* `vendorfiles/t480s/tb.bin`
These have already been padded, to the correct size of 1MB, whereas the original
size (within the `.exe` file) was 256KB.
These files are *also* generated, if you used the `./mk inject` command,
on a pre-compiled release image, as documented [here](ivy_has_common.md).
**WARNING: DO NOT FLASH IT FIRST; YOU MUST PERFORM SOME PRE-REQUISITE STEPS
FIRST, BEFORE FLASHING `tb.bin`**:
**Firstly, please note that this procedure has *only* been tested with Lenovo's
UEFI firmware installed on the main flash. Please ensure that you have also
switched Lenovo UEFI/EC firmware to the specific version referenced on this
page, for your board.** - for the rest of this, we will assume that you've not
yet flashed Libreboot, though there's no reason in principle why this can't
also work *after* you've flashed Libreboot; it's just that we only tested it
from Lenovo UEFI firmware.
Now, *remove* the CR2032 battery (yellow coin-cell battery). Please also ensure
that you've disabled *ThunderBolt Assist* in the Lenovo UEFI setup menu. You
should also disable the internal battery, on T480 specifically (T480s only has
an internal battery). You should do this with no batteries connected anyway.
Firstly, make *two dumps* of the flash, using [flashprog](spi.md) - and the
linked guide generally tells you how to dump/flash the chip. Make sure both
dumps have the same checksum, using e.g. `sha512sum`.
Now, *erase* the flash. This example command is when using a Raspberry Pi Pico,
assuming that the device shows up as `/dev/ttyACM0` - please adapt accordingly
to whatever programmer you have:
flashprog -p serprog:dev=/dev/ttyACM0 -E
Note that the `-E` argument is what specifies that the chip should be *erased*.
Now, you must create a file called `null.bin`, which contains all zeroes:
dd if=/dev/zero of=null.bin bs=1M count=1
Please ensure (in hexdump) that the file does contain all zeroes, and that it
is 1MB in size. You will now flash it, again adapting the command below to
whatever programmer you have:
flashprog -p serprog:dev=/dev/ttyACM0 -w null.bin
**NOW, REMOVE the clip. Button it back up and turn the T480 on, with both
the battery and the charger connected, plugging in the battery first.**
It *should* boot up and show the Lenovo boot screen. Give it a few moments.
When you've confirmed that it has booted the Lenovo firmware, *shut down* the
machine and remove the battery / power supply again. It *may take a while* to
boot Lenovo's firmware when doing this, so please be very patient.
After you've confirmed that the machine boots, I say again: make sure to shut
it down fully, removing all batteries and power supplies.
It is at this moment that you will externally flash the `tb.bin` file. Please
make sure to flash the correct one for your board:
* T480: `vendorfiles/t480/tb.bin`
* T480s: `vendorfiles/t480s/tb.bin`
Libreboot's automated build system has a lot more dependencies. If you want to
avoid installing them, and extract the file manually, you can. Simply download
the `.exe` file and do this:
innoextract filename.exe
The `innoextract` utility will probably be available in your distro's package
manager. You can otherwise find it here:\
<https://constexpr.org/innoextract/> - credit goes to Daniel Scharrer for
writing this excellent software.
A directory will be created with the extracted files. Inside it, you will
find a file named `TBT.bin`. You can pad it like so:
dd if=/dev/null of=TBT.bin bs=1 seek=1048576
Note that the `seek` variable here matching 1MB flash size. If you encounter
a different flash size, adapt accordingly (the same applies when creating
the `null.bin` file). Libreboot's build system makes this size configurable
per board, on the theory that we may encounter other flash sizes in the future,
when we add more ThinkPads of this generation to Libreboot.
Ok, so you have the file. Now you can flash it.
Example:
flashprog -p serprog:dev=/dev/ttyACM0 -w tb.bin
Adapt `tb.bin` in the command above, to the actual one that you wish to flash.
You *MUST* do it in the exact order as prescribed above. After flashing
the `tb.bin` image, un-clip and simply re-assemble. After you boot up, it should
once again show the boot screen, and USB-C / ThunderBolt will work perfectly.
You can repeat the above steps to restore the old firmware version. This is why
you were instructed to make a backup, on the off-chance that you may wish to do
so for some reason in the future.
Troubleshooting:
If you accidentally flashed an incorrect firmware image, or you didn't properly
erase and boot first before flashing the new image, you can simply repeat the
steps again; on erase/null, you then boot up and *wait* and it'll eventually
show the boot screen again. If it doesn't work, just keep doing it until it does.
Credits go
to [Adam McNutt](https://gitlab.com/MobileAZN/lenovo-t480-thunderbolt-firmware-fixes)
who originally provided such instructions, for the ThinkPad T480. The information
there was adapted for *this* guide, in the Libreboot documentation. Libreboot
may very well support other ThinkPads from the same generation, in a future
release after Libreboot 20241206, and many of those have this same issue; when
it does, Libreboot will document this fix for those machines too, and probably
move these instructions to a dedicated page on the website.
Flash a ROM image (software)
-----------------------