#146 Some nvramtool parameters have no effect

Open
opened 3 years ago by ctag · 10 comments

Hi,

X200, libreboot 2016-09-07, x200_8mb_usqwerty_vesafb.rom from a mirror.

I'd like to swap the fn and ctrl keys, so that my keyboard layout matches across several devices. From this page I can see how to use nvramtool, but changes don't persist after a reboot.

As recommended on irc, I can use nvramtool -C on the libreboot rom before flashing. Now the changes can be read with nvramtool after a reboot.

Below is the rom which I recently flashed to my X200.

$ nvramtool -C x200_8mb_usqwerty_vesafb.rom -a
boot_option = Fallback
baud_rate = 115200
debug_level = Spew
sata_mode = AHCI
power_on_after_fail = Disable
first_battery = Primary
bluetooth = Enable
wwan = Enable
wlan = Enable
trackpoint = Enable
fn_ctrl_swap = Enable
sticky_fn = Disable
boot_devices = 
boot_default = 0x0
power_management_beeps = Disable
low_battery_beep = Enable
uwb = Disable
volume = 0x3
gfx_uma_size = 256M

Here I've disabled the power management beeps and enabled fn-ctrl swap. Power beeps don't happen anymore, but the fn and ctrl keys retain their old function.

Does libreboot not have fn_ctrl_swap implemented, or have I misconfigured my system?

Hi, X200, libreboot 2016-09-07, `x200_8mb_usqwerty_vesafb.rom` from a mirror. I'd like to swap the fn and ctrl keys, so that my keyboard layout matches across several devices. From [this page](https://libreboot.org/docs/misc/#power-management-beeps-on-thinkpads) I can see how to use nvramtool, but changes don't persist after a reboot. As recommended on irc, I can use `nvramtool -C` on the libreboot rom before flashing. Now the changes can be read with nvramtool after a reboot. Below is the rom which I recently flashed to my X200. ``` $ nvramtool -C x200_8mb_usqwerty_vesafb.rom -a boot_option = Fallback baud_rate = 115200 debug_level = Spew sata_mode = AHCI power_on_after_fail = Disable first_battery = Primary bluetooth = Enable wwan = Enable wlan = Enable trackpoint = Enable fn_ctrl_swap = Enable sticky_fn = Disable boot_devices = boot_default = 0x0 power_management_beeps = Disable low_battery_beep = Enable uwb = Disable volume = 0x3 gfx_uma_size = 256M ``` Here I've disabled the power management beeps and enabled fn-ctrl swap. Power beeps don't happen anymore, but the fn and ctrl keys retain their old function. Does libreboot not have fn_ctrl_swap implemented, or have I misconfigured my system?
Leah Rowe commented 3 years ago
Owner

yes, this is a known issue... thanks for reporting it. regarding fn ctrl swap

can you look into it, in the coreboot source code? submit the fix to librecore, our future upstream

yes, this is a known issue... thanks for reporting it. regarding fn ctrl swap can you look into it, in the coreboot source code? submit the fix to librecore, our future upstream
Christopher Bero commented 3 years ago
Poster

A little bit of searching around yielded a bug report for X60 which seems to indicate that at least some subset of Thinkpads don't support fn-ctrl swapping at all. Fastest way to find out would probably be to get an X200 with stock BIOS on it and check for that feature.. But I don't have a backup of the stock bios for my own X200 so no joy.

At the same time there's an email thread about fn_ctrl_swap on X200 which seems to indicate that if you wanted this feature with older stock BIOSes you had to flash some hacked up rom, but it was at least possible. Oddly enough X60 is listed as having a working hacked rom for fn-ctrl swap.. huh.

I've got coreboot's source cloned, and am poking through it to see if I can understand the EC stuff going on with params set by nvramtool.

A little bit of searching around yielded [a bug report for X60](https://ticket.coreboot.org/issues/24) which seems to indicate that at least some subset of Thinkpads don't support fn-ctrl swapping at all. Fastest way to find out would probably be to get an X200 with stock BIOS on it and check for that feature.. But I don't have a backup of the stock bios for my own X200 so no joy. At the same time there's [an email thread about fn_ctrl_swap on X200](https://www.mail-archive.com/coreboot@coreboot.org/msg45350.html) which seems to indicate that if you wanted this feature with older stock BIOSes you had to flash some hacked up rom, but it was at least possible. Oddly enough X60 is listed as having a working hacked rom for fn-ctrl swap.. huh. I've got coreboot's source cloned, and am poking through it to see if I can understand the EC stuff going on with params set by nvramtool.

Hey there :)

