#147 [Feature request] Swapping fn and ctrl on Thinkpad T440p?

Closed
opened 1 year ago by emily · 2 comments

Would it be possible to swap the Fn and Ctrl key on Thinkpads?

This is a really annoying issue to the point that I often rather use an external keyboard or another device because of the non-standard Ctrl button placement.

Recent original Thinkpad firmwares have this option apparently. I know someone who would be happy to look into implementing this but we have no idea where to start looking...

Would it be possible to swap the `Fn` and `Ctrl` key on Thinkpads? This is a really annoying issue to the point that I often rather use an external keyboard or another device because of the non-standard `Ctrl` button placement. Recent original Thinkpad firmwares have this option apparently. I know someone who would be happy to look into implementing this but we have no idea where to start looking...
Leah Rowe commented 1 year ago
Owner

I checked and there is the option fn_ctrl_swap for T440p.

Use the -C option in nvramtool, to change the defaults in the ROM before flashing, because Libreboot hardcodes this at boot time. Set is to fn_ctrl_swap=Enable.

Nvramtool is available under util/nvramtool in coreboot (git repository). You can learn about how to use it there, by running it without arguments to get a list of options.

I checked and there is the option `fn_ctrl_swap` for T440p. Use the `-C` option in nvramtool, to change the defaults in the ROM before flashing, because Libreboot hardcodes this at boot time. Set is to `fn_ctrl_swap=Enable`. Nvramtool is available under `util/nvramtool` in coreboot (git repository). You can learn about how to use it there, by running it without arguments to get a list of options.

I did it! Here's how I did it on the T440p. I'm not sure if I followed best practices, especially since I had to use the force -F option of cbfstool when writing the updated coreboot region. I'd be happy to write a tutorial into the website but I'd rather hear if I did something dangerously first.

First I got the tools ready (flashrom, nvramtool, cbfstool). I installed flashrom using my system's package manager. For the other two I cloned the lbmk repository after forking it, downloaded the coreboot parts (using download coreboot x60 to not download everything. Perhaps there could be an option download coreboot utils?), and built the tools:

git clone git@notabug.org:emily/libreboot-lbmk.git
cd libreboot-lbmk.git
make download
./download coreboot x60
cd coreboot/coreboot/util/nvramtool/
make CC=gcc
cd ../cbfstool/
make CC=gcc
mkdir ~/fn_ctrl_swap-dir
ln -s cbfstool ~/fn_ctrl_swap-dir/cbfstool
ln -s ../nvramtool/nvramtool ~/fn_ctrl_swap-dir/nvramtool

Then I rebooted with kernel parameter iomem=relaxed to allow flashrom to read and write to the flash chip.

For the last steps, read the flash chip, extract the coreboot region, modify it, add it back, and write the modified rom to the flash chip. This is the part that I'd be happy to improve since it's the first time I use cbfstool to change anything else than the grub.cfg in libreboot.

cd ~/fn_ctrl_swap-dir
sudo flashrom -p internal --read current.rom
cp current.rom next.rom
./cbfstool next.rom read -r COREBOOT -f COREBOOT-region.cbfs
./nvramtool -C COREBOOT-region.cbfs -a
./nvramtool -C COREBOOT-region.cbfs -w fn_ctrl_swap=Enable
./nvramtool -C COREBOOT-region.cbfs -a
./cbfstool next.rom write -F -r COREBOOT -f COREBOOT-region.cbfs
sudo flashrom -p internal -w next.rom
I did it! Here's how I did it on the T440p. I'm not sure if I followed best practices, especially since I had to use the force `-F` option of `cbfstool` when writing the updated coreboot region. I'd be happy to write a tutorial into the website but I'd rather hear if I did something dangerously first. First I got the tools ready (`flashrom`, `nvramtool`, `cbfstool`). I installed `flashrom` using my system's package manager. For the other two I cloned the `lbmk` repository after forking it, downloaded the coreboot parts (using `download coreboot x60` to not download everything. Perhaps there could be an option `download coreboot utils`?), and built the tools: ```sh git clone git@notabug.org:emily/libreboot-lbmk.git cd libreboot-lbmk.git make download ./download coreboot x60 cd coreboot/coreboot/util/nvramtool/ make CC=gcc cd ../cbfstool/ make CC=gcc mkdir ~/fn_ctrl_swap-dir ln -s cbfstool ~/fn_ctrl_swap-dir/cbfstool ln -s ../nvramtool/nvramtool ~/fn_ctrl_swap-dir/nvramtool ``` Then I rebooted with kernel parameter `iomem=relaxed` to allow flashrom to read and write to the flash chip. For the last steps, read the flash chip, extract the coreboot region, modify it, add it back, and write the modified rom to the flash chip. This is the part that I'd be happy to improve since it's the first time I use `cbfstool` to change anything else than the `grub.cfg` in libreboot. ```sh cd ~/fn_ctrl_swap-dir sudo flashrom -p internal --read current.rom cp current.rom next.rom ./cbfstool next.rom read -r COREBOOT -f COREBOOT-region.cbfs ./nvramtool -C COREBOOT-region.cbfs -a ./nvramtool -C COREBOOT-region.cbfs -w fn_ctrl_swap=Enable ./nvramtool -C COREBOOT-region.cbfs -a ./cbfstool next.rom write -F -r COREBOOT -f COREBOOT-region.cbfs sudo flashrom -p internal -w next.rom ```
Sign in to join this conversation.
No Label
No Milestone
No assignee
2 Participants
Loading...
Cancel
Save
There is no content yet.