I am currently looking into this. My x200 shipped with libreboot directly so I also did not have the factory rom but I just got it from vikings.net (thanks!). I also tried to make it easier to flash the EC firmware without using Windows: https://github.com/hamishcoleman/thinkpad-ec/pull/32 Maybe give me a bit of time and I will report how it went.

I don’t think that coreboot sources will help you. I already looked at it and fn_ctrl_swap seems to only cause coreboot/libreboot set a bit in the RAM of the EC which would swap the keys if the EC firmware would support it.

Hey there :) I am currently looking into this. My [x200 shipped with libreboot](https://store.vikings.net/libre-friendly-hardware/x200-ryf-certfied) directly so I also did not have the factory rom but I just got it from vikings.net (thanks!). I also tried to make it easier to flash the EC firmware without using Windows: https://github.com/hamishcoleman/thinkpad-ec/pull/32 Maybe give me a bit of time and I will report how it went. I don’t think that coreboot sources will help you. I already looked at it and fn_ctrl_swap seems to only cause coreboot/libreboot set a bit in the RAM of the EC which would swap the keys if the EC firmware would support it.
Swift Geek commented 3 years ago
Collaborator

@Christopher Bero thinkpady thinkpads have more or less stable interface which is why all those options are exposed for all true thinkpads (ones with PMH/thinker). Some settings won't change anything irl for some models, and that's completely normal and intended for compatibility/portability reasons.

@Christopher Bero thinkpady thinkpads have more or less stable interface which is why all those options are exposed for all true thinkpads (ones with PMH/thinker). Some settings won't change anything irl for some models, and that's completely normal and intended for compatibility/portability reasons.

Success, https://github.com/hamishcoleman/thinkpad-ec/pull/32 works nicely. It will also downgrade the factory rom to an older version. But that was already reported by other thinkpad users. All credits go to middleton.

I will do some more work on this and test if it can also be flashed when having libreboot installed. Unfortunately, this will also install the factory BIOS back. I guess the only way back to libreboot is to flash externally then. Doing that later. First I want to try if I can forward port the binary patch to the latest EC firmware. What would be really nice if the firmware could be patched to check fn_ctrl_swap is set but I don’t know enough about this to implement this yet.

Success, https://github.com/hamishcoleman/thinkpad-ec/pull/32 works nicely. It will also downgrade the factory rom to an older version. But that was already reported by other thinkpad users. All credits go to middleton. I will do some more work on this and test if it can also be flashed when having libreboot installed. Unfortunately, this will also install the factory BIOS back. I guess the only way back to libreboot is to flash externally then. Doing that later. First I want to try if I can forward port the binary patch to the latest EC firmware. What would be really nice if the firmware could be patched to check fn_ctrl_swap is set but I don’t know enough about this to implement this yet.
Swift Geek commented 3 years ago
Collaborator

Use x200 bios modified to have whitelist removed - in addition to that feature it has modified bootblock that doesn't set PRx registers, making internal flashing possible

Use x200 bios modified to have whitelist removed - in addition to that feature it has modified bootblock that doesn't set PRx registers, making internal flashing possible
Christopher Bero commented 3 years ago
Poster

@ypid Thanks for following up on that!

@swiftgeek Even though it looks like a binary blob patch for the proprietary bios works, that seems pretty far removed from coreboot/libreboot. Do you think it's feasible for this feature to be added to libreboot?

@ypid Thanks for following up on that! @swiftgeek Even though it looks like a binary blob patch for the proprietary bios works, that seems pretty far removed from coreboot/libreboot. Do you think it's feasible for this feature to be added to libreboot?

@ctag You are welcome.

Works. Note that the patch does not affect the BIOS image at all so it is no problem to install libreboot later on again with the key swap still being in effect. The only bytes that middleton patched are in the FL2 file which contains the firmware for the embedded controller. Refer to https://libreboot.org/faq.html#ec-embedded-controller-firmware for details. So, this is not directly related to coreboot/libreboot. As said, coreboot only sets a bit that the EC firmware later reads (or not if the EC fw does not support it which is the case for the x200).

@ctag You are welcome. Works. Note that the patch does not affect the BIOS image at all so it is no problem to install libreboot later on again with the key swap still being in effect. The only bytes that middleton patched are in the FL2 file which contains the firmware for the embedded controller. Refer to https://libreboot.org/faq.html#ec-embedded-controller-firmware for details. So, this is not directly related to coreboot/libreboot. As said, coreboot only sets a bit that the EC firmware later reads (or not if the EC fw does not support it which is the case for the x200).

I forward ported the patch by middleton to the latest EC firmware which worked nicely. This includes a battery fix from lenovo. Not sure what it does but lets hope it is useful until also this last blob can be replaced. Also one interesting thing is that I was able to flash libreboot when I was on the factory ROM (BIOS 3.22 (7XET72WW) EC 1.07 (7XHT25WW)). I used Debian stretch and flashrom from stretch. It just worked although it should not as pointed out by @swiftgeek. In case it helps, that is the hardware I tested on:

Handle 0x0000, DMI type 0, 24 bytes
BIOS Information
        Vendor: coreboot
        Version: CBET4000 3774c98
        Release Date: 09/07/2016
        ROM Size: 8192 kB
        Characteristics:
                PCI is supported
                PC Card (PCMCIA) is supported
                BIOS is upgradeable
                Selectable boot is supported
                ACPI is supported
                Targeted content distribution is supported
        BIOS Revision: 4.0
        Firmware Revision: 0.0

Handle 0x0001, DMI type 1, 27 bytes
System Information
        Manufacturer: LENOVO
        Product Name: 7459GW4
        Version: ThinkPad X200
        Serial Number: XXXXXXX
        Wake-up Type: Reserved
        SKU Number: Not Specified
        Family: Not Specified

Handle 0x0002, DMI type 2, 8 bytes
Base Board Information
        Manufacturer: LENOVO
        Product Name: 7459GW4
        Version: ThinkPad X200
        Serial Number: XXXXXXX

Unfortunately, I managed to brick the EC as it seems but this was unrelated to patching the EC firmware. Ref: https://github.com/hamishcoleman/thinkpad-ec/pull/32

I forward ported the patch by middleton to the latest EC firmware which worked nicely. This includes a battery fix from lenovo. Not sure what it does but lets hope it is useful until also this last blob can be replaced. Also one interesting thing is that I was able to flash libreboot when I was on the factory ROM (BIOS 3.22 (7XET72WW) EC 1.07 (7XHT25WW)). I used Debian stretch and flashrom from stretch. It just worked although it should not as pointed out by @swiftgeek. In case it helps, that is the hardware I tested on: ``` Handle 0x0000, DMI type 0, 24 bytes BIOS Information Vendor: coreboot Version: CBET4000 3774c98 Release Date: 09/07/2016 ROM Size: 8192 kB Characteristics: PCI is supported PC Card (PCMCIA) is supported BIOS is upgradeable Selectable boot is supported ACPI is supported Targeted content distribution is supported BIOS Revision: 4.0 Firmware Revision: 0.0 Handle 0x0001, DMI type 1, 27 bytes System Information Manufacturer: LENOVO Product Name: 7459GW4 Version: ThinkPad X200 Serial Number: XXXXXXX Wake-up Type: Reserved SKU Number: Not Specified Family: Not Specified Handle 0x0002, DMI type 2, 8 bytes Base Board Information Manufacturer: LENOVO Product Name: 7459GW4 Version: ThinkPad X200 Serial Number: XXXXXXX ``` Unfortunately, I managed to brick the EC as it seems but this was unrelated to patching the EC firmware. Ref: https://github.com/hamishcoleman/thinkpad-ec/pull/32
Swift Geek commented 3 years ago
Collaborator

To clear it up, it's just isn't a real factory image. It's way too easy to confuse them as it's close to impossible to use factory image ^^'

To clear it up, it's just isn't a real factory image. It's way too easy to confuse them as it's close to impossible to use factory image ^^'
Sign in to join this conversation.
Loading...
Cancel
Save
There is no content yet